[SCM] python-pyo/master: New pyo release.
tiago at users.alioth.debian.org
tiago at users.alioth.debian.org
Tue Dec 13 20:35:48 UTC 2016
The following commit has been merged in the master branch:
commit ddd58481602e52c5ededbde3ccbae05a30459013
Author: Tiago Bortoletto Vaz <tiago at debian.org>
Date: Tue Dec 13 13:15:20 2016 -0500
New pyo release.
diff --git a/ChangeLog b/ChangeLog
index 27a003c..9e0ab06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,207 @@
+2016-12-08 belangeo <belangeo at gmail.com>
+
+ * Upgraded version number to 0.8.1.
+
+2016-12-08 belangeo <belangeo at gmail.com>
+
+ * Iter now accepts PyoObjects in its list of values.
+
+2016-12-08 belangeo <belangeo at gmail.com>
+
+ * Iter now sends a thrigger when it reaches the last value.
+
+2016-11-25 belangeo <belangeo at gmail.com>
+
+ * SigTo ramp time now can be controlled at audio rate (issue #87).
+
+2016-11-23 belangeo <belangeo at gmail.com>
+
+ * Added __iter__(), __next__() and next() (python 2 compatibility) methods
+ to PyoBaseObject.
+
+2016-11-22 belangeo <belangeo at gmail.com>
+
+ * Added reset method to various objects (AllpassWG, Chorus, Freeverb,
+ Harmonizer, STRev, WGVerb, Waveguide).
+
+2016-11-16 belangeo <belangeo at gmail.com>
+
+ * TableWrite now takes into account the feedback argument of NewTable
+ object and interpolates to fill in gaps if position moves faster than
+ the sampling rate.
+
+2016-11-07 belangeo <belangeo at gmail.com>
+
+ * Added missing methods to Notein object and ctrl() method in midi.py.
+
+2016-11-07 belangeo <belangeo at gmail.com>
+
+ * Added a `callback` argument to PyoObject.set() method.
+
+2016-11-06 Aron Granberg <http://arongranberg.com>
+
+ * Python 3 migration. Still need to port pyo's GUI written with WxPython
+ to WxPython Phoenix (the port of WxPython Classic to python 3). Some
+ widgets are broken.
+
+2016-11-02 belangeo <belangeo at gmail.com>
+
+ * Fixed jack ports auto-connection algorithm.
+
+2016-10-28 belangeo <belangeo at gmail.com>
+
+ * Added an 'inverse' argument to PVGate object. When set to True, the
+ damping factor is applied to bins with an amplitude above the threshold.
+
+2016-10-26 belangeo <belangeo at gmail.com>
+
+ * Added a time stream, which gives the current normalized position, to Looper object.
+
+ * Added loopnow() method to Looper object.
+
+ * Added appendFadeTime() and fadeInSeconds() methods to Looper object.
+
+2016-10-24 belangeo <belangeo at gmail.com>
+
+ * Added a new file, called `How to improve performance of your pyo
+ programs`, to the documentation.
+
+2016-10-21 belangeo <belangeo at gmail.com>
+
+ * Added Server.getCurrentTime() and Server.getCurrentAmp() methods.
+
+2016-10-04 belangeo <belangeo at gmail.com>
+
+ * Added new object: LogiMap, random generator based on the logistic map.
+
+ * Added Server.setCallback method to allow the user to define a custom
+ process function. This function will be called once per buffer size,
+ just before the computation of the audio object tree.
+
+ * Added PyoTableObject.getBuffer() method. The PyoTableObject now support
+ the buffer protocol (see PEP 3118), which allow a table to share its
+ data memory with any object that support the buffer protocol
+ (ex. numpy ndarray).
+
+2016-09-29 belangeo <belangeo at gmail.com>
+
+ * Added sysexout() method to the Server object.
+
+2016-09-08 belangeo <belangeo at gmail.com>
+
+ * Added new examples, 05-envelopes and 06-filters.
+
+2016-08-09 belangeo <belangeo at gmail.com>
+
+ * Replaced all printf statements with PySys_WriteStdout. This allow to
+ redirect message from pyo to a string or a file, instead of the stdout.
+
+2016-06-01 belangeo <belangeo at gmail.com>
+
+ * Added WDMKS in the portaudio build routine.
+
+2016-05-13 belangeo <belangeo at gmail.com>
+
+ * Fixed wrong definition of withOsc() and withCoreaudio().
+ * Real final revision for version 0.8.0.
+ - SHA:
+
+2016-05-12 belangeo <belangeo at gmail.com>
+
+ * Final revision for version 0.8.0.
+ - SHA: e833e404e20e9531b901ee8924b66f711f3c5e8f
+
+2016-05-10 belangeo <belangeo at gmail.com>
+
+ * Added new functions: withPortaudio, withPortmidi, withCoreaudio, withJack, withOSC.
+
+2016-05-10 belangeo <belangeo at gmail.com>
+
+ * Added a bela framework (BeagleBone Black) with instructions in the embedded folder.
+
+2016-05-10 belangeo <belangeo at gmail.com>
+
+ * Added a new compilation flag, --minimal, to build without portaudio, portmidi and liblo.
+
+2016-05-10 belangeo <belangeo at gmail.com>
+
+ * Added new examples on the online documentation.
+
+2016-05-06 belangeo <belangeo at gmail.com>
+
+ * Made portaudio, portmidi and liblo optional dependencies.
+
+2016-04-29 belangeo <belangeo at gmail.com>
+
+ * Added a quality factor everywhere a FLAC or OGG sound file can be saved on disk.
+
+2016-04-03 belangeo <belangeo at gmail.com>
+
+ * Disto uses now a simple but more efficient waveshaper formula. This algorithm
+ is faster and does not produce large amplitude variation like the atan2 function.
+
+2016-04-03 belangeo <belangeo at gmail.com>
+
+ * Added new object: Exp, calculates the value of e to the power of x.
+
+2016-04-02 belangeo <belangeo at gmail.com>
+
+ * Revision, clean-up and optimization of various filters in the library.
+ (Biquad, Biquadx, Port, Tone, Atone, Allpass, Allpass2, Phaser, BandSplit MoogLP).
+
+2016-03-31 belangeo <belangeo at gmail.com>
+
+ * Fixed bug when a LFO object receives a negative frequency.
+
+2016-03-28 belangeo <belangeo at gmail.com>
+
+ * Added new object: FastSine, two fast sin approximations (faster than linear table lookup).
+
+2016-03-27 belangeo <belangeo at gmail.com>
+
+ * Added new function : getPyoKeywords, returns the list of pyo keywords (classes and functions).
+
+2016-03-26 belangeo <belangeo at gmail.com>
+
+ * Added an argument arg to the Pattern object.
+
+2016-03-25 belangeo <belangeo at gmail.com>
+
+ * Fixed unwanted offset in type 7 (sinmod) of LFO object.
+
+2016-03-23 belangeo <belangeo at gmail.com>
+
+ * Added setExp() method to Fader, Adsr, MidiAdsr and MidiDelAdsr, allowing
+
+2016-03-18 belangeo <belangeo at gmail.com>
+
+ * Fixed Counter.reset() method.
+
+2016-03-18 belangeo <belangeo at gmail.com>
+
+ * A CallAfter object can now be triggered many times.
+
+2016-03-18 belangeo <belangeo at gmail.com>
+
+ * Added new object: MoogLP, 24dB/oct resonant lowpass filter.
+
+2016-03-16 belangeo <belangeo at gmail.com>
+
+ * Added new object: ChenLee, another chaotic attractor based on the Chen-Lee system.
+
+2016-03-16 belangeo <belangeo at gmail.com>
+
+ * Added new object: PadSynthTable, a beautiful algorithm from Nasca Octavian Paul.
+
+2016-03-13 belangeo <belangeo at gmail.com>
+
+ * Added rotate and copyData methods to the PyoTableObject.
+
+2016-03-12 belangeo <belangeo at gmail.com>
+
+ * Fixed TableWrite writing pointer in the table. Added a mode attribute
+ to select between normalized (0->1) or raw (samples) position.
+
2016-03-01 belangeo <belangeo at gmail.com>
* Final revision for version 0.7.9.
diff --git a/README.md b/README.md
index 49b1075..1fd9a95 100644
--- a/README.md
+++ b/README.md
@@ -15,23 +15,26 @@ MIDI protocol, for generating sound events and controlling process parameters.
pyo allows creation of sophisticated signal processing chains with all the
benefits of a mature, and widely used, general programming language.
-Systems : OS X (10.5 -> 10.10), linux, Windows (XP, Vista, 7, 8)
+Systems : macOS (10.6 -> 10.12), linux, Windows (XP, Vista, 7, 8, 10)
-Python versions : 2.6, 2.7
+Python versions : 2.7.x (stable), 3.x.x (still experimental)
[PYO OFFICAL WEB SITE](http://ajaxsoundstudio.com/pyo/)
-**Download latest binaries, source release and documentation** [HERE](http://ajaxsoundstudio.com/pyo/)!
+**Download latest binaries, source release and documentation**
+[HERE](http://ajaxsoundstudio.com/pyo/)!
How to get pyo running from sources on OS X and linux:
[INSTALL Instructions](http://ajaxsoundstudio.com/pyodoc/compiling.html)
-pyo was awarded **second prize** in the [Lomus 2012](http://concours.afim-asso.org/2012/) Free Software Competition.
+pyo was awarded **second prize** in the
+[Lomus 2012](http://concours.afim-asso.org/2012/) Free Software Competition.
## Radio Pyo ##
-If you want to listen to scripts rendered in real-time, just connect to [Radio Pyo](http://radiopyo.acaia.ca/) !
+If you want to listen to scripts rendered in real-time, just connect to
+[Radio Pyo](http://radiopyo.acaia.ca/) !
You want to have your script played on the radio ? Follow the instructions on this
[post](http://acaia.ca/~tiago/posts/introducing-radio-pyo-live-music-in-python/) !
@@ -40,11 +43,16 @@ You want to have your script played on the radio ? Follow the instructions on th
[Zyne](https://github.com/belangeo/zyne) : A modular soft synthesizer.
-[Soundgrain](http://ajaxsoundstudio.com/software/soundgrain/) : A graphical interface where users can draw and edit trajectories to control granular sound synthesis.
+[Soundgrain](http://ajaxsoundstudio.com/software/soundgrain/) :
+A graphical interface where users can draw and edit trajectories to control
+granular sound synthesis.
-[Cecilia 5](http://ajaxsoundstudio.com/software/cecilia/) : An audio signal processing environment.
+[Cecilia 5](http://ajaxsoundstudio.com/software/cecilia/) : An audio signal
+processing environment.
-[PsychoPy](http://www.psychopy.org/) : An open-source application to allow the presentation of stimuli and collection of data for a wide range of neuroscience, psychology and psychophysics experiments.
+[PsychoPy](http://www.psychopy.org/) : An open-source application to allow the
+presentation of stimuli and collection of data for a wide range of neuroscience,
+psychology and psychophysics experiments.
## Examples ##
@@ -92,4 +100,4 @@ If you feel this project is useful to you and want to support it and it's
future development please consider donating money. I only ask for a small
donation, but of course I appreciate any amount.
-[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9CA99DH6ES3HA)
\ No newline at end of file
+[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9CA99DH6ES3HA)
diff --git a/doc-sphinx/build.py b/doc-sphinx/build.py
index 50c9fe8..457067b 100644
--- a/doc-sphinx/build.py
+++ b/doc-sphinx/build.py
@@ -1,5 +1,4 @@
import os, sys
-from types import ListType
from pyo import *
build_format = "html"
@@ -7,6 +6,9 @@ build_folder = "./build_html"
if "--latex" in sys.argv:
build_format = "latex"
build_folder = "./build_latex"
+elif "--man" in sys.argv:
+ build_format = "man"
+ build_folder = "./build_man"
f = open(os.getcwd() + '/source/api/alphabetical.rst', 'w')
@@ -36,15 +38,19 @@ def getDocFirstLine(obj):
format = "- :py:class:`%s` : %s\n"
lines = []
-for key in ['Server', 'Stream', 'TableStream', 'PyoObjectBase', 'Map']:
- if type(OBJECTS_TREE[key]) == ListType:
- for obj in OBJECTS_TREE[key]:
- lines.append(format % (obj, getDocFirstLine(obj)))
+for key in ['Server', 'Stream', 'TableStream', 'PyoObjectBase', 'Map',
+ 'MidiListener', 'OscListener', 'PyoGui']:
+ if type(OBJECTS_TREE[key]) == list:
+ if key in ['MidiListener', 'OscListener']:
+ lines.append(format % (key, getDocFirstLine(key)))
+ else:
+ for obj in OBJECTS_TREE[key]:
+ lines.append(format % (obj, getDocFirstLine(obj)))
else:
if key == 'Map': key2list = ['SLMap']
else: key2list = ['PyoMatrixObject', 'PyoTableObject', 'PyoObject', 'PyoPVObject']
for key2 in key2list:
- if type(OBJECTS_TREE[key][key2]) == ListType:
+ if type(OBJECTS_TREE[key][key2]) == list:
for obj in OBJECTS_TREE[key][key2]:
lines.append(format % (obj, getDocFirstLine(obj)))
else:
@@ -58,6 +64,39 @@ for line in lines:
f.close()
+# New examples listing
+os.mkdir("source/examples")
+folders = sorted([d for d in os.listdir("../examples") if d[0] in ['0', '1']])
+for dir in folders:
+ os.mkdir("source/examples/%s" % dir)
+ index = open("source/examples/%s/index.rst" % dir, "w")
+ index.write(dir + "\n")
+ index.write("="*40)
+ index.write("\n\n.. toctree::\n :maxdepth: 1\n\n")
+ for name in sorted(os.listdir("../examples/%s" % dir)):
+ index.write(" " + name[:-3] + "\n")
+ with open("../examples/%s/%s" % (dir, name), "r") as f:
+ text = f.read()
+ with open("source/examples/%s/%s.rst" % (dir, name[:-3]), "w") as f:
+ pos = text.find('"""')
+ pos = text.find('"""', pos+3)
+ code = text[pos+3:].strip()
+ intro = text[:pos+3].replace('"""', '').strip()
+ tpos = intro.find("\n")
+ title = intro[:tpos]
+ f.write(title + "\n")
+ f.write("="*140)
+ f.write("\n")
+ f.write(intro[tpos:])
+ f.write("\n\n")
+ f.write(".. code-block:: python\n\n")
+ for line in code.splitlines():
+ f.write(" " + line + "\n")
+ f.write("\n")
+ index.close()
+
+os.system("cp ../utils/E-PyoIcon.png source/")
+
os.system("sphinx-build -a -b %s ./source %s" % (build_format, build_folder))
if build_format == "latex":
@@ -67,3 +106,6 @@ 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")
+os.system("rm -r source/examples")
+
+os.system("rm source/E-PyoIcon.png")
diff --git a/doc-sphinx/source/_static/nature.css b/doc-sphinx/source/_static/nature.css
index 5d73f48..7fc7c54 100644
--- a/doc-sphinx/source/_static/nature.css
+++ b/doc-sphinx/source/_static/nature.css
@@ -132,12 +132,12 @@ div.sphinxsidebar input[type=text]{
/* -- body styles ----------------------------------------------------------- */
a {
- color: #005B81;
+ color: #333388;
text-decoration: none;
}
a:hover {
- color: #E32EFF;
+ color: #111166;
text-decoration: underline;
}
diff --git a/doc-sphinx/source/about.rst b/doc-sphinx/source/about.rst
index c79d72d..e90824b 100644
--- a/doc-sphinx/source/about.rst
+++ b/doc-sphinx/source/about.rst
@@ -1,10 +1,12 @@
-About Pyo
+About pyo
=================
Pyo is a Python module written in C to help digital signal processing script
-creation.
+creation. It provides a complete set of classes to build audio softwares,
+compose algorithmic musics or simply explore audio processing with a simple,
+mature and powerful programming language.
-Pyo is a Python module written in C to help DSP script creation. Pyo contains
+Pyo contains
classes for a wide variety of audio signal processing. With pyo, the user will
be able to include signal processing chains directly in Python scripts or
projects, and to manipulate them in real time through the interpreter. Tools
@@ -19,9 +21,11 @@ widely used general programming language.
Pyo is developed by Olivier Bélanger < belangeo at gmail.com >
-For questions and comments, please subscribe to the `pyo-discuss <http://groups.google.com/group/pyo-discuss>`_ mailing list.
+For questions and comments, please subscribe to the
+`pyo-discuss <http://groups.google.com/group/pyo-discuss>`_ mailing list.
-To report a bug or to request a feature, use the `issues tracker <https://github.com/belangeo/pyo/issues>`_ on github.
+To report a bug or to request a feature, use the
+`issues tracker <https://github.com/belangeo/pyo/issues>`_ on github.
Sources and binaries can be downloaded at:
http://ajaxsoundstudio.com/software/pyo/
diff --git a/doc-sphinx/source/api/alphabetical.rst b/doc-sphinx/source/api/alphabetical.rst
index 6ae547a..34878f3 100644
--- a/doc-sphinx/source/api/alphabetical.rst
+++ b/doc-sphinx/source/api/alphabetical.rst
@@ -36,6 +36,7 @@ Alphabetical class reference
- :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.
+- :py:class:`ChenLee` : Chaotic attractor for the Chen-Lee system.
- :py:class:`Choice` : Periodically choose a new value from a user list.
- :py:class:`Chorus` : 8 modulated delay lines chorus processor.
- :py:class:`Clean_objects` : Stops and deletes PyoObjects after a given time.
@@ -64,18 +65,20 @@ Alphabetical class reference
- :py:class:`Delay1` : Delays a signal by one sample.
- :py:class:`Delay` : Sweepable recursive delay.
- :py:class:`Denorm` : Mixes low level noise to an input signal.
-- :py:class:`Disto` : Arc tangent distortion.
+- :py:class:`Disto` : Kind of Arc tangent distortion.
- :py:class:`Dummy` : Dummy object used to perform arithmetics on PyoObject.
- :py:class:`EQ` : Equalizer filter.
- :py:class:`Euclide` : Euclidean rhythm generator.
- :py:class:`ExpTable` : Construct a table from exponential interpolated segments.
+- :py:class:`Exp` : Calculates the value of e to the power of x.
- :py:class:`Expr` : Prefix audio expression evaluator.
- :py:class:`Expr` : Prefix audio expression evaluator.
-- :py:class:`Expseg` : Trace a series of exponential segments between specified break-points.
+- :py:class:`Expseg` : Draw 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:`FastSine` : A fast sine wave approximation using the formula of a parabola.
- :py:class:`Floor` : Rounds to largest integral value not greater than audio signal.
- :py:class:`Follower2` : Envelope follower with different attack and release times.
- :py:class:`Follower` : Envelope follower.
@@ -102,11 +105,12 @@ 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` : Draw 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.
- :py:class:`Log` : Performs a natural log function on audio signal.
+- :py:class:`LogiMap` : Random generator based on the logistic map.
- :py:class:`Lookup` : Uses table to do waveshaping on an audio signal.
- :py:class:`Looper` : Crossfading looper.
- :py:class:`Lorenz` : Chaotic attractor for the Lorenz system.
@@ -120,11 +124,13 @@ Alphabetical class reference
- :py:class:`Metro` : Generates isochronous trigger signals.
- :py:class:`MidiAdsr` : Midi triggered ADSR envelope generator.
- :py:class:`MidiDelAdsr` : Midi triggered ADSR envelope generator with pre-delay.
+- :py:class:`MidiListener` : Self-contained midi listener thread.
- :py:class:`Midictl` : Get the current value of a Midi controller.
- :py:class:`Min` : Outputs the minimum of two values.
- :py:class:`Mirror` : Reflects the signal that exceeds the `min` and `max` thresholds.
- :py:class:`Mix` : Mix audio streams to arbitrary number of streams.
- :py:class:`Mixer` : Audio mixer.
+- :py:class:`MoogLP` : A fourth-order resonant lowpass filter.
- :py:class:`NewMatrix` : Create a new matrix 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.
@@ -136,6 +142,7 @@ Alphabetical class reference
- :py:class:`OscDataReceive` : Receives data values over a network via the Open Sound Control protocol.
- :py:class:`OscDataSend` : Sends data values over a network via the Open Sound Control protocol.
- :py:class:`OscListReceive` : Receives list of values over a network via the Open Sound Control protocol.
+- :py:class:`OscListener` : Self-contained OSC listener thread.
- :py:class:`OscLoop` : A simple oscillator with feedback reading a waveform table.
- :py:class:`OscReceive` : Receives values over a network via the Open Sound Control protocol.
- :py:class:`OscSend` : Sends values over a network via the Open Sound Control protocol.
@@ -159,6 +166,7 @@ Alphabetical class reference
- :py:class:`PVSynth` : Phase Vocoder synthesis object.
- :py:class:`PVTranspose` : Transpose the frequency components of a pv stream.
- :py:class:`PVVerb` : Spectral domain reverberation.
+- :py:class:`PadSynthTable` : Generates wavetable with the PadSynth algorithm from Nasca Octavian Paul.
- :py:class:`Pan` : Cosinus panner with control on the spread factor.
- :py:class:`ParaTable` : Generates parabola window function.
- :py:class:`PartialTable` : Inharmonic waveform generator.
@@ -177,6 +185,13 @@ Alphabetical class reference
- :py:class:`Print` : Print PyoObject's current value.
- :py:class:`Programin` : Get the current value of a program change Midi controller.
- :py:class:`Pulsar` : Pulsar synthesis oscillator.
+- :py:class:`PyoGuiControlSlider` : Floating-point control slider.
+- :py:class:`PyoGuiGrapher` : Multi-modes break-points function editor.
+- :py:class:`PyoGuiMultiSlider` : Data multi-sliders editor.
+- :py:class:`PyoGuiScope` : Oscilloscope display.
+- :py:class:`PyoGuiSndView` : Soundfile display.
+- :py:class:`PyoGuiSpectrum` : Frequency spectrum display.
+- :py:class:`PyoGuiVuMeter` : Multi-channels Vu Meter.
- :py:class:`RCOsc` : Waveform aproximation of a RC circuit.
- :py:class:`RandDur` : Recursive time varying pseudo-random generator.
- :py:class:`RandInt` : Periodic pseudo-random integer generator.
diff --git a/doc-sphinx/source/api/classes/arithmetic.rst b/doc-sphinx/source/api/classes/arithmetic.rst
index 757bdfc..f7278cd 100644
--- a/doc-sphinx/source/api/classes/arithmetic.rst
+++ b/doc-sphinx/source/api/classes/arithmetic.rst
@@ -89,4 +89,9 @@ Tools to perform arithmetic operations on audio signals.
.. autoclass:: Pow
:members:
+*Exp*
+------------
+
+.. autoclass:: Exp
+ :members:
diff --git a/doc-sphinx/source/api/classes/expression.rst b/doc-sphinx/source/api/classes/expression.rst
index 4d544b6..9953f4e 100644
--- a/doc-sphinx/source/api/classes/expression.rst
+++ b/doc-sphinx/source/api/classes/expression.rst
@@ -3,6 +3,8 @@ Prefix expression evaluators
.. module:: pyo
+.. highlight:: none
+
Prefix audio expression evaluator.
This family implements a tiny functional programming language that
@@ -237,6 +239,8 @@ A triangle waveform generator (use Sig(0) as input argument to bypass input)::
)
triangle #freq
+.. highlight:: python
+
**Objects**
-----------
diff --git a/doc-sphinx/source/api/classes/filters.rst b/doc-sphinx/source/api/classes/filters.rst
index 358744b..ba96b4e 100644
--- a/doc-sphinx/source/api/classes/filters.rst
+++ b/doc-sphinx/source/api/classes/filters.rst
@@ -186,3 +186,8 @@ sinusoidal component according to its frequency.
.. autoclass:: ComplexRes
:members:
+*MoogLP*
+------------
+
+.. autoclass:: MoogLP
+ :members:
diff --git a/doc-sphinx/source/api/classes/generators.rst b/doc-sphinx/source/api/classes/generators.rst
index 17632ce..0316e5d 100644
--- a/doc-sphinx/source/api/classes/generators.rst
+++ b/doc-sphinx/source/api/classes/generators.rst
@@ -18,12 +18,24 @@ processing chain or as parameter's modifiers.
.. autoclass:: BrownNoise
:members:
+*ChenLee*
+-----------------------------------
+
+.. autoclass:: ChenLee
+ :members:
+
*CrossFM*
-----------------------------------
.. autoclass:: CrossFM
:members:
+*FastSine*
+-----------------------------------
+
+.. autoclass:: FastSine
+ :members:
+
*FM*
-----------------------------------
diff --git a/doc-sphinx/source/api/classes/opensndctrl.rst b/doc-sphinx/source/api/classes/opensndctrl.rst
index fbffedc..7cab1d7 100644
--- a/doc-sphinx/source/api/classes/opensndctrl.rst
+++ b/doc-sphinx/source/api/classes/opensndctrl.rst
@@ -14,6 +14,11 @@ input port.
The audio streams of these objects are essentially intended to be
controls and can't be sent to the output soundcard.
+.. note::
+
+ These objects are available only if pyo is built with OSC (Open Sound
+ Control) support.
+
*OscDataReceive*
-----------------------------------
diff --git a/doc-sphinx/source/api/classes/randoms.rst b/doc-sphinx/source/api/classes/randoms.rst
index b7f79e8..c49c505 100644
--- a/doc-sphinx/source/api/classes/randoms.rst
+++ b/doc-sphinx/source/api/classes/randoms.rst
@@ -11,6 +11,12 @@ Set of objects that implement different kinds of random noise generators.
.. autoclass:: Choice
:members:
+*LogiMap*
+-----------------------------------
+
+.. autoclass:: LogiMap
+ :members:
+
*RandDur*
-----------------------------------
diff --git a/doc-sphinx/source/api/classes/tables.rst b/doc-sphinx/source/api/classes/tables.rst
index 326aefa..653f2dc 100644
--- a/doc-sphinx/source/api/classes/tables.rst
+++ b/doc-sphinx/source/api/classes/tables.rst
@@ -119,3 +119,9 @@ in memory and access them quickly.
.. autoclass:: AtanTable
:members:
+
+*PadSynthTable*
+-----------------------------------
+
+.. autoclass:: PadSynthTable
+ :members:
diff --git a/doc-sphinx/source/api/classes/utils.rst b/doc-sphinx/source/api/classes/utils.rst
index 360e6e7..782529f 100644
--- a/doc-sphinx/source/api/classes/utils.rst
+++ b/doc-sphinx/source/api/classes/utils.rst
@@ -59,6 +59,12 @@ Miscellaneous objects.
.. autoclass:: Denorm
:members:
+*FToM*
+-----------------------------------
+
+.. autoclass:: FToM
+ :members:
+
*Interp*
-----------------------------------
diff --git a/doc-sphinx/source/api/functions/audio.rst b/doc-sphinx/source/api/functions/audio.rst
index eeff482..71202c2 100644
--- a/doc-sphinx/source/api/functions/audio.rst
+++ b/doc-sphinx/source/api/functions/audio.rst
@@ -1,6 +1,12 @@
Audio Setup
======================================
+Set of functions to inspect the system's audio configuration.
+
+.. note::
+
+ These functions are available only if pyo is built with portaudio support.
+
.. module:: pyo
*pa_get_version*
diff --git a/doc-sphinx/source/api/functions/midi.rst b/doc-sphinx/source/api/functions/midi.rst
index 7adfd0d..7356e77 100644
--- a/doc-sphinx/source/api/functions/midi.rst
+++ b/doc-sphinx/source/api/functions/midi.rst
@@ -1,6 +1,12 @@
Midi Setup
======================================
+Set of functions to inspect the system's midi configuration.
+
+.. note::
+
+ These functions are available only if pyo is built with portmidi support.
+
.. module:: pyo
*pm_get_default_output*
diff --git a/doc-sphinx/source/api/functions/server.rst b/doc-sphinx/source/api/functions/server.rst
index 07b8b15..1fb29d5 100644
--- a/doc-sphinx/source/api/functions/server.rst
+++ b/doc-sphinx/source/api/functions/server.rst
@@ -1,4 +1,4 @@
-Server Quieries
+Server Queries
======================================
.. module:: pyo
diff --git a/doc-sphinx/source/api/functions/util.rst b/doc-sphinx/source/api/functions/util.rst
index f89c566..6193cf5 100644
--- a/doc-sphinx/source/api/functions/util.rst
+++ b/doc-sphinx/source/api/functions/util.rst
@@ -18,6 +18,36 @@ Utilities
.. autofunction:: getVersion
+*getPyoKeywords*
+---------------------------------
+
+.. autofunction:: getPyoKeywords
+
+*withPortaudio*
+---------------------------------
+
+.. autofunction:: withPortaudio
+
+*withPortmidi*
+---------------------------------
+
+.. autofunction:: withPortmidi
+
+*withJack*
+---------------------------------
+
+.. autofunction:: withJack
+
+*withCoreaudio*
+---------------------------------
+
+.. autofunction:: withCoreaudio
+
+*withOSC*
+---------------------------------
+
+.. autofunction:: withOSC
+
*convertStringToSysEncoding*
---------------------------------
diff --git a/doc-sphinx/source/api/index.rst b/doc-sphinx/source/api/index.rst
index 30d459a..fcecb5c 100644
--- a/doc-sphinx/source/api/index.rst
+++ b/doc-sphinx/source/api/index.rst
@@ -1,4 +1,4 @@
-API Documentation
+API documentation
===============================
.. toctree::
diff --git a/doc-sphinx/source/compiling.rst b/doc-sphinx/source/compiling.rst
index 4f26874..cc40692 100644
--- a/doc-sphinx/source/compiling.rst
+++ b/doc-sphinx/source/compiling.rst
@@ -1,24 +1,29 @@
-Compiling
-=====================
+Compiling pyo from sources
+==========================
-Here is how you can compile pyo from sources.
+Here is how you can compile pyo from sources on Linux and MacOS (if you are
+interested in the adventure of compiling pyo from sources on Windows, you can
+take a look at my personal notes in `windows-7-build-routine.txt
+<https://github.com/belangeo/pyo/blob/master/scripts/win/windows-7-build-routine.txt>`_).
Dependencies
---------------
+------------
-To compile pyo, you will need the following dependencies:
+To compile pyo with all its features, you will need the following dependencies:
-- `Python 2.6 or 2.7 <https://www.python.org/downloads/>`_
+- `Python 2.7.x or 3.5.x <https://www.python.org/downloads/>`_
- `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/>`_
+- `git <https://git-scm.com/>`_ (if you want the latest sources)
Getting sources
--------------------
+---------------
-You can download pyo's source checking out the source code here:
+You can download pyo's sources by checking out the source code
+`here <https://github.com/belangeo/pyo>`_:
.. code-block:: bash
@@ -27,7 +32,7 @@ You can download pyo's source checking out the source code here:
Compilation
---------------
-Please note that under Mac OS X you will need to install the
+Please note that under MacOS you will need to install the
**Apple's developer tools** to compile pyo.
Once you have all the required dependencies, go in pyo's directory:
@@ -36,33 +41,42 @@ Once you have all the required dependencies, go in pyo's directory:
cd path/to/pyo
-You then need to build the extension:
+And build the library:
+MacOS:
+
.. code-block:: bash
sudo python setup.py install
-You can customize you compilation by giving some flags to the command line.
+Debian & Ubuntu:
+
+.. code-block:: bash
+
+ sudo python setup.py install --install-layout=deb
+
+You can customize your compilation by giving some flags to the command line.
.. _compilation-flags-label:
Compilation flags
-*********************
+*****************
-If you want to be able to use coreaudio (Mac OS X):
+If you want to be able to use coreaudio (MacOS):
.. code-block:: bash
--use-coreaudio
-If you want JACK support (Linux, Mac OS X):
+If you want JACK support (Linux, MacOS):
.. code-block:: bash
--use-jack
If you want to be able to use a 64-bit pyo (All platforms, this is the sample
-resolution, not the architecture), this will build both single and double precision:
+resolution, not the architecture), this will build both single and double
+precisions:
.. code-block:: bash
@@ -74,14 +88,39 @@ If you want to disable most of messages printed to the console:
--no-messages
-If you want to compile external classes defined in externals folder:
+If you want to compile external classes defined in pyo/externals folder:
.. code-block:: bash
--compile-externals
+By default, debug symbols are off. If you want to compile pyo with debug symbols:
+
+.. code-block:: bash
+
+ --debug
+
+By default, optimizations are activated. If you want to compile pyo without
+optimizations:
+
+.. code-block:: bash
+
+ --fast-compile
+
+If you want to compile pyo with minimal dependencies (mostly for integrated use
+in a host environment):
+
+.. code-block:: bash
+
+ --minimal
+
+This will compile pyo without portaudio, portmidi and liblo support.
+
Compilation scripts
-**********************
+*******************
+
+In the ./scripts folder, there is some alternate scripts to simplify the
+compilation process a little bit.
To compile both 32-bit and 64-bit resolutions on linux (with jack support):
@@ -89,22 +128,23 @@ To compile both 32-bit and 64-bit resolutions on linux (with jack support):
sudo sh scripts/compile_linux_withJack.sh
-To compile both 32-bit and 64-bit resolutions on OS X (without Jack):
+To compile both 32-bit and 64-bit resolutions on macOS (without Jack):
.. code-block:: bash
sudo sh scripts/compile_OSX.sh
-To compile both 32-bit and 64-bit resolutions on OS X (with Jack):
+To compile both 32-bit and 64-bit resolutions on macOS (with Jack):
.. code-block:: bash
sudo sh scripts/compile_OSX_withJack.sh
-Ubuntu (Debian)
--------------------
+Debian & Ubuntu (apt-get)
+-------------------------
-Under Ubuntu you can type the following commands to get pyo up and running:
+Under Debian & Ubuntu you can type the following commands to get pyo up
+and running:
.. code-block:: bash
@@ -117,32 +157,20 @@ Under Ubuntu you can type the following commands to get pyo up and running:
* On Ubuntu system prior to vivid, wxpython 3.0 must be compiled from sources.
-OSX (Homebrew)
---------------------
+MacOS (Homebrew)
+----------------
-Under OS X, it is very simple to build pyo from sources with the Homebrew package mananger.
+Under macOS, it is very simple to build pyo from sources with the Homebrew
+package manager.
-First, you need to install `Homebrew <http://brew.sh/>`. Then, in a terminal window:
+First, install Python and WxPython from the binary installers.
+
+Second, you need to install `Homebrew <http://brew.sh/>`_. Then, in a terminal
+window:
.. code-block:: bash
- brew install python liblo libsndfile portaudio portmidi --universal
+ brew install liblo libsndfile portaudio portmidi --universal
git clone https://github.com/belangeo/pyo.git
cd pyo
python setup.py install --use-coreaudio --use-double
-
-* To build a universal portmidi library with homebrew, the formula must be modified like this:
-
-Add the option "universal":
-
-.. code-block:: bash
-
- option :universal
-
-And modify the "install function" to add the universal variable:
-
-.. code-block:: bash
-
- def install
- ENV.universal_binary if build.universal?
-
diff --git a/doc-sphinx/source/conf.py b/doc-sphinx/source/conf.py
index 0d8b3c1..b551713 100644
--- a/doc-sphinx/source/conf.py
+++ b/doc-sphinx/source/conf.py
@@ -43,7 +43,7 @@ master_doc = 'index'
# General information about the project.
project = u'Pyo'
-copyright = u'2015, Olivier Bélanger'
+copyright = u'2016, 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
diff --git a/doc-sphinx/source/download.rst b/doc-sphinx/source/download.rst
index 2865006..56eac40 100644
--- a/doc-sphinx/source/download.rst
+++ b/doc-sphinx/source/download.rst
@@ -1,8 +1,35 @@
-Downloading
-=================
+Downloading the installer
+==========================
-Installers are available for Windows (Win 7/8/10) and for Max OS X (from 10.6 to 10.10).
+Installers are available for Windows (XP/Vista/7/8/10) and for MacOS
+(from 10.6 to 10.12).
-To download the latest pre-compiled version of pyo, go to the pyo's `web page <http://ajaxsoundstudio.com/software/pyo/>`_.
+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**.
+Under Debian and Fedora distros, you can get pyo from the package manager.
+The library's name is **python-pyo**.
+
+If you are running Arch linux, the package is called **python2-pyo**.
+
+
+Content of the installer
+----------------------------
+
+The installer installs two distinct softwares on the system. First, it will
+install the pyo module (compiled for both single and double precision) and its
+dependencies under the current python distribution. Secondly, it will install
+E-Pyo, a simple text editor especially tuned to edit and run audio python script.
+
+Pyo is a python module...
+-----------------------------
+
+... which means that python must be present (version 2.7.x is the current one,
+version 3.5.x is experimental but everything seems to work well so far) on the
+system. If python is not installed, you can download it on
+`python.org <https://www.python.org/downloads/>`_.
+
+Pyo also offers some GUI facilities to control or visualize the audio processing.
+If you want to use all of pyo's GUI features, you must install WxPython 3.0
+(**classic** for python 2.7.x and **phoenix** for python 3.5.x), available on
+`wxpython.org <http://wxpython.org/download.php>`_.
\ No newline at end of file
diff --git a/doc-sphinx/source/gettingstarted.rst b/doc-sphinx/source/gettingstarted.rst
index f4ed369..785da52 100644
--- a/doc-sphinx/source/gettingstarted.rst
+++ b/doc-sphinx/source/gettingstarted.rst
@@ -1,26 +1,45 @@
-Getting Started
+Getting started
=================================
-Here is quick introduction to Pyo. It assumes you already know Python and basics about Object-oriented programming.
+Here is quick introduction to Pyo. It assumes you already know Python and
+basics about OOP (Object-Oriented Programming).
The Pyo Server and GUI
-----------------------
-The first thing you need to do to use Pyo is import the pyo python module and boot the server. This audio server will open audio and midi interfaces and will be ready to send to them the audio and MIDI produced by other pyo objects. You then need to make some sound:
+The first thing you need to do to use Pyo is import the pyo python module and
+boot the server. This audio server will open audio and midi interfaces and
+will be ready to send to them the audio and MIDI produced by other pyo objects.
+You then need to make some sound:
>>> from pyo import *
>>> s = Server().boot()
>>> s.start()
>>> a = Sine(mul=0.01).out()
-The `s` variable holds the Server instance, which has been booted, using the boot function. Booting the server includes opening audio and MIDI interfaces, and setting up the sample rate and number of channels, but the server will not be processing audio until its start() method is called. Then we create a Sine object, and store it in variable a, after calling its out method. The Sine class defines a Sine wave oscillator. The out method from this class connects the output of the oscillator to the server audio outputs. I have set the mul attribute of the Sine object to make sure you don't blow your ears when you play this, as the default amplitude multiplier is 1, i.e. a sine wave at the maximum amplitude before clipping! (But I'll talk about attributes later...) You can stop the server with:
+The `s` variable holds the Server instance, which has been booted, using the
+boot function. Booting the server includes opening audio and MIDI interfaces,
+and setting up the sample rate and number of channels, but the server will
+not be processing audio until its start() method is called. Then we create a
+Sine object, and store it in variable a, after calling its out method. The
+Sine class defines a Sine wave oscillator. The out method from this class
+connects the output of the oscillator to the server audio outputs. I have
+set the mul attribute of the Sine object to make sure you don't blow your
+ears when you play this, as the default amplitude multiplier is 1, i.e. a
+sine wave at the maximum amplitude before clipping! (But I'll talk about
+attributes later...) You can stop the server with:
>>> s.stop()
To interact or not to interact
--------------------------------
-If you tried the above script from an interactive python shell you would have heard a sine tone, but if you ran it from a python script non-interactively, you are probably asking yourself why you haven't heard anything. The reason is that the script has finished before the server has sent any audio to the outputs! So if you are using python non-interactively, the way to hear this example is:
+If you tried the above script from an interactive python shell you would have
+heard a sine tone, but if you ran it from a python script non-interactively,
+you are probably asking yourself why you haven't heard anything. The reason
+is that the script has finished before the server has sent any audio to the
+outputs! So if you are using python non-interactively, the way to hear this
+example is:
.. code-block:: python
@@ -30,7 +49,14 @@ If you tried the above script from an interactive python shell you would have he
a = Sine(mul=0.01).out()
s.gui(locals())
-In the last line, you can see a very handy method from the Server class, which creates a small control GUI for the current instance. The gui method for the Server object, keeps a script running and allows you to start and stop the server, control the output volume and record to an audio file the sound generated in the server. A handy feature of the server GUI is the interpreter text box in the bottom. From it you can send commands interactively to the interpreter, to start and stop objects, create or destroy them, etc.
+In the last line, you can see a very handy method from the Server class,
+which creates a small control GUI for the current instance. The gui method
+for the Server object, keeps a script running and allows you to start and
+stop the server, control the output volume and record to an audio file the
+sound generated in the server. A handy feature of the server GUI is the
+interpreter text box in the bottom. From it you can send commands
+interactively to the interpreter, to start and stop objects, create or
+destroy them, etc.
Changing Object Characteristics
----------------------------------
@@ -41,7 +67,11 @@ The Sine class constructor is defined as:
Sine(self, freq=1000, phase=0, mul=1, add=0)
-So you can give it a frequency, starting phase, multiplier and DC offset value when you create it. Also, if you want to do without the server gui, you can use the server method start() from your script, but you might need to use the sleep function from the time module to have your script run the server for a while if you are running Python non-interactively:
+So you can give it a frequency, starting phase, multiplier and DC offset
+value when you create it. Also, if you want to do without the server gui,
+you can use the server method start() from your script, but you might need
+to use the sleep function from the time module to have your script run the
+server for a while if you are running Python non-interactively:
.. code-block:: python
@@ -53,13 +83,17 @@ So you can give it a frequency, starting phase, multiplier and DC offset value w
time.sleep(1)
s.stop()
-Notice that you can set the parameters for Sine in the order in which they are defined, but you can also give the parameters a name if you want to leave the rest at their default:
+Notice that you can set the parameters for Sine in the order in which they
+are defined, but you can also give the parameters a name if you want to leave
+the rest at their default:
.. code-block:: python
a = Sine(mul=0.1).out()
-Once the object has been created, you can modify its attributes using the access methods. For example, to modify the frequency of the a oscillator object after it has been created you can use:
+Once the object has been created, you can modify its attributes using the
+access methods. For example, to modify the frequency of the a oscillator
+object after it has been created you can use:
.. code-block:: python
@@ -74,7 +108,8 @@ But you can also set the attributes directly:
Chaining objects
-----------------
-Oscillators like the Sine class can be used as inputs to other classes, for example for frequency modulation:
+Oscillators like the Sine class can be used as inputs to other classes, for
+example for frequency modulation:
.. code-block:: python
@@ -98,7 +133,8 @@ You can create an envelope for a sine wave like this:
Class examples
----------------
-All Classes in Pyo come with an example which shows how it can be used. To execute the example you can do:
+All Classes in Pyo come with an example which shows how it can be used. To
+execute the example you can do:
>>> from pyo import *
>>> example(Harmonizer)
diff --git a/doc-sphinx/source/index.rst b/doc-sphinx/source/index.rst
index 64e0d41..c5223e6 100644
--- a/doc-sphinx/source/index.rst
+++ b/doc-sphinx/source/index.rst
@@ -3,11 +3,20 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
-Welcome to the Pyo 0.7.9 documentation
+Welcome to the pyo 0.8.1 documentation
===================================================
+.. image:: E-PyoIcon.png
+ :scale: 50 %
+ :align: center
+
Pyo is a Python module written in C to help digital signal processing script
-creation.
+creation. It provides a complete set of classes to build audio softwares,
+compose algorithmic musics or simply explore audio processing with a simple,
+mature and powerful programming language.
+
+Parts of the documentation
+--------------------------
.. toctree::
:maxdepth: 1
@@ -15,12 +24,38 @@ creation.
about
download
compiling
+ structure
gettingstarted
- tutorials/index
+ perftips
api/index
+Examples
+---------------
+
+.. toctree::
+ :maxdepth: 1
+
+ First steps <examples/01-intro/index>
+ Parameter control <examples/02-controls/index>
+ Synthesis generators <examples/03-generators/index>
+ Playing with soundfiles <examples/04-soundfiles/index>
+ Amplitude envelopes <examples/05-envelopes/index>
+ Filtering <examples/06-filters/index>
+
+Much more to come... Stay tuned!
+
+Advanced tutorials
+--------------------------
+
+.. toctree::
+ :maxdepth: 1
+
+ tutorials/pyoobject1
+ tutorials/pyoobject2
+ tutorials/pyotableobject1
+
Indices and tables
-==================
+------------------
* :ref:`genindex`
* :ref:`search`
diff --git a/doc-sphinx/source/tutorials/index.rst b/doc-sphinx/source/tutorials/index.rst
deleted file mode 100644
index 8aaf72c..0000000
--- a/doc-sphinx/source/tutorials/index.rst
+++ /dev/null
@@ -1,9 +0,0 @@
-Tutorials
-==============
-
-.. toctree::
- :maxdepth: 1
-
- pyoobject1
- pyoobject2
- pyotableobject1
diff --git a/doc-sphinx/source/tutorials/pyoobject1.rst b/doc-sphinx/source/tutorials/pyoobject1.rst
index 18e7e40..cda0d75 100644
--- a/doc-sphinx/source/tutorials/pyoobject1.rst
+++ b/doc-sphinx/source/tutorials/pyoobject1.rst
@@ -1,5 +1,5 @@
-Tutorial on creating a custom PyoObject (RingMod)
-==================================================
+Tutorial about creating a custom PyoObject (RingMod)
+=====================================================
There are few steps we need to take care of in order to create a class with all
of the PyoObject behaviors.
diff --git a/doc-sphinx/source/tutorials/pyoobject2.rst b/doc-sphinx/source/tutorials/pyoobject2.rst
index 3b31ba5..881bd19 100644
--- a/doc-sphinx/source/tutorials/pyoobject2.rst
+++ b/doc-sphinx/source/tutorials/pyoobject2.rst
@@ -1,5 +1,5 @@
-Tutorial on creating a custom PyoObject (Flanger)
-==================================================
+Another tutorial about creating a custom PyoObject (Flanger)
+=============================================================
There are few steps we need to take care of in order to create a class with all
of the PyoObject behaviors.
diff --git a/doc-sphinx/source/tutorials/pyotableobject1.rst b/doc-sphinx/source/tutorials/pyotableobject1.rst
index de3a66b..c3cdae0 100644
--- a/doc-sphinx/source/tutorials/pyotableobject1.rst
+++ b/doc-sphinx/source/tutorials/pyotableobject1.rst
@@ -1,5 +1,5 @@
-Example of a custom PyoTableObject
-====================================
+Tutorial about creating a custom PyoTableObject (TriTable)
+===========================================================
.. code-block:: python
diff --git a/embedded/m_pyo.h b/embedded/m_pyo.h
index 74afaca..832b1a6 100644
--- a/embedded/m_pyo.h
+++ b/embedded/m_pyo.h
@@ -7,6 +7,16 @@
extern "C" {
#endif
+/* Unicode/string handling. */
+#if PY_MAJOR_VERSION >= 3
+#define PyInt_AsLong PyLong_AsLong
+#define PY_STRING_CHECK(a) PyUnicode_Check(arg)
+#define PY_STRING_AS_STRING(a) PyUnicode_AsUTF8(a)
+#else
+#define PY_STRING_CHECK(a) (PyUnicode_Check(a) || PyBytes_Check(a))
+#define PY_STRING_AS_STRING(a) PyBytes_AsString(a)
+#endif
+
/*
** Creates a new python interpreter and starts a pyo server in it.
** Each instance of pyo, in order to be fully independent of other
@@ -24,7 +34,7 @@ inline PyThreadState * pyo_new_interpreter(float sr, int bufsize, int chnls) {
char msg[64];
PyThreadState *interp;
if(!Py_IsInitialized()) {
- Py_Initialize();
+ Py_InitializeEx(0);
PyEval_InitThreads();
PyEval_ReleaseLock();
}
@@ -58,7 +68,7 @@ inline unsigned long pyo_get_input_buffer_address(PyThreadState *interp) {
PyEval_AcquireThread(interp);
module = PyImport_AddModule("__main__");
obj = PyObject_GetAttrString(module, "_in_address_");
- address = PyString_AsString(obj);
+ address = PY_STRING_AS_STRING(obj);
uadd = strtoul(address, NULL, 0);
PyEval_ReleaseThread(interp);
return uadd;
@@ -80,7 +90,7 @@ inline unsigned long long pyo_get_input_buffer_address_64(PyThreadState *interp)
PyEval_AcquireThread(interp);
module = PyImport_AddModule("__main__");
obj = PyObject_GetAttrString(module, "_in_address_");
- address = PyString_AsString(obj);
+ address = PY_STRING_AS_STRING(obj);
uadd = strtoull(address, NULL, 0);
PyEval_ReleaseThread(interp);
return uadd;
@@ -102,7 +112,7 @@ inline unsigned long pyo_get_output_buffer_address(PyThreadState *interp) {
PyEval_AcquireThread(interp);
module = PyImport_AddModule("__main__");
obj = PyObject_GetAttrString(module, "_out_address_");
- address = PyString_AsString(obj);
+ address = PY_STRING_AS_STRING(obj);
uadd = strtoul(address, NULL, 0);
PyEval_ReleaseThread(interp);
return uadd;
@@ -130,7 +140,7 @@ inline unsigned long pyo_get_embedded_callback_address(PyThreadState *interp) {
PyEval_AcquireThread(interp);
module = PyImport_AddModule("__main__");
obj = PyObject_GetAttrString(module, "_emb_callback_");
- address = PyString_AsString(obj);
+ address = PY_STRING_AS_STRING(obj);
uadd = strtoul(address, NULL, 0);
PyEval_ReleaseThread(interp);
return uadd;
@@ -163,10 +173,15 @@ inline int pyo_get_server_id(PyThreadState *interp) {
** interp : pointer, pointer to the targeted Python thread state.
*/
inline void pyo_end_interpreter(PyThreadState *interp) {
+ PyEval_AcquireThread(interp);
+ PyRun_SimpleString("_s_.setServer()\n_s_.stop()\n_s_.shutdown()");
+ PyEval_ReleaseThread(interp);
+
/* Old method (causing segfault) */
//PyEval_AcquireThread(interp);
//Py_EndInterpreter(interp);
//PyEval_ReleaseLock();
+
/* New method (seems to be ok) */
PyThreadState_Swap(interp);
PyThreadState_Swap(NULL);
@@ -275,7 +290,7 @@ inline int pyo_exec_file(PyThreadState *interp, const char *file, char *msg, int
obj = PyObject_GetAttrString(module, "_ok_");
ok = PyInt_AsLong(obj);
if (ok) {
- sprintf(msg, "try:\n execfile('./%s')\nexcept:\n execfile('%s')",
+ sprintf(msg, "try:\n exec(open('./%s').read())\nexcept:\n exec(open('%s').read())",
file, file);
if (!add) {
PyRun_SimpleString("_s_.setServer()\n_s_.stop()\n_s_.shutdown()");
@@ -319,7 +334,7 @@ inline int pyo_exec_statement(PyThreadState *interp, char *msg, int debug) {
module = PyImport_AddModule("__main__");
obj = PyObject_GetAttrString(module, "_error_");
if (obj != Py_None) {
- strcpy(msg, PyString_AsString(obj));
+ strcpy(msg, PY_STRING_AS_STRING(obj));
err = 1;
}
PyEval_ReleaseThread(interp);
diff --git a/embedded/openframeworks/README b/embedded/openframeworks/README
index da83818..6d02d4d 100644
--- a/embedded/openframeworks/README
+++ b/embedded/openframeworks/README
@@ -14,13 +14,13 @@ default location (OF_ROOT/apps/myApps).
Step 2 - Add pyo files to your project. You only need to copy
these files in your project's src folder:
-- from this folder:
+- from the folder pyo/embedded:
+m_pyo.h
+
+- from the folder pyo/embedded/openframeworks:
PyoClass.cpp
PyoClass.h
-- from the folder "embedded":
-m_pyo.h
-
------------------------------------------------------------------------
Step 3 - Make sure that your project includes flags for compiling
and linking against Python. On Unix systems, you can set the Python
diff --git a/embedded/puredata/pyo~-help.pd b/embedded/puredata/pyo~-help.pd
index f2101a2..ef4257d 100644
--- a/embedded/puredata/pyo~-help.pd
+++ b/embedded/puredata/pyo~-help.pd
@@ -233,8 +233,8 @@ in pyo~ inputs).;
#X text 26 96 play a soundfile to send audio signals to pyo;
#N canvas 193 300 450 300 README 0;
#X text 14 33 Author : Olivier Belanger;
-#X text 14 81 Last update : October 2015;
-#X text 14 57 Version : 0.7.9;
+#X text 14 81 Last update : December 2016;
+#X text 14 57 Version : 0.8.1;
#X text 15 108 pyo website : http://ajaxsoundstudio.com/software/pyo/
;
#X text 15 10 pyo~ : Embedded pyo scripting inside puredata.;
diff --git a/embedded/puredata/pyo~.c b/embedded/puredata/pyo~.c
index 2434653..240b93a 100644
--- a/embedded/puredata/pyo~.c
+++ b/embedded/puredata/pyo~.c
@@ -178,7 +178,7 @@ void pyo_tilde_create(t_pyo_tilde *x, t_symbol *s, int argc, t_atom *argv) {
}
void pyo_tilde_midi_event(t_pyo_tilde *x, t_symbol *s, int argc, t_atom *argv) {
- int status, data1 = 0, data2 = 0;
+ int status = 0, data1 = 0, data2 = 0;
if (argc > 0)
status = (int)atom_getfloat(argv);
if (argc > 1)
diff --git a/examples/algorithmic/01_music_box.py b/examples/algorithmic/01_music_box.py
index 3548f95..cd99c25 100644
--- a/examples/algorithmic/01_music_box.py
+++ b/examples/algorithmic/01_music_box.py
@@ -23,4 +23,4 @@ sines = SineLoop(port, feedback=[.06,.057,.033,.035,.016], mul=[.15,.15,.1,.1,.0
pan = SPan(sines, pan=[0, 1, .2, .8, .5]).out()
#<--
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/algorithmic/02_scale_snap.py b/examples/algorithmic/02_scale_snap.py
index 28a678a..9303a4a 100644
--- a/examples/algorithmic/02_scale_snap.py
+++ b/examples/algorithmic/02_scale_snap.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
"""
Algorithmic melody patterns snapped on a specific scale...
@@ -24,7 +25,7 @@ def changeScl():
global curscl
curscl = (curscl + 1) % len(scls)
snp.choice = scls[curscl]
- print snp.choice
+ print(snp.choice)
metscl = Metro(time=8).play()
tr = TrigFunc(metscl, function=changeScl)
@@ -36,5 +37,3 @@ d2 = Osc(table=wav, freq=snp*1.002, mul=c).out()
d3 = Osc(table=wav, freq=snp*0.997, mul=c).out()
s.gui(locals())
-
-
diff --git a/examples/algorithmic/03_melody_algo.py b/examples/algorithmic/03_melody_algo.py
index f8871cc..c989dc3 100644
--- a/examples/algorithmic/03_melody_algo.py
+++ b/examples/algorithmic/03_melody_algo.py
@@ -12,6 +12,7 @@ s = Server(sr=44100, nchnls=2, buffersize=512, duplex=0).boot()
SCALES = [[0,2,5,7,9,11], [0,2,3,7,8,11], [0,3,5,7,8,10]]
class Melo:
+
def __init__(self, amp=.1, speed=1, midirange=(48,84)):
# table to record new melody fragment
self.table = NewTable(2)
@@ -50,4 +51,4 @@ objs = [a,b,c]
pat = Pattern(time=20, function=choose_scale).play()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/algorithmic/04_drum_machine.py b/examples/algorithmic/04_drum_machine.py
index 8b3c973..bff2b6a 100644
--- a/examples/algorithmic/04_drum_machine.py
+++ b/examples/algorithmic/04_drum_machine.py
@@ -9,20 +9,20 @@ from pyo import *
# Set this constant to True to loop over preset bank
WITH_PRESET = False
-snds3 = ['../snds/alum1.wav', '../snds/alum2.wav',
+snds3 = ['../snds/alum1.wav', '../snds/alum2.wav',
'../snds/alum3.wav', '../snds/alum4.wav']
-presets = [[[16, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0],
- [16, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0],
- [16, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0]],
- [[16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1],
- [16, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0],
- [16, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0]],
- [[16, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1],
- [16, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0],
- [16, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0]],
- [[16, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1],
- [16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0],
+presets = [[[16, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0],
+ [16, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0],
+ [16, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0]],
+ [[16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1],
+ [16, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0],
+ [16, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0]],
+ [[16, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1],
+ [16, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0],
+ [16, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0]],
+ [[16, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1],
+ [16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0],
[16, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1]]]
s = Server(sr=44100, nchnls=2, buffersize=512, duplex=0).boot()
diff --git a/examples/control/01_ctrl_slider.py b/examples/control/01_ctrl_slider.py
index 15a9fe4..619aff8 100644
--- a/examples/control/01_ctrl_slider.py
+++ b/examples/control/01_ctrl_slider.py
@@ -19,4 +19,4 @@ a.ctrl(title="Frequency modulation controls")
b = a.mix(2)
b.out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/control/02_ctrl_multislider.py b/examples/control/02_ctrl_multislider.py
index ea49091..d7413f0 100644
--- a/examples/control/02_ctrl_multislider.py
+++ b/examples/control/02_ctrl_multislider.py
@@ -15,4 +15,4 @@ a = BrownNoise()
b = Biquadx(a, freq=[200, 400, 800, 1600, 3200, 6400], q=10, type=2).out()
b.ctrl(title="Bank of bandpass filters")
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/control/03_table_grapher.py b/examples/control/03_table_grapher.py
index 101ad50..5e9b05c 100644
--- a/examples/control/03_table_grapher.py
+++ b/examples/control/03_table_grapher.py
@@ -44,4 +44,4 @@ ind = TrigEnv(met, table=ind_table, dur=NOTE_DUR)
fm = FM(carrier=freq, ratio=[.997, 1.002], index=ind, mul=amp).out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/control/04_set_example.py b/examples/control/04_set_example.py
index 72115e0..8e86ab9 100644
--- a/examples/control/04_set_example.py
+++ b/examples/control/04_set_example.py
@@ -11,8 +11,8 @@ from random import uniform
s = Server(sr=44100, nchnls=2, buffersize=1024, duplex=0).boot()
-a = FM(carrier=[uniform(197,203) for i in range(10)],
- ratio=[uniform(0.49,0.51) for i in range(10)],
+a = FM(carrier=[uniform(197,203) for i in range(10)],
+ ratio=[uniform(0.49,0.51) for i in range(10)],
index=[uniform(10,15) for i in range(10)], mul=.05).out()
def go():
@@ -21,9 +21,8 @@ def go():
a.set("index", [uniform(5,9) for i in range(10)], 23)
def reset():
- a.carrier=[uniform(197,203) for i in range(10)]
- a.ratio=[uniform(0.49,0.51) for i in range(10)]
- a.index=[uniform(8,12) for i in range(10)]
-
-s.gui(locals())
+ a.carrier = [uniform(197,203) for i in range(10)]
+ a.ratio = [uniform(0.49,0.51) for i in range(10)]
+ a.index = [uniform(8,12) for i in range(10)]
+s.gui(locals())
diff --git a/examples/control/05_mixer.py b/examples/control/05_mixer.py
index 31eb20f..108ea2b 100644
--- a/examples/control/05_mixer.py
+++ b/examples/control/05_mixer.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# encoding: utf-8
+from __future__ import print_function
"""
Mixing multiple inputs to multiple outputs with fade time.
@@ -42,9 +43,9 @@ def assign():
vin = random.randint(0, 2)
vout = random.randint(0, 2)
amp = random.choice([0,0,.25,.33])
- print "%s -> %s, amp = %f" % (inputs[vin], outputs[vout], amp)
+ print("%s -> %s, amp = %f" % (inputs[vin], outputs[vout], amp))
mm.setAmp(vin=vin, vout=vout, amp=amp)
pat = Pattern(function=assign, time=3).play()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/control/06_lfo_controls.py b/examples/control/06_lfo_controls.py
index bdeb860..3a92ca2 100644
--- a/examples/control/06_lfo_controls.py
+++ b/examples/control/06_lfo_controls.py
@@ -18,4 +18,4 @@ feedctl = LFO(freq=freqctl, sharp=.8, type=2, mul=.05, add=.07)
synth = SineLoop(freq=[201.32,199.76,200,201.55], feedback=feedctl, mul=.1).out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/effects/01_flanger.py b/examples/effects/01_flanger.py
index 9be597d..860f5d6 100644
--- a/examples/effects/01_flanger.py
+++ b/examples/effects/01_flanger.py
@@ -17,4 +17,4 @@ 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
+s.gui(locals())
diff --git a/examples/effects/05_fuzz_disto.py b/examples/effects/05_fuzz_disto.py
index e4f9a90..4353c5d 100644
--- a/examples/effects/05_fuzz_disto.py
+++ b/examples/effects/05_fuzz_disto.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# encoding: utf-8
"""
-Fuzz distortion. High gain followed by, asymmetrical clipping,
+Fuzz distortion. High gain followed by, asymmetrical clipping,
hard clip on top, soft compression on bottom.
"""
@@ -41,4 +41,4 @@ out = Interp(src, lp, interp=BALANCE).out()
sc = Scope(out)
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/effects/06_simple_reverb.py b/examples/effects/06_simple_reverb.py
index ced6de4..15747d1 100644
--- a/examples/effects/06_simple_reverb.py
+++ b/examples/effects/06_simple_reverb.py
@@ -21,4 +21,4 @@ c2 = Tone(b2, 3000, mul=0.2).out()
c3 = Tone(b3, 1500, mul=0.2).out()
c4 = Tone(b4, 500, mul=0.2).out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/effects/07_simple_reverb2.py b/examples/effects/07_simple_reverb2.py
index 042f602..58bf39b 100644
--- a/examples/effects/07_simple_reverb2.py
+++ b/examples/effects/07_simple_reverb2.py
@@ -23,4 +23,4 @@ all2 = Allpass(all1, delay=[.0117,.0123], feedback=0.61)
lowp = Tone(all2, freq=3500, mul=.2).out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/effects/08_vocoder_main.py b/examples/effects/08_vocoder_main.py
index 1e0c16e..cb8f998 100644
--- a/examples/effects/08_vocoder_main.py
+++ b/examples/effects/08_vocoder_main.py
@@ -6,7 +6,7 @@ Main script using hand-written vocoder (defined in vocoder_lib.py).
"""
from pyo import *
from vocoder_lib import MyVocoder
-
+
s = Server(sr=44100, nchnls=2, duplex=0).boot()
a = SfPlayer('../snds/baseballmajeur_m.aif', loop=True)
diff --git a/examples/effects/vocoder_lib.py b/examples/effects/vocoder_lib.py
index 6b7f02a..a480213 100644
--- a/examples/effects/vocoder_lib.py
+++ b/examples/effects/vocoder_lib.py
@@ -11,10 +11,10 @@ class MyVocoder(PyoObject):
"""
Vocoder effect.
- A vocoder is an analysis/synthesis system. In the encoder, the input 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
+ A vocoder is an analysis/synthesis system. In the encoder, the input 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 in the (re)synthesizer.
@@ -27,7 +27,7 @@ class MyVocoder(PyoObject):
in2 : PyoObject
Audio source exciting the bank of filters.
base : float or PyoObject, optional
- Base frequency used to compute filter notch frequencies.
+ Base frequency used to compute filter notch frequencies.
Defaults to 50.
spread : float or PyoObject, optional
Spreading of the filter notch frequencies. Defaults to 1.5.
@@ -86,7 +86,7 @@ class MyVocoder(PyoObject):
# Convert all arguments to lists for "list expansion"
# convertArgsToLists function returns variables in argument as lists + maximum list size
- in1_fader, in2_fader, base, spread, q, mul, add, lmax = convertArgsToLists(self._in1_fader,
+ in1_fader, in2_fader, base, spread, q, mul, add, lmax = convertArgsToLists(self._in1_fader,
self._in2_fader, base, spread, q, mul, add)
# Init some lists to keep track of created objects
@@ -100,7 +100,7 @@ class MyVocoder(PyoObject):
# self._base_objs is the audio output seen by the outside world!
# .play(), .out(), .stop() and .mix() methods act on this list
- # "mul" and "add" attributes are also applied on this list's objects
+ # "mul" and "add" attributes are also applied on this list's objects
self._base_objs = []
# Each cycle of the loop creates a mono stream of sound
@@ -151,11 +151,11 @@ class MyVocoder(PyoObject):
[obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._amps)]
[obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._excs)]
[obj.play(wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._outs)]
- if type(chnl) == ListType:
+ if type(chnl) == list:
self._base_objs = [obj.out(wrap(chnl,i), wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
else:
if chnl < 0:
- self._base_objs = [obj.out(i*inc, wrap(dur,i), wrap(delay,i)) \
+ self._base_objs = [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:
self._base_objs = [obj.out(chnl+i*inc, wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
diff --git a/examples/fft/01_fft_filter.py b/examples/fft/01_fft_filter.py
index 942c6a4..fad1a37 100644
--- a/examples/fft/01_fft_filter.py
+++ b/examples/fft/01_fft_filter.py
@@ -4,6 +4,7 @@
Spectral domain filter.
"""
+from __future__ import division
from pyo import *
s = Server(duplex=0).boot()
@@ -12,11 +13,11 @@ a = Noise(.1).mix(2)
size = 1024
olaps = 4
-filter_init = [(0,0.0000),(5,0.9337),(13,0.0000),(21,0.4784),(32,0.0000),(37,0.1927),(size/2,0.0000)]
+filter_init = [(0,0.0000),(5,0.9337),(13,0.0000),(21,0.4784),(32,0.0000),(37,0.1927),(size//2,0.0000)]
fin = FFT(a, size=size, overlaps=olaps, wintype=2)
-t = ExpTable(filter_init, size=size/2)
+t = ExpTable(filter_init, size=size//2)
t.graph(title="Filter shape")
amp = TableIndex(t, fin["bin"])
diff --git a/examples/fft/02_fft_cross.py b/examples/fft/02_fft_cross.py
index 313f9d5..cce72fd 100644
--- a/examples/fft/02_fft_cross.py
+++ b/examples/fft/02_fft_cross.py
@@ -33,4 +33,3 @@ def setSize(x):
fout.size = x
s.gui(locals())
-
diff --git a/examples/fft/04_fft_gate.py b/examples/fft/04_fft_gate.py
index 3681278..e1a4f9f 100644
--- a/examples/fft/04_fft_gate.py
+++ b/examples/fft/04_fft_gate.py
@@ -12,7 +12,7 @@ snd = "../snds/flute.aif"
chnls = sndinfo(snd)[3]
src = SfPlayer(snd, loop=True, mul=.5)
-size = 1024
+size = 1024
olaps = 4
# bin-by-bin amplitude threshold
@@ -27,7 +27,7 @@ fin = FFT(src, size=size, overlaps=olaps)
mag = Sqrt(fin["real"]*fin["real"] + fin["imag"]*fin["imag"])
amp = Compare(mag*50, thresh, ">")
-scl = amp * (1 - mult) + mult
+scl = amp * (1 - mult) + mult
re = fin["real"] * scl
im = fin["imag"] * scl
@@ -35,4 +35,3 @@ fout = IFFT(re, im, size=size, overlaps=olaps)
ffout = Mix(fout, chnls, mul=.5).out()
s.gui(locals())
-
diff --git a/examples/fft/05_fft_delay.py b/examples/fft/05_fft_delay.py
index 660bfaa..d37f58f 100644
--- a/examples/fft/05_fft_delay.py
+++ b/examples/fft/05_fft_delay.py
@@ -4,6 +4,7 @@
Apply spectral delays on a sound.
"""
+from __future__ import division
from pyo import *
s = Server(duplex=0).boot()
@@ -27,7 +28,7 @@ binmax = duplicate([5,15,30,40,80,145], num)
delays = duplicate([80,20,40,100,60,120], num)
# delays conversion : number of frames -> seconds
for i in range(len(delays)):
- delays[i] = delays[i] * (size/2) / s.getSamplingRate()
+ delays[i] = delays[i] * (size//2) / s.getSamplingRate()
fin = FFT(src*1.25, size=size, overlaps=olaps)
diff --git a/examples/fft/06_fft_vectral.py b/examples/fft/06_fft_vectral.py
index 7244437..9011261 100644
--- a/examples/fft/06_fft_vectral.py
+++ b/examples/fft/06_fft_vectral.py
@@ -30,7 +30,7 @@ mult = Sig(.1)
mult.ctrl([SLMap(0.0001,1,"log","value",0.0001)], title="Gate Attenuation")
amp = Compare(pol["mag"]*50, thresh, ">")
-scl = amp * (1 - mult) + mult
+scl = amp * (1 - mult) + mult
delta = Vectral(pol["mag"]*scl, framesize=size, overlaps=olaps, down=.35)
delta.ctrl(title="Blur controls")
diff --git a/examples/fft/07_fft_stretch.py b/examples/fft/07_fft_stretch.py
index 067f8d9..5bcfbad 100644
--- a/examples/fft/07_fft_stretch.py
+++ b/examples/fft/07_fft_stretch.py
@@ -4,6 +4,7 @@
Time stretching using FFT/IFFT.
"""
+from __future__ import division
from pyo import *
s = Server(sr=44100, nchnls=2, buffersize=512, duplex=0).boot()
@@ -17,12 +18,12 @@ wintype = 7
info = sndinfo(snd)
chnls = info[3]
-hop = size/olaps
-nframes = info[0] / size
+hop = size // olaps
+nframes = info[0] // size
a = SfPlayer(snd, mul=.1)
-# "overlaps * chnls" Matrices of width FFTSIZE and height NUM_OF_FRAMES
+# "overlaps * chnls" Matrices of width FFTSIZE and height NUM_OF_FRAMES
# to record magnitude and phase analysis frames
m_mag = [NewMatrix(width=size, height=nframes) for i in range(olaps*chnls)]
m_pha = [NewMatrix(width=size, height=nframes) for i in range(olaps*chnls)]
diff --git a/examples/fft/08_fft_spec.py b/examples/fft/08_fft_spec.py
index 406975b..f8ad6a6 100644
--- a/examples/fft/08_fft_spec.py
+++ b/examples/fft/08_fft_spec.py
@@ -4,10 +4,11 @@
Display the sonogram of a sound using a PyoMatrixObject.
A better display can be achieved by using a custom drawing.
-After the playback ending, call "m.view()" from the
+After the playback ending, call "m.view()" from the
interpreter widget of the Server window to show the spectrum.
"""
+from __future__ import division
from pyo import *
s = Server(duplex=0).boot()
@@ -17,7 +18,7 @@ info = sndinfo(son)
a = SfPlayer(son, mul=.25).mix(1).out()
size = 512
-m = NewMatrix(width=size, height=info[0]/size)
+m = NewMatrix(width=size, height=info[0]//size)
fin = FFT(a*100, overlaps=1)
mag = Sqrt(fin["real"]*fin["real"] + fin["imag"]*fin["imag"])
diff --git a/examples/matrix/02_matrix_record.py b/examples/matrix/02_matrix_record.py
index 5cf5b4f..5c2c6c8 100644
--- a/examples/matrix/02_matrix_record.py
+++ b/examples/matrix/02_matrix_record.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# encoding: utf-8
+from __future__ import print_function
"""
Wave terrain synthesis of a live recording of FM synthesis in the matrix.
@@ -24,7 +25,7 @@ c = MatrixPointer(matrix=mm, x=x, y=y, mul=.25)
filt = Tone(input=c, freq=3000).out()
def func():
- print "End of recording"
+ print("End of recording")
tr = TrigFunc(rec['trig'], func)
diff --git a/examples/matrix/03_matrix_algo.py b/examples/matrix/03_matrix_algo.py
index 025534d..5b9d1cc 100644
--- a/examples/matrix/03_matrix_algo.py
+++ b/examples/matrix/03_matrix_algo.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# encoding: utf-8
"""
-This script demonstrates how to use a matrix to do some
+This script demonstrates how to use a matrix to do some
algorithmic generation of notes.
"""
diff --git a/examples/sampling/01_sound_cloud.py b/examples/sampling/01_sound_cloud.py
index 5733054..99bc296 100644
--- a/examples/sampling/01_sound_cloud.py
+++ b/examples/sampling/01_sound_cloud.py
@@ -33,4 +33,4 @@ for j in range(olaps):
mix = Mix(trtabs, voices=2)
out = Freeverb(mix, size=.9, damp=.95, bal=.1, mul=.3).out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/sampling/02_live_looper.py b/examples/sampling/02_live_looper.py
index af1942a..0d38569 100644
--- a/examples/sampling/02_live_looper.py
+++ b/examples/sampling/02_live_looper.py
@@ -2,7 +2,7 @@
# encoding: utf-8
"""
To record sound from input mic in the buffer (4 seconds), call:
-rec.play()
+rec.play()
The buffer is looped with some funny parameters...
@@ -22,10 +22,10 @@ a = Looper( table=tab, # table to loop in
start=start, # loop start position
dur=dur, # loop duration
xfade=20, # crossfade duration in %
- mode=1, # looping mode
+ mode=1, # looping mode
xfadeshape=0, # crossfade shape
startfromloop=False, # first start position, False means from beginning of the table
interp=4 # interpolation method
).out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/sampling/03_rec_and_loop.py b/examples/sampling/03_rec_and_loop.py
index d1da2d9..5264d19 100644
--- a/examples/sampling/03_rec_and_loop.py
+++ b/examples/sampling/03_rec_and_loop.py
@@ -25,4 +25,4 @@ t = NewTable(length=buffer_length, chnls=2)
r = TableRec(mic, table=t, fadetime=0.1)
tr = TrigFunc(r["trig"], function=cp)
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/sampling/04_live_convolution.py b/examples/sampling/04_live_convolution.py
index a02527c..7022ddc 100644
--- a/examples/sampling/04_live_convolution.py
+++ b/examples/sampling/04_live_convolution.py
@@ -41,4 +41,4 @@ t = NewTable(length=sampsToSec(TLEN), chnls=1)
m = TableMorph(pha, t, [t1,t2,t3,t4])
a = Convolve(sf, table=t, size=t.getSize(), mul=.1).mix(2).out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/sequencing/01_starttime_duration.py b/examples/sequencing/01_starttime_duration.py
index c0251b7..307fec2 100644
--- a/examples/sequencing/01_starttime_duration.py
+++ b/examples/sequencing/01_starttime_duration.py
@@ -18,7 +18,7 @@ a = SineLoop(freqs, feedback=.05, mul=fade1).out(dur=5, delay=start1)
start2 = 30
dur2 = 40
snds = ['../snds/alum1.wav', '../snds/alum2.wav', '../snds/alum3.wav', '../snds/alum4.wav']
-tabs = SndTable(snds)
+tabs = SndTable(snds)
fade2 = Fader(.05, 10, dur2, mul=.7).play(dur=dur2, delay=start2)
b = Beat(time=.125, w1=[90,30,30,20], w2=[30,90,50,40], w3=[0,30,30,40], poly=1).play(dur=dur2, delay=start2)
out = TrigEnv(b, tabs, b['dur'], mul=b['amp']*fade2).out(dur=dur2, delay=start2)
@@ -28,4 +28,4 @@ dur3 = 30
fade3 = Fader(15, 15, dur3, mul=.02).play(dur=dur3, delay=start3)
fm = FM(carrier=[149,100,151,50]*3, ratio=[.2499,.501,.75003], index=10, mul=fade3).out(dur=dur3, delay=start3)
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/sequencing/02_random_score.py b/examples/sequencing/02_random_score.py
index e1146e9..bd829b2 100644
--- a/examples/sequencing/02_random_score.py
+++ b/examples/sequencing/02_random_score.py
@@ -2,7 +2,7 @@
# encoding: utf-8
"""
Calling Python function from an audio stream with the Score object.
-
+
"""
from pyo import *
import random
@@ -22,19 +22,19 @@ camp = Linseg([(0,0),(1./GEN_FREQ,1),(2./GEN_FREQ,0)], mul=.25).stop()
csyn = FM(carrier=[100,100], ratio=[.49,.5], index=6, mul=camp).out()
def event_0():
- print "playing chaotic attractor"
+ print("playing chaotic attractor")
asyn.pitch = random.uniform(0.25,0.75)
asyn.chaos = random.uniform(0.2,0.8)
aamp.play()
def event_1():
- print "playing looped oscillator"
- bsyn.freq = [random.choice(range(50,501,50))*random.uniform(0.99,1.01) for i in range(2)]
+ print("playing looped oscillator")
+ bsyn.freq = [random.choice(list(range(50,501,50)))*random.uniform(0.99,1.01) for i in range(2)]
bsyn.feedback = random.uniform(0.01, 0.1)
bamp.play()
def event_2():
- print "playing frequency modulation"
+ print("playing frequency modulation")
csyn.carrier = [random.choice([50,100,150,200,250])*random.uniform(0.99,1.01) for i in range(2)]
csyn.ratio = [random.choice([.1251,.249,.502,.7501,1.003]) for i in range(2)]
camp.play()
@@ -42,4 +42,4 @@ def event_2():
tr = RandInt(max=3, freq=GEN_FREQ)
sc = Score(input=tr, fname='event_')
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/sequencing/03_function_call.py b/examples/sequencing/03_function_call.py
index cdbab85..3283bf2 100644
--- a/examples/sequencing/03_function_call.py
+++ b/examples/sequencing/03_function_call.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# encoding: utf-8
+from __future__ import print_function
"""
Python function regularly called with a Pattern object.
@@ -23,9 +24,9 @@ def change():
f4 = random.uniform(2000,4000)
lst = [f1, f2, f3, f4]
frs.value = lst
- print "%.2f, %.2f, %.2f, %.2f" % tuple(lst)
+ print("%.2f, %.2f, %.2f, %.2f" % tuple(lst))
lfo = Sine(freq=.1, mul=.5, add=.75)
pat = Pattern(function=change, time=lfo).play()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/synthesis/01_pulsar_synthesis.py b/examples/synthesis/01_pulsar_synthesis.py
index ac6b866..690b676 100644
--- a/examples/synthesis/01_pulsar_synthesis.py
+++ b/examples/synthesis/01_pulsar_synthesis.py
@@ -24,4 +24,4 @@ scl = a * (a <= frac) * (1. / frac)
c = Pointer(table=HannTable(), index=scl, mul=.05)
d = Pointer(table=t, index=scl, mul=c).out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/synthesis/02_FM3.py b/examples/synthesis/02_FM3.py
index 6805dfc..9c8fbdf 100644
--- a/examples/synthesis/02_FM3.py
+++ b/examples/synthesis/02_FM3.py
@@ -11,6 +11,7 @@ s = Server(sr=48000, nchnls=2, buffersize=512, duplex=0).boot()
t = HarmTable([1,0.1])
class FM3:
+
def __init__(self, fcar, ratio1, ratio2, index1, index2, out=0):
self.fmod = fcar * ratio1
self.fmodmod = self.fmod * ratio2
diff --git a/examples/synthesis/03_cos_waveshaping.py b/examples/synthesis/03_cos_waveshaping.py
index fa5ff8c..e7c9598 100644
--- a/examples/synthesis/03_cos_waveshaping.py
+++ b/examples/synthesis/03_cos_waveshaping.py
@@ -30,5 +30,5 @@ a = OscBank(t, freq=frs, spread=.0001, slope=1, num=24, fjit=True, mul=f)
b = Cos(math.pi * a + phi)
b1 = DCBlock(b*phiscl)
c = Sig(b1 / amp, mul=.2).out()
-
-s.gui(locals())
\ No newline at end of file
+
+s.gui(locals())
diff --git a/examples/synthesis/04_degrade_synthesis.py b/examples/synthesis/04_degrade_synthesis.py
index 5c2da79..a60ee9b 100644
--- a/examples/synthesis/04_degrade_synthesis.py
+++ b/examples/synthesis/04_degrade_synthesis.py
@@ -27,4 +27,4 @@ b = Lookup(t, a, 1.-lf)
c = Degrade(b, bitdepth=5.967, srscale=0.0233, mul=f).out()
c.ctrl()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/synthesis/05_ring_mod_class.py b/examples/synthesis/05_ring_mod_class.py
index f0467c6..dc9672b 100644
--- a/examples/synthesis/05_ring_mod_class.py
+++ b/examples/synthesis/05_ring_mod_class.py
@@ -12,6 +12,7 @@ tab_m = HarmTable([1,0,0,0,0,.3,0,0,0,0,0,.2,0,0,0,0,0,.1,0,0,0,0,.05]).normaliz
tab_p = HarmTable([1,0,.33,0,.2,0,.143,0,.111])
class Ring:
+
def __init__(self, fport=250, fmod=100, amp=.3):
self.mod = Osc(tab_m, freq=fmod, mul=amp)
self.port = Osc(tab_p, freq=fport, mul=self.mod)
@@ -19,7 +20,7 @@ class Ring:
def out(self):
self.port.out()
return self
-
+
def sig(self):
return self.port
@@ -30,4 +31,4 @@ rg = Ring(fport = [random.choice([62.5,125,187.5,250]) * random.uniform(.99,1.01
res = Waveguide(rg.sig(), freq=[30.1,60.05,119.7,181,242.5,303.33], dur=30, mul=.1).out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/synthesis/06_paf.py b/examples/synthesis/06_paf.py
index 8470df0..fd7adc8 100644
--- a/examples/synthesis/06_paf.py
+++ b/examples/synthesis/06_paf.py
@@ -7,6 +7,7 @@ twopi = math.pi * 2
s = Server(duplex=0).boot()
class PAF:
+
def __init__(self, f0, fc, bw, fs, amp):
self.bell = WinTable(8) # half-sine
self.shape = WinTable(4) # {4, 5 or 6}
@@ -33,9 +34,9 @@ for_tenor = {"ou": [290, 750, 2300, 3080], "o": [360, 770, 2530, 3200], "oo": [5
"oee": [570, 1560, 2560, 3450], "oe": [500, 1330, 2370, 3310], "eu": [350, 1350, 2250, 3170],
"e": [420, 2050, 2630, 3340], "u": [250, 1750, 2160, 3060], "i": [250, 2250, 2980, 3280]}
-amp_tenor = {"ou": [-10, -21, -52, -64], "o": [-10, -21, -52, -64], "oo": [-10, -20, -53, -65],
- "aa": [-8, -27, -52, -60], "a": [-8, -25, -50, -59], "ee": [-10, -30, -47, -57],
- "oee": [-8, -27, -52, -60], "oe": [-10, -44, -49, -64], "eu": [-10, -46, -49, -64],
+amp_tenor = {"ou": [-10, -21, -52, -64], "o": [-10, -21, -52, -64], "oo": [-10, -20, -53, -65],
+ "aa": [-8, -27, -52, -60], "a": [-8, -25, -50, -59], "ee": [-10, -30, -47, -57],
+ "oee": [-8, -27, -52, -60], "oe": [-10, -44, -49, -64], "eu": [-10, -46, -49, -64],
"e": [-10, -30, -52, -60], "u": [-10, -44, -49, -64], "i": [-10, -40, -52, -57]}
bw_tenor = {"ou": [30, 35, 45, 50], "o": [30, 35, 54, 59], "oo": [35, 40, 54, 59], "aa": [40, 45, 59, 64],
@@ -73,5 +74,5 @@ def set(new):
c.bw.value = vo[2]
d.bw.value = vo[3]
e.bw.value = vo[3] + 10
-
+
s.gui(locals())
diff --git a/examples/synthesis/07_split_sideband_synthesis.py b/examples/synthesis/07_split_sideband_synthesis.py
index 5a62155..80eeee2 100644
--- a/examples/synthesis/07_split_sideband_synthesis.py
+++ b/examples/synthesis/07_split_sideband_synthesis.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# encoding: utf-8
"""
-Split-Sideband Synthesis. Variation of three well known distortion techniques,
+Split-Sideband Synthesis. Variation of three well known distortion techniques,
Waveshaping, Singlesideband modulation and Frequency Modulation.
Based on the article :
@@ -59,4 +59,4 @@ soddLower = soddReal - soddImag
mix = Mix([sevenLower, sevenUpper], voices=2, mul=.2).out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/tables/01_curve_table.py b/examples/tables/01_curve_table.py
index 509e96f..1acdd44 100644
--- a/examples/tables/01_curve_table.py
+++ b/examples/tables/01_curve_table.py
@@ -19,7 +19,7 @@ synth2 = FM(carrier=[100,50], ratio=[.495,1.01], index=10, mul=a).out()
# LFO from 0 to 20
c = Sine(.1, 0, 10, 10)
-
+
# Modifying the bias parameter 10 times per second
def change():
# get the current value of the LFO
@@ -30,4 +30,4 @@ def change():
p = Pattern(change, .1).play()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/tables/02_scrubbing.py b/examples/tables/02_scrubbing.py
index 5db7547..f0c2fb1 100644
--- a/examples/tables/02_scrubbing.py
+++ b/examples/tables/02_scrubbing.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# encoding: utf-8
+from __future__ import print_function
"""
Scrubbing in a sound window.
@@ -11,7 +12,7 @@ from pyo import *
s = Server(buffersize=512, duplex=0).boot()
def mouse(mpos):
- print "X = %.2f, Y = %.2f" % tuple(mpos)
+ print("X = %.2f, Y = %.2f" % tuple(mpos))
pos.value = mpos[0]
l, r = 1. - mpos[1], mpos[1]
mul.value = [l, r]
diff --git a/examples/tables/03_granulation.py b/examples/tables/03_granulation.py
index 94be9d5..8a5728b 100644
--- a/examples/tables/03_granulation.py
+++ b/examples/tables/03_granulation.py
@@ -16,8 +16,7 @@ snd.view()
pos = Phasor(freq=snd.getRate()*.25, mul=snd.getSize(), add=Noise(3))
dur = Noise(.001, .1)
-gran = Granulator(table=snd, env=WinTable(7), pitch=[.999, 1.0011],
+gran = Granulator(table=snd, env=WinTable(7), pitch=[.999, 1.0011],
pos=pos, dur=dur, grains=40, basedur=.1, mul=.05).out()
s.gui(locals())
-
diff --git a/examples/tables/04_granule.py b/examples/tables/04_granule.py
index fb2c48f..354341e 100644
--- a/examples/tables/04_granule.py
+++ b/examples/tables/04_granule.py
@@ -23,4 +23,4 @@ env = TrigEnv(met, t2, dur=grain_dur, mul=.05)
ind = TrigEnv(met, t3, dur=grain_dur, mul=jit*(grain_dur/snd_dur), add=pos)
snd = Pointer(t1, ind, env).out()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/tables/05_table_maker.py b/examples/tables/05_table_maker.py
index fdcd0ae..dd24b93 100644
--- a/examples/tables/05_table_maker.py
+++ b/examples/tables/05_table_maker.py
@@ -40,4 +40,4 @@ def gen():
gen()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/utilities/01_get_example.py b/examples/utilities/01_get_example.py
index e1701db..49bbe3f 100644
--- a/examples/utilities/01_get_example.py
+++ b/examples/utilities/01_get_example.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# encoding: utf-8
+from __future__ import print_function
"""
The PyoObject.get() method can be used to convert audio stream to usable python data.
@@ -14,8 +15,8 @@ synth = SineLoop(freq=lfos, feedback=.07, mul=.05).out()
def print_val():
# Print all four frequency values assigned to SineLoop's freq argument
- print "%.2f, %.2f, %.2f, %.2f" % tuple(lfos.get(all=True))
+ print("%.2f, %.2f, %.2f, %.2f" % tuple(lfos.get(all=True)))
pat = Pattern(print_val, .25).play()
-s.gui(locals())
\ No newline at end of file
+s.gui(locals())
diff --git a/examples/utilities/02_midi_ctl_scan.py b/examples/utilities/02_midi_ctl_scan.py
index 8332f58..aa0d123 100644
--- a/examples/utilities/02_midi_ctl_scan.py
+++ b/examples/utilities/02_midi_ctl_scan.py
@@ -1,25 +1,27 @@
#!/usr/bin/env python
# encoding: utf-8
-
"""
Scan for Midi controller numbers. Launch this script from a terminal.
"""
from pyo import *
-import time
+import time, sys
+
+if sys.version_info[0] < 3:
+ input = raw_input
pm_list_devices()
-num = input("Enter your Midi interface number : ")
+num = eval(input("Enter your Midi interface number : "))
s = Server(duplex=0)
s.setMidiInputDevice(num)
s.boot().start()
-print "Play with your Midi controllers..."
+print("Play with your Midi controllers...")
def pp(x):
- print "controller number =", x
+ print("controller number =", x)
scan = CtlScan(pp, False)
@@ -27,12 +29,11 @@ again = "y"
while again == "y":
time.sleep(10)
scan.stop()
- again = raw_input("Do you want to continue ? (y/n) : ")
+ again = input("Do you want to continue ? (y/n) : ")
if again == "y":
- print "Continue..."
+ print("Continue...")
scan.play()
-
+
s.stop()
time.sleep(1)
exit()
-
\ No newline at end of file
diff --git a/examples/utilities/02_osc_scan.py b/examples/utilities/02_osc_scan.py
index 442247e..d89f46c 100644
--- a/examples/utilities/02_osc_scan.py
+++ b/examples/utilities/02_osc_scan.py
@@ -1,24 +1,28 @@
#!/usr/bin/env python
# encoding: utf-8
+from __future__ import print_function
"""
Scan Open Sound Control inputs. Launch this script from a terminal.
"""
from pyo import *
-import time
+import time, sys
-port = input("Enter the incoming port number : ")
+if sys.version_info[0] < 3:
+ input = raw_input
+
+port = eval(input("Enter the incoming port number : "))
s = Server().boot().start()
-print "Play with your OSC interface..."
+print("Play with your OSC interface...")
go = True
-def pp(address, *args):
+def pp(address, *args):
if go:
- print "Address =", address
- print "Values =", args
- print "---------------"
+ print("Address =", address)
+ print("Values =", args)
+ print("---------------")
scan = OscDataReceive(port, "*", pp)
@@ -26,12 +30,11 @@ again = "y"
while again == "y":
time.sleep(10)
go = False
- again = raw_input("Do you want to continue ? (y/n) : ")
+ again = input("Do you want to continue ? (y/n) : ")
if again == "y":
- print "Continue..."
+ print("Continue...")
go = True
-
+
s.stop()
time.sleep(1)
-exit()
-
\ No newline at end of file
+sys.exit()
diff --git a/examples/utilities/03_savefile.py b/examples/utilities/03_savefile.py
index fadc063..3256f6c 100644
--- a/examples/utilities/03_savefile.py
+++ b/examples/utilities/03_savefile.py
@@ -16,4 +16,4 @@ dur = 5
chnls = 2
samples = [[uniform(-0.5,0.5) for i in range(sr*dur)] for i in range(chnls)]
-savefile(samples=samples, path=path, sr=sr, channels=chnls, fileformat=1, sampletype=1)
\ No newline at end of file
+savefile(samples=samples, path=path, sr=sr, channels=chnls, fileformat=1, sampletype=1)
diff --git a/examples/utilities/04_batch_processing.py b/examples/utilities/04_batch_processing.py
index fa1f6b6..729addd 100644
--- a/examples/utilities/04_batch_processing.py
+++ b/examples/utilities/04_batch_processing.py
@@ -18,7 +18,7 @@ if not os.path.isdir(output_folder):
os.mkdir(output_folder)
# get the list of files to process
-sounds = [file for file in os.listdir(folder_path) if sndinfo(os.path.join(folder_path, file)) != None]
+sounds = [file for file in os.listdir(folder_path) if sndinfo(os.path.join(folder_path, file)) is not None]
# enter the batch processing loop
for sound in sounds:
@@ -27,22 +27,22 @@ for sound in sounds:
info = sndinfo(path)
dur, sr, chnls = info[1], info[2], info[3]
fformat = ['WAVE', 'AIFF', 'AU', 'RAW', 'SD2', 'FLAC', 'CAF', 'OGG'].index(info[4])
- samptype = ['16 bit int', '24 bit int', '32 bit int', '32 bit float',
+ samptype = ['16 bit int', '24 bit int', '32 bit int', '32 bit float',
'64 bits float', 'U-Law encoded', 'A-Law encoded'].index(info[5])
# set server parameters
s.setSamplingRate(sr)
s.setNchnls(chnls)
s.boot()
- s.recordOptions(dur=dur, filename=os.path.join(output_folder, sound),
+ s.recordOptions(dur=dur, filename=os.path.join(output_folder, sound),
fileformat=fformat, sampletype=samptype)
-
+
# processing
sf = SfPlayer(path)
bp = ButBP(sf, 1000, 2)
dt = Disto(bp, drive=0.9, slope=0.8)
mx = Interp(sf, dt, interp=0.5, mul=0.5).out()
-
+
# start the render
s.start()
# cleanup
diff --git a/examples/utilities/04_batch_synthesis.py b/examples/utilities/04_batch_synthesis.py
index 8b32246..5e9bd62 100644
--- a/examples/utilities/04_batch_synthesis.py
+++ b/examples/utilities/04_batch_synthesis.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# encoding: utf-8
+from __future__ import print_function
"""
This script demonstrates how to use pyo to do synthesis batch generation.
@@ -21,7 +22,7 @@ for i in range(NUM):
s.boot()
note = 60 + i
noteFreq = midiToHz(note)
- s.recordOptions(dur=dur+.1, filename=os.path.join(output_folder, "file_%02d.wav" % note),
+ s.recordOptions(dur=dur+.1, filename=os.path.join(output_folder, "file_%02d.wav" % note),
fileformat=0, sampletype=0)
### processing goes here ###
@@ -35,5 +36,5 @@ for i in range(NUM):
# cleanup
s.shutdown()
-print "Batch processing done"
+print("Batch processing done")
diff --git a/examples/utilities/05_high_sr_processing.py b/examples/utilities/05_high_sr_processing.py
index 50e0b37..ecc2bb1 100644
--- a/examples/utilities/05_high_sr_processing.py
+++ b/examples/utilities/05_high_sr_processing.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python
# encoding: utf-8
+from __future__ import print_function
"""
-This script demonstrates how to use pyo to apply processing on an
+This script demonstrates how to use pyo to apply processing on an
up sampled sound. Steps are:
1 - Up sampling the source.
@@ -22,10 +23,10 @@ DOWN_SND = os.path.join(os.path.expanduser("~"), "Desktop", "baseballmajeur_dist
DUR = sndinfo(IN_SND)[1]
SR = sndinfo(IN_SND)[2]
-print "Up sampling %i times..." % UP
+print("Up sampling %i times..." % UP)
upsamp(IN_SND, UP_SND, UP, SIZE)
-print "Apply distortion at a sampling rate of %i Hz." % (SR*UP)
+print("Apply distortion at a sampling rate of %i Hz." % (SR*UP))
s = Server(sr=SR*UP, nchnls=1, duplex=0, audio="offline").boot()
s.recordOptions(dur=DUR+.1, filename=PROC_SND, fileformat=0, sampletype=0)
sf = SfPlayer(IN_SND, loop=False, interp=4, mul=0.7)
@@ -33,10 +34,10 @@ dist = Disto(sf, drive=0.75, slope=0.7, mul=0.3)
filt = Biquad(dist, freq=8000, q=0.7, type=0).out()
s.start()
-print "Down sampling %i times..." % DOWN
+print("Down sampling %i times..." % DOWN)
downsamp(PROC_SND, DOWN_SND, DOWN, SIZE)
os.remove(UP_SND)
os.remove(PROC_SND)
-print "Done"
+print("Done")
diff --git a/examples/utilities/06_separated_threads.py b/examples/utilities/06_separated_threads.py
index fa019c9..6492a3b 100644
--- a/examples/utilities/06_separated_threads.py
+++ b/examples/utilities/06_separated_threads.py
@@ -21,5 +21,3 @@ for i in range(20):
# Stop the audio Server before exiting
pipe.write("s.stop()\ntime.sleep(0.25)\n")
pipe.close()
-
-
diff --git a/examples/utilities/07_scope.py b/examples/utilities/07_scope.py
index 4af4ec3..f26608b 100644
--- a/examples/utilities/07_scope.py
+++ b/examples/utilities/07_scope.py
@@ -7,6 +7,7 @@ Simple scope example.
from pyo import *
class Scope:
+
def __init__(self, input, length=0.05):
self.input = input
self.table = NewTable(length=length, chnls=len(input))
@@ -27,7 +28,7 @@ s = Server(duplex=1).boot()
CHNLS = 2
LENGTH = 0.05
-inp = Input(chnl=range(CHNLS))
+inp = Input(chnl=list(range(CHNLS)))
scope = Scope(inp, LENGTH)
s.gui(locals())
diff --git a/examples/wxgui/01_gui_widgets_example.py b/examples/wxgui/01_gui_widgets_example.py
index a196501..a7b4d7c 100644
--- a/examples/wxgui/01_gui_widgets_example.py
+++ b/examples/wxgui/01_gui_widgets_example.py
@@ -8,7 +8,8 @@ from pyo import *
NCHNLS = 2
-server = Server(nchnls=NCHNLS).boot().start()
+server = Server(nchnls=NCHNLS).boot()
+server.start()
### A basic audio process ###
snd = SndTable([SNDS_PATH+"/transparent.aif"]*NCHNLS)
@@ -25,8 +26,12 @@ sp = Spectrum(f)
sc = Scope(f)
class MyFrame(wx.Frame):
+
def __init__(self, parent, title, pos=(50, 50), size=(850, 600)):
wx.Frame.__init__(self, parent, -1, title, pos, size)
+
+ self.Bind(wx.EVT_CLOSE, self.on_quit)
+
self.panel = wx.Panel(self)
vmainsizer = wx.BoxSizer(wx.VERTICAL)
mainsizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -63,7 +68,7 @@ class MyFrame(wx.Frame):
midbox.Add(sizer6, 1, wx.ALL | wx.EXPAND, 5)
rightbox.Add(sizer2, 1, wx.ALL | wx.EXPAND, 5)
-
+
mainsizer.Add(leftbox, 1, wx.ALL | wx.EXPAND, 5)
mainsizer.Add(midbox, 1, wx.ALL | wx.EXPAND, 5)
mainsizer.Add(rightbox, 0, wx.ALL | wx.EXPAND, 5)
@@ -71,17 +76,22 @@ class MyFrame(wx.Frame):
vmainsizer.Add(sizer7, 1, wx.ALL | wx.EXPAND, 5)
self.panel.SetSizerAndFit(vmainsizer)
+ def on_quit(self, evt):
+ server.stop()
+ time.sleep(0.25)
+ self.Destroy()
+
def createFreqSlider(self):
sizer = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self.panel, -1, "PyoGuiControlSlider: filter's center frequency (log scale)")
- sizer.Add(label, 0, wx.CENTER|wx.ALL, 5)
- self.freq = PyoGuiControlSlider(parent=self.panel,
- minvalue=20,
- maxvalue=20000,
- init=1000,
- pos=(0, 0),
+ sizer.Add(label, 0, wx.CENTER|wx.ALL, 5)
+ self.freq = PyoGuiControlSlider(parent=self.panel,
+ minvalue=20,
+ maxvalue=20000,
+ init=1000,
+ pos=(0, 0),
size=(200, 16),
- log=True,
+ log=True,
integer=False,
powoftwo=False,
orient=wx.HORIZONTAL)
@@ -94,22 +104,22 @@ class MyFrame(wx.Frame):
def createOutputBox(self):
sizer = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self.panel, -1, "dB slider - PyoGuiVuMeter")
- sizer.Add(label, 0, wx.CENTER|wx.ALL, 5)
+ sizer.Add(label, 0, wx.CENTER|wx.ALL, 5)
sizer1 = wx.BoxSizer(wx.HORIZONTAL)
- self.amp = PyoGuiControlSlider(parent=self.panel,
- minvalue=-60,
- maxvalue=18,
- init=-12,
- pos=(0, 0),
+ self.amp = PyoGuiControlSlider(parent=self.panel,
+ minvalue=-60,
+ maxvalue=18,
+ init=-12,
+ pos=(0, 0),
size=(200, 16),
- log=False,
+ log=False,
integer=False,
powoftwo=False,
orient=wx.VERTICAL)
self.amp.Bind(EVT_PYO_GUI_CONTROL_SLIDER, self.changeGain)
- self.meter = PyoGuiVuMeter(parent=self.panel,
- nchnls=NCHNLS,
- pos=(0, 0),
+ self.meter = PyoGuiVuMeter(parent=self.panel,
+ nchnls=NCHNLS,
+ pos=(0, 0),
size=(5*NCHNLS, 200),
orient=wx.VERTICAL,
style=0)
@@ -128,13 +138,13 @@ class MyFrame(wx.Frame):
sizer = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self.panel, -1, "PyoGuiGrapher: Filter's Q automation")
sizer.Add(label, 0, wx.CENTER|wx.ALL, 5)
- self.graph = PyoGuiGrapher(parent=self.panel,
- xlen=8192,
- yrange=(1.0, 10.0),
- init=[(0.0, 0.0), (1.0, 1.0)],
- mode=2,
+ self.graph = PyoGuiGrapher(parent=self.panel,
+ xlen=8192,
+ yrange=(1.0, 10.0),
+ init=[(0.0, 0.0), (1.0, 1.0)],
+ mode=2,
exp=t2.exp,
- inverse=True,
+ inverse=True,
tension=0.75,
bias=8.0,
size=(300,100),
@@ -150,9 +160,9 @@ class MyFrame(wx.Frame):
sizer = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self.panel, -1, "PyoGuiMultiSlider: Step Sequencer")
sizer.Add(label, 0, wx.CENTER|wx.ALL, 5)
- self.steps = PyoGuiMultiSlider(parent=self.panel,
- xlen=16,
- yrange=(0, 1),
+ self.steps = PyoGuiMultiSlider(parent=self.panel,
+ xlen=16,
+ yrange=(0, 1),
init=[1,0,0,0]*4,
size=(300,100),
style=0)
@@ -166,7 +176,7 @@ class MyFrame(wx.Frame):
sizer = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self.panel, -1, "PyoGuiSpectrum: Frequency display")
sizer.Add(label, 0, wx.CENTER|wx.ALL, 5)
- self.spectrum = PyoGuiSpectrum(parent=self.panel,
+ self.spectrum = PyoGuiSpectrum(parent=self.panel,
lowfreq=0,
highfreq=22050,
fscaling=1,
@@ -181,7 +191,7 @@ class MyFrame(wx.Frame):
sizer = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self.panel, -1, "PyoGuiScope: Oscilloscope display")
sizer.Add(label, 0, wx.CENTER|wx.ALL, 5)
- self.scope = PyoGuiScope(parent=self.panel,
+ self.scope = PyoGuiScope(parent=self.panel,
length=0.05,
gain=1,
size=(300,150),
@@ -196,7 +206,7 @@ class MyFrame(wx.Frame):
sizer = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self.panel, -1, "PyoGuiSndView: Soundfile display")
sizer.Add(label, 0, wx.CENTER|wx.ALL, 5)
- self.sndview = PyoGuiSndView(parent=self.panel,
+ self.sndview = PyoGuiSndView(parent=self.panel,
size=(300,200),
style=0)
self.sndview.setTable(snd)
@@ -219,7 +229,7 @@ class MyFrame(wx.Frame):
am.setChoice(evt.value)
def mousePos(self, evt):
- print(evt.value)
+ print((evt.value))
def sndSelection(self, evt):
pos.replace([(0.0, evt.value[0]), (m.time, evt.value[1])])
@@ -228,9 +238,3 @@ app = wx.App(False)
mainFrame = MyFrame(None, title='Test Pyo GUI objects')
mainFrame.Show()
app.MainLoop()
-
-# Clean up...
-server.stop()
-time.sleep(0.25)
-server.shutdown()
-time.sleep(0.25)
\ No newline at end of file
diff --git a/externals/externalmodule-template.c b/externals/externalmodule-template.c
index c6079bb..9cb89a2 100644
--- a/externals/externalmodule-template.c
+++ b/externals/externalmodule-template.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -222,7 +223,7 @@ Gain_dealloc(Gain* self)
{
pyo_DEALLOC
Gain_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
/**********************************************************************
@@ -401,7 +402,7 @@ static PyNumberMethods Gain_as_number = {
(binaryfunc)Gain_add, /*nb_add*/
(binaryfunc)Gain_sub, /*nb_subtract*/
(binaryfunc)Gain_multiply, /*nb_multiply*/
-(binaryfunc)Gain_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -415,16 +416,16 @@ static PyNumberMethods Gain_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Gain_inplace_add, /*inplace_add*/
(binaryfunc)Gain_inplace_sub, /*inplace_subtract*/
(binaryfunc)Gain_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Gain_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -433,9 +434,9 @@ static PyNumberMethods Gain_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Gain_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Gain_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
@@ -445,8 +446,7 @@ where XXX is replaced by the name of the object.
Fields in PyTypeObject that are not used should be 0.
**************************************************************/
PyTypeObject GainType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
/* How the object will be exposed to the
python interpreter. The name of the C component
of a PyoObject should be "XXX_base", where XXX
diff --git a/include/pyomodule.h b/include/pyomodule.h
index 4b61140..c336f3e 100644
--- a/include/pyomodule.h
+++ b/include/pyomodule.h
@@ -21,7 +21,7 @@
#include "Python.h"
#include <math.h>
-#define PYO_VERSION "0.7.9"
+#define PYO_VERSION "0.8.1"
#ifndef __MYFLT_DEF
#define __MYFLT_DEF
@@ -73,6 +73,8 @@
#define TYPE_F_OF "f|Of"
#define TYPE__OFFI "|Offi"
#define TYPE__OFII "|Ofii"
+#define TYPE__OFIOO "|OfiOO"
+#define TYPE__OOFOO "|OOfOO"
#define TYPE__FIIOO "|fiiOO"
#define TYPE_O_OFOO "O|OfOO"
#define TYPE_O_OOOOFF "O|OOOOff"
@@ -87,6 +89,7 @@
#define TYPE_O_OOFFOO "O|OOffOO"
#define TYPE_O_OOOFOO "O|OOOfOO"
#define TYPE_OO_OOOIFOO "OO|OOOifOO"
+#define TYPE__FFFFIFI "|ffffifi"
#define SF_WRITE sf_write_float
#define SF_READ sf_read_float
@@ -156,6 +159,8 @@
#define TYPE_F_OF "d|Od"
#define TYPE__OFFI "|Oddi"
#define TYPE__OFII "|Odii"
+#define TYPE__OFIOO "|OdiOO"
+#define TYPE__OOFOO "|OOdOO"
#define TYPE__FIIOO "|diiOO"
#define TYPE_O_OFOO "O|OdOO"
#define TYPE_O_OOOOFF "O|OOOOdd"
@@ -170,6 +175,7 @@
#define TYPE_O_OOFFOO "O|OOddOO"
#define TYPE_O_OOOFOO "O|OOOdOO"
#define TYPE_OO_OOOIFOO "OO|OOOidOO"
+#define TYPE__FFFFIFI "|ddddidi"
#define SF_WRITE sf_write_double
#define SF_READ sf_read_double
@@ -199,9 +205,21 @@
#include "externalmodule.h"
#endif
+#ifdef USE_PORTMIDI
extern PyTypeObject MidiListenerType;
+#endif
+#ifdef USE_OSC
extern PyTypeObject OscListenerType;
+extern PyTypeObject OscSendType;
+extern PyTypeObject OscReceiveType;
+extern PyTypeObject OscReceiverType;
+extern PyTypeObject OscDataSendType;
+extern PyTypeObject OscDataReceiveType;
+extern PyTypeObject OscListReceiveType;
+extern PyTypeObject OscListReceiverType;
+#endif
extern PyTypeObject SineType;
+extern PyTypeObject FastSineType;
extern PyTypeObject SineLoopType;
extern PyTypeObject FmType;
extern PyTypeObject CrossFmType;
@@ -211,6 +229,8 @@ extern PyTypeObject RosslerType;
extern PyTypeObject RosslerAltType;
extern PyTypeObject LorenzType;
extern PyTypeObject LorenzAltType;
+extern PyTypeObject ChenLeeType;
+extern PyTypeObject ChenLeeAltType;
extern PyTypeObject PhasorType;
extern PyTypeObject SuperSawType;
extern PyTypeObject PointerType;
@@ -303,6 +323,7 @@ extern PyTypeObject IRAverageType;
extern PyTypeObject IRFMType;
extern PyTypeObject GranulatorType;
extern PyTypeObject LooperType;
+extern PyTypeObject LooperTimeStreamType;
extern PyTypeObject HarmonizerType;
extern PyTypeObject MidictlType;
extern PyTypeObject CtlScanType;
@@ -355,13 +376,6 @@ extern PyTypeObject MatrixPointerType;
extern PyTypeObject MatrixRecType;
extern PyTypeObject MatrixRecLoopType;
extern PyTypeObject MatrixMorphType;
-extern PyTypeObject OscSendType;
-extern PyTypeObject OscReceiveType;
-extern PyTypeObject OscReceiverType;
-extern PyTypeObject OscDataSendType;
-extern PyTypeObject OscDataReceiveType;
-extern PyTypeObject OscListReceiveType;
-extern PyTypeObject OscListReceiverType;
extern PyTypeObject TrigRandIntType;
extern PyTypeObject TrigValType;
extern PyTypeObject TrigRandType;
@@ -420,6 +434,7 @@ extern PyTypeObject M_FloorType;
extern PyTypeObject M_CeilType;
extern PyTypeObject M_RoundType;
extern PyTypeObject M_TanhType;
+extern PyTypeObject M_ExpType;
extern PyTypeObject FFTMainType;
extern PyTypeObject FFTType;
extern PyTypeObject IFFTType;
@@ -446,6 +461,7 @@ extern PyTypeObject ButLPType;
extern PyTypeObject ButHPType;
extern PyTypeObject ButBPType;
extern PyTypeObject ButBRType;
+extern PyTypeObject MoogLPType;
extern PyTypeObject PVAnalType;
extern PyTypeObject PVSynthType;
extern PyTypeObject PVTransposeType;
@@ -488,13 +504,15 @@ extern PyTypeObject AtanTableType;
extern PyTypeObject RawMidiType;
extern PyTypeObject ResampleType;
extern PyTypeObject ExprType;
+extern PyTypeObject PadSynthTableType;
+extern PyTypeObject LogiMapType;
/* Constants */
#define E M_E
#define PI M_PI
#define TWOPI (2 * M_PI)
-#define PYO_RAND_MAX 4294967295
+#define PYO_RAND_MAX 4294967295u
/* random uniform (0.0 -> 1.0) */
#define RANDOM_UNIFORM (pyorand()/((MYFLT)(PYO_RAND_MAX)+1))
@@ -975,6 +993,71 @@ extern PyTypeObject ExprType;
Py_INCREF(Py_None); \
return Py_None; \
+/* Table rotation */
+#define TABLE_ROTATE \
+ int i, j, pos; \
+ MYFLT tmp; \
+ static char *kwlist[] = {"pos", NULL}; \
+ \
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, &pos)) \
+ return PyInt_FromLong(-1); \
+ \
+ pos = -pos; \
+ while (pos > self->size) pos -= self->size; \
+ while (pos < 0) pos += self->size; \
+ \
+ j = self->size; \
+ for (i=0; i<--j; i++) { \
+ tmp = self->data[i]; \
+ self->data[i] = self->data[j]; \
+ self->data[j] = tmp; \
+ } \
+ j = pos; \
+ for (i=0; i<--j; i++) { \
+ tmp = self->data[i]; \
+ self->data[i] = self->data[j]; \
+ self->data[j] = tmp; \
+ } \
+ j = self->size; \
+ for (i=pos; i<--j; i++) { \
+ tmp = self->data[i]; \
+ self->data[i] = self->data[j]; \
+ self->data[j] = tmp; \
+ } \
+ \
+ self->data[self->size] = self->data[0]; \
+ \
+ Py_RETURN_NONE;
+
+/* Table copy from table */
+#define TABLE_COPYDATA \
+ PyObject *tabletmp; \
+ int i, tabsize, srcpos=0, destpos=0, length=-1; \
+ PyObject *table = NULL; \
+ MYFLT *list = NULL; \
+ static char *kwlist[] = {"table", "srcpos", "destpos", "length", NULL}; \
+ \
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|iii", kwlist, &tabletmp, &srcpos, &destpos, &length)) \
+ return PyInt_FromLong(-1); \
+ \
+ if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 1 ) { \
+ Py_XDECREF(table); \
+ table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", ""); \
+ tabsize = TableStream_getSize((TableStream *)table); \
+ if (length < 0) \
+ length = tabsize < self->size ? tabsize : self->size; \
+ if ((srcpos + length) > tabsize) \
+ length = tabsize - srcpos; \
+ if ((destpos + length) > self->size) \
+ length = self->size - destpos; \
+ list = TableStream_getData((TableStream *)table); \
+ for (i=0; i<length; i++) { \
+ self->data[destpos+i] = list[srcpos+i]; \
+ } \
+ } \
+ \
+ Py_RETURN_NONE;
+
/* Table bipolar gain */
#define TABLE_BIPOLAR_GAIN \
MYFLT gpos = 1.0, gneg = 1.0; \
@@ -1412,7 +1495,7 @@ extern PyTypeObject ExprType;
if (isNumber == 1) { \
if (PyFloat_AsDouble(tmp) != 0.) { \
Py_DECREF(self->mul); \
- self->mul = PyNumber_Divide(PyFloat_FromDouble(1.), PyNumber_Float(tmp)); \
+ self->mul = PyNumber_TrueDivide(PyFloat_FromDouble(1.), PyNumber_Float(tmp)); \
self->modebuffer[0] = 0; \
} \
} \
@@ -1674,3 +1757,39 @@ extern PyTypeObject ExprType;
val = old / tmp - add[i]; \
self->data[i] = val; \
}
+
+/* Tables buffer protocol. */
+#if PY_MAJOR_VERSION < 3
+#define TABLESTREAM_READ_WRITE_BUFFER \
+ if ( index != 0 ) { \
+ PySys_WriteStdout("Accessing non-existent bytes segment..."); \
+ return -1; \
+ } \
+ *ptr = (void *)self->data; \
+ return (Py_ssize_t)self->size * sizeof(MYFLT);
+
+#define TABLESTREAM_SEG_COUNT \
+ if ( lenp ) \
+ *lenp = (Py_ssize_t)self->size * sizeof(MYFLT); \
+ return 1;
+#endif
+
+#define TABLESTREAM_GET_BUFFER \
+ if (view == NULL) { \
+ PySys_WriteStdout("NULL view in getBuffer."); \
+ return -1; \
+ } \
+ self->shape[0] = self->size; \
+ view->obj = (PyObject *)self; \
+ view->buf = (void *)self->data; \
+ view->len = self->size * sizeof(MYFLT); \
+ view->readonly = 0; \
+ view->itemsize = sizeof(MYFLT); \
+ view->format = TYPE_F; \
+ view->ndim = 1; \
+ view->shape = self->shape; \
+ view->strides = NULL; \
+ view->suboffsets = NULL; \
+ view->internal = NULL; \
+ Py_INCREF(self); \
+ return 0;
diff --git a/include/servermodule.h b/include/servermodule.h
index 255f674..2e2dd34 100644
--- a/include/servermodule.h
+++ b/include/servermodule.h
@@ -17,9 +17,9 @@
* 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: *
- * https://github.com/guibarrette/PyoPlug *
+ * Octobre 2013 : Multiple servers facility and embedded backend added *
+ * by Guillaume Barrette. *
+ * 2014-2016 : Several improvements by Olivier Belanger. *
*************************************************************************/
#ifndef Py_SERVERMODULE_H
@@ -28,19 +28,9 @@
extern "C" {
#endif
-#include "portaudio.h"
-#include "portmidi.h"
#include "sndfile.h"
#include "pyomodule.h"
-#ifdef USE_JACK
-#include <jack/jack.h>
-#endif
-
-#ifdef USE_COREAUDIO
-# include <CoreAudio/AudioHardware.h>
-#endif
-
typedef enum {
PyoPortaudio = 0,
PyoCoreaudio = 1,
@@ -50,33 +40,45 @@ typedef enum {
PyoEmbedded
} PyoAudioBackendType;
-typedef struct {
- PaStream *stream;
-} PyoPaBackendData;
+typedef enum {
+ PyoPortmidi = 0
+} PyoMidiBackendType;
+
+/* Portmidi midi message and event type clones. */
+typedef long PyoMidiTimestamp;
+
+#define PyoMidi_Message(status, data1, data2) \
+ ((((data2) << 16) & 0xFF0000) | \
+ (((data1) << 8) & 0xFF00) | \
+ ((status) & 0xFF))
+#define PyoMidi_MessageStatus(msg) ((msg) & 0xFF)
+#define PyoMidi_MessageData1(msg) (((msg) >> 8) & 0xFF)
+#define PyoMidi_MessageData2(msg) (((msg) >> 16) & 0xFF)
+
+typedef long PyoMidiMessage;
typedef struct {
-#ifdef USE_JACK
- jack_client_t *jack_client;
- jack_port_t **jack_in_ports;
- jack_port_t **jack_out_ports;
-#endif
-} PyoJackBackendData;
+ PyoMidiMessage message;
+ PyoMidiTimestamp timestamp;
+} PyoMidiEvent;
+
+/************************************************/
typedef struct {
PyObject_HEAD
PyObject *streams;
PyoAudioBackendType audio_be_type;
+ PyoMidiBackendType midi_be_type;
void *audio_be_data;
+ void *midi_be_data;
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) */
- 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];
+ PyObject *jackAutoConnectInputPorts; /* list of lists of jack auto-connection ports to pyo inputs */
+ PyObject *jackAutoConnectOutputPorts; /* list of lists of jack auto-connection ports from pyo outputs */
+ PyoMidiEvent midiEvents[200];
int midiin_count;
int midiout_count;
- PmEvent midiEvents[200];
int midi_count;
double samplingRate;
int nchnls;
@@ -121,6 +123,7 @@ typedef struct {
char *recpath;
int recformat;
int rectype;
+ double recquality;
SNDFILE *recfile;
SF_INFO recinfo;
@@ -138,6 +141,9 @@ typedef struct {
int tcount;
PyObject *TIME;
+ /* custom callback */
+ PyObject *CALLBACK;
+
/* Properties */
int verbosity; /* a sum of values to display different levels: 1 = error */
/* 2 = message, 4 = warning , 8 = debug. Default 7.*/
@@ -148,15 +154,25 @@ PyObject * PyServer_get_server();
extern unsigned int pyorand();
extern PyObject * Server_removeStream(Server *self, int sid);
extern MYFLT * Server_getInputBuffer(Server *self);
-extern PmEvent * Server_getMidiEventBuffer(Server *self);
+extern PyoMidiEvent * Server_getMidiEventBuffer(Server *self);
extern int Server_getMidiEventCount(Server *self);
extern int Server_getCurrentResamplingFactor(Server *self);
extern int Server_getLastResamplingFactor(Server *self);
extern int Server_generateSeed(Server *self, int oid);
extern PyTypeObject ServerType;
+void pyoGetMidiEvents(Server *self);
+void Server_process_buffers(Server *server);
+void Server_error(Server *self, char * format, ...);
+void Server_message(Server *self, char * format, ...);
+void Server_warning(Server *self, char * format, ...);
+void Server_debug(Server *self, char * format, ...);
+PyObject * Server_shut_down(Server *self);
+PyObject *Server_stop(Server *self);
+void Server_process_gui(Server *server);
+void Server_process_time(Server *server);
+int Server_start_rec_internal(Server *self, char *filename);
#ifdef __cplusplus
}
-#endif
-
-#endif /* !defined(Py_SERVERMODULE_H) */
+#endif /* __cplusplus */
+#endif /* Py_SERVERMODULE_H */
diff --git a/include/tablemodule.h b/include/tablemodule.h
index 26e2ac5..e07857c 100644
--- a/include/tablemodule.h
+++ b/include/tablemodule.h
@@ -28,6 +28,7 @@ typedef struct {
int size;
double samplingRate;
MYFLT *data;
+ Py_ssize_t shape[1]; /* 1-dimension array (must be set to table size) needed by the buffer protocol. */
} TableStream;
diff --git a/installers/osx/PkgResources_x86_64/License.rtf b/installers/osx/PkgResources_x86_64/License.rtf
deleted file mode 100755
index 50a49ab..0000000
--- a/installers/osx/PkgResources_x86_64/License.rtf
+++ /dev/null
@@ -1,423 +0,0 @@
-{\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
deleted file mode 100755
index 23774ec..0000000
--- a/installers/osx/PkgResources_x86_64/ReadMe.rtf
+++ /dev/null
@@ -1,88 +0,0 @@
-{\rtf1\ansi\deff4\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\froman\fprq0\fcharset128 Times New Roman;}{\f5\froman\fprq0\fcharset128 Liberation Serif{\*\falt Times New Roman};}{\f6\froman\fprq0\fcharset128 LucidaGrande;}{\f7\froman\fprq0\fcharset128 Liberation Sans{\*\falt Arial};}{\f8\fnil\fprq2\fcharset0 FreeSans;}{\f9\fnil\fprq2\fcharset0 Liberation Serif{\*\falt Times New Roman};}}
-{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}
-{\stylesheet{\s0\snext0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084 Normal;}
-{\s1\sbasedon15\snext1\ql\nowidctlpar\sb240\sa120\keepn\ltrpar\cf1\kerning1\dbch\af8\langfe1081\dbch\af9\afs24\loch\f7\fs28\lang3084 Heading 1;}
-{\s2\sbasedon15\snext2\ql\nowidctlpar\sb240\sa120\keepn\ltrpar\cf1\kerning1\dbch\af8\langfe1081\dbch\af9\afs24\loch\f7\fs28\lang3084 Heading 2;}
-{\s3\sbasedon15\snext3\ql\nowidctlpar\sb240\sa120\keepn\ltrpar\cf1\kerning1\dbch\af8\langfe1081\dbch\af9\afs24\loch\f7\fs28\lang3084 Heading 3;}
-{\s15\sbasedon0\snext16\ql\nowidctlpar\sb240\sa120\keepn\ltrpar\cf1\kerning1\dbch\af8\langfe1081\dbch\af9\afs24\loch\f7\fs28\lang3084 Heading;}
-{\s16\sbasedon0\snext16\sl288\slmult1\ql\nowidctlpar\sb0\sa140\ltrpar\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\loch\f5\fs24\lang3084 Text Body;}
-{\s17\sbasedon16\snext17\sl288\slmult1\ql\nowidctlpar\sb0\sa140\ltrpar\cf1\kerning1\dbch\af8\langfe1081\dbch\af9\afs24\loch\f5\fs24\lang3084 List;}
-{\s18\sbasedon0\snext18\ql\nowidctlpar\sb120\sa120\ltrpar\cf1\i\kerning1\dbch\af8\langfe1081\dbch\af9\afs24\loch\f5\fs24\lang3084 Caption;}
-{\s19\sbasedon0\snext19\ql\nowidctlpar\ltrpar\cf1\kerning1\dbch\af8\langfe1081\dbch\af9\afs24\loch\f5\fs24\lang3084 Index;}
-{\s20\sbasedon0\snext20\ql\nowidctlpar\ltrpar\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\loch\f5\fs24\lang3084 Quotations;}
-{\s21\sbasedon15\snext21\ql\nowidctlpar\sb240\sa120\keepn\ltrpar\cf1\kerning1\dbch\af8\langfe1081\dbch\af9\afs24\loch\f7\fs28\lang3084 Title;}
-{\s22\sbasedon15\snext22\ql\nowidctlpar\sb240\sa120\keepn\ltrpar\cf1\kerning1\dbch\af8\langfe1081\dbch\af9\afs24\loch\f7\fs28\lang3084 Subtitle;}
-}{\*\generator LibreOffice/5.0.2.2$Linux_X86_64 LibreOffice_project/00m0$Build-2}{\info{\author olivier }{\creatim\yr0\mo0\dy0\hr0\min0}{\author Olivier }{\revtim\yr2016\mo2\dy3\hr18\min50}{\printim\yr0\mo0\dy0\hr0\min0}}\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\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\rtlch \ltrch\loch\fs26\loch\f6
-Python-pyo (version 0.7}{\rtlch \ltrch\loch\fs26\loch\f6
-.8}{\rtlch \ltrch\loch\fs26\loch\f6
-)}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar\rtlch \ltrch\loch\fs26\loch\f6
-
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\rtlch \ltrch\loch\fs26\loch\f6
-System requirements : OS X 10.6 to 10.10}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar\rtlch \ltrch\loch\fs26\loch\f6
-
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\rtlch \ltrch\loch\fs26\loch\f6
-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\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar\rtlch \ltrch\loch\fs26\loch\f6
-
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\rtlch \ltrch\loch\fs26\loch\f6
-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\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar\rtlch \ltrch\loch\fs26\loch\f6
-
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b\rtlch \ltrch\loch\fs26\loch\f6
-1. pyo extension:}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-The following components will be installed in the site-packages folder of the current Python Framework:}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar\b0\rtlch \ltrch\loch\fs26\loch\f6
-
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-_pyo.so}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-_pyo64.so}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-pyo.py}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-pyo64.py}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-pyolib (folder)}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar\b0\rtlch \ltrch\loch\fs26\loch\f6
-
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b\rtlch \ltrch\loch\fs26\loch\f6
-2. Support libraries (i386 and x86_64):}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-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\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar\b0\rtlch \ltrch\loch\fs26\loch\f6
-
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b\rtlch \ltrch\loch\fs26\loch\f6
-Warning:}{\b0\rtlch \ltrch\loch\fs26\loch\f6
- 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\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar\b0\rtlch \ltrch\loch\fs26\loch\f6
-
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-liblo.7.dylib}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-libportaudio.2.dylib}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-libportmidi.dylib}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-libsndfile.1.dylib}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-libFLAC.8.dylib}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-libvorbisenc.2.dylib}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-libvorbis.0.dylib}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-libogg.0.dylib}
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ltrpar\b0\rtlch \ltrch\loch\fs26\loch\f6
-
-\par \pard\plain \s0\ql\nowidctlpar\ltrpar\hyphpar0\cf1\kerning1\dbch\af9\langfe1081\dbch\af9\afs24\alang1081\loch\f5\fs24\lang3084\ql\nowidctlpar\ltrpar{\b0\rtlch \ltrch\loch\fs26\loch\f6
-Olivier B\u233\'3flanger, 2015}
-\par }
\ No newline at end of file
diff --git a/installers/osx/PkgResources_x86_64/Welcome.rtf b/installers/osx/PkgResources_x86_64/Welcome.rtf
deleted file mode 100755
index b8b9917..0000000
--- a/installers/osx/PkgResources_x86_64/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_x86_64/postinstall b/installers/osx/PkgResources_x86_64/postinstall
deleted file mode 100755
index ddcb4ab..0000000
--- a/installers/osx/PkgResources_x86_64/postinstall
+++ /dev/null
@@ -1,93 +0,0 @@
-#! /bin/sh
-
-# 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
- 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 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.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
-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
-
-# 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
-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
diff --git a/installers/osx/PkgResources_x86_64/postupgrade b/installers/osx/PkgResources_x86_64/postupgrade
deleted file mode 100755
index ddcb4ab..0000000
--- a/installers/osx/PkgResources_x86_64/postupgrade
+++ /dev/null
@@ -1,93 +0,0 @@
-#! /bin/sh
-
-# 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
- 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 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.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
-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
-
-# 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
-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
diff --git a/installers/osx/release_x86_64.sh b/installers/osx/release_x86_64.sh
deleted file mode 100644
index bcd1103..0000000
--- a/installers/osx/release_x86_64.sh
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/sh
-
-# 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 installers/osx and build the realease, only x86_64 version
-
-export PACKAGE_NAME=pyo_0.7.9_x86_64.pkg
-export DMG_DIR="pyo 0.7.9 Universal"
-export DMG_NAME="pyo_0.7.9_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
-export BUILD_RESOURCES=$INSTALLER_DIR/PkgResources/English.lproj
-export PKG_RESOURCES=$INSTALLER_DIR/../PkgResources_x86_64
-
-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
-
-cd ../..
-git checkout-index -a -f --prefix=installers/osx/installer/pyo-build/
-cd installers/osx/installer/pyo-build
-
-echo "building pyo for python 2.6 (64-bit)..."
-sudo /usr/bin/python setup.py install --use-coreaudio
-
-sudo rm -rf build/temp.macosx-10.6-universal-2.6
-sudo /usr/bin/python setup.py install --use-coreaudio --only-double
-
-sudo cp -R build/lib.macosx-10.6-universal-2.6 $PYO_MODULE_DIR/python26
-
-echo "building pyo for python 2.7 (64-bit)..."
-sudo /usr/local/bin/python2.7 setup.py install --use-coreaudio --use-double
-
-sudo cp -R build/lib.macosx-10.6-intel-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/win/build_installers_win.bat b/installers/win/build_installers_win.bat
index 0861ba3..4278992 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 *** Build installer for python3.5 ***
+Compil32 /cc "win_installer_py35.iss"
diff --git a/installers/win/win_installer_py26.iss b/installers/win/win_installer_py26.iss
index e4ee877..1ac3b9d 100644
--- a/installers/win/win_installer_py26.iss
+++ b/installers/win/win_installer_py26.iss
@@ -3,7 +3,7 @@
#define appName "pyo"
#define pyVer "2.6"
-#define appVer "0.7.9"
+#define appVer "0.8.0"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
diff --git a/installers/win/win_installer_py27.iss b/installers/win/win_installer_py27.iss
index 809431f..d34ab8a 100644
--- a/installers/win/win_installer_py27.iss
+++ b/installers/win/win_installer_py27.iss
@@ -3,7 +3,7 @@
#define appName "pyo"
#define pyVer "2.7"
-#define appVer "0.7.9"
+#define appVer "0.8.1"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
diff --git a/pyo.py b/pyo.py
index 59f18b0..5791e4f 100644
--- a/pyo.py
+++ b/pyo.py
@@ -1,5 +1,5 @@
"""
-Copyright 2009-2015 Olivier Belanger
+Copyright 2009-2016 Olivier Belanger
This file is part of pyo, a python module to help digital signal
processing script creation.
@@ -69,65 +69,141 @@ if WITH_EXTERNALS:
import pyolib.external as external
from pyolib.external import *
-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', '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', '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', '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', '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']),
- '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', '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', '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', 'Euclide', 'TrigBurst']),
- 'utils': sorted(['Clean_objects', 'Print', 'Snap', 'Interp', 'SampHold', 'Compare', 'Record', 'Between', 'Denorm',
- 'ControlRec', 'ControlRead', 'NoteinRec', 'NoteinRead', 'DBToA', 'AToDB', 'Scale', 'CentsToTranspo',
- 'TranspoToCents', 'MToF', 'FToM', 'MToT', 'TrackHold', 'Resample', 'Expr']),
- 'expression': sorted(['Expr']),
- 'fourier': sorted(['FFT', 'IFFT', 'CarToPol', 'PolToCar', 'FrameDelta', 'FrameAccum', 'Vectral', 'CvlVerb'])}},
- 'Map': {'SLMap': sorted(['SLMapFreq', 'SLMapMul', 'SLMapPhase', 'SLMapQ', 'SLMapDur', 'SLMapPan'])},
- 'Server': [],
- 'MidiListener': [],
- 'OscListener': [],
- 'Stream': [],
- 'TableStream': [],
- 'PyoGui': ['PyoGuiControlSlider', 'PyoGuiVuMeter', 'PyoGuiGrapher', 'PyoGuiMultiSlider', 'PyoGuiSpectrum', 'PyoGuiScope',
- 'PyoGuiSndView']}
+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', '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', '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',
+ 'AtanTable', 'PadSynthTable']),
+ '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', 'Exp']),
+ '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', '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', 'MoogLP']),
+ 'generators': sorted(['Noise', 'Phasor', 'Sine', 'Input', 'CrossFM',
+ 'SineLoop', 'Blit', 'PinkNoise', 'FM', 'LFO',
+ 'BrownNoise', 'Rossler', 'Lorenz', 'ChenLee',
+ 'SumOsc', 'SuperSaw', 'RCOsc', 'FastSine']),
+ 'internals': sorted(['Dummy', 'InputFader', 'Mix', 'VarPort']),
+ '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',
+ 'LogiMap']),
+ 'players': sorted(['SfMarkerShuffler', 'SfPlayer', 'SfMarkerLooper']),
+ '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', 'Trig',
+ 'TrigRandInt', 'Select', 'Counter', 'TrigChoice',
+ 'TrigFunc', 'Thresh', 'Cloud', 'TrigXnoise',
+ 'TrigXnoiseMidi', 'Timer', 'Count', 'Change',
+ 'TrigLinseg', 'TrigExpseg', 'Percent', 'Seq',
+ 'TrigTableRec', 'Iter', 'NextTrig', 'TrigVal',
+ 'Euclide', 'TrigBurst']),
+ 'utils': sorted(['Clean_objects', 'Print', 'Snap', 'Interp',
+ 'SampHold', 'Compare', 'Record', 'DBToA', 'AToDB',
+ 'Between', 'Denorm', 'ControlRec', 'ControlRead',
+ 'NoteinRec', 'NoteinRead', 'Scale', 'TrackHold',
+ 'CentsToTranspo', 'TranspoToCents', 'MToF', 'FToM',
+ 'MToT', 'Resample', 'Expr']),
+ 'expression': sorted(['Expr']),
+ 'fourier': sorted(['FFT', 'IFFT', 'CarToPol', 'PolToCar',
+ 'FrameDelta', 'FrameAccum', 'Vectral', 'CvlVerb'])
+ }
+ },
+ 'Map': {'SLMap': sorted(['SLMapFreq', 'SLMapMul', 'SLMapPhase',
+ 'SLMapQ', 'SLMapDur', 'SLMapPan'])},
+ 'Server': [],
+ 'MidiListener': [],
+ 'OscListener': [],
+ 'Stream': [],
+ 'TableStream': [],
+ 'PyoGui': ['PyoGuiControlSlider', 'PyoGuiVuMeter', 'PyoGuiGrapher',
+ 'PyoGuiMultiSlider', 'PyoGuiSpectrum', 'PyoGuiScope',
+ 'PyoGuiSndView']}
-DOC_KEYWORDS = ['Attributes', 'Examples', 'Parameters', 'Methods', 'Notes', 'Methods details', 'See also', 'Parentclass']
\ No newline at end of file
+DOC_KEYWORDS = ['Attributes', 'Examples', 'Parameters', 'Methods', 'Notes',
+ 'Methods details', 'See also', 'Parentclass']
+
+def getPyoKeywords():
+ """
+ Returns a list of every keywords (classes and functions) of pyo.
+
+ >>> keywords = getPyoKeywords()
+
+ """
+ tree = OBJECTS_TREE
+ _list = []
+ for k1 in tree.keys():
+ if type(tree[k1]) == type({}):
+ for k2 in tree[k1].keys():
+ if type(tree[k1][k2]) == type({}):
+ for k3 in tree[k1][k2].keys():
+ for val in tree[k1][k2][k3]:
+ _list.append(val)
+ else:
+ for val in tree[k1][k2]:
+ _list.append(val)
+ else:
+ for val in tree[k1]:
+ _list.append(val)
+ _list.extend(["PyoObjectBase", "PyoObject", "PyoTableObject",
+ "PyoMatrixObject", "PyoPVObject"])
+ _list.extend(["Server", "Map", "SLMap", "MidiListener", "OscListener",
+ "Stream", "TableStream"])
+ return _list
+
+OBJECTS_TREE["functions"] = sorted(OBJECTS_TREE["functions"] + ["getPyoKeywords"])
diff --git a/pyo64.py b/pyo64.py
index 04f100f..e2263ca 100644
--- a/pyo64.py
+++ b/pyo64.py
@@ -17,6 +17,13 @@ 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 __builtin__
-__builtin__.pyo_use_double = True
+import sys
+if sys.version_info[0] < 3:
+ import __builtin__
+ builtins = __builtin__
+else:
+ import builtins
+
+builtins.pyo_use_double = True
+
from pyo import *
\ No newline at end of file
diff --git a/pyolib/_core.py b/pyolib/_core.py
index 7575fb9..acf8a70 100644
--- a/pyolib/_core.py
+++ b/pyolib/_core.py
@@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
+from __future__ import division
+from __future__ import print_function
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -18,51 +21,99 @@ 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 BooleanType, ListType, TupleType, SliceType, LongType, IntType, FloatType, StringType, UnicodeType, NoneType
+import types
import random, os, sys, inspect, tempfile
from subprocess import call
from weakref import proxy
-import __builtin__
-if hasattr(__builtin__, 'pyo_use_double'):
+if sys.version_info[0] < 3:
+ import __builtin__
+ builtins = __builtin__
+ bytes_t = str
+ unicode_t = unicode
+ def tobytes(str, encoding=None):
+ return bytes(str)
+else:
+ import builtins
+ bytes_t = bytes
+ unicode_t = str
+ def tobytes(str, encoding="utf-8"):
+ return bytes(str, encoding=encoding)
+
+if hasattr(builtins, 'pyo_use_double'):
import pyo64 as current_pyo
from _pyo64 import *
else:
import pyo as current_pyo
from _pyo import *
-from _maps import *
-from _widgets import createCtrlWindow, createViewTableWindow, createViewMatrixWindow
-
+from ._maps import *
+from ._widgets import createCtrlWindow
+from ._widgets import createViewTableWindow
+from ._widgets import createViewMatrixWindow
+
######################################################################
### 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}
-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()",
- "pa_list_devices": "pa_list_devices()", "pa_get_devices_infos": "pa_get_devices_infos()",
- "pa_get_version": "pa_get_version()", "pa_get_version_text": "pa_get_version_text()",
- "pa_get_input_devices": "pa_get_input_devices()", "pa_get_output_devices": "pa_get_output_devices()",
- "pa_get_default_input": "pa_get_default_input()", "pa_get_default_output": "pa_get_default_output()",
- "pa_get_input_max_channels": "pa_get_input_max_channels(x)", "pa_get_output_max_channels": "pa_get_output_max_channels(x)",
- "pm_get_default_output": "pm_get_default_output()", "pm_get_default_input": "pm_get_default_input()",
- "pm_get_output_devices": "pm_get_output_devices()", "pm_get_input_devices": "pm_get_input_devices()",
- "pm_list_devices": "pm_list_devices()", "pm_count_devices": "pm_count_devices()",
- "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)", "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)", "floatmap": "floatmap(x, min=0, max=1, exp=1)"
- }
+current_pyo_path = os.path.dirname(current_pyo.__file__)
+SNDS_PATH = os.path.join(current_pyo_path, "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}
+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()",
+ "pa_list_devices": "pa_list_devices()",
+ "pa_get_devices_infos": "pa_get_devices_infos()",
+ "pa_get_version": "pa_get_version()",
+ "pa_get_version_text": "pa_get_version_text()",
+ "pa_get_input_devices": "pa_get_input_devices()",
+ "pa_get_output_devices": "pa_get_output_devices()",
+ "pa_get_default_input": "pa_get_default_input()",
+ "pa_get_default_output": "pa_get_default_output()",
+ "pa_get_input_max_channels": "pa_get_input_max_channels(x)",
+ "pa_get_output_max_channels": "pa_get_output_max_channels(x)",
+ "pm_get_default_output": "pm_get_default_output()",
+ "pm_get_default_input": "pm_get_default_input()",
+ "pm_get_output_devices": "pm_get_output_devices()",
+ "pm_get_input_devices": "pm_get_input_devices()",
+ "pm_list_devices": "pm_list_devices()",
+ "pm_count_devices": "pm_count_devices()",
+ "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)",
+ "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)",
+ "floatmap": "floatmap(x, min=0, max=1, exp=1)",
+ "getPyoKeywords": "getPyoKeywords()"
+}
class PyoError(Exception):
"""Base class for all pyo exceptions."""
@@ -84,126 +135,135 @@ def isMatrixObject(obj):
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.
+
+ 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
+
+ - 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.
-
+
"""
+ if sys.version_info[0] < 3:
+ # Python 2
+ longType = int
+ else:
+ # Python 3
+ # Not used in Python 3, ignore it
+ longType = None
+
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]:
+ argtype not in [list, int, longType, float]:
expected = "float or PyoObject"
elif f == "o":
- if not isAudioObject(args[i]) and argtype not in [ListType]:
+ if not isAudioObject(args[i]) and argtype not in [list]:
expected = "PyoObject"
elif f == "T":
- if not isTableObject(args[i]) and argtype not in [FloatType, ListType]:
+ if not isTableObject(args[i]) and argtype not in [float, list]:
expected = "float or PyoTableObject"
elif f == "t":
- if not isTableObject(args[i]) and argtype not in [ListType]:
+ if not isTableObject(args[i]) and argtype not in [list]:
expected = "PyoTableObject"
elif f == "m":
- if not isMatrixObject(args[i]) and argtype not in [ListType]:
+ if not isMatrixObject(args[i]) and argtype not in [list]:
expected = "PyoMatrixObject"
elif f == "p":
- if not isPVObject(args[i]) and argtype not in [ListType]:
+ if not isPVObject(args[i]) and argtype not in [list]:
expected = "PyoPVObject"
elif f == "n":
- if argtype not in [ListType, IntType, LongType, FloatType]:
+ if argtype not in [list, int, longType, float]:
expected = "any number"
elif f == "N":
- if argtype not in [IntType, LongType, FloatType]:
+ if argtype not in [int, longType, float]:
expected = "any number - list not allowed"
elif f == "f":
- if argtype not in [ListType, FloatType]:
+ if argtype not in [list, float]:
expected = "float"
elif f == "F":
- if argtype not in [FloatType]:
+ if argtype not in [float]:
expected = "float - list not allowed"
elif f == "i":
- if argtype not in [ListType, IntType, LongType]:
+ if argtype not in [list, int, longType]:
expected = "integer"
elif f == "I":
- if argtype not in [IntType, LongType]:
+ if argtype not in [int, longType]:
expected = "integer - list not allowed"
elif f == "s":
- if argtype not in [ListType, StringType, UnicodeType]:
+ if argtype not in [list, bytes_t, unicode_t]:
expected = "string"
elif f == "S":
- if argtype not in [StringType, UnicodeType]:
+ if argtype not in [bytes_t, unicode_t]:
expected = "string - list not allowed"
elif f == "b":
- if argtype not in [BooleanType, ListType, IntType, LongType]:
+ if argtype not in [bool, list, int, longType]:
expected = "boolean"
elif f == "B":
- if argtype not in [BooleanType, IntType, LongType]:
+ if argtype not in [bool, int, longType]:
expected = "boolean - list not allowed"
elif f == "l":
- if argtype not in [ListType]:
+ if argtype not in [list]:
expected = "list"
elif f == "L":
- if argtype not in [ListType, NoneType]:
+ if argtype not in [list, type(None)]:
expected = "list or None"
elif f == "u":
- if argtype not in [TupleType]:
+ if argtype not in [tuple]:
expected = "tuple"
elif f == "x":
- if argtype not in [ListType, TupleType]:
+ if argtype not in [list, tuple]:
expected = "list or tuple"
elif f == "c":
- if not callable(args[i]) and argtype not in [ListType, TupleType, NoneType]:
+ if not callable(args[i]) and argtype not in [list, tuple, type(None)]:
expected = "callable"
elif f == "C":
- if not callable(args[i]) and argtype not in [NoneType]:
+ if not callable(args[i]) and argtype not in [type(None)]:
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))
+ err = 'bad argument at position %d to "%s" (%s expected, got %s)'
+ raise PyoArgumentTypeError(err % (i, name, expected, argtype))
def convertStringToSysEncoding(str):
"""
@@ -213,24 +273,24 @@ def convertStringToSysEncoding(str):
:Args:
- str : string
+ str: string
String to convert.
"""
- if type(str) != UnicodeType:
+ if type(str) not in [bytes_t, unicode_t]:
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 PyoObjectBase.
Return new args and maximum list length.
"""
converted = []
for i in args:
- if isinstance(i, PyoObjectBase) or type(i) == ListType:
+ if isinstance(i, PyoObjectBase) or type(i) == list:
converted.append(i)
else:
converted.append([i])
@@ -255,14 +315,14 @@ def example(cls, dur=5, toprint=True, double=False):
:Args:
- cls : PyoObject class
+ cls: PyoObject class
Class reference of the desired object example.
- dur : float, optional
+ dur: float, optional
Duration of the example.
- toprint : boolean, optional
+ toprint: boolean, optional
If True, the example script will be printed to the console.
Defaults to True.
- double : boolean, optional
+ double: boolean, optional
If True, force the example to run in double precision (64-bit)
Defaults to False.
@@ -283,11 +343,11 @@ def example(cls, dur=5, toprint=True, double=False):
lines.append(line)
if lines == []:
- print "There is no manual example for %s object." % cls.__name__
+ print("There is no manual example for %s object." % cls.__name__)
return
- ex_lines = [line.lstrip(" ") for line in lines if ">>>" in line or "..." in line]
- if hasattr(__builtin__, 'pyo_use_double') or double:
+ ex_lines = [l.lstrip(" ") for l in lines if ">>>" in l or "..." in l]
+ if hasattr(builtins, 'pyo_use_double') or double:
ex = "import time\nfrom pyo64 import *\n"
else:
ex = "import time\nfrom pyo import *\n"
@@ -299,15 +359,18 @@ def example(cls, dur=5, toprint=True, double=False):
ex += "time.sleep(%f)\ns.stop()\ntime.sleep(0.25)\ns.shutdown()\n" % dur
f = tempfile.NamedTemporaryFile(delete=False)
if toprint:
- f.write('print """\n%s\n"""\n' % ex)
- f.write(ex)
+ f.write(tobytes('print("""\n%s\n""")\n' % ex))
+ f.write(tobytes(ex))
f.close()
- p = call(["python", f.name])
+ executable = sys.executable
+ if not executable or executable is None:
+ executable = "python"
+ p = call([executable, f.name])
def removeExtraDecimals(x):
- if type(x) == FloatType:
+ if type(x) == float:
return "=%.2f" % x
- elif type(x) == StringType:
+ elif type(x) in [bytes_t, unicode_t]:
return '="%s"' % x
else:
return "=" + str(x)
@@ -321,10 +384,10 @@ def class_args(cls):
:Args:
- cls : PyoObject class
+ cls: PyoObject class
Class reference of the desired object's init line.
- >>> print class_args(Sine)
+ >>> print(class_args(Sine))
>>> 'Sine(freq=1000, phase=0, mul=1, add=0)'
"""
@@ -332,7 +395,8 @@ def class_args(cls):
try:
# Try for a class __init__ function
arg, varargs, varkw, defaults = inspect.getargspec(getattr(cls, "__init__"))
- arg = inspect.formatargspec(arg, varargs, varkw, defaults, formatvalue=removeExtraDecimals)
+ arg = inspect.formatargspec(arg, varargs, varkw, defaults,
+ formatvalue=removeExtraDecimals)
arg = arg.replace("self, ", "")
return name + arg
except TypeError:
@@ -341,8 +405,9 @@ def class_args(cls):
if name in FUNCTIONS_INIT_LINES:
return FUNCTIONS_INIT_LINES[name]
except:
- print "class_args was unable to retrieve the init line of the object as an argument."
- return ""
+ print("class_args was unable to retrieve the "
+ "init line of the object as an argument.")
+ return ""
def getVersion():
"""
@@ -351,9 +416,9 @@ def getVersion():
This function returns the version number of the current pyo
installation as a 3-ints tuple (major, minor, rev).
- The returned tuple for version '0.4.1' will look like : (0, 4, 1)
+ The returned tuple for version '0.4.1' will look like: (0, 4, 1)
- >>> print getVersion()
+ >>> print(getVersion())
>>> (0, 5, 1)
"""
@@ -361,7 +426,7 @@ def getVersion():
return (int(major), int(minor), int(rev))
def getWeakMethodRef(x):
- if type(x) in [ListType, TupleType]:
+ if type(x) in [list, tuple]:
tmp = []
for y in x:
if hasattr(y, "__self__"):
@@ -378,6 +443,10 @@ class WeakMethod(object):
Once created, call this object -- MyWeakMethod() --
and pass args/kwargs as you normally would.
"""
+ def __new__(cls, callobj):
+ if callable(callobj):
+ return super(WeakMethod, cls).__new__(cls)
+
def __init__(self, callobj):
if hasattr(callobj, "__self__"):
self.target = proxy(callobj.__self__)
@@ -410,9 +479,12 @@ class PyoObjectBase(object):
**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.
+ >>> 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.
+ >>> for x in obj: # Can be used as an iterator (iterates over
+ >>> # object's audio streams).
"""
@@ -421,10 +493,13 @@ class PyoObjectBase(object):
_STREAM_TYPE = ''
def __init__(self):
+ self.__index = 0
if not serverCreated():
- raise PyoServerStateException("You must create and boot a Server before creating any audio object.")
+ raise PyoServerStateException("You must create and boot a Server "
+ "before creating any audio object.")
if not serverBooted():
- raise PyoServerStateException("The Server must be booted before creating any audio object.")
+ raise PyoServerStateException("The Server must be booted before "
+ "creating any audio object.")
def dump(self):
"""
@@ -472,16 +547,31 @@ class PyoObjectBase(object):
"""
return self._base_objs[0].getServer().getBufferSize()
+ def __iter__(self):
+ self.__index = 0
+ return self
+
+ def __next__(self):
+ if self.__index >= len(self):
+ raise StopIteration
+ x = self[self.__index]
+ self.__index += 1
+ return x
+
+ def next(self):
+ # In Python 2.x, __next__() method is called next().
+ return self.__next__()
+
def __getitem__(self, i):
if i == 'trig': # not safe...
return self._trig_objs
- if type(i) == SliceType or i < len(self._base_objs):
+ if type(i) == slice or i < len(self._base_objs):
return self._base_objs[i]
else:
- if type(i) == StringType:
- print "Object %s has no stream named '%s'!" % (self.__class__.__name__, i)
+ if type(i) in [bytes_t, unicode_t]:
+ print("Object %s has no stream named '%s'!" % (self.__class__.__name__, i))
else:
- print "'i' too large in slicing %s object %s!" % (self._STREAM_TYPE, self.__class__.__name__)
+ print("'i' too large in slicing %s object %s!" % (self._STREAM_TYPE, self.__class__.__name__))
def __len__(self):
return len(self._base_objs)
@@ -507,9 +597,9 @@ class PyoObject(PyoObjectBase):
:Args:
- mul : float or PyoObject, optional
+ mul: float or PyoObject, optional
Multiplication factor. Defaults to 1.
- add : float or PyoObject, optional
+ add: float or PyoObject, optional
Addition factor. Defaults to 0.
.. note::
@@ -533,10 +623,10 @@ class PyoObject(PyoObjectBase):
**Exponent** and **modulo**
- >>> a ** 10 # returns a Pow object created as : Pow(a, 10)
- >>> 10 ** a # returns a Pow object created as : Pow(10, a)
- >>> a % 4 # returns a Wrap object created as : Wrap(a, 0, 4)
- >>> a % b # returns a Wrap object created as : Wrap(a, 0, b)
+ >>> a ** 10 # returns a Pow object created as: Pow(a, 10)
+ >>> 10 ** a # returns a Pow object created as: Pow(10, a)
+ >>> a % 4 # returns a Wrap object created as: Wrap(a, 0, 4)
+ >>> a % b # returns a Wrap object created as: Wrap(a, 0, b)
**Unary negative** (**-**)
@@ -544,12 +634,12 @@ class PyoObject(PyoObjectBase):
**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="==")
- >>> 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=">=")
+ >>> 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="==")
+ >>> 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=">=")
A special case concerns the comparison of a PyoObject with None. All operators
return False except `a != None`, which returns True.
@@ -562,6 +652,7 @@ class PyoObject(PyoObjectBase):
PyoObjectBase.__init__(self)
self._target_dict = {}
self._signal_dict = {}
+ self._callback_dict = {}
self._keep_trace = []
self._mul = mul
self._add = add
@@ -572,7 +663,7 @@ class PyoObject(PyoObjectBase):
def __add__(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)])
+ _add_dummy = Dummy([obj + wrap(x,i//self._op_duplicate) for i, obj in enumerate(self._base_objs)])
else:
if isinstance(x, PyoObject):
_add_dummy = x + self
@@ -584,7 +675,7 @@ class PyoObject(PyoObjectBase):
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)])
+ _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)])
self._keep_trace.append(_add_dummy)
@@ -597,7 +688,7 @@ class PyoObject(PyoObjectBase):
def __sub__(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)])
+ _add_dummy = Dummy([obj - wrap(x,i//self._op_duplicate) for i, obj in enumerate(self._base_objs)])
else:
if isinstance(x, PyoObject):
_add_dummy = Dummy([wrap(self._base_objs,i) - wrap(x,i) for i in range(lmax)])
@@ -611,7 +702,7 @@ class PyoObject(PyoObjectBase):
if self.__len__() >= lmax:
tmp = []
for i, obj in enumerate(self._base_objs):
- sub_upsamp = Sig(wrap(x, i/self._op_duplicate))
+ sub_upsamp = Sig(wrap(x, i//self._op_duplicate))
self._keep_trace.append(sub_upsamp)
tmp.append(sub_upsamp - obj)
_add_dummy = Dummy(tmp)
@@ -632,7 +723,7 @@ class PyoObject(PyoObjectBase):
def __mul__(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)])
+ _mul_dummy = Dummy([obj * wrap(x,i//self._op_duplicate) for i, obj in enumerate(self._base_objs)])
else:
if isinstance(x, PyoObject):
_mul_dummy = x * self
@@ -644,7 +735,7 @@ class PyoObject(PyoObjectBase):
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)])
+ _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)])
self._keep_trace.append(_mul_dummy)
@@ -654,10 +745,19 @@ class PyoObject(PyoObjectBase):
self.setMul(x)
return self
+ def __truediv__(self, x):
+ return self.__div__(x)
+
+ def __rtruediv__(self, x):
+ return self.__rdiv__(x)
+
+ def __itruediv__(self, x):
+ return self.__idiv__(x)
+
def __div__(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)])
+ _mul_dummy = Dummy([obj / wrap(x,i//self._op_duplicate) for i, obj in enumerate(self._base_objs)])
else:
if isinstance(x, PyoObject):
_mul_dummy = Dummy([wrap(self._base_objs,i) / wrap(x,i) for i in range(lmax)])
@@ -671,7 +771,7 @@ class PyoObject(PyoObjectBase):
if self.__len__() >= lmax:
tmp = []
for i, obj in enumerate(self._base_objs):
- div_upsamp = Sig(wrap(x, i/self._op_duplicate))
+ div_upsamp = Sig(wrap(x, i//self._op_duplicate))
self._keep_trace.append(div_upsamp)
tmp.append(div_upsamp / obj)
_mul_dummy = Dummy(tmp)
@@ -699,7 +799,7 @@ class PyoObject(PyoObjectBase):
return Wrap(self, 0, x)
def __neg__(self):
- if self._zeros == None:
+ if self._zeros is None:
self._zeros = Sig(0)
return self._zeros - self
@@ -722,7 +822,7 @@ class PyoObject(PyoObjectBase):
return self.__do_comp__(comp=x, mode=">=")
def __do_comp__(self, comp, mode, default=False):
- if comp == None:
+ if comp is None:
return default
else:
return Compare(self, comp=comp, mode=mode)
@@ -733,7 +833,7 @@ class PyoObject(PyoObjectBase):
:Args:
- all : boolean, optional
+ all: boolean, optional
If True, the object returns a list with the state of all
streams managed by the object.
@@ -753,7 +853,7 @@ class PyoObject(PyoObjectBase):
:Args:
- all : boolean, optional
+ all: boolean, optional
If True, the object returns a list with the state of all
streams managed by the object.
@@ -780,7 +880,7 @@ class PyoObject(PyoObjectBase):
:Args:
- all : boolean, optional
+ all: boolean, optional
If True, the first value of each object's stream
will be returned as a list.
@@ -804,17 +904,17 @@ class PyoObject(PyoObjectBase):
:Args:
- dur : float, optional
+ dur: float, optional
Duration, in seconds, of the object's activation. The default is 0
and means infinite duration.
- delay : float, optional
+ 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"):
- if type(self._trig_objs) == ListType:
+ if type(self._trig_objs) == list:
for i in range(lmax):
for obj in self._trig_objs:
obj.play(wrap(dur,i), wrap(delay,i))
@@ -834,15 +934,15 @@ class PyoObject(PyoObjectBase):
:Args:
- chnl : int, optional
+ chnl: int, optional
Physical output assigned to the first audio stream of the object.
Defaults to 0.
- inc : int, optional
+ inc: int, optional
Output channel increment value. Defaults to 1.
- dur : float, optional
+ dur: float, optional
Duration, in seconds, of the object's activation. The default is 0
and means infinite duration.
- delay : float, optional
+ delay: float, optional
Delay, in seconds, before the object's activation. Defaults to 0.
If `chnl` >= 0, successive streams increment the output number by
@@ -859,7 +959,7 @@ class PyoObject(PyoObjectBase):
pyoArgsAssert(self, "iInn", chnl, inc, dur, delay)
dur, delay, lmax = convertArgsToLists(dur, delay)
if hasattr(self, "_trig_objs"):
- if type(self._trig_objs) == ListType:
+ if type(self._trig_objs) == list:
for i in range(lmax):
for obj in self._trig_objs:
obj.play(wrap(dur,i), wrap(delay,i))
@@ -867,7 +967,7 @@ class PyoObject(PyoObjectBase):
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:
+ if type(chnl) == list:
[obj.out(wrap(chnl,i), wrap(dur,i), wrap(delay,i)) for i, obj in enumerate(self._base_objs)]
else:
if chnl < 0:
@@ -885,7 +985,7 @@ class PyoObject(PyoObjectBase):
"""
if hasattr(self, "_trig_objs"):
- if type(self._trig_objs) == ListType:
+ if type(self._trig_objs) == list:
[obj.stop() for obj in self._trig_objs]
else:
self._trig_objs.stop()
@@ -901,7 +1001,7 @@ class PyoObject(PyoObjectBase):
:Args:
- voices : int, optional
+ voices: int, optional
Number of audio streams of the Mix object created by this method.
Defaults to 1.
@@ -925,9 +1025,9 @@ class PyoObject(PyoObjectBase):
:Args:
- min : float
+ min: float
Minimum value of the output signal.
- max : float
+ max: float
Maximum value of the output signal.
"""
@@ -949,14 +1049,14 @@ class PyoObject(PyoObjectBase):
:Args:
- x : float or PyoObject
+ 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)]
+ [obj.setMul(wrap(x,i//self._op_duplicate)) for i, obj in enumerate(self._base_objs)]
def setAdd(self, x):
"""
@@ -964,14 +1064,14 @@ class PyoObject(PyoObjectBase):
:Args:
- x : float or PyoObject
+ 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)]
+ [obj.setAdd(wrap(x,i//self._op_duplicate)) for i, obj in enumerate(self._base_objs)]
def setSub(self, x):
"""
@@ -979,14 +1079,14 @@ class PyoObject(PyoObjectBase):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
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)]
+ [obj.setSub(wrap(x,i//self._op_duplicate)) for i, obj in enumerate(self._base_objs)]
def setDiv(self, x):
"""
@@ -994,16 +1094,16 @@ class PyoObject(PyoObjectBase):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
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)]
+ [obj.setDiv(wrap(x,i//self._op_duplicate)) for i, obj in enumerate(self._base_objs)]
- def set(self, attr, value, port=0.025):
+ def set(self, attr, value, port=0.025, callback=None):
"""
Replace any attribute with portamento.
@@ -1013,18 +1113,23 @@ class PyoObject(PyoObjectBase):
:Args:
- attr : string
+ attr: string
Name of the attribute as a string.
- value : float
+ value: float
New value.
- port : float, optional
+ port: float, optional
Time, in seconds, to reach the new value.
+ callback: callable, optional
+ A python function to be called at the end of the ramp. If the
+ end of the ramp is not reached (ex.: called again before the
+ end of the portamento), the callback will not be called.
"""
- pyoArgsAssert(self, "Snn", attr, value, port)
+ pyoArgsAssert(self, "SnnC", attr, value, port, callback)
self._target_dict[attr] = value
+ self._callback_dict[attr] = callback
init = getattr(self, attr)
- if self._signal_dict.has_key(attr):
+ if attr in self._signal_dict:
if isinstance(self._signal_dict[attr], VarPort):
if self._signal_dict[attr].isPlaying():
init = self._signal_dict[attr].get(True)
@@ -1035,6 +1140,9 @@ class PyoObject(PyoObjectBase):
def _reset_from_set(self, attr=None):
if isinstance(getattr(self, attr), VarPort):
setattr(self, attr, self._target_dict[attr])
+ if self._callback_dict[attr] is not None:
+ self._callback_dict[attr]()
+ del self._callback_dict[attr]
self._signal_dict[attr].stop()
def ctrl(self, map_list=None, title=None, wxnoserver=False):
@@ -1048,13 +1156,13 @@ class PyoObject(PyoObjectBase):
:Args:
- map_list : list of SLMap objects, optional
+ map_list: list of SLMap objects, optional
Users defined set of parameters scaling. There is default
scaling for each object that accept `ctrl` method.
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -1062,10 +1170,10 @@ class PyoObject(PyoObjectBase):
the server GUI before showing the controller window.
"""
- if map_list == None:
+ if map_list is None:
map_list = self._map_list
if map_list == []:
- print("There is no controls for %s object." % self.__class__.__name__)
+ print(("There are no controls for %s object." % self.__class__.__name__))
return
createCtrlWindow(self, map_list, title, wxnoserver)
@@ -1098,7 +1206,7 @@ class PyoTableObject(PyoObjectBase):
:Args:
- size : int
+ size: int
Length of the table in samples. Usually provided by the child object.
"""
@@ -1111,7 +1219,7 @@ class PyoTableObject(PyoObjectBase):
self.viewFrame = None
self.graphFrame = None
- def save(self, path, format=0, sampletype=0):
+ def save(self, path, format=0, sampletype=0, quality=0.4):
"""
Writes the content of the table in an audio file.
@@ -1121,9 +1229,9 @@ class PyoTableObject(PyoObjectBase):
:Args:
- path : string
+ path: string
Full path (including extension) of the new file.
- format : int, optional
+ format: int, optional
Format type of the new file. Supported formats are:
0. WAVE - Microsoft WAV format (little endian) {.wav, .wave}
1. AIFF - Apple/SGI AIFF format (big endian) {.aif, .aiff}
@@ -1133,7 +1241,7 @@ class PyoTableObject(PyoObjectBase):
5. FLAC - FLAC lossless file format {.flac}
6. CAF - Core Audio File format {.caf}
7. OGG - Xiph OGG container {.ogg}
- sampletype : int, optional
+ sampletype: int, optional
Bit depth encoding of the audio file.
SD2 and FLAC only support 16 or 24 bit int. Supported types are:
@@ -1144,15 +1252,19 @@ class PyoTableObject(PyoObjectBase):
4. 64 bit float
5. U-Law encoded
6. A-Law encoded
+ quality: float, optional
+ The encoding quality value, between 0.0 (lowest quality) and
+ 1.0 (highest quality). This argument has an effect only with
+ FLAC and OGG compressed formats. Defaults to 0.4.
"""
- pyoArgsAssert(self, "SII", path, format, sampletype)
+ pyoArgsAssert(self, "SIIN", path, format, sampletype, quality)
ext = path.rsplit('.')
if len(ext) >= 2:
ext = ext[-1].lower()
- if FILE_FORMATS.has_key(ext):
+ if ext in FILE_FORMATS:
format = FILE_FORMATS[ext]
- savefileFromTable(self, path, format, sampletype)
+ savefileFromTable(self, path, format, sampletype, quality)
def write(self, path, oneline=True):
"""
@@ -1163,9 +1275,9 @@ class PyoTableObject(PyoObjectBase):
:Args:
- path : string
+ path: string
Full path of the generated file.
- oneline : boolean, optional
+ oneline: boolean, optional
If True, list of samples will inserted on one line.
If False, list of samples will be truncated to 8 floats
@@ -1196,7 +1308,7 @@ class PyoTableObject(PyoObjectBase):
:Args:
- path : string
+ path: string
Full path of the file to read.
The format is a list of lists of floats. For example, A two
@@ -1216,6 +1328,27 @@ class PyoTableObject(PyoObjectBase):
[obj.setData(f_list[i%f_len]) for i, obj in enumerate(self._base_objs)]
self.refreshView()
+ def getBuffer(self, chnl=0):
+ """
+ Return a reference to the underlying object implementing the buffer protocol.
+
+ With the buffer protocol, a table can be referenced and modified, without
+ copying the data, with numpy functions. To create an array using the same
+ memory as the table:
+
+ t = SndTable(SNDS_PATH+"/transparent.aif")
+ arr = numpy.asarray(t.getBuffer())
+
+ Now, every changes applied to the array will be reflected in the SndTable.
+
+ For more details about the buffer protocol, see PEP 3118 and python documentation.
+
+ """
+ if chnl < 0 or chnl >= len(self):
+ print("getBuffer(chnl): `chnl` argument out-of-range...")
+ else:
+ return self._base_objs[chnl].getTableStream()
+
def setSize(self, size):
"""
Change the size of the table.
@@ -1224,7 +1357,7 @@ class PyoTableObject(PyoObjectBase):
:Args:
- size : int
+ size: int
New table size in samples.
"""
@@ -1239,7 +1372,7 @@ class PyoTableObject(PyoObjectBase):
:Args:
- all : boolean
+ 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.
@@ -1249,7 +1382,7 @@ class PyoTableObject(PyoObjectBase):
if all:
return [obj.getSize() for obj in self._base_objs]
else:
- if type(self._size) == ListType:
+ if type(self._size) == list:
return self._size[0]
else:
return self._size
@@ -1264,9 +1397,9 @@ class PyoTableObject(PyoObjectBase):
:Args:
- value : float
+ value: float
Value, as floating-point, to record in the table.
- pos : int, optional
+ pos: int, optional
Position, in samples, where to record value. Defaults to 0.
"""
@@ -1284,7 +1417,7 @@ class PyoTableObject(PyoObjectBase):
:Args:
- pos : int, optional
+ pos: int, optional
Position, in samples, where to read the value. Defaults to 0.
"""
@@ -1299,7 +1432,7 @@ class PyoTableObject(PyoObjectBase):
:Args:
- all : boolean, optional
+ all: boolean, optional
If True, all sub tables are retrieved and returned as a list
of list of floats.
@@ -1373,7 +1506,7 @@ class PyoTableObject(PyoObjectBase):
:Args:
- exp : float, optional
+ exp: float, optional
Exponent factor. Defaults to 10.
"""
@@ -1388,9 +1521,9 @@ class PyoTableObject(PyoObjectBase):
:Args:
- gpos : float, optional
+ gpos: float, optional
Gain factor for positive samples. Defaults to 1.
- gneg : float, optional
+ gneg: float, optional
Gain factor for negative samples. Defaults to 1.
"""
@@ -1405,7 +1538,7 @@ class PyoTableObject(PyoObjectBase):
:Args:
- freq : float, optional
+ freq: float, optional
Filter's cutoff, in Hertz. Defaults to 1000.
"""
@@ -1420,7 +1553,7 @@ class PyoTableObject(PyoObjectBase):
:Args:
- dur : float, optional
+ dur: float, optional
Fade in duration, in seconds. Defaults to 0.1.
"""
@@ -1435,7 +1568,7 @@ class PyoTableObject(PyoObjectBase):
:Args:
- dur : float, optional
+ dur: float, optional
Fade out duration, in seconds. Defaults to 0.1.
"""
@@ -1453,13 +1586,13 @@ class PyoTableObject(PyoObjectBase):
:Args:
- x : float, list or PyoTableObject
+ x: float, list or PyoTableObject
value(s) to add.
"""
pyoArgsAssert(self, "T", x)
- if type(x) == ListType:
- if type(x[0]) == ListType:
+ if type(x) == list:
+ if type(x[0]) == list:
[obj.add(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
else:
[obj.add(x) for obj in self._base_objs]
@@ -1478,13 +1611,13 @@ class PyoTableObject(PyoObjectBase):
:Args:
- x : float, list or PyoTableObject
+ x: float, list or PyoTableObject
value(s) to substract.
"""
pyoArgsAssert(self, "T", x)
- if type(x) == ListType:
- if type(x[0]) == ListType:
+ if type(x) == list:
+ if type(x[0]) == list:
[obj.sub(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
else:
[obj.sub(x) for obj in self._base_objs]
@@ -1503,13 +1636,13 @@ class PyoTableObject(PyoObjectBase):
:Args:
- x : float, list or PyoTableObject
+ x: float, list or PyoTableObject
value(s) to multiply.
"""
pyoArgsAssert(self, "T", x)
- if type(x) == ListType:
- if type(x[0]) == ListType:
+ if type(x) == list:
+ if type(x[0]) == list:
[obj.mul(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
else:
[obj.mul(x) for obj in self._base_objs]
@@ -1519,6 +1652,50 @@ class PyoTableObject(PyoObjectBase):
self.refreshView()
return self
+ def copyData(self, table, srcpos=0, destpos=0, length=-1):
+ """
+ Copy samples from a source table.
+
+ Copy `length` samples from a source table to this table.
+
+ :Args:
+
+ table: PyoTableObject
+ The source table.
+ srcpos: int, optional
+ The start position in the source table. Defaults to 0.
+ destpos ; int, optional
+ The start position in the destination (self) table. Defaults
+ to 0.
+ length: int, optional
+ The number of samples to copy from source to destination. if
+ length is negative, the length of the smallest table is used.
+ Defaults to -1.
+
+ """
+ pyoArgsAssert(self, "tIII", table, srcpos, destpos, length)
+ [obj.copyData(table[i], srcpos, destpos, length) for i, obj in enumerate(self._base_objs)]
+ self.refreshView()
+
+ def rotate(self, pos):
+ """
+ Rotate the table content to the left around the position given as argument.
+
+ Samples between the given position and the end of the table will
+ be relocated in front of the samples from the beginning to the
+ given position.
+
+ :Args:
+
+ pos: int
+ The rotation position in samples. A negative position means
+ a rotation to the right.
+
+ """
+ pyoArgsAssert(self, "I", pos)
+ [obj.rotate(pos) for obj in self._base_objs]
+ self.refreshView()
+
def copy(self):
"""
Returns a deep copy of the object.
@@ -1527,7 +1704,7 @@ class PyoTableObject(PyoObjectBase):
args = [getattr(self, att) for att in self.__dir__()]
if self.__class__.__name__ == "SndTable":
_size = self.getSize()
- if type(_size) != ListType:
+ if type(_size) != list:
_size = [_size]
_chnls = len(self._base_objs)
args[0] = None
@@ -1546,9 +1723,9 @@ class PyoTableObject(PyoObjectBase):
:Args:
- title : string, optional
+ title: string, optional
Window title. Defaults to "Table waveform".
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -1571,12 +1748,19 @@ class PyoTableObject(PyoObjectBase):
Updates the graphical display of the table, if applicable.
"""
- if self.viewFrame != None:
+ if self.viewFrame is not None:
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())
+ if self.graphFrame is not None:
+ data = self._get_current_data()
+ length = len(data)
+ flength = self.graphFrame.getLength()
+ if length < flength:
+ data = data + [0] * (flength - length)
+ elif length > flength:
+ data = data[:flength]
+ self.graphFrame.update(data)
@property
def size(self):
@@ -1616,7 +1800,7 @@ class PyoMatrixObject(PyoObjectBase):
:Args:
- path : string
+ path: string
Full path of the generated file.
"""
@@ -1642,7 +1826,7 @@ class PyoMatrixObject(PyoObjectBase):
:Args:
- path : string
+ path: string
Full path of the file to read.
"""
@@ -1681,11 +1865,11 @@ class PyoMatrixObject(PyoObjectBase):
:Args:
- min : float, optional
+ min: float, optional
Minimum value. Defaults to -1.0.
- max : float, optional
+ max: float, optional
Maximum value. Defaults to 1.0.
- boost : float, optional
+ boost: float, optional
Amount of boost applied on each value. Defaults to 0.01.
"""
@@ -1702,11 +1886,11 @@ class PyoMatrixObject(PyoObjectBase):
:Args:
- value : float
+ value: float
Value, as floating-point, to record in the matrix.
- x : int, optional
+ x: int, optional
X position where to record value. Defaults to 0.
- y : int, optional
+ y: int, optional
Y position where to record value. Defaults to 0.
"""
@@ -1723,9 +1907,9 @@ class PyoMatrixObject(PyoObjectBase):
:Args:
- x : int, optional
+ x: int, optional
X position where to get value. Defaults to 0.
- y : int, optional
+ y: int, optional
Y position where to get value. Defaults to 0.
"""
@@ -1740,9 +1924,9 @@ class PyoMatrixObject(PyoObjectBase):
:Args:
- title : string, optional
+ title: string, optional
Window title. Defaults to "Matrix viewer".
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -1751,7 +1935,7 @@ class PyoMatrixObject(PyoObjectBase):
"""
pyoArgsAssert(self, "SB", title, wxnoserver)
- samples = self._base_objs[0].getViewData()
+ samples = self._base_objs[0].getImageData()
createViewMatrixWindow(samples, self.getSize(), title, wxnoserver, self)
def _setViewFrame(self, frame):
@@ -1762,8 +1946,8 @@ class PyoMatrixObject(PyoObjectBase):
Updates the graphical display of the matrix, if applicable.
"""
- if self.viewFrame != None:
- samples = self._base_objs[0].getViewData()
+ if self.viewFrame is not None:
+ samples = self._base_objs[0].getImageData()
self.viewFrame.update(samples)
######################################################################
@@ -1793,7 +1977,7 @@ class PyoPVObject(PyoObjectBase):
:Args:
- all : boolean, optional
+ all: boolean, optional
If True, the object returns a list with the state of all
streams managed by the object.
@@ -1817,10 +2001,10 @@ class PyoPVObject(PyoObjectBase):
:Args:
- dur : float, optional
+ dur: float, optional
Duration, in seconds, of the object's activation. The default is 0
and means infinite duration.
- delay : float, optional
+ delay: float, optional
Delay, in seconds, before the object's activation. Defaults to 0.
"""
@@ -1858,18 +2042,18 @@ class PyoPVObject(PyoObjectBase):
:Args:
- attr : string
+ attr: string
Name of the attribute as a string.
- value : float
+ value: float
New value.
- port : float, optional
+ port: float, optional
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):
+ if attr in self._signal_dict:
if isinstance(self._signal_dict[attr], VarPort):
if self._signal_dict[attr].isPlaying():
init = self._signal_dict[attr].get(True)
@@ -1893,13 +2077,13 @@ class PyoPVObject(PyoObjectBase):
:Args:
- map_list : list of SLMap objects, optional
+ map_list: list of SLMap objects, optional
Users defined set of parameters scaling. There is default
scaling for each object that accept `ctrl` method.
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -1907,10 +2091,10 @@ class PyoPVObject(PyoObjectBase):
the server GUI before showing the controller window.
"""
- if map_list == None:
+ if map_list is None:
map_list = self._map_list
if map_list == []:
- print("There is no controls for %s object." % self.__class__.__name__)
+ print(("There are no controls for %s object." % self.__class__.__name__))
return
createCtrlWindow(self, map_list, title, wxnoserver)
@@ -1928,9 +2112,9 @@ class Mix(PyoObject):
:Args:
- input : PyoObject or list of PyoObjects
+ input: PyoObject or list of PyoObjects
Input signal(s) to mix the streams.
- voices : int, optional
+ 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
streams. Defaults to 1.
@@ -1949,9 +2133,9 @@ class Mix(PyoObject):
>>> s.start()
>>> a = Sine([random.uniform(400,600) for i in range(50)], mul=.02)
>>> b = Mix(a, voices=2).out()
- >>> print len(a)
+ >>> print(len(a))
50
- >>> print len(b)
+ >>> print(len(b))
1
"""
@@ -1960,7 +2144,7 @@ class Mix(PyoObject):
PyoObject.__init__(self, mul, add)
self._input = input
mul, add, lmax = convertArgsToLists(mul, add)
- if type(input) == ListType:
+ if type(input) == list:
input_objs = []
input_objs = [obj for pyoObj in input for obj in pyoObj.getBaseObjects()]
else:
@@ -1993,7 +2177,7 @@ class Dummy(PyoObject):
:Args:
- objs_list : list of audio Stream objects
+ objs_list: list of audio Stream objects
List of Stream objects return by the PyoObject hidden method
getBaseObjects().
@@ -2010,9 +2194,9 @@ class Dummy(PyoObject):
>>> a = Sine()
>>> b = a * .5
- >>> print a
+ >>> print(a)
<pyolib.input.Sine object at 0x11fd610>
- >>> print b
+ >>> print(b)
<pyolib._core.Dummy object at 0x11fd710>
>>> s = Server().boot()
@@ -2041,7 +2225,7 @@ class InputFader(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal.
.. note::
@@ -2072,9 +2256,9 @@ class InputFader(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2098,7 +2282,7 @@ class Sig(PyoObject):
:Args:
- value : float or PyoObject
+ value: float or PyoObject
Numerical value to convert.
>>> import random
@@ -2126,7 +2310,7 @@ class Sig(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
Numerical value to convert.
"""
@@ -2158,16 +2342,16 @@ class VarPort(PyoObject):
:Args:
- value : float
+ value: float
Numerical value to convert.
- time : float, optional
+ time: float, optional
Ramp time, in seconds, to reach the new value. Defaults to 0.025.
- init : float, optional
+ init: float, optional
Initial value of the internal memory. Defaults to 0.
- function : Python callable, optional
+ function: Python callable, optional
If provided, it will be called at the end of the line.
Defaults to None.
- arg : any Python object, optional
+ arg: any Python object, optional
Optional argument sent to the function called at the end of the line.
Defaults to None.
@@ -2178,8 +2362,8 @@ class VarPort(PyoObject):
>>> s = Server().boot()
>>> s.start()
>>> def callback(arg):
- ... print "end of line"
- ... print 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()
@@ -2200,7 +2384,7 @@ class VarPort(PyoObject):
:Args:
- x : float
+ x: float
Numerical value to convert.
"""
@@ -2215,7 +2399,7 @@ class VarPort(PyoObject):
:Args:
- x : float
+ x: float
New ramp time.
"""
@@ -2230,7 +2414,7 @@ class VarPort(PyoObject):
:Args:
- x : Python function
+ x: Python function
new `function` attribute.
"""
@@ -2268,9 +2452,9 @@ class Pow(PyoObject):
:Args:
- base : float or PyoObject, optional
+ base: float or PyoObject, optional
Base composant. Defaults to 10.
- exponent : float or PyoObject, optional
+ exponent: float or PyoObject, optional
Exponent composant. Defaults to 1.
>>> s = Server().boot()
@@ -2295,7 +2479,7 @@ class Pow(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `base` attribute.
"""
@@ -2310,7 +2494,7 @@ class Pow(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `exponent` attribute.
"""
@@ -2344,11 +2528,11 @@ class Wrap(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- min : float or PyoObject, optional
+ min: float or PyoObject, optional
Minimum possible value. Defaults to 0.
- max : float or PyoObject, optional
+ max: float or PyoObject, optional
Maximum possible value. Defaults to 1.
.. note::
@@ -2384,9 +2568,9 @@ class Wrap(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2400,7 +2584,7 @@ class Wrap(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `min` attribute.
"""
@@ -2415,7 +2599,7 @@ class Wrap(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `max` attribute.
"""
@@ -2463,11 +2647,11 @@ class Compare(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal.
- comp : float or PyoObject
+ comp: float or PyoObject
comparison signal.
- mode : string, optional
+ mode: string, optional
Comparison operator as a string. Allowed operator are "<", "<=",
">", ">=", "==", "!=". Default to "<".
@@ -2500,9 +2684,9 @@ class Compare(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -2516,7 +2700,7 @@ class Compare(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New comparison signal.
"""
@@ -2533,7 +2717,7 @@ class Compare(PyoObject):
:Args:
- x : string
+ x: string
New `mode` attribute.
"""
@@ -2561,4 +2745,4 @@ class Compare(PyoObject):
"""string. Comparison operator."""
return self._mode
@mode.setter
- def mode(self, x): self.setMode(x)
\ No newline at end of file
+ def mode(self, x): self.setMode(x)
diff --git a/pyolib/_maps.py b/pyolib/_maps.py
index 9687aa7..fe2bf70 100644
--- a/pyolib/_maps.py
+++ b/pyolib/_maps.py
@@ -31,11 +31,11 @@ class Map:
:Args:
- min : int or float
+ min: int or float
Lowest value of the range.
- max : int or float
+ max: int or float
Highest value of the range.
- scale : string {'lin', 'log'}
+ scale: string {'lin', 'log'}
Method used to scale the input value on the specified range.
>>> m = Map(20., 20000., 'log')
@@ -57,7 +57,7 @@ class Map:
elif x > 1: x = 1.0
if self._scale == 'log':
- return pow(10, x * log10(self._max/self._min) + log10(self._min))
+ return pow(10, x * log10(self._max / self._min) + log10(self._min))
else:
return (self._max - self._min) * x + self._min
@@ -69,7 +69,7 @@ class Map:
"""
if self._scale == 'log':
- return log10(x/self._min) / log10(self._max/self._min)
+ return log10(x / self._min) / log10(self._max / self._min)
else:
return (x - self._min) / (self._max - self._min)
@@ -79,7 +79,7 @@ class Map:
:Args:
- x : float
+ x: float
New `min` attribute.
"""
@@ -91,7 +91,7 @@ class Map:
:Args:
- x : float
+ x: float
New `max` attribute.
"""
@@ -103,7 +103,7 @@ class Map:
:Args:
- x : string
+ x: string
New `scale` attribute.
"""
@@ -142,23 +142,23 @@ class SLMap(Map):
:Args:
- min : int or float
+ min: int or float
Smallest value of the range.
- max : int or float
+ max: int or float
Highest value of the range.
- scale : string {'lin', 'log'}
+ scale: string {'lin', 'log'}
Method used to scale the input value on the specified range.
- name : string
+ name: string
Name of the attributes the slider is affected to.
- init : int or float
+ init: int or float
Initial value. Specified in the real range, not between 0 and 1. Use
the `set` method to retreive the normalized corresponding value.
- res : string {'int', 'float'}, optional
+ res: string {'int', 'float'}, optional
Sets the resolution of the slider. Defaults to 'float'.
- ramp : float, optional
+ ramp: float, optional
Ramp time, in seconds, used to smooth the signal sent from slider
to object's attribute. Defaults to 0.025.
- dataOnly : boolean, optional
+ 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.
@@ -204,7 +204,7 @@ class SLMapFreq(SLMap):
:Args:
- init : int or float, optional
+ init: int or float, optional
Initial value. Specified in the real range, not between 0 and 1.
Defaults to 1000.
@@ -231,7 +231,7 @@ class SLMapMul(SLMap):
:Args:
- init : int or float, optional
+ init: int or float, optional
Initial value. Specified in the real range, not between 0 and 1.
Defaults to 1.
@@ -258,7 +258,7 @@ class SLMapPhase(SLMap):
:Args:
- init : int or float, optional
+ init: int or float, optional
Initial value. Specified in the real range, not between 0 and 1.
Defaults to 0.
@@ -285,7 +285,7 @@ class SLMapPan(SLMap):
:Args:
- init : int or float, optional
+ init: int or float, optional
Initial value. Specified in the real range, not between 0 and 1.
Defaults to 0.
@@ -312,7 +312,7 @@ class SLMapQ(SLMap):
:Args:
- init : int or float, optional
+ init: int or float, optional
Initial value. Specified in the real range, not between 0 and 1.
Defaults to 1.
@@ -339,7 +339,7 @@ class SLMapDur(SLMap):
:Args:
- init : int or float, optional
+ init: int or float, optional
Initial value. Specified in the real range, not between 0 and 1.
Defaults to 1.
@@ -356,4 +356,4 @@ class SLMapDur(SLMap):
"""
def __init__(self, init=1.):
- SLMap.__init__(self, 0., 60., 'lin', 'dur', init, 'float', 0.025)
\ No newline at end of file
+ SLMap.__init__(self, 0., 60., 'lin', 'dur', init, 'float', 0.025)
diff --git a/pyolib/_tkwidgets.py b/pyolib/_tkwidgets.py
index f4b0f1c..84e5b2a 100644
--- a/pyolib/_tkwidgets.py
+++ b/pyolib/_tkwidgets.py
@@ -1,3 +1,6 @@
+from __future__ import division
+from __future__ import print_function
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -17,17 +20,14 @@ 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, FloatType, IntType
import math, sys, os
-from Tkinter import *
-
-try:
- from PIL import Image, ImageDraw, ImageTk
-except:
- pass
+if sys.version_info[0] < 3:
+ from Tkinter import *
+else:
+ from tkinter import *
# constants for platform displays with Tk
-if sys.platform == 'linux2':
+if sys.platform.startswith('linux'):
Y_OFFSET = 0
VM_OFFSET = 2
elif sys.platform == 'win32':
@@ -41,6 +41,7 @@ else:
### Multisliders
######################################################################
class MultiSlider(Frame):
+
def __init__(self, master, init, key, command):
Frame.__init__(self, master, bd=0, relief=FLAT)
self._values = init
@@ -76,13 +77,13 @@ class MultiSlider(Frame):
def move(self, event):
if event.state == 0x0100:
- slide = (event.y - Y_OFFSET) / self._height
+ slide = (event.y - Y_OFFSET) // self._height
if 0 <= slide < len(self._lines):
self.update(event)
def update(self, event):
w = self.canvas.winfo_width()
- slide = (event.y - Y_OFFSET) / self._height
+ slide = (event.y - Y_OFFSET) // self._height
val = event.x / float(w)
self._values[slide] = val
y = self._height * slide + Y_OFFSET
@@ -93,6 +94,7 @@ class MultiSlider(Frame):
### Control window for PyoObject
######################################################################
class Command:
+
def __init__(self, func, key):
self.func = func
self.key = key
@@ -101,9 +103,10 @@ class Command:
self.func(self.key, value)
class PyoObjectControl(Frame):
+
def __init__(self, master=None, obj=None, map_list=None):
Frame.__init__(self, master, bd=1, relief=GROOVE)
- from controls import SigTo
+ from .controls import SigTo
self.bind('<Destroy>', self._destroy)
self._obj = obj
self._map_list = map_list
@@ -116,7 +119,7 @@ class PyoObjectControl(Frame):
for i, m in enumerate(self._map_list):
key, init = m.name, m.init
# filters PyoObjects
- if type(init) not in [ListType, FloatType, IntType]:
+ if type(init) not in [list, float, int]:
self._excluded.append(key)
else:
self._maps[key] = m
@@ -124,7 +127,7 @@ class PyoObjectControl(Frame):
label = Label(self, height=1, width=10, highlightthickness=0, text=key)
label.grid(row=i, column=0)
# create and pack slider
- if type(init) != ListType:
+ if type(init) != list:
self._sliders.append(Scale(self, command=Command(self.setval, key),
orient=HORIZONTAL, relief=GROOVE, from_=0., to=1., showvalue=False,
resolution=.0001, bd=1, length=225, troughcolor="#BCBCAA", width=12))
@@ -139,7 +142,7 @@ class PyoObjectControl(Frame):
display = Label(self, height=disp_height, width=10, highlightthickness=0, textvariable=textvar)
display.grid(row=i, column=2)
self._displays[key] = textvar
- if type(init) != ListType:
+ if type(init) != list:
self._displays[key].set("%.4f" % init)
else:
self._displays[key].set("\n".join(["%.4f" % i for i in init]))
@@ -166,7 +169,7 @@ class PyoObjectControl(Frame):
del self._sigs[key]
def setval(self, key, x):
- if type(x) != ListType:
+ if type(x) != list:
value = self._maps[key].get(float(x))
self._displays[key].set("%.4f" % value)
else:
@@ -179,29 +182,13 @@ class PyoObjectControl(Frame):
######################################################################
### View window for PyoTableObject
######################################################################
-class ViewTable_withPIL(Frame):
- def __init__(self, master=None, samples=None):
- Frame.__init__(self, master, bd=1, relief=GROOVE)
- self.width = 500
- 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")
- print Image
- im = Image.new("L", (self.width, self.height), 255)
- draw = ImageDraw.Draw(im)
- 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.grid()
- self.grid(ipadx=10, ipady=10)
+class ViewTable(Frame):
-class ViewTable_withoutPIL(Frame):
def __init__(self, master=None, samples=None):
Frame.__init__(self, master, bd=1, relief=GROOVE)
self.width = 500
self.height = 200
- self.half_height = self.height / 2
+ 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(*samples)
@@ -211,18 +198,8 @@ class ViewTable_withoutPIL(Frame):
######################################################################
## View window for PyoMatrixObject
#####################################################################
-class ViewMatrix_withPIL(Frame):
- def __init__(self, master=None, samples=None, size=None):
- Frame.__init__(self, master, bd=1, relief=GROOVE)
- self.canvas = Canvas(self, width=size[0], height=size[1], relief=SUNKEN, bd=1, bg="#EFEFEF")
- im = Image.new("L", size, None)
- im.putdata(samples)
- self.img = ImageTk.PhotoImage(im)
- self.canvas.create_image(size[0]/2+Y_OFFSET,size[1]/2+Y_OFFSET,image=self.img)
- self.canvas.grid()
- self.grid(ipadx=0, ipady=0)
+class ViewMatrix(Frame):
-class ViewMatrix_withoutPIL(Frame):
def __init__(self, master=None, samples=None, size=None):
Frame.__init__(self, master, bd=1, relief=GROOVE)
self.width = size[0]
@@ -230,11 +207,11 @@ class ViewMatrix_withoutPIL(Frame):
self.canvas = Canvas(self, width=self.width, height=self.height, relief=SUNKEN, bd=1, bg="#EFEFEF")
for i in range(self.width*self.height):
x = i % self.width
- y = i / self.width
- x1 = x+Y_OFFSET
- y1 = y+Y_OFFSET
- x2 = x+Y_OFFSET+1
- y2 = y+Y_OFFSET+1
+ y = i // self.width
+ x1 = x + Y_OFFSET
+ y1 = y + Y_OFFSET
+ x2 = x + Y_OFFSET + 1
+ y2 = y + Y_OFFSET + 1
amp = int(samples[i])
amp = hex(amp).replace('0x', '')
if len(amp) == 1:
@@ -248,6 +225,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,
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)
@@ -275,7 +253,6 @@ class ServerGUI(Frame):
if started == 1:
self.start(True)
-
def createWidgets(self):
row = 0
self.startStringVar = StringVar(self)
@@ -321,7 +298,7 @@ class ServerGUI(Frame):
self.timetext.grid(ipadx=5, row=row, column=0, columnspan=3)
row += 1
- if self.locals != None:
+ if self.locals is not None:
self.interp_label = Label(self, text='Interpreter')
self.interp_label.grid(ipadx=0, row=row, column=0, columnspan=3)
row += 1
@@ -332,7 +309,6 @@ class ServerGUI(Frame):
self.text.bind("<Up>", self.getPrev)
self.text.bind("<Down>", self.getNext)
-
def on_quit(self):
self.shutdown()
self.quit()
@@ -360,7 +336,7 @@ class ServerGUI(Frame):
def getText(self, event):
source = self.text.get("1.0", END)
self.text.delete("1.0", END)
- exec source in self.locals
+ exec(source, self.locals)
self._history.append(source)
self._histo_count = len(self._history)
return "break"
@@ -407,4 +383,4 @@ class ServerGUI(Frame):
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)
\ No newline at end of file
+ self.vumeter.coords(self.red[i], self.B2, y, amp, y)
diff --git a/pyolib/_widgets.py b/pyolib/_widgets.py
index 63459eb..f4a32e6 100644
--- a/pyolib/_widgets.py
+++ b/pyolib/_widgets.py
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
+from __future__ import print_function
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -18,49 +20,46 @@ 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, FloatType, IntType
import math, sys, os, random
-try:
- from PIL import Image, ImageDraw, ImageTk
- WITH_PIL = True
-except:
- WITH_PIL = False
+use_wx = 1
+if "PYO_GUI_WX" in os.environ:
+ use_wx = int(os.environ["PYO_GUI_WX"])
-try:
+if use_wx:
try:
- import wxversion
- if (wxversion.checkInstalled("2.8")):
- wxversion.ensureMinimal("2.8")
+ import wx
+ from ._wxwidgets import *
+ PYO_USE_WX = True
except:
- pass
- import wx
- from _wxwidgets import *
- PYO_USE_WX = True
-except:
+ PYO_USE_WX = False
+ print("""
+WxPython is not found for the current python version.
+Pyo will use a minimal GUI toolkit written with Tkinter (if available).
+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/
+""")
+else:
PYO_USE_WX = False
PYO_USE_TK = False
if not PYO_USE_WX:
try:
- from Tkinter import *
- from _tkwidgets import *
+ if sys.version_info[0] < 3:
+ from Tkinter import *
+ else:
+ 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:
PYO_USE_TK = False
- print """
+ 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 = []
@@ -110,7 +109,7 @@ def wxDisplayWindow(f, title):
global CURRENT_X, MAX_X, NEXT_Y
f.SetTitle(title)
x, y = f.GetSize()
- if sys.platform == "linux2":
+ if sys.platform.startswith("linux"):
y += 25
if y + NEXT_Y < Y:
px, py, NEXT_Y = CURRENT_X, NEXT_Y, NEXT_Y + y
@@ -133,14 +132,14 @@ def wxShowWindow(f, title, root):
def wxCreateDelayedCtrlWindows():
for win in CTRLWINDOWS:
f = PyoObjectControl(None, win[0], win[1])
- if win[2] == None: title = win[0].__class__.__name__
+ if win[2] is None: title = win[0].__class__.__name__
else: title = win[2]
wxDisplayWindow(f, title)
def wxCreateDelayedGraphWindows():
for win in GRAPHWINDOWS:
f = TableGrapher(None, win[0], win[1], win[2], win[3])
- if win[4] == None: title = win[0].__class__.__name__
+ if win[4] is None: title = win[0].__class__.__name__
else: title = win[4]
wxDisplayWindow(f, title)
@@ -148,7 +147,7 @@ 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__
+ if win[2] is None: title = win[0].__class__.__name__
else: title = win[2]
wxDisplayWindow(f, title)
@@ -157,7 +156,7 @@ def wxCreateDelayedTableWindows():
for win in TABLEWINDOWS:
object = win[3]
f = ViewTable(None, win[0], win[1], object)
- if object != None:
+ if object is not None:
object._setViewFrame(f)
wxDisplayWindow(f, win[2])
@@ -172,34 +171,33 @@ def wxCreateDelayedMatrixWindows():
global CURRENT_X, MAX_X, NEXT_Y
for win in MATRIXWINDOWS:
object = win[3]
- if WITH_PIL: f = ViewMatrix_withPIL(None, win[0], win[1], object)
- else: f = ViewMatrix_withoutPIL(None, win[0], win[1], object)
- if object != None:
+ f = ViewMatrix(None, win[0], win[1], object)
+ if object is not None:
object._setViewFrame(f)
wxDisplayWindow(f, win[2])
def wxCreateDelayedSpectrumWindows():
for win in SPECTRUMWINDOWS:
f = SpectrumDisplay(None, win[0])
- if win[1] == None: title = win[0].__class__.__name__
+ if win[1] is None: title = win[0].__class__.__name__
else: title = win[1]
- if win[0] != None:
+ if win[0] is not 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__
+ if win[1] is None: title = win[0].__class__.__name__
else: title = win[1]
- if win[0] != None:
+ if win[0] is not None:
win[0]._setViewFrame(f)
wxDisplayWindow(f, title)
def wxCreateDelayedExprEditorWindows():
for win in EXPREDITORWINDOWS:
f = ExprEditorFrame(None, win[0])
- if win[1] == None: title = win[0].__class__.__name__
+ if win[1] is None: title = win[0].__class__.__name__
else: title = win[1]
wxDisplayWindow(f, title)
@@ -209,37 +207,37 @@ def createCtrlWindow(obj, map_list, title, wxnoserver=False):
win = tkCreateToplevelWindow()
f = PyoObjectControl(win, obj, map_list)
win.resizable(True, False)
- if title == None: title = obj.__class__.__name__
+ if title is None: title = obj.__class__.__name__
win.title(title)
else:
if wxnoserver or wx.GetApp() is not None:
root = createRootWindow()
f = PyoObjectControl(None, obj, map_list)
- if title == None: title = obj.__class__.__name__
+ if title is None: title = obj.__class__.__name__
wxShowWindow(f, title, root)
else:
CTRLWINDOWS.append([obj, map_list, title])
def createGraphWindow(obj, mode, xlen, yrange, title, wxnoserver=False):
if not PYO_USE_WX:
- print "WxPython must be installed to use the 'graph()' method."
+ print("WxPython must be installed to use the 'graph()' method.")
else:
if wxnoserver or wx.GetApp() is not None:
root = createRootWindow()
f = TableGrapher(None, obj, mode, xlen, yrange)
- if title == None: title = obj.__class__.__name__
+ if title is None: title = obj.__class__.__name__
wxShowWindow(f, title, root)
else:
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."
+ print("WxPython must be installed to use the 'graph()' method.")
else:
if wxnoserver or wx.GetApp() is not None:
root = createRootWindow()
f = DataTableGrapher(None, obj, yrange)
- if title == None: title = obj.__class__.__name__
+ if title is None: title = obj.__class__.__name__
obj._setGraphFrame(f)
wxShowWindow(f, title, root)
else:
@@ -249,15 +247,14 @@ def createViewTableWindow(samples, title="Table waveform", wxnoserver=False, tab
if not PYO_USE_WX:
createRootWindow()
win = tkCreateToplevelWindow()
- if WITH_PIL: f = ViewTable_withPIL(win, samples)
- else: f = ViewTable_withoutPIL(win, samples)
+ f = ViewTable(win, samples)
win.resizable(False, False)
win.title(title)
else:
if wxnoserver or wx.GetApp() is not None:
root = createRootWindow()
f = ViewTable(None, samples, tableclass, object)
- if object != None:
+ if object is not None:
object._setViewFrame(f)
wxShowWindow(f, title, root)
else:
@@ -267,36 +264,31 @@ def createSndViewTableWindow(obj, title="Table waveform", wxnoserver=False, tabl
if not PYO_USE_WX:
createRootWindow()
win = tkCreateToplevelWindow()
- if WITH_PIL: f = ViewTable_withPIL(win, obj._base_objs[0].getViewTable())
- else: f = ViewTable_withoutPIL(win, obj._base_objs[0].getViewTable())
+ f = ViewTable(win, obj._base_objs[0].getViewTable())
win.resizable(False, False)
win.title(title)
else:
if wxnoserver or wx.GetApp() is not None:
root = createRootWindow()
f = SndViewTable(None, obj, tableclass, mouse_callback)
- if title == None: title = obj.__class__.__name__
+ if title is None: title = obj.__class__.__name__
obj._setViewFrame(f)
wxShowWindow(f, title, root)
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.
-It helps a lot to speed up matrix drawing!"""
if not PYO_USE_WX:
createRootWindow()
win = tkCreateToplevelWindow()
- if WITH_PIL: f = ViewMatrix_withPIL(win, samples, size)
- else: f = ViewMatrix_withoutPIL(win, samples, size)
+ f = ViewMatrix(win, samples, size)
win.resizable(False, False)
win.title(title)
else:
if wxnoserver or wx.GetApp() is not None:
root = createRootWindow()
- if WITH_PIL: f = ViewMatrix_withPIL(None, samples, size, object)
- else: f = ViewMatrix_withoutPIL(None, samples, size, object)
- if object != None:
+ f = ViewMatrix(None, samples, size, object)
+ if object is not None:
object._setViewFrame(f)
wxShowWindow(f, title, root)
else:
@@ -304,13 +296,13 @@ It helps a lot to speed up matrix drawing!"""
def createSpectrumWindow(object, title, wxnoserver=False):
if not PYO_USE_WX:
- print "WxPython must be installed to use the Spectrum display."
+ print("WxPython must be installed to use the Spectrum display.")
else:
if wxnoserver or wx.GetApp() is not None:
root = createRootWindow()
f = SpectrumDisplay(None, object)
- if title == None: title = object.__class__.__name__
- if object != None:
+ if title is None: title = object.__class__.__name__
+ if object is not None:
object._setViewFrame(f)
wxShowWindow(f, title, root)
else:
@@ -318,13 +310,13 @@ def createSpectrumWindow(object, title, wxnoserver=False):
def createScopeWindow(object, title, wxnoserver=False):
if not PYO_USE_WX:
- print "WxPython must be installed to use the Scope display."
+ print("WxPython must be installed to use the Scope display.")
else:
if wxnoserver or wx.GetApp() is not None:
root = createRootWindow()
f = ScopeDisplay(None, object)
- if title == None: title = object.__class__.__name__
- if object != None:
+ if title is None: title = object.__class__.__name__
+ if object is not None:
object._setViewFrame(f)
wxShowWindow(f, title, root)
else:
@@ -332,12 +324,12 @@ def createScopeWindow(object, title, wxnoserver=False):
def createExprEditorWindow(object, title, wxnoserver=False):
if not PYO_USE_WX:
- print "WxPython must be installed to use the Expr editor display."
+ print("WxPython must be installed to use the Expr editor display.")
else:
if wxnoserver or wx.GetApp() is not None:
root = createRootWindow()
f = ExprEditorFrame(None, object)
- if title == None: title = object.__class__.__name__
+ if title is None: title = object.__class__.__name__
wxShowWindow(f, title, root)
else:
EXPREDITORWINDOWS.append([object, title])
@@ -357,7 +349,7 @@ def createServerGUI(nchnls, start, stop, recstart, recstop, setAmp, started, loc
f.SetPosition((30, 30))
f.Show()
X,Y = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)-50, wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)-50
- if sys.platform == "linux2":
+ if sys.platform.startswith("linux"):
MAX_X, NEXT_Y = f.GetSize()[0]+30, f.GetSize()[1]+55
else:
MAX_X, NEXT_Y = f.GetSize()[0]+30, f.GetSize()[1]+30
diff --git a/pyolib/_wxwidgets.py b/pyolib/_wxwidgets.py
index 4f8a6d4..4ea6228 100644
--- a/pyolib/_wxwidgets.py
+++ b/pyolib/_wxwidgets.py
@@ -1,3 +1,6 @@
+from __future__ import division
+from __future__ import print_function
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -18,32 +21,32 @@ 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, unicodedata
-from types import ListType, FloatType, IntType, UnicodeType, TupleType
import wx.stc as stc
-try:
- from PIL import Image, ImageDraw, ImageTk
-except:
- pass
+if "phoenix" in wx.version():
+ wx.GraphicsContext_Create = wx.GraphicsContext.Create
+ wx.EmptyBitmap = wx.Bitmap
+ wx.EmptyImage = wx.Image
+ wx.BitmapFromImage = wx.Bitmap
BACKGROUND_COLOUR = "#EBEBEB"
def interpFloat(t, v1, v2):
"interpolator for a single value; interprets t in [0-1] between v1 and v2"
- return (v2-v1)*t + v1
+ return (v2 - v1) * t + v1
def tFromValue(value, v1, v2):
"returns a t (in range 0-1) given a value in the range v1 to v2"
- return float(value-v1)/(v2-v1)
+ return float(value - v1) / (v2 - v1)
def clamp(v, minv, maxv):
"clamps a value within a range"
- if v<minv: v=minv
- if v> maxv: v=maxv
+ if v < minv: v = minv
+ if v > maxv: v = maxv
return v
def toLog(t, v1, v2):
- return math.log10(t/v1) / math.log10(v2/v1)
+ return math.log10(t / v1) / math.log10(v2 / v1)
def toExp(t, v1, v2):
return math.pow(10, t * (math.log10(v2) - math.log10(v1)) + math.log10(v1))
@@ -73,6 +76,7 @@ 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, orient=wx.HORIZONTAL):
if size == (200,16) and orient == wx.VERTICAL:
@@ -110,7 +114,7 @@ class ControlSlider(wx.Panel):
self.propagate = True
self.midictl = None
self.new = ''
- if init != None:
+ if init is not None:
self.SetValue(init)
self.init = init
else:
@@ -126,7 +130,7 @@ class ControlSlider(wx.Panel):
self.Bind(wx.EVT_KEY_DOWN, self.keyDown)
self.Bind(wx.EVT_KILL_FOCUS, self.LooseFocus)
- if sys.platform == "win32":
+ if sys.platform == "win32" or sys.platform.startswith("linux"):
self.dcref = wx.BufferedPaintDC
else:
self.dcref = wx.PaintDC
@@ -324,21 +328,21 @@ class ControlSlider(wx.Panel):
if self._enable: sliderColour = "#99A7CC"
else: sliderColour = "#BBBBBB"
if self.orient == wx.VERTICAL:
- w2 = (w - self.sliderWidth) / 2
+ 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
+ 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))
+ if self.midictl is not None:
+ if sys.platform == 'win32' or sys.platform.startswith('linux'):
+ dc.SetFont(wx.Font(6, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
else:
- dc.SetFont(wx.Font(9, wx.ROMAN, wx.NORMAL, wx.NORMAL))
+ dc.SetFont(wx.Font(9, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
dc.SetTextForeground('#FFFFFF')
if self.orient == wx.VERTICAL:
dc.DrawLabel(str(self.midictl), wx.Rect(w2,2,self.sliderWidth,12), wx.ALIGN_CENTER)
@@ -367,10 +371,10 @@ class ControlSlider(wx.Panel):
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))
+ if sys.platform == 'win32' or sys.platform.startswith('linux'):
+ dc.SetFont(wx.Font(7, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
else:
- dc.SetFont(wx.Font(10, wx.ROMAN, wx.NORMAL, wx.NORMAL))
+ dc.SetFont(wx.Font(10, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
# Draw text
if self.selected and self.new:
@@ -386,7 +390,7 @@ class ControlSlider(wx.Panel):
val = '%.3f' % self.GetValue()
elif abs(self.GetValue()) < 10:
val = '%.4f' % self.GetValue()
- if sys.platform == 'linux2':
+ if sys.platform.startswith('linux'):
width = len(val) * (dc.GetCharWidth() - 3)
else:
width = len(val) * dc.GetCharWidth()
@@ -403,6 +407,7 @@ class ControlSlider(wx.Panel):
# TODO: key, command and slmap should be removed from the multislider widget.
# It should work in the same way as the ControlSlider widget.
class MultiSlider(wx.Panel):
+
def __init__(self, parent, init, key, command, slmap):
wx.Panel.__init__(self, parent, size=(250,250))
self.backgroundColour = BACKGROUND_COLOUR
@@ -420,10 +425,10 @@ class MultiSlider(wx.Panel):
self._key = key
self._command = command
self._height = 16
- if sys.platform in ['win32', 'linux2']:
- self._font = wx.Font(7, wx.ROMAN, wx.NORMAL, wx.NORMAL)
+ if sys.platform == 'win32' or sys.platform.startswith('linux'):
+ self._font = wx.Font(7, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
else:
- self._font = wx.Font(10, wx.ROMAN, wx.NORMAL, wx.NORMAL)
+ self._font = wx.Font(10, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)
self.SetSize((250, self._nchnls*16))
self.SetMinSize((250,self._nchnls*16))
@@ -444,15 +449,15 @@ class MultiSlider(wx.Panel):
for i in range(self._nchnls):
x = int(self._values[i] * w)
y = self._height * i
- dc.DrawRectangle(0, y+1, x, self._height-2)
- rec = wx.Rect(w/2-15, y, 30, self._height)
+ dc.DrawRectangle(0, y + 1, x, self._height-2)
+ rec = wx.Rect(w // 2 - 15, y, 30, self._height)
dc.DrawLabel("%s" % self._labels[i], rec, wx.ALIGN_CENTER)
def MouseDown(self, evt):
w,h = self.GetSize()
pos = evt.GetPosition()
- slide = pos[1] / self._height
- if 0 <= slide < self._nchnls:
+ slide = pos[1] // self._height
+ if slide >= 0 and slide < self._nchnls:
self._values[slide] = pos[0] / float(w)
if self._slmap._res == 'int':
self._labels = [int(self._slmap.get(x)) for x in self._values]
@@ -471,8 +476,8 @@ class MultiSlider(wx.Panel):
w,h = self.GetSize()
pos = evt.GetPosition()
if evt.Dragging() and evt.LeftIsDown():
- slide = pos[1] / self._height
- if 0 <= slide < self._nchnls:
+ slide = pos[1] // self._height
+ if slide >= 0 and slide < self._nchnls:
self._values[slide] = pos[0] / float(w)
if self._slmap._res == 'int':
self._labels = [int(self._slmap.get(x)) for x in self._values]
@@ -482,7 +487,8 @@ class MultiSlider(wx.Panel):
self.Refresh()
class VuMeter(wx.Panel):
- def __init__(self, parent, size=(200,11), numSliders=2, orient=wx.HORIZONTAL,
+
+ def __init__(self, parent, size=(200,11), numSliders=2, orient=wx.HORIZONTAL,
pos=wx.DefaultPosition, style=0):
if orient == wx.HORIZONTAL:
size = (size[0], numSliders * 5 + 1)
@@ -623,6 +629,7 @@ class VuMeter(wx.Panel):
# TODO: BACKGROUND_COLOUR hard-coded all over the place in this class.
class RangeSlider(wx.Panel):
+
def __init__(self, parent, minvalue, maxvalue, init=None, pos=(0,0), size=(200,15),
valtype='int', log=False, function=None, backColour=None):
wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY, pos=pos, size=size, style=wx.NO_BORDER)
@@ -636,17 +643,17 @@ class RangeSlider(wx.Panel):
self.sliderHeight = 15
self.borderWidth = 1
self.action = None
- self.fillcolor = "#AAAAAA" #SLIDER_BACK_COLOUR
- self.knobcolor = "#333333" #SLIDER_KNOB_COLOUR
+ self.fillcolor = "#AAAAAA" # SLIDER_BACK_COLOUR
+ self.knobcolor = "#333333" # SLIDER_KNOB_COLOUR
self.handlecolor = wx.Colour(int(self.knobcolor[1:3])-10, int(self.knobcolor[3:5])-10, int(self.knobcolor[5:7])-10)
self.outFunction = function
- if valtype.startswith('i'): self.myType = IntType
- else: self.myType = FloatType
+ if valtype.startswith('i'): self.myType = int
+ else: self.myType = float
self.log = log
self.SetRange(minvalue, maxvalue)
self.handles = [minvalue, maxvalue]
- if init != None:
- if type(init) in [ListType, TupleType]:
+ if init is not None:
+ if type(init) in [list, tuple]:
if len(init) == 1:
self.SetValue([init[0],init[0]])
else:
@@ -672,7 +679,7 @@ class RangeSlider(wx.Panel):
dc.DrawRectangle(0,0,w,h)
dc.SetBrush(wx.Brush("#777777"))
dc.SetPen(wx.Pen("#FFFFFF", width=1))
- h2 = self.sliderHeight / 4
+ h2 = self.sliderHeight // 4
dc.DrawRoundedRectangle(0, h2, w, self.sliderHeight, 4)
dc.SelectObject(wx.NullBitmap)
b.SetMaskColour("#777777")
@@ -710,7 +717,7 @@ class RangeSlider(wx.Panel):
def MouseDown(self, evt):
size = self.GetSize()
xpos = evt.GetPosition()[0]
- self.middle = (self.handlePos[1] - self.handlePos[0]) / 2 + self.handlePos[0]
+ self.middle = (self.handlePos[1] - self.handlePos[0]) // 2 + self.handlePos[0]
midrec = wx.Rect(self.middle-7, 4, 15, size[1]-9)
if midrec.Contains(evt.GetPosition()):
self.lastpos = xpos
@@ -762,6 +769,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),
valtype='int', log=False, function=None, backColour=None):
RangeSlider.__init__(self, parent, minvalue, maxvalue, init, pos, size, valtype, log, function, backColour)
@@ -790,7 +798,7 @@ class HRangeSlider(RangeSlider):
dc.DrawRectangle(0, 0, w, h)
# Draw inner part
- h2 = self.sliderHeight / 4
+ h2 = self.sliderHeight // 4
rec = wx.Rect(0, h2, w, self.sliderHeight)
dc.GradientFillLinear(rec, "#666666", self.fillcolor, wx.BOTTOM)
dc.DrawBitmap(self.sliderMask, 0, 0, True)
@@ -805,7 +813,7 @@ class HRangeSlider(RangeSlider):
else:
t = tFromValue(value, self.minvalue, self.maxvalue)
value = interpFloat(t, self.minvalue, self.maxvalue)
- if self.myType == IntType:
+ if self.myType == int:
value = int(value)
self.handles[which] = value
self.OnResize(None)
@@ -821,7 +829,7 @@ class HRangeSlider(RangeSlider):
else:
t = tFromValue(value, self.minvalue, self.maxvalue)
value = interpFloat(t, self.minvalue, self.maxvalue)
- if self.myType == IntType:
+ if self.myType == int:
value = int(value)
tmp.append(value)
self.handles = tmp
@@ -835,7 +843,7 @@ class HRangeSlider(RangeSlider):
val = toExp(t, self.minvalue, self.maxvalue)
else:
val = value
- if self.myType == IntType:
+ if self.myType == int:
val = int(val)
tmp.append(val)
tmp = [min(tmp), max(tmp)]
@@ -857,13 +865,13 @@ class HRangeSlider(RangeSlider):
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)
- dc.DrawRoundedRectangleRect(rec, 4)
+ rec = (self.handlePos[0], 3, self.handlePos[1]-self.handlePos[0], h-7)
+ dc.DrawRoundedRectangle(rec[0], rec[1], rec[2], rec[3], 4)
dc.SetPen(wx.Pen(self.fillcolor, width=1, style=wx.SOLID))
dc.SetBrush(wx.Brush(self.fillcolor))
- mid = (self.handlePos[1]-self.handlePos[0]) / 2 + self.handlePos[0]
- rec = wx.Rect(mid-4, 4, 8, h-9)
- dc.DrawRoundedRectangleRect(rec, 3)
+ mid = (self.handlePos[1] - self.handlePos[0]) // 2 + self.handlePos[0]
+ rec = (mid-4, 4, 8, h-9)
+ dc.DrawRoundedRectangle(rec[0], rec[1], rec[2], rec[3], 3)
# Send value
if self.outFunction:
@@ -873,6 +881,7 @@ class HRangeSlider(RangeSlider):
### Control window for PyoObject
######################################################################
class Command:
+
def __init__(self, func, key):
self.func = func
self.key = key
@@ -881,9 +890,10 @@ class Command:
self.func(self.key, value)
class PyoObjectControl(wx.Frame):
+
def __init__(self, parent=None, obj=None, map_list=None):
wx.Frame.__init__(self, parent)
- from controls import SigTo
+ from .controls import SigTo
self.menubar = wx.MenuBar()
self.fileMenu = wx.Menu()
self.fileMenu.Append(-1, 'Close\tCtrl+W', kind=wx.ITEM_NORMAL)
@@ -908,7 +918,7 @@ class PyoObjectControl(wx.Frame):
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]:
+ if type(init) not in [list, float, int]:
self._excluded.append(key)
else:
self._maps[key] = m
@@ -918,7 +928,7 @@ class PyoObjectControl(wx.Frame):
else:
label = wx.StaticText(panel, -1, key)
# create and pack slider
- if type(init) != ListType:
+ if type(init) != list:
if scl == 'log': scl = True
else: scl = False
if res == 'int': res = True
@@ -966,6 +976,7 @@ class PyoObjectControl(wx.Frame):
### View window for PyoTableObject
######################################################################
class ViewTable(wx.Frame):
+
def __init__(self, parent, samples=None, tableclass=None, object=None):
wx.Frame.__init__(self, parent, size=(500,200))
self.SetMinSize((300, 150))
@@ -994,6 +1005,7 @@ class ViewTable(wx.Frame):
self.Destroy()
class ViewTablePanel(wx.Panel):
+
def __init__(self, parent, obj):
wx.Panel.__init__(self, parent)
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
@@ -1001,7 +1013,7 @@ class ViewTablePanel(wx.Panel):
self.samples = []
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_SIZE, self.OnSize)
- if sys.platform == "win32":
+ if sys.platform == "win32" or sys.platform.startswith("linux"):
self.dcref = wx.BufferedPaintDC
else:
self.dcref = wx.PaintDC
@@ -1022,12 +1034,13 @@ class ViewTablePanel(wx.Panel):
gc.SetBrush(wx.Brush("#FFFFFF"))
if len(self.samples) > 1:
gc.DrawLines(self.samples)
- dc.DrawLine(0, h/2+1, w, h/2+1)
+ 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))
@@ -1064,6 +1077,7 @@ class SndViewTable(wx.Frame):
self.Destroy()
class SndViewTablePanel(wx.Panel):
+
def __init__(self, parent, obj=None, mouse_callback=None, select_callback=None):
wx.Panel.__init__(self, parent)
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
@@ -1090,7 +1104,7 @@ class SndViewTablePanel(wx.Panel):
self.img = [[]]
self.mouse_callback = mouse_callback
self.select_callback = select_callback
- if sys.platform == "win32":
+ if sys.platform == "win32" or sys.platform.startswith("linux"):
self.dcref = wx.BufferedPaintDC
else:
self.dcref = wx.PaintDC
@@ -1107,7 +1121,7 @@ class SndViewTablePanel(wx.Panel):
if self.background_bitmap is not None:
self.refresh_from_selection = True
self.Refresh()
- if self.select_callback != None:
+ if self.select_callback is not None:
self.select_callback((0.0, 1.0))
def setSelection(self, start, stop):
@@ -1116,9 +1130,9 @@ class SndViewTablePanel(wx.Panel):
if self.background_bitmap is not None:
self.refresh_from_selection = True
self.Refresh()
- if self.select_callback != None:
+ if self.select_callback is not None:
self.select_callback((self.selstart, self.selend))
-
+
def setBegin(self, x):
self.begin = x
@@ -1145,11 +1159,11 @@ class SndViewTablePanel(wx.Panel):
size = self.GetSize()
pos = evt.GetPosition()
if pos[1] <= 0:
- pos = (float(pos[0])/size[0], 1.0)
+ pos = (float(pos[0]) / size[0], 1.0)
else:
- pos = (float(pos[0])/size[0], 1.-(float(pos[1])/size[1]))
+ pos = (float(pos[0]) / size[0], 1. - (float(pos[1]) / size[1]))
pos = self.clipPos(pos)
- if self.mouse_callback != None:
+ if self.mouse_callback is not None:
self.mouse_callback(pos)
self.CaptureMouse()
@@ -1157,9 +1171,9 @@ class SndViewTablePanel(wx.Panel):
size = self.GetSize()
pos = evt.GetPosition()
if pos[1] <= 0:
- pos = (float(pos[0])/size[0], 1.0)
+ pos = (float(pos[0]) / size[0], 1.0)
else:
- pos = (float(pos[0])/size[0], 1.-(float(pos[1])/size[1]))
+ pos = (float(pos[0]) / size[0], 1. - (float(pos[1]) / size[1]))
pos = self.clipPos(pos)
if evt.ShiftDown():
if self.selstart is not None and self.selend is not None:
@@ -1169,7 +1183,7 @@ class SndViewTablePanel(wx.Panel):
self.selstart = self.selend = None
self.refresh_from_selection = True
self.Refresh()
- if self.select_callback != None:
+ if self.select_callback is not None:
self.select_callback((0.0, 1.0))
else:
self.createSelection = True
@@ -1181,12 +1195,12 @@ class SndViewTablePanel(wx.Panel):
size = self.GetSize()
pos = evt.GetPosition()
if pos[1] <= 0:
- pos = (float(pos[0])/size[0], 1.0)
+ pos = (float(pos[0]) / size[0], 1.0)
else:
- pos = (float(pos[0])/size[0], 1.-(float(pos[1])/size[1]))
+ pos = (float(pos[0]) / size[0], 1. - (float(pos[1]) / size[1]))
pos = self.clipPos(pos)
if evt.LeftIsDown():
- if self.mouse_callback != None:
+ if self.mouse_callback is not None:
self.mouse_callback(pos)
elif evt.RightIsDown():
refresh = False
@@ -1194,7 +1208,7 @@ class SndViewTablePanel(wx.Panel):
self.selend = pos[0]
refresh = True
elif self.moveSelection:
- diff = pos[0] - self.movepos
+ diff = pos[0] - self.movepos
self.movepos = pos[0]
self.selstart += diff
self.selend += diff
@@ -1202,7 +1216,7 @@ class SndViewTablePanel(wx.Panel):
if refresh:
self.refresh_from_selection = True
self.Refresh()
- if self.select_callback != None:
+ if self.select_callback is not None:
self.select_callback((self.selstart, self.selend))
def OnMouseUp(self, evt):
@@ -1219,7 +1233,7 @@ class SndViewTablePanel(wx.Panel):
dc.Clear()
dc.DrawRectangle(0,0,w,h)
- off = h/self.chnls/2
+ off = h // self.chnls // 2
gc.SetPen(wx.Pen('#000000', width=1, style=wx.SOLID))
gc.SetBrush(wx.Brush("#FFFFFF", style=wx.TRANSPARENT))
dc.SetTextForeground("#444444")
@@ -1231,7 +1245,7 @@ class SndViewTablePanel(wx.Panel):
font = dc.GetFont()
font.SetPointSize(8)
dc.SetFont(font)
- tickstep = w / 10
+ tickstep = w // 10
if tickstep < 40:
timelabel = "%.1f"
elif tickstep < 80:
@@ -1242,7 +1256,7 @@ class SndViewTablePanel(wx.Panel):
timelabel = "%.4f"
timestep = (self.end - self.begin) * 0.1
for i, samples in enumerate(self.img):
- y = h/self.chnls*i
+ y = h // self.chnls * i
if len(samples):
gc.DrawLines(samples)
dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
@@ -1296,7 +1310,8 @@ class SndViewTablePanel(wx.Panel):
######################################################################
## View window for PyoMatrixObject
#####################################################################
-class ViewMatrix(wx.Frame):
+class ViewMatrixBase(wx.Frame):
+
def __init__(self, parent, size=None, object=None):
wx.Frame.__init__(self, parent)
self.object = object
@@ -1319,18 +1334,15 @@ class ViewMatrix(wx.Frame):
self.object._setViewFrame(None)
self.Destroy()
-class ViewMatrix_withPIL(ViewMatrix):
- _WITH_PIL = True
+class ViewMatrix(ViewMatrixBase):
def __init__(self, parent, samples=None, size=None, object=None):
- ViewMatrix.__init__(self, parent, size, object)
+ ViewMatrixBase.__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)
image = wx.EmptyImage(self.size[0], self.size[1])
- image.SetData(im.convert("RGB").tostring())
+ image.SetData(samples)
self.img = wx.BitmapFromImage(image)
self.Refresh()
@@ -1338,35 +1350,11 @@ class ViewMatrix_withPIL(ViewMatrix):
dc = wx.PaintDC(self)
dc.DrawBitmap(self.img, 0, 0)
-class ViewMatrix_withoutPIL(ViewMatrix):
- _WITH_PIL = False
- def __init__(self, parent, samples=None, size=None, object=None):
- ViewMatrix.__init__(self, parent, size, object)
- self.width = size[0]
- self.height = size[1]
- self.setImage(samples)
-
- def setImage(self, samples):
- self.samples = samples
- self.Refresh()
-
- def OnPaint(self, evt):
- dc = wx.PaintDC(self)
- for i in range(self.width*self.height):
- x = i % self.width
- y = i / self.width
- amp = int(self.samples[i])
- amp = hex(amp).replace('0x', '')
- 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.DrawPoint(x, y)
-
######################################################################
## Spectrum Display
######################################################################
class SpectrumDisplay(wx.Frame):
+
def __init__(self, parent, obj=None):
wx.Frame.__init__(self, parent, size=(600,350))
self.SetMinSize((400,240))
@@ -1497,7 +1485,8 @@ class SpectrumDisplay(wx.Frame):
# TODO: Adjust the font size according to the size of the panel.
class SpectrumPanel(wx.Panel):
- def __init__(self, parent, chnls, lowfreq, highfreq, fscaling, mscaling,
+
+ def __init__(self, parent, chnls, lowfreq, highfreq, fscaling, mscaling,
pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
wx.Panel.__init__(self, parent, pos=pos, size=size, style=style)
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
@@ -1516,7 +1505,7 @@ class SpectrumPanel(wx.Panel):
self.brushes = [wx.Brush(wx.Colour(166,4,0,128)), wx.Brush(wx.Colour(8,11,116,128)), wx.Brush(wx.Colour(0,204,0,128)),
wx.Brush(wx.Colour(255,167,0,128)), wx.Brush(wx.Colour(133,0,75,128)), wx.Brush(wx.Colour(255,236,0,128)),
wx.Brush(wx.Colour(1,147,154,128)), wx.Brush(wx.Colour(162,239,0,128))]
- if sys.platform == "win32":
+ if sys.platform == "win32" or sys.platform.startswith("linux"):
self.dcref = wx.BufferedPaintDC
else:
self.dcref = wx.PaintDC
@@ -1537,7 +1526,7 @@ class SpectrumPanel(wx.Panel):
def setImage(self, points):
self.img = [points[i] for i in range(len(points))]
- self.Refresh()
+ wx.CallAfter(self.Refresh)
def setFscaling(self, x):
self.fscaling = x
@@ -1556,7 +1545,7 @@ class SpectrumPanel(wx.Panel):
dc = self.dcref(self)
gc = wx.GraphicsContext_Create(dc)
tw, th = dc.GetTextExtent("0")
-
+
# background
background = gc.CreatePath()
background.AddRectangle(0,0,w-1,h-1)
@@ -1573,13 +1562,13 @@ class SpectrumPanel(wx.Panel):
tw, th = dc.GetTextExtent(text)
step = (self.highfreq - self.lowfreq) / 8
dc.DrawText(text, 2, 2)
- w8 = w / 8
+ w8 = w // 8
for i in range(1,8):
- pos = w8*i
+ pos = w8 * i
dc.DrawLine(pos, th+4, pos, h-2)
- text = str(int(self.lowfreq+step*i))
+ text = str(int(self.lowfreq + step * i))
tw, th = dc.GetTextExtent(text)
- dc.DrawText(text, pos-tw/2, 2)
+ dc.DrawText(text, pos - tw // 2, 2)
# frequency logarithmic grid
else:
if self.lowfreq < 20:
@@ -1592,11 +1581,11 @@ class SpectrumPanel(wx.Panel):
mag = pow(10.0, math.floor(lf))
if lrange > 6:
t = pow(10.0, math.ceil(lf))
- base = pow(10.0, math.floor(lrange/6))
+ base = pow(10.0, math.floor(lrange / 6))
def inc(t, floor_t):
return t*base-t
else:
- t = math.ceil(pow(10.0,lf)/mag)*mag
+ t = math.ceil(pow(10.0, lf) / mag) * mag
def inc(t, floor_t):
return pow(10.0, floor_t)
@@ -1610,18 +1599,18 @@ class SpectrumPanel(wx.Panel):
tw, th = dc.GetTextExtent(ticklabel)
else:
if hf-lf < 2:
- minortick = int(t/pow(10.0,majortick)+.5)
- ticklabel = '%de%d'%(minortick,majortick)
+ minortick = int(t / pow(10.0, majortick) + .5)
+ ticklabel = '%de%d' % (minortick, majortick)
ticklabel = str(int(float(ticklabel)))
tw, th = dc.GetTextExtent(ticklabel)
if not minortick%2 == 0:
ticklabel = ''
else:
ticklabel = ''
- pos = (math.log10(t) - lf) / lrange * w
+ pos = int((math.log10(t) - lf) / lrange * w)
if pos < (w-25):
- dc.DrawLine(pos, th+4, pos, h-2)
- dc.DrawText(ticklabel, pos-tw/2, 2)
+ dc.DrawLine(pos, th + 4, pos, h - 2)
+ dc.DrawText(ticklabel, pos - tw // 2, 2)
t += inc(t, floor_t)
# magnitude linear grid
@@ -1632,18 +1621,18 @@ class SpectrumPanel(wx.Panel):
pos = int(h - i * step)
text = "%.1f" % (i * 0.1)
tw, th = dc.GetTextExtent(text)
- dc.DrawText(text, w-tw-2, pos-th/2)
- dc.DrawLine(0, pos, w-tw-4, pos)
+ dc.DrawText(text, w - tw - 2, pos - th // 2)
+ dc.DrawLine(0, pos, w - tw - 4, pos)
dc.SetPen(wx.Pen("#555555", style=wx.SOLID))
- dc.DrawLine(0, pos, w-tw-6, pos)
+ dc.DrawLine(0, pos, w - tw - 6, pos)
dc.SetPen(wx.Pen("#555555", style=wx.DOT))
i += 1
while (i*step < (h-th-5)):
pos = int(h - i * step)
text = "%.1f" % (i * 0.1)
tw, th = dc.GetTextExtent(text)
- dc.DrawText(text, w-tw-2, pos-th/2)
- dc.DrawLine(0, pos, w-tw-6, pos)
+ dc.DrawText(text, w - tw - 2, pos - th // 2)
+ dc.DrawLine(0, pos, w - tw - 6, pos)
i += 1
# magnitude logarithmic grid
else:
@@ -1657,7 +1646,7 @@ class SpectrumPanel(wx.Panel):
mval = 0
text = "%d" % mval
tw, th = dc.GetTextExtent(text)
- dc.DrawText(text, w-tw-2, pos-th/2)
+ dc.DrawText(text, w-tw-2, pos - th // 2)
dc.DrawLine(0, pos, w-mw-6, pos)
dc.SetPen(wx.Pen("#555555", style=wx.SOLID))
dc.DrawLine(0, pos, w-mw-4, pos)
@@ -1667,12 +1656,12 @@ class SpectrumPanel(wx.Panel):
pos = int(h - i * step)
text = "%d" % int((10-i) * -6.0)
tw, th = dc.GetTextExtent(text)
- dc.DrawText(text, w-tw-2, pos-th/2)
+ dc.DrawText(text, w-tw-2, pos - th // 2)
dc.DrawLine(0, pos, w-mw-6, pos)
i += 1
# spectrum
- if self.img != None:
+ if self.img is not None:
last_tw = tw
# legend
tw, th = dc.GetTextExtent("chan 8")
@@ -1689,6 +1678,7 @@ class SpectrumPanel(wx.Panel):
## Spectrum Display
######################################################################
class ScopeDisplay(wx.Frame):
+
def __init__(self, parent, obj=None):
wx.Frame.__init__(self, parent, size=(600,350))
self.SetMinSize((400,240))
@@ -1753,7 +1743,8 @@ class ScopeDisplay(wx.Frame):
self.Destroy()
class ScopePanel(wx.Panel):
- def __init__(self, parent, obj=None, pos=wx.DefaultPosition,
+
+ def __init__(self, parent, obj=None, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=0):
wx.Panel.__init__(self, parent, pos=pos, size=size, style=style)
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
@@ -1772,7 +1763,7 @@ class ScopePanel(wx.Panel):
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":
+ if sys.platform == "win32" or sys.platform.startswith("linux"):
self.dcref = wx.BufferedPaintDC
else:
self.dcref = wx.PaintDC
@@ -1784,6 +1775,7 @@ class ScopePanel(wx.Panel):
self.obj.setHeight(size[1])
except:
pass
+ wx.CallAfter(self.Refresh)
def setGain(self, gain):
self.gain = gain
@@ -1793,7 +1785,7 @@ class ScopePanel(wx.Panel):
def setImage(self, points):
self.img = points
- self.Refresh()
+ wx.CallAfter(self.Refresh)
def OnPaint(self, evt):
w,h = self.GetSize()
@@ -1817,18 +1809,18 @@ class ScopePanel(wx.Panel):
dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
# horizontal grid
- step = h / 6
+ 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.DrawText(text, w-tw-2, pos - th // 2)
dc.DrawLine(0, pos, w-tw-10, pos)
# vertical grid
- tickstep = w / 4
+ tickstep = w // 4
timestep = self.length * 0.25
for j in range(4):
dc.SetPen(wx.Pen('#888888', width=1, style=wx.DOT))
@@ -1857,6 +1849,7 @@ 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, pos=(0, 0),
size=(300, 200), style=0):
@@ -1885,12 +1878,13 @@ class Grapher(wx.Panel):
self.points = [tup for tup in init]
self.outFunction = outFunction
- if sys.platform == "win32":
+ if sys.platform == "win32" or sys.platform.startswith("linux"):
self.dcref = wx.BufferedPaintDC
else:
self.dcref = wx.PaintDC
self.SetFocus()
+ wx.CallAfter(self.sendValues)
def setInitPoints(self, pts):
self.init = [(p[0],p[1]) for p in pts]
@@ -1915,7 +1909,7 @@ class Grapher(wx.Panel):
def pointToValues(self, pt):
x = pt[0] * self.xlen
- if type(self.xlen) == IntType:
+ if type(self.xlen) == int:
x = int(x)
y = pt[1] * (self.yrange[1]-self.yrange[0]) + self.yrange[0]
return x, y
@@ -1967,7 +1961,7 @@ class Grapher(wx.Panel):
return values
def sendValues(self):
- if self.outFunction != None:
+ if self.outFunction is not None:
values = self.getValues()
self.outFunction(values)
@@ -1980,7 +1974,7 @@ class Grapher(wx.Panel):
self.Refresh()
def OnKeyDown(self, evt):
- if self.selected != None and evt.GetKeyCode() in [wx.WXK_BACK, wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE]:
+ if self.selected is not None and evt.GetKeyCode() in [wx.WXK_BACK, wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE]:
del self.points[self.selected]
self.sendValues()
self.selected = None
@@ -2026,7 +2020,7 @@ class Grapher(wx.Panel):
self.pos = self.borderClip(evt.GetPosition())
self.pos[1] = h - self.pos[1]
if self.HasCapture():
- if self.selected != None:
+ if self.selected is not None:
self.pos = self.pointClip(self.pos)
x, y = self.pixelsToPoint(self.pos)
if self.mode == 4 and y <= 0:
@@ -2183,15 +2177,15 @@ class Grapher(wx.Panel):
# Draw grid
dc.SetPen(wx.Pen("#CCCCCC", 1))
- xstep = int(round((w-OFF2) / float(10)))
- ystep = int(round((h-OFF2) / float(10)))
+ xstep = int(round((w-OFF2) / 10.0))
+ ystep = int(round((h-OFF2) / 10.0))
for i in range(10):
xpos = i * xstep + OFF
dc.DrawLine(xpos, OFF, xpos, h-OFF)
ypos = i * ystep + OFF
dc.DrawLine(OFF, ypos, w-OFF, ypos)
if i > 0:
- if type(self.xlen) == IntType:
+ if type(self.xlen) == int:
t = "%d" % int(self.xlen * i * 0.1)
else:
t = "%.2f" % (self.xlen * i * 0.1)
@@ -2207,7 +2201,7 @@ class Grapher(wx.Panel):
dc.SetBrush(wx.Brush("#000000"))
# Draw bounding box
for i in range(4):
- dc.DrawLinePoint(corners[i], corners[(i+1)%4])
+ dc.DrawLine(corners[i][0], corners[i][1], corners[(i+1)%4][0], corners[(i+1)%4][1])
# Convert points in pixels
w,h = w-OFF2-RAD2, h-OFF2-RAD2
@@ -2231,24 +2225,24 @@ class Grapher(wx.Panel):
tmp2 = self.getCosPoints(tmp[i], tmp[i+1])
if i == 0 and len(tmp2) < 2:
gc.DrawLines([tmp[i], tmp[i+1]])
- if last_p != None:
+ if last_p is not None:
gc.DrawLines([last_p, tmp[i]])
for j in range(len(tmp2)-1):
gc.DrawLines([tmp2[j], tmp2[j+1]])
last_p = tmp2[j+1]
- if last_p != None:
+ if last_p is not None:
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:
gc.DrawLines([tmp[i], tmp[i+1]])
- if last_p != None:
+ if last_p is not None:
gc.DrawLines([last_p, tmp[i]])
for j in range(len(tmp2)-1):
gc.DrawLines([tmp2[j], tmp2[j+1]])
last_p = tmp2[j+1]
- if last_p != None:
+ if last_p is not None:
gc.DrawLines([last_p, tmp[-1]])
elif self.mode == 3:
curvetmp = self.addImaginaryPoints(tmp)
@@ -2256,12 +2250,12 @@ class Grapher(wx.Panel):
tmp2 = self.getCurvePoints(curvetmp[i-1], curvetmp[i], curvetmp[i+1], curvetmp[i+2])
if i == 1 and len(tmp2) < 2:
gc.DrawLines([curvetmp[i], curvetmp[i+1]])
- if last_p != None:
+ if last_p is not None:
gc.DrawLines([last_p, curvetmp[i]])
for j in range(len(tmp2)-1):
gc.DrawLines([tmp2[j], tmp2[j+1]])
last_p = tmp2[j+1]
- if last_p != None:
+ if last_p is not None:
gc.DrawLines([last_p, tmp[-1]])
elif self.mode == 4:
back_tmp = [p for p in tmp]
@@ -2273,12 +2267,12 @@ class Grapher(wx.Panel):
tmp2[j] = (tmp2[j][0], int(round((1.0-tmp2[j][1]) * h)) + OFF + RAD)
if i == 0 and len(tmp2) < 2:
gc.DrawLines([back_tmp[i], back_tmp[i+1]])
- if last_p != None:
+ if last_p is not None:
gc.DrawLines([last_p, back_tmp[i]])
for j in range(len(tmp2)-1):
gc.DrawLines([tmp2[j], tmp2[j+1]])
last_p = tmp2[j+1]
- if last_p != None:
+ if last_p is not None:
gc.DrawLines([last_p, back_tmp[-1]])
tmp = [p for p in back_tmp]
elif self.mode == 5:
@@ -2291,12 +2285,12 @@ class Grapher(wx.Panel):
tmp2[j] = (tmp2[j][0], int(round((1.0-tmp2[j][1]) * h)) + OFF + RAD)
if i == 0 and len(tmp2) < 2:
gc.DrawLines([back_tmp[i], back_tmp[i+1]])
- if last_p != None:
+ if last_p is not None:
gc.DrawLines([last_p, back_tmp[i]])
for j in range(len(tmp2)-1):
gc.DrawLines([tmp2[j], tmp2[j+1]])
last_p = tmp2[j+1]
- if last_p != None:
+ if last_p is not None:
gc.DrawLines([last_p, back_tmp[-1]])
tmp = [p for p in back_tmp]
@@ -2316,12 +2310,13 @@ class Grapher(wx.Panel):
dc.SetTextForeground("#222222")
posptx, pospty = self.pixelsToPoint(self.pos)
xval, yval = self.pointToValues((posptx, pospty))
- if type(self.xlen) == IntType:
+ if type(self.xlen) == int:
dc.DrawText("%d, %.3f" % (xval, yval), w-75, OFF)
else:
dc.DrawText("%.3f, %.3f" % (xval, yval), w-75, OFF)
class TableGrapher(wx.Frame):
+
def __init__(self, parent=None, obj=None, mode=0, xlen=8192, yrange=(0.0, 1.0)):
wx.Frame.__init__(self, parent, size=(500,250))
pts = obj.getPoints()
@@ -2361,7 +2356,7 @@ class TableGrapher(wx.Frame):
pstr = "["
for i, pt in enumerate(pts):
pstr += "("
- if type(pt[0]) == IntType:
+ if type(pt[0]) == int:
pstr += "%d," % pt[0]
else:
pstr += "%.4f," % pt[0]
@@ -2381,6 +2376,7 @@ class TableGrapher(wx.Frame):
self.graph.reset()
class DataMultiSlider(wx.Panel):
+
def __init__(self, parent, init, yrange=(0,1), outFunction=None,
pos=(0, 0), size=(300, 200), style=0):
wx.Panel.__init__(self, parent, pos=pos, size=size, style=style)
@@ -2392,22 +2388,25 @@ class DataMultiSlider(wx.Panel):
self.Bind(wx.EVT_LEFT_DOWN, self.MouseDown)
self.Bind(wx.EVT_LEFT_UP, self.MouseUp)
self.Bind(wx.EVT_MOTION, self.MouseMotion)
+ self.changed = True
self.values = [v for v in init]
self.len = len(self.values)
self.yrange = (float(yrange[0]), float(yrange[1]))
self.outFunction = outFunction
- if sys.platform == "win32":
+
+ if sys.platform == "win32" or sys.platform.startswith("linux"):
self.dcref = wx.BufferedPaintDC
else:
self.dcref = wx.PaintDC
def OnResize(self, event):
self.Layout()
- self.Refresh()
+ wx.CallAfter(self.Refresh)
def update(self, points):
self.values = points
- self.Refresh()
+ self.changed = True
+ wx.CallAfter(self.Refresh)
def OnPaint(self, event):
w,h = self.GetSize()
@@ -2441,7 +2440,8 @@ class DataMultiSlider(wx.Panel):
points.append((w,y))
points.append((w,h))
gc.DrawLines(points)
- if self.outFunction != None:
+ if self.outFunction is not None and self.changed:
+ self.changed = False
self.outFunction(self.values)
def MouseDown(self, evt):
@@ -2454,7 +2454,8 @@ class DataMultiSlider(wx.Panel):
x = int(pos[0] / bw)
y = (h - pos[1]) / float(h) * scl + mini
self.values[x] = y
- self.Refresh()
+ self.changed = True
+ wx.CallAfter(self.Refresh)
evt.Skip()
def MouseUp(self, evt):
@@ -2492,13 +2493,16 @@ class DataMultiSlider(wx.Panel):
if x2 >= 0 and x2 < self.len:
self.values[x2] = y2
self.lastpos = pos
- self.Refresh()
+ self.changed = True
+ wx.CallAfter(self.Refresh)
class DataTableGrapher(wx.Frame):
+
def __init__(self, parent=None, obj=None, yrange=(0.0, 1.0)):
wx.Frame.__init__(self, parent, size=(500,250))
self.obj = obj
- self.multi = DataMultiSlider(self, self.obj.getTable(), yrange, outFunction=self.obj.replace)
+ self.length = len(self.obj._get_current_data())
+ self.multi = DataMultiSlider(self, self.obj._get_current_data(), yrange, outFunction=self.obj.replace)
self.menubar = wx.MenuBar()
self.fileMenu = wx.Menu()
self.fileMenu.Append(9999, 'Close\tCtrl+W', kind=wx.ITEM_NORMAL)
@@ -2506,19 +2510,22 @@ class DataTableGrapher(wx.Frame):
self.menubar.Append(self.fileMenu, "&File")
self.SetMenuBar(self.menubar)
+ def getLength(self):
+ return self.length
+
def close(self, evt):
self.Destroy()
def update(self, samples):
- wx.CallAfter(self.multi.update, samples)
+ self.multi.update(samples)
class ExprLexer(object):
"""Defines simple interface for custom lexer objects."""
STC_EXPR_DEFAULT, STC_EXPR_KEYWORD, STC_EXPR_KEYWORD2, STC_EXPR_COMMENT, \
- STC_EXPR_VARIABLE, STC_EXPR_LETVARIABLE = range(6)
+ STC_EXPR_VARIABLE, STC_EXPR_LETVARIABLE = list(range(6))
def __init__(self):
super(ExprLexer, self).__init__()
-
+
self.alpha = "abcdefghijklmnopqrstuvwxyz"
self.digits = "0123456789"
self.keywords = ["sin", "cos", "tan", "tanh", "atan", "atan2", "sqrt", "log",
@@ -2579,7 +2586,8 @@ class ExprLexer(object):
stc.SetStyling(1, style)
start_pos += 1
-class ExprEditor(stc.StyledTextCtrl):
+class ExprEditor(stc.StyledTextCtrl):
+
def __init__(self, parent, id=-1, obj=None):
stc.StyledTextCtrl.__init__(self, parent, id)
@@ -2592,18 +2600,18 @@ class ExprEditor(stc.StyledTextCtrl):
accel_ctrl = wx.ACCEL_CTRL
self.faces = {'mono' : 'Monospace', 'size' : 10}
- atable = wx.AcceleratorTable([(accel_ctrl, wx.WXK_RETURN, 10000),
- (accel_ctrl, ord("z"), wx.ID_UNDO),
- (accel_ctrl|wx.ACCEL_SHIFT, ord("z"), wx.ID_REDO)])
+ atable = wx.AcceleratorTable([(accel_ctrl, wx.WXK_RETURN, 10000),
+ (accel_ctrl, ord("z"), wx.ID_UNDO),
+ (accel_ctrl|wx.ACCEL_SHIFT, ord("z"), wx.ID_REDO)])
self.SetAcceleratorTable(atable)
-
+
self.Bind(wx.EVT_MENU, self.onExecute, id=10000)
self.Bind(wx.EVT_MENU, self.undo, id=wx.ID_UNDO)
self.Bind(wx.EVT_MENU, self.redo, id=wx.ID_REDO)
self.Bind(stc.EVT_STC_UPDATEUI, self.OnUpdateUI)
self.lexer = ExprLexer()
-
+
self.currentfile = ""
self.modified = False
@@ -2698,7 +2706,7 @@ class ExprEditor(stc.StyledTextCtrl):
if braceAtCaret >= 0:
braceOpposite = self.BraceMatch(braceAtCaret)
- if braceAtCaret != -1 and braceOpposite == -1:
+ if braceAtCaret != -1 and braceOpposite == -1:
self.BraceBadLight(braceAtCaret)
else:
self.BraceHighlight(braceAtCaret, braceOpposite)
@@ -2721,6 +2729,7 @@ class ExprEditor(stc.StyledTextCtrl):
self.SetSelection(pos, pos)
class ExprEditorFrame(wx.Frame):
+
def __init__(self, parent=None, obj=None):
wx.Frame.__init__(self, parent, size=(500,350))
self.obj = obj
@@ -2741,7 +2750,7 @@ class ExprEditorFrame(wx.Frame):
self.SetMenuBar(self.menubar)
def open(self, evt):
- dlg = wx.FileDialog(self, message="Choose a file",
+ dlg = wx.FileDialog(self, message="Choose a file",
defaultDir=os.path.expanduser("~"),
defaultFile="", style=wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
@@ -2762,7 +2771,7 @@ class ExprEditorFrame(wx.Frame):
def saveas(self, evt):
deffile = os.path.split(self.editor.currentfile)[1]
- dlg = wx.FileDialog(self, message="Save file as ...",
+ dlg = wx.FileDialog(self, message="Save file as ...",
defaultDir=os.path.expanduser("~"),
defaultFile=deffile, style=wx.SAVE)
dlg.SetFilterIndex(0)
@@ -2775,9 +2784,10 @@ class ExprEditorFrame(wx.Frame):
self.editor.SetText(text)
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.,
+
+ 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)
@@ -2845,13 +2855,13 @@ class ServerGUI(wx.Frame):
if timer:
box.AddSpacer(10)
- tt = wx.StaticText(panel, -1, "Elapsed time (hh : mm : ss : ms)")
+ tt = wx.StaticText(panel, -1, "Elapsed time (hh:mm:ss:ms)")
box.Add(tt, 0, wx.LEFT, leftMargin)
box.AddSpacer(3)
self.timetext = wx.StaticText(panel, -1, "00 : 00 : 00 : 000")
box.Add(self.timetext, 0, wx.LEFT, leftMargin)
- if self.locals != None:
+ if self.locals is not None:
box.AddSpacer(10)
t = wx.StaticText(panel, -1, "Interpreter")
box.Add(t, 0, wx.LEFT, leftMargin)
@@ -2875,28 +2885,31 @@ class ServerGUI(wx.Frame):
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')
if self.exit:
wx.CallAfter(self.quitButton.Disable)
+ if not justSet:
+ self.startf()
else:
- wx.CallLater(100, self.stopf)
self._started = False
wx.CallAfter(self.startButton.SetLabel, 'Start')
if self.exit:
wx.CallAfter(self.quitButton.Enable)
+ # TODO: Need a common method for every OSes.
+ #wx.CallLater(100, self.stopf)
+ #wx.CallAfter(self.stopf)
+ self.stopf()
def record(self, evt):
if self._recstarted == False:
self.recstartf()
self._recstarted = True
- self.recButton.SetLabel('Rec Stop')
+ wx.CallAfter(self.recButton.SetLabel, 'Rec Stop')
else:
self.recstopf()
self._recstarted = False
- self.recButton.SetLabel('Rec Start')
+ wx.CallAfter(self.recButton.SetLabel, 'Rec Start')
def quit_from_code(self):
wx.CallAfter(self.on_quit, None)
@@ -2904,6 +2917,7 @@ class ServerGUI(wx.Frame):
def on_quit(self, evt):
if self.exit:
self.shutdown()
+ time.sleep(0.25)
self.Destroy()
if self.exit:
sys.exit()
@@ -2923,14 +2937,14 @@ class ServerGUI(wx.Frame):
self._histo_count = len(self._history)
else:
self.text.SetValue(self._history[self._histo_count])
- self.text.SetInsertionPointEnd()
+ wx.CallAfter(self.text.SetInsertionPointEnd)
def getText(self, evt):
source = self.text.GetValue()
self.text.Clear()
self._history.append(source)
self._histo_count = len(self._history)
- exec source in self.locals
+ exec(source, self.locals)
def onChar(self, evt):
key = evt.GetKeyCode()
@@ -2950,7 +2964,7 @@ class ServerGUI(wx.Frame):
self.meter.setRms(*args)
def ensureNFD(unistr):
- if sys.platform in ['linux2', 'win32']:
+ if sys.platform == 'win32' or sys.platform.startswith('linux'):
encodings = [sys.getdefaultencoding(), sys.getfilesystemencoding(),
'cp1252', 'iso-8859-1', 'utf-16']
format = 'NFC'
@@ -2959,7 +2973,7 @@ def ensureNFD(unistr):
'macroman', 'iso-8859-1', 'utf-16']
format = 'NFC'
decstr = unistr
- if type(decstr) != UnicodeType:
+ if type(decstr) != unicode_t:
for encoding in encodings:
try:
decstr = decstr.decode(encoding)
@@ -2968,7 +2982,7 @@ def ensureNFD(unistr):
continue
except:
decstr = "UnableToDecodeString"
- print "Unicode encoding not in a recognized format..."
+ print("Unicode encoding not in a recognized format...")
break
if decstr == "UnableToDecodeString":
return unistr
diff --git a/pyolib/analysis.py b/pyolib/analysis.py
index 5188da3..38b8ce6 100644
--- a/pyolib/analysis.py
+++ b/pyolib/analysis.py
@@ -1,3 +1,5 @@
+from __future__ import division
+from __future__ import absolute_import
"""
Tools to analyze audio signals.
@@ -27,10 +29,10 @@ 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
+from ._core import *
+from ._maps import *
+from ._widgets import createSpectrumWindow, createScopeWindow
+from .pattern import Pattern
class Follower(PyoObject):
"""
@@ -42,9 +44,9 @@ class Follower(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Cutoff frequency of the filter in hertz. Default to 20.
.. note::
@@ -52,6 +54,10 @@ class Follower(PyoObject):
The out() method is bypassed. Follower's signal can not be sent to
audio outs.
+ .. seealso::
+
+ :py:class:`Follower2`, :py:class: `Balance`
+
>>> s = Server().boot()
>>> s.start()
>>> sf = SfPlayer(SNDS_PATH + "/transparent.aif", loop=True, mul=.4).out()
@@ -74,9 +80,9 @@ class Follower(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -90,7 +96,7 @@ class Follower(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -130,11 +136,11 @@ class Follower2(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- risetime : float or PyoObject, optional
+ risetime: float or PyoObject, optional
Time to reach upward value in seconds. Default to 0.01.
- falltime : float or PyoObject, optional
+ falltime: float or PyoObject, optional
Time to reach downward value in seconds. Default to 0.1.
.. note::
@@ -142,6 +148,10 @@ class Follower2(PyoObject):
The out() method is bypassed. Follower's signal can not be sent to
audio outs.
+ .. seealso::
+
+ :py:class:`Follower`, :py:class: `Balance`
+
>>> s = Server().boot()
>>> s.start()
>>> sf = SfPlayer(SNDS_PATH + "/transparent.aif", loop=True, mul=.4).out()
@@ -165,9 +175,9 @@ class Follower2(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -181,7 +191,7 @@ class Follower2(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `risetime` attribute.
"""
@@ -196,7 +206,7 @@ class Follower2(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `falltime` attribute.
"""
@@ -244,9 +254,9 @@ class ZCross(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- thresh : float, optional
+ thresh: float, optional
Minimum amplitude difference allowed between adjacent samples
to be included in the zeros count.
@@ -277,9 +287,9 @@ class ZCross(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -293,7 +303,7 @@ class ZCross(PyoObject):
:Args:
- x : float
+ x: float
New amplitude difference threshold.
"""
@@ -339,23 +349,23 @@ class Yin(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- tolerance : float, optional
+ tolerance: float, optional
Parameter for minima selection, between 0 and 1. Defaults to 0.2.
- minfreq : float, optional
+ minfreq: float, optional
Minimum estimated frequency in Hz. Frequency below this threshold will
be ignored. Defaults to 40.
- maxfreq : float, optional
+ maxfreq: float, optional
Maximum estimated frequency in Hz. Frequency above this threshold will
be ignored. Defaults to 1000.
- cutoff : float, optional
+ 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.
- winsize : int, optional
+ winsize: int, optional
Size, in samples, of the analysis window. Must be higher that two period
of the lowest desired frequency.
@@ -390,9 +400,9 @@ class Yin(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -406,7 +416,7 @@ class Yin(PyoObject):
:Args:
- x : float
+ x: float
New parameter for minima selection, between 0 and 1.
"""
@@ -421,7 +431,7 @@ class Yin(PyoObject):
:Args:
- x : float
+ x: float
New minimum frequency detected.
"""
@@ -436,7 +446,7 @@ class Yin(PyoObject):
:Args:
- x : float
+ x: float
New maximum frequency detected.
"""
@@ -451,7 +461,7 @@ class Yin(PyoObject):
:Args:
- x : float
+ x: float
New input lowpass filter cutoff frequency.
"""
@@ -520,9 +530,9 @@ class Centroid(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- size : int, optional
+ 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.
@@ -556,9 +566,9 @@ class Centroid(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -594,23 +604,23 @@ class AttackDetector(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- deltime : float, optional
+ deltime: float, optional
Delay time, in seconds, between previous and current rms analysis to compare.
Defaults to 0.005.
- cutoff : float, optional
+ 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
+ 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
+ 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
+ reltime: float, optional
Time, in seconds, to wait before reporting a new attack. Defaults to 0.1.
@@ -641,9 +651,9 @@ class AttackDetector(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -657,7 +667,7 @@ class AttackDetector(PyoObject):
:Args:
- x : float
+ x: float
New delay between rms analysis.
"""
@@ -672,7 +682,7 @@ class AttackDetector(PyoObject):
:Args:
- x : float
+ x: float
New cutoff for the follower lowpass filter.
"""
@@ -687,7 +697,7 @@ class AttackDetector(PyoObject):
:Args:
- x : float
+ x: float
New attack threshold in dB.
"""
@@ -702,7 +712,7 @@ class AttackDetector(PyoObject):
:Args:
- x : float
+ x: float
New minimum threshold in dB.
"""
@@ -717,7 +727,7 @@ class AttackDetector(PyoObject):
:Args:
- x : float
+ x: float
Time, in seconds, to wait before reporting a new attack.
"""
@@ -732,7 +742,7 @@ class AttackDetector(PyoObject):
"""
[obj.readyToDetect() for obj in self._base_objs]
-
+
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
@@ -798,13 +808,13 @@ class Spectrum(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- size : int {pow-of-two > 4}, optional
+ 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
+ wintype: int, optional
Shape of the envelope used to filter each input frame.
Possible shapes are :
0. rectangular (no windowing)
@@ -816,7 +826,7 @@ class Spectrum(PyoObject):
6. Blackman-Harris 7-term
7. Tuckey (alpha = 0.66)
8. Sine (half-sine window)
- function : python callable, optional
+ 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.
@@ -854,7 +864,7 @@ class Spectrum(PyoObject):
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)]
self._timer = Pattern(self.refreshView, 0.05).play()
- if function == None:
+ if function is None:
self.view()
def setInput(self, x, fadetime=0.05):
@@ -863,9 +873,9 @@ class Spectrum(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -879,7 +889,7 @@ class Spectrum(PyoObject):
:Args:
- x : int
+ x: int
new `size` attribute.
"""
@@ -894,7 +904,7 @@ class Spectrum(PyoObject):
:Args:
- x : int
+ x: int
new `wintype` attribute.
"""
@@ -909,7 +919,7 @@ class Spectrum(PyoObject):
:Args:
- function : python callable
+ 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).
@@ -924,7 +934,7 @@ class Spectrum(PyoObject):
:Args:
- active : boolean
+ active: boolean
If True, starts the analysis polling, False to stop it.
defaults to True.
@@ -941,7 +951,7 @@ class Spectrum(PyoObject):
:Args:
- time : float
+ time: float
Adjusts the frequency of the internal timer used to
retrieve the current analysis frame. defaults to 0.05.
@@ -955,7 +965,7 @@ class Spectrum(PyoObject):
:Args:
- x : float
+ x: float
New low frequency in Hz. Adjusts the `lowbound` attribute, as `x / sr`.
"""
@@ -971,7 +981,7 @@ class Spectrum(PyoObject):
:Args:
- x : float
+ x: float
New high frequency in Hz. Adjusts the `highbound` attribute, as `x / sr`.
"""
@@ -989,7 +999,7 @@ class Spectrum(PyoObject):
:Args:
- x : float {0 <= x <= 0.5}
+ x: float {0 <= x <= 0.5}
new `lowbound` attribute.
"""
@@ -1007,7 +1017,7 @@ class Spectrum(PyoObject):
:Args:
- x : float {0 <= x <= 0.5}
+ x: float {0 <= x <= 0.5}
new `highbound` attribute.
"""
@@ -1040,7 +1050,7 @@ class Spectrum(PyoObject):
:Args:
- x : int
+ x: int
new `width` attribute.
"""
@@ -1057,7 +1067,7 @@ class Spectrum(PyoObject):
:Args:
- x : int
+ x: int
new `height` attribute.
"""
@@ -1072,7 +1082,7 @@ class Spectrum(PyoObject):
:Args:
- x : boolean
+ x: boolean
If True, the frequency display is logarithmic. False turns
it back to linear. Defaults to False.
@@ -1081,7 +1091,7 @@ class Spectrum(PyoObject):
self._fscaling = x
x, lmax = convertArgsToLists(x)
[obj.setFscaling(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
- if self.viewFrame != None:
+ if self.viewFrame is not None:
self.viewFrame.setFscaling(self._fscaling)
def setMscaling(self, x):
@@ -1090,7 +1100,7 @@ class Spectrum(PyoObject):
:Args:
- x : boolean
+ x: boolean
If True, the magnitude display is logarithmic (which means in dB).
False turns it back to linear. Defaults to True.
@@ -1099,7 +1109,7 @@ class Spectrum(PyoObject):
self._mscaling = x
x, lmax = convertArgsToLists(x)
[obj.setMscaling(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
- if self.viewFrame != None:
+ if self.viewFrame is not None:
self.viewFrame.setMscaling(self._mscaling)
def getFscaling(self):
@@ -1126,7 +1136,7 @@ class Spectrum(PyoObject):
:Args:
- x : float
+ x: float
new `gain` attribute, as linear values.
"""
@@ -1141,9 +1151,9 @@ class Spectrum(PyoObject):
:Args:
- title : string, optional
+ title: string, optional
Window title. Defaults to "Spectrum".
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -1165,9 +1175,9 @@ class Spectrum(PyoObject):
"""
self.points = [obj.display() for obj in self._base_objs]
- if self._function != None:
+ if self._function is not None:
self._function(self.points)
- if self.viewFrame != None:
+ if self.viewFrame is not None:
self.viewFrame.update(self.points)
@property
@@ -1251,15 +1261,15 @@ class Scope(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- length : float, optional
+ length: float, optional
Length, in seconds, of the displayed window. Can't be a list.
Defaults to 0.05.
- gain : float, optional
+ gain: float, optional
Linear gain applied to the signal to be displayed.
Can't be a list. Defaults to 0.67.
- function : python callable, optional
+ function: python callable, optional
If set, this function will be called with samples (as
list of lists, one list per channel). Useful if someone
wants to save the analysis data into a text file.
@@ -1293,7 +1303,7 @@ class Scope(PyoObject):
in_fader, lmax = convertArgsToLists(self._in_fader)
self._base_objs = [Scope_base(wrap(in_fader,i), length) for i in range(lmax)]
self._timer = Pattern(self.refreshView, length).play()
- if function == None:
+ if function is None:
self.view()
def setInput(self, x, fadetime=0.05):
@@ -1302,9 +1312,9 @@ class Scope(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1318,7 +1328,7 @@ class Scope(PyoObject):
:Args:
- x : float
+ x: float
new `length` attribute.
"""
@@ -1333,7 +1343,7 @@ class Scope(PyoObject):
:Args:
- x : float
+ x: float
new `gain` attribute, as linear values.
"""
@@ -1348,7 +1358,7 @@ class Scope(PyoObject):
:Args:
- active : boolean
+ active: boolean
If True, starts the analysis polling, False to stop it.
defaults to True.
@@ -1368,7 +1378,7 @@ class Scope(PyoObject):
:Args:
- x : int
+ x: int
Width of the display in pixel value. The default
width is 500.
@@ -1386,7 +1396,7 @@ class Scope(PyoObject):
:Args:
- x : int
+ x: int
Height of the display in pixel value. The default
height is 400.
@@ -1401,9 +1411,9 @@ class Scope(PyoObject):
:Args:
- title : string, optional
+ title: string, optional
Window title. Defaults to "Spectrum".
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -1420,7 +1430,7 @@ class Scope(PyoObject):
:Args:
- function : python callable
+ 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).
@@ -1440,7 +1450,7 @@ class Scope(PyoObject):
"""
self.points = [obj.display() for obj in self._base_objs]
- if self.viewFrame != None:
+ if self.viewFrame is not None:
self.viewFrame.update(self.points)
if self._function is not None:
self._function(self.points)
@@ -1483,9 +1493,9 @@ class PeakAmp(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- function : callable, optional
+ function: callable, optional
Function that will be called with amplitude values in arguments.
Default to None.
@@ -1522,9 +1532,9 @@ class PeakAmp(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1538,7 +1548,7 @@ class PeakAmp(PyoObject):
:Args:
- x : callable
+ x: callable
New function to call with amplitude values in arguments.
"""
@@ -1552,7 +1562,7 @@ class PeakAmp(PyoObject):
:Args:
- x : float
+ x: float
New polling time in seconds.
"""
@@ -1563,7 +1573,7 @@ class PeakAmp(PyoObject):
return self.play(dur, delay)
def _buildList(self):
- if self._function != None:
+ if self._function is not None:
values = [obj.getValue() for obj in self._base_objs]
self._function(*values)
@@ -1583,4 +1593,4 @@ class PeakAmp(PyoObject):
"""PyoObject. function signal to process."""
return self._function
@function.setter
- def function(self, x): self.setFunction(x)
\ No newline at end of file
+ def function(self, x): self.setFunction(x)
diff --git a/pyolib/arithmetic.py b/pyolib/arithmetic.py
index f1a476b..e8d300e 100644
--- a/pyolib/arithmetic.py
+++ b/pyolib/arithmetic.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
"""
Tools to perform arithmetic operations on audio signals.
@@ -22,8 +23,8 @@ 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 ._core import *
+from ._maps import *
class Sin(PyoObject):
"""
@@ -35,7 +36,7 @@ class Sin(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal, angle in radians.
>>> s = Server().boot()
@@ -60,9 +61,9 @@ class Sin(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -87,7 +88,7 @@ class Cos(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal, angle in radians.
>>> s = Server().boot()
@@ -111,9 +112,9 @@ class Cos(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -138,7 +139,7 @@ class Tan(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal, angle in radians.
>>> s = Server().boot()
@@ -169,9 +170,9 @@ class Tan(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -196,7 +197,7 @@ class Abs(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
>>> s = Server().boot()
@@ -222,9 +223,9 @@ class Abs(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -249,7 +250,7 @@ class Sqrt(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
>>> s = Server().boot()
@@ -280,9 +281,9 @@ class Sqrt(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -308,7 +309,7 @@ class Log(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
>>> s = Server().boot()
@@ -334,9 +335,9 @@ class Log(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -362,7 +363,7 @@ class Log2(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
>>> s = Server().boot()
@@ -388,9 +389,9 @@ class Log2(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -416,7 +417,7 @@ class Log10(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
>>> s = Server().boot()
@@ -442,9 +443,9 @@ class Log10(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -471,9 +472,9 @@ class Atan2(PyoObject):
:Args:
- b : float or PyoObject, optional
+ b: float or PyoObject, optional
Numerator. Defaults to 1.
- a : float or PyoObject, optional
+ a: float or PyoObject, optional
Denominator. Defaults to 1.
>>> s = Server().boot()
@@ -499,7 +500,7 @@ class Atan2(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `b` attribute.
"""
@@ -514,7 +515,7 @@ class Atan2(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `a` attribute.
"""
@@ -548,7 +549,7 @@ class Floor(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
>>> s = Server().boot()
@@ -574,9 +575,9 @@ class Floor(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -602,7 +603,7 @@ class Ceil(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
>>> s = Server().boot()
@@ -628,9 +629,9 @@ class Ceil(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -656,7 +657,7 @@ class Round(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
>>> s = Server().boot()
@@ -682,9 +683,9 @@ class Round(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -709,7 +710,7 @@ class Tanh(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal, angle in radians.
>>> s = Server().boot()
@@ -734,9 +735,9 @@ class Tanh(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -749,4 +750,60 @@ class Tanh(PyoObject):
"""PyoObject. Input signal to process."""
return self._input
@input.setter
- def input(self, x): self.setInput(x)
\ No newline at end of file
+ def input(self, x): self.setInput(x)
+
+class Exp(PyoObject):
+ """
+ Calculates the value of e to the power of x.
+
+ Returns the value of e to the power of x, where e is the base of the
+ natural logarithm, 2.718281828...
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input: PyoObject
+ Input signal, the exponent.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> a = Sine(freq=200)
+ >>> lf = Sine(freq=.5, mul=5, add=6)
+ >>> # Tanh style distortion
+ >>> t = Exp(2 * a * lf)
+ >>> th = (t - 1) / (t + 1)
+ >>> out = (th * 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 = [M_Exp_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)
diff --git a/pyolib/controls.py b/pyolib/controls.py
index 405c4bb..00b21bf 100644
--- a/pyolib/controls.py
+++ b/pyolib/controls.py
@@ -9,6 +9,7 @@ soundcard.
"""
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -28,11 +29,11 @@ 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 sys
-from _core import *
-from _maps import *
-from _widgets import createGraphWindow
-from types import ListType, TupleType
+from ._core import *
+from ._maps import *
+from ._widgets import createGraphWindow
######################################################################
### Controls
@@ -51,11 +52,11 @@ class Fader(PyoObject):
:Args:
- fadein : float, optional
+ fadein: float, optional
Rising time of the envelope in seconds. Defaults to 0.01.
- fadeout : float, optional
+ fadeout: float, optional
Falling time of the envelope in seconds. Defaults to 0.1.
- dur : float, optional
+ dur: float, optional
Total duration of the envelope. Defaults to 0, which means wait
for the stop() method to start the fadeout.
@@ -65,7 +66,10 @@ class Fader(PyoObject):
The play() method starts the envelope.
- The stop() calls the envelope's release phase if `dur` = 0.
+ The stop() method calls the envelope's release phase if `dur` = 0.
+
+ As of version 0.8.0, exponential or logarithmic envelopes can be created
+ with the exponent factor (see setExp() method).
>>> s = Server().boot()
>>> s.start()
@@ -82,6 +86,7 @@ class Fader(PyoObject):
self._fadein = fadein
self._fadeout = fadeout
self._dur = dur
+ self._exp = 1.0
fadein, fadeout, dur, mul, add, lmax = convertArgsToLists(fadein, fadeout, dur, mul, add)
self._base_objs = [Fader_base(wrap(fadein,i), wrap(fadeout,i), wrap(dur,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
@@ -94,7 +99,7 @@ class Fader(PyoObject):
:Args:
- x : float
+ x: float
new `fadein` attribute.
"""
@@ -109,7 +114,7 @@ class Fader(PyoObject):
:Args:
- x : float
+ x: float
new `fadeout` attribute.
"""
@@ -124,7 +129,7 @@ class Fader(PyoObject):
:Args:
- x : float
+ x: float
new `dur` attribute.
"""
@@ -133,6 +138,25 @@ class Fader(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setDur(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ def setExp(self, x):
+ """
+ Sets an exponent factor to create exponential or logarithmic envelope.
+
+ The default value is 1.0, which means linear segments. A value
+ higher than 1.0 will produce exponential segments while a value
+ between 0 and 1 will produce logarithmic segments. Must be > 0.0.
+
+ :Args:
+
+ x: float
+ 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)]
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0, 10., 'lin', 'fadein', self._fadein, dataOnly=True),
SLMap(0, 10., 'lin', 'fadeout', self._fadeout, dataOnly=True),
@@ -160,6 +184,13 @@ class Fader(PyoObject):
@dur.setter
def dur(self, x): self.setDur(x)
+ @property
+ def exp(self):
+ """float. Exponent factor of the envelope."""
+ return self._exp
+ @exp.setter
+ def exp(self, x): self.setExp(x)
+
class Adsr(PyoObject):
"""
@@ -176,15 +207,15 @@ class Adsr(PyoObject):
:Args:
- attack : float, optional
+ attack: float, optional
Duration of the attack phase in seconds. Defaults to 0.01.
- decay : float, optional
+ decay: float, optional
Duration of the decay in seconds. Defaults to 0.05.
- sustain : float, optional
+ sustain: float, optional
Amplitude of the sustain phase. Defaults to 0.707.
- release : float, optional
+ release: float, optional
Duration of the release in seconds. Defaults to 0.1.
- dur : float, optional
+ dur: float, optional
Total duration of the envelope. Defaults to 0, which means wait
for the stop() method to start the release phase.
@@ -195,7 +226,10 @@ class Adsr(PyoObject):
The play() method starts the envelope.
- The stop() calls the envelope's release phase if `dur` = 0.
+ The stop() method calls the envelope's release phase if `dur` = 0.
+
+ As of version 0.8.0, exponential or logarithmic envelopes can be created
+ with the exponent factor (see setExp() method).
>>> s = Server().boot()
>>> s.start()
@@ -214,6 +248,7 @@ class Adsr(PyoObject):
self._sustain = sustain
self._release = release
self._dur = dur
+ self._exp = 1.0
attack, decay, sustain, release, dur, mul, add, lmax = convertArgsToLists(attack, decay, sustain, release, dur, mul, add)
self._base_objs = [Adsr_base(wrap(attack,i), wrap(decay,i), wrap(sustain,i), wrap(release,i), wrap(dur,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
@@ -226,7 +261,7 @@ class Adsr(PyoObject):
:Args:
- x : float
+ x: float
new `attack` attribute.
"""
@@ -241,7 +276,7 @@ class Adsr(PyoObject):
:Args:
- x : float
+ x: float
new `decay` attribute.
"""
@@ -256,7 +291,7 @@ class Adsr(PyoObject):
:Args:
- x : float
+ x: float
new `sustain` attribute.
"""
@@ -271,7 +306,7 @@ class Adsr(PyoObject):
:Args:
- x : float
+ x: float
new `sustain` attribute.
"""
@@ -286,7 +321,7 @@ class Adsr(PyoObject):
:Args:
- x : float
+ x: float
new `dur` attribute.
"""
@@ -295,6 +330,25 @@ class Adsr(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setDur(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ def setExp(self, x):
+ """
+ Sets an exponent factor to create exponential or logarithmic envelope.
+
+ The default value is 1.0, which means linear segments. A value
+ higher than 1.0 will produce exponential segments while a value
+ between 0 and 1 will produce logarithmic segments. Must be > 0.0.
+
+ :Args:
+
+ x: float
+ 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)]
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0, 5, 'lin', 'attack', self._attack, dataOnly=True),
SLMap(0, 5, 'lin', 'decay', self._decay, dataOnly=True),
@@ -338,9 +392,16 @@ class Adsr(PyoObject):
@dur.setter
def dur(self, x): self.setDur(x)
+ @property
+ def exp(self):
+ """float. Exponent factor of the envelope."""
+ return self._exp
+ @exp.setter
+ def exp(self, x): self.setExp(x)
+
class Linseg(PyoObject):
"""
- Trace a series of line segments between specified break-points.
+ Draw a series of line segments between specified break-points.
The play() method starts the envelope and is not called at the
object creation time.
@@ -349,14 +410,14 @@ class Linseg(PyoObject):
:Args:
- list : list of tuples
+ list: list of tuples
Points used to construct the line segments. Each tuple is a
new point in the form (time, value).
Times are given in seconds and must be in increasing order.
- loop : boolean, optional
+ loop: boolean, optional
Looping mode. Defaults to False.
- initToFirstVal : boolean, optional
+ initToFirstVal: boolean, optional
If True, audio buffer will be filled at initialization with the
first value of the line. Defaults to False.
@@ -378,7 +439,7 @@ class Linseg(PyoObject):
self._list = list
self._loop = loop
initToFirstVal, loop, mul, add, lmax = convertArgsToLists(initToFirstVal, loop, mul, add)
- if type(list[0]) != ListType:
+ if type(list[0]) != list:
self._base_objs = [Linseg_base(list, wrap(loop,i), wrap(initToFirstVal,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
else:
listlen = len(list)
@@ -394,13 +455,13 @@ class Linseg(PyoObject):
:Args:
- x : list of tuples
+ x: list of tuples
new `list` attribute.
"""
pyoArgsAssert(self, "l", x)
self._list = x
- if type(x[0]) != ListType:
+ if type(x[0]) != list:
[obj.setList(x) for i, obj in enumerate(self._base_objs)]
else:
[obj.setList(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -411,7 +472,7 @@ class Linseg(PyoObject):
:Args:
- x : list of tuples
+ x: list of tuples
new `list` attribute.
"""
@@ -426,7 +487,7 @@ class Linseg(PyoObject):
:Args:
- x : boolean
+ x: boolean
new `loop` attribute.
"""
@@ -454,16 +515,16 @@ class Linseg(PyoObject):
:Args:
- xlen : float, optional
+ xlen: float, optional
Set the maximum value of the X axis of the graph. If None, the
maximum value is retrieve from the current list of points.
- yrange : tuple, optional
+ yrange: tuple, optional
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: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -471,11 +532,11 @@ class Linseg(PyoObject):
server GUI before showing the controller window.
"""
- if xlen == None:
+ if xlen is None:
xlen = float(self._list[-1][0])
else:
xlen = float(xlen)
- if yrange == None:
+ if yrange is None:
ymin = float(min([x[1] for x in self._list]))
ymax = float(max([x[1] for x in self._list]))
if ymin == ymax:
@@ -500,7 +561,7 @@ class Linseg(PyoObject):
class Expseg(PyoObject):
"""
- Trace a series of exponential segments between specified break-points.
+ Draw a series of exponential segments between specified break-points.
The play() method starts the envelope and is not called at the
object creation time.
@@ -509,20 +570,20 @@ class Expseg(PyoObject):
:Args:
- list : list of tuples
+ list: list of tuples
Points used to construct the line segments. Each tuple is a
new point in the form (time, value).
Times are given in seconds and must be in increasing order.
- loop : boolean, optional
+ loop: boolean, optional
Looping mode. Defaults to False.
- exp : float, optional
+ exp: float, optional
Exponent factor. Used to control the slope of the curves.
Defaults to 10.
- inverse : boolean, optional
+ inverse: boolean, optional
If True, downward slope will be inversed. Useful to create
biexponential curves. Defaults to True.
- initToFirstVal : boolean, optional
+ initToFirstVal: boolean, optional
If True, audio buffer will be filled at initialization with the
first value of the line. Defaults to False.
@@ -546,7 +607,7 @@ class Expseg(PyoObject):
self._exp = exp
self._inverse = inverse
loop, exp, inverse, initToFirstVal, mul, add, lmax = convertArgsToLists(loop, exp, inverse, initToFirstVal, mul, add)
- if type(list[0]) != ListType:
+ if type(list[0]) != list:
self._base_objs = [Expseg_base(list, wrap(loop,i), wrap(exp,i), wrap(inverse,i), wrap(initToFirstVal,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
else:
listlen = len(list)
@@ -562,13 +623,13 @@ class Expseg(PyoObject):
:Args:
- x : list of tuples
+ x: list of tuples
new `list` attribute.
"""
pyoArgsAssert(self, "l", x)
self._list = x
- if type(x[0]) != ListType:
+ if type(x[0]) != list:
[obj.setList(x) for i, obj in enumerate(self._base_objs)]
else:
[obj.setList(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -579,7 +640,7 @@ class Expseg(PyoObject):
:Args:
- x : boolean
+ x: boolean
new `loop` attribute.
"""
@@ -594,7 +655,7 @@ class Expseg(PyoObject):
:Args:
- x : float
+ x: float
new `exp` attribute.
"""
@@ -609,7 +670,7 @@ class Expseg(PyoObject):
:Args:
- x : boolean
+ x: boolean
new `inverse` attribute.
"""
@@ -624,7 +685,7 @@ class Expseg(PyoObject):
:Args:
- x : list of tuples
+ x: list of tuples
new `list` attribute.
"""
@@ -652,18 +713,18 @@ class Expseg(PyoObject):
:Args:
- xlen : float, optional
+ xlen: float, optional
Set the maximum value of the X axis of the graph. If None, the
maximum value is retrieve from the current list of points.
Defaults to None.
- yrange : tuple, optional
+ yrange: tuple, optional
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.
Defaults to None.
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -671,11 +732,11 @@ class Expseg(PyoObject):
server GUI before showing the controller window.
"""
- if xlen == None:
+ if xlen is None:
xlen = float(self._list[-1][0])
else:
xlen = float(xlen)
- if yrange == None:
+ if yrange is None:
ymin = float(min([x[1] for x in self._list]))
ymax = float(max([x[1] for x in self._list]))
if ymin == ymax:
@@ -724,11 +785,11 @@ class SigTo(PyoObject):
:Args:
- value : float or PyoObject
+ value: float or PyoObject
Numerical value to convert.
- time : float, optional
+ time: float or PyoObject, optional
Ramp time, in seconds, to reach the new value. Defaults to 0.025.
- init : float, optional
+ init: float, optional
Initial value of the internal memory. Defaults to 0.
.. note::
@@ -747,7 +808,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)
+ pyoArgsAssert(self, "OOnOO", value, time, init, mul, add)
PyoObject.__init__(self, mul, add)
self._value = value
self._time = time
@@ -760,7 +821,7 @@ class SigTo(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
Numerical value to convert.
"""
@@ -775,17 +836,17 @@ class SigTo(PyoObject):
:Args:
- x : float
- New ramp time.
+ x: float or PyoObject
+ New ramp time in seconds.
"""
- pyoArgsAssert(self, "n", x)
+ 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 ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(0, 10, 'lin', 'time', self._time, dataOnly=True)]
+ self._map_list = [SLMap(0, 10, 'lin', 'time', self._time)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
@@ -797,7 +858,7 @@ class SigTo(PyoObject):
@property
def time(self):
- """float. Ramp time."""
+ """floator PyoObject. Ramp time in seconds."""
return self._time
@time.setter
- def time(self, x): self.setTime(x)
\ No newline at end of file
+ def time(self, x): self.setTime(x)
diff --git a/pyolib/dynamics.py b/pyolib/dynamics.py
index 5867977..872f0d2 100644
--- a/pyolib/dynamics.py
+++ b/pyolib/dynamics.py
@@ -3,6 +3,7 @@ Objects to modify the dynamic range and sample quality of audio signals.
"""
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -22,8 +23,9 @@ 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 *
+
+from ._core import *
+from ._maps import *
class Clip(PyoObject):
"""
@@ -33,11 +35,11 @@ class Clip(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- min : float or PyoObject, optional
+ min: float or PyoObject, optional
Minimum possible value. Defaults to -1.
- max : float or PyoObject, optional
+ max: float or PyoObject, optional
Maximum possible value. Defaults to 1.
>>> s = Server().boot()
@@ -64,9 +66,9 @@ class Clip(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -80,7 +82,7 @@ class Clip(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `min` attribute.
"""
@@ -95,7 +97,7 @@ class Clip(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `max` attribute.
"""
@@ -142,11 +144,11 @@ class Mirror(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- min : float or PyoObject, optional
+ min: float or PyoObject, optional
Minimum possible value. Defaults to 0.
- max : float or PyoObject, optional
+ max: float or PyoObject, optional
Maximum possible value. Defaults to 1.
.. note::
@@ -178,9 +180,9 @@ class Mirror(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -194,7 +196,7 @@ class Mirror(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `min` attribute.
"""
@@ -209,7 +211,7 @@ class Mirror(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `max` attribute.
"""
@@ -256,12 +258,12 @@ class Degrade(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- bitdepth : float or PyoObject, optional
+ bitdepth: float or PyoObject, optional
Signal quantization in bits. Must be in range 1 -> 32.
Defaults to 16.
- srscale : float or PyoObject, optional
+ srscale: float or PyoObject, optional
Sampling rate multiplier. Must be in range 0.0009765625 -> 1.
Defaults to 1.
@@ -290,9 +292,9 @@ class Degrade(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -306,7 +308,7 @@ class Degrade(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `bitdepth` attribute.
"""
@@ -321,7 +323,7 @@ class Degrade(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `srscale` attribute.
"""
@@ -368,30 +370,30 @@ class Compress(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- thresh : float or PyoObject, optional
+ thresh: float or PyoObject, optional
Level, expressed in dB, above which the signal is reduced.
Reference level is 0dB. Defaults to -20.
- ratio : float or PyoObject, optional
+ ratio: float or PyoObject, optional
Determines the input/output ratio for signals above the
threshold. Defaults to 2.
- risetime : float or PyoObject, optional
+ risetime: float or PyoObject, optional
Used in amplitude follower, time to reach upward value in
seconds. Defaults to 0.01.
- falltime : float or PyoObject, optional
+ falltime: float or PyoObject, optional
Used in amplitude follower, time to reach downward value in
seconds. Defaults to 0.1.
- lookahead : float, optional
+ lookahead: float, optional
Delay length, in ms, for the "look-ahead" buffer. Range is
0 -> 25 ms. Defaults to 5.0.
- knee : float optional
+ 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
knee. Defaults to 0.
- outputAmp : boolean, optional
+ outputAmp: boolean, optional
If True, the object's output signal will be the compression level
alone, not the compressed signal.
@@ -426,9 +428,9 @@ class Compress(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -442,7 +444,7 @@ class Compress(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `thresh` attribute.
"""
@@ -457,7 +459,7 @@ class Compress(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `ratio` attribute.
"""
@@ -472,7 +474,7 @@ class Compress(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `risetime` attribute.
"""
@@ -487,7 +489,7 @@ class Compress(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `falltime` attribute.
"""
@@ -502,7 +504,7 @@ class Compress(PyoObject):
:Args:
- x : float
+ x: float
New `lookahead` attribute.
"""
@@ -517,7 +519,7 @@ class Compress(PyoObject):
:Args:
- x : float
+ x: float
New `knee` attribute.
"""
@@ -527,12 +529,12 @@ class Compress(PyoObject):
[obj.setKnee(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(-60., 0., 'lin', 'thresh', self._thresh),
- SLMap(1., 10., 'lin', 'ratio', self._ratio),
- SLMap(0.001, .3, 'lin', 'risetime', self._risetime),
- SLMap(0.001, .3, 'lin', 'falltime', self._falltime),
- SLMap(0, 25, 'lin', 'lookahead', self._lookahead, dataOnly=True),
- SLMap(0, 1, 'lin', 'knee', self._knee, dataOnly=True),
+ self._map_list = [SLMap(-60., 0., 'lin', 'thresh', self._thresh),
+ SLMap(1., 10., 'lin', 'ratio', self._ratio),
+ SLMap(0.001, .3, 'lin', 'risetime', self._risetime),
+ SLMap(0.001, .3, 'lin', 'falltime', self._falltime),
+ SLMap(0, 25, 'lin', 'lookahead', self._lookahead, dataOnly=True),
+ SLMap(0, 1, 'lin', 'knee', self._knee, dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@@ -599,19 +601,19 @@ class Gate(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- thresh : float or PyoObject, optional
+ thresh: float or PyoObject, optional
Level, expressed in dB, below which the gate is closed.
Reference level is 0dB. Defaults to -70.
- risetime : float or PyoObject, optional
+ risetime: float or PyoObject, optional
Time to open the gate in seconds. Defaults to 0.01.
- falltime : float or PyoObject, optional
+ falltime: float or PyoObject, optional
Time to close the gate in seconds. Defaults to 0.05.
- lookahead : float, optional
+ lookahead: float, optional
Delay length, in ms, for the "look-ahead" buffer. Range is
0 -> 25 ms. Defaults to 5.0.
- outputAmp : boolean, optional
+ outputAmp: boolean, optional
If True, the object's output signal will be the gating level
alone, not the gated signal.
@@ -644,9 +646,9 @@ class Gate(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -660,7 +662,7 @@ class Gate(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `thresh` attribute.
"""
@@ -675,7 +677,7 @@ class Gate(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `risetime` attribute.
"""
@@ -690,7 +692,7 @@ class Gate(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `falltime` attribute.
"""
@@ -705,7 +707,7 @@ class Gate(PyoObject):
:Args:
- x : float
+ x: float
New `lookahead` attribute.
"""
@@ -715,10 +717,10 @@ class Gate(PyoObject):
[obj.setLookAhead(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(-100., 0., 'lin', 'thresh', self._thresh),
- SLMap(0.0001, .3, 'lin', 'risetime', self._risetime),
- SLMap(0.0001, .3, 'lin', 'falltime', self._falltime),
- SLMap(0, 25, 'lin', 'lookahead', self._lookahead, dataOnly=True),
+ self._map_list = [SLMap(-100., 0., 'lin', 'thresh', self._thresh),
+ SLMap(0.0001, .3, 'lin', 'risetime', self._risetime),
+ SLMap(0.0001, .3, 'lin', 'falltime', self._falltime),
+ SLMap(0, 25, 'lin', 'lookahead', self._lookahead, dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@@ -767,11 +769,11 @@ class Balance(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- input2 : PyoObject
+ input2: PyoObject
Comparator signal.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Cutoff frequency of the lowpass filter in hertz. Default to 10.
>>> s = Server().boot()
@@ -800,9 +802,9 @@ class Balance(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -818,9 +820,9 @@ class Balance(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -836,7 +838,7 @@ class Balance(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -878,9 +880,9 @@ class Min(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- comp : float or PyoObject, optional
+ comp: float or PyoObject, optional
Comparison value. If `input` is lower than this value,
`input` is send to the output, otherwise, `comp` is outputted.
@@ -907,9 +909,9 @@ class Min(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -923,7 +925,7 @@ class Min(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `comp` attribute.
"""
@@ -958,9 +960,9 @@ class Max(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- comp : float or PyoObject, optional
+ comp: float or PyoObject, optional
Comparison value. If `input` is higher than this value,
`input` is send to the output, otherwise, `comp` is outputted.
@@ -987,9 +989,9 @@ class Max(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1003,7 +1005,7 @@ class Max(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `comp` attribute.
"""
diff --git a/pyolib/effects.py b/pyolib/effects.py
index 0e4e915..a445139 100644
--- a/pyolib/effects.py
+++ b/pyolib/effects.py
@@ -4,6 +4,7 @@ as distortions, delays, chorus and reverbs.
"""
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -23,27 +24,42 @@ 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 *
-from generators import Sine
-from filters import Hilbert
+
+from ._core import *
+from ._maps import *
+from .generators import Sine
+from .filters import Hilbert
class Disto(PyoObject):
"""
- Arc tangent distortion.
+ Kind of Arc tangent distortion.
+
+ Apply a kind of arc tangent distortion with controllable drive, followed
+ by a one pole lowpass filter, to the input signal.
+
+ As of version 0.8.0, this object use a simple but very efficient (4x
+ faster than tanh or atan2 functions) waveshaper formula describe here:
+
+ http://musicdsp.org/archive.php?classid=4#46
- Apply an arc tangent distortion with controllable drive to the input signal.
+ The waveshaper algorithm is:
+
+ y[n] = (1 + k) * x[n] / (1 + k * abs(x[n]))
+
+ where:
+
+ k = (2 * drive) / (1 - drive)
:Parent: :py:class:`PyoObject`
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- drive : float or PyoObject, optional
+ drive: float or PyoObject, optional
Amount of distortion applied to the signal, between 0 and 1.
Defaults to 0.75.
- slope : float or PyoObject, optional
+ slope: float or PyoObject, optional
Slope of the lowpass filter applied after distortion,
between 0 and 1. Defaults to 0.5.
@@ -70,9 +86,9 @@ class Disto(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -86,7 +102,7 @@ class Disto(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `drive` attribute.
"""
@@ -101,7 +117,7 @@ class Disto(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `slope` attribute.
"""
@@ -145,14 +161,14 @@ class Delay(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to delayed.
- delay : float or PyoObject, optional
+ delay: float or PyoObject, optional
Delay time in seconds. Defaults to 0.25.
- feedback : float or PyoObject, optional
+ feedback: float or PyoObject, optional
Amount of output signal sent back into the delay line.
Defaults to 0.
- maxdelay : float, optional
+ maxdelay: float, optional
Maximum delay length in seconds. Available only at initialization.
Defaults to 1.
@@ -190,9 +206,9 @@ class Delay(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to delayed.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -206,7 +222,7 @@ class Delay(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `delay` attribute.
"""
@@ -221,7 +237,7 @@ class Delay(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `feedback` attribute.
"""
@@ -238,7 +254,7 @@ class Delay(PyoObject):
[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),
+ self._map_list = [SLMap(0.001, self._maxdelay, 'log', 'delay', self._delay),
SLMap(0., 1., 'lin', 'feedback', self._feedback),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@@ -272,11 +288,11 @@ class SDelay(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to delayed.
- delay : float or PyoObject, optional
+ delay: float or PyoObject, optional
Delay time in seconds. Defaults to 0.25.
- maxdelay : float, optional
+ maxdelay: float, optional
Maximum delay length in seconds. Available only at initialization.
Defaults to 1.
@@ -308,9 +324,9 @@ class SDelay(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -324,7 +340,7 @@ class SDelay(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `delay` attribute.
"""
@@ -341,7 +357,7 @@ class SDelay(PyoObject):
[obj.reset() for obj in self._base_objs]
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(0.0001, self._maxdelay, 'log', 'delay', self._delay),
+ self._map_list = [SLMap(0.0001, self._maxdelay, 'log', 'delay', self._delay),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@@ -370,15 +386,15 @@ class Waveguide(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency, in cycle per second, of the waveguide (i.e. the inverse
of delay time). Defaults to 100.
- dur : float or PyoObject, optional
+ dur: float or PyoObject, optional
Duration, in seconds, for the waveguide to drop 40 dB below it's
maxima. Defaults to 10.
- minfreq : float, optional
+ minfreq: float, optional
Minimum possible frequency, used to initialized delay length.
Available only at initialization. Defaults to 20.
@@ -405,9 +421,9 @@ class Waveguide(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -421,7 +437,7 @@ class Waveguide(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -436,7 +452,7 @@ class Waveguide(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `dur` attribute.
"""
@@ -445,8 +461,15 @@ class Waveguide(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setDur(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(10, 500., 'log', 'freq', self._freq),
+ self._map_list = [SLMap(10, 500., 'log', 'freq', self._freq),
SLMapDur(self._dur),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@@ -483,18 +506,18 @@ class AllpassWG(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency, in cycle per second, of the waveguide (i.e. the inverse
of delay time). Defaults to 100.
- feed : float or PyoObject, optional
+ 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
+ detune: float or PyoObject, optional
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
+ minfreq: float, optional
Minimum possible frequency, used to initialized delay length.
Available only at initialization. Defaults to 20.
@@ -524,9 +547,9 @@ class AllpassWG(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -540,7 +563,7 @@ class AllpassWG(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -555,7 +578,7 @@ class AllpassWG(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `feed` attribute.
"""
@@ -570,7 +593,7 @@ class AllpassWG(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `detune` attribute.
"""
@@ -579,8 +602,15 @@ class AllpassWG(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setDetune(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(20., 500., 'log', 'freq', self._freq),
+ self._map_list = [SLMap(20., 500., 'log', 'freq', self._freq),
SLMap(0., 1., 'lin', 'feed', self._feed),
SLMap(0., 1., 'lin', 'detune', self._detune),
SLMapMul(self._mul)]
@@ -627,16 +657,16 @@ class Freeverb(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- size : float or PyoObject, optional
+ size: float or PyoObject, optional
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
+ 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.
Defaults to 0.5.
- bal : float or PyoObject, optional
+ bal: float or PyoObject, optional
Balance between wet and dry signal, between 0 and 1. 0 means no
reverb. Defaults to 0.5.
@@ -663,9 +693,9 @@ class Freeverb(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -679,7 +709,7 @@ class Freeverb(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `size` attribute.
"""
@@ -694,7 +724,7 @@ class Freeverb(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `damp` attribute.
"""
@@ -709,7 +739,7 @@ class Freeverb(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `bal` attribute.
"""
@@ -718,10 +748,17 @@ class Freeverb(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setMix(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., 1., 'lin', 'size', self._size),
- SLMap(0., 1., 'lin', 'damp', self._damp),
- SLMap(0., 1., 'lin', 'bal', self._bal),
+ self._map_list = [SLMap(0., 1., 'lin', 'size', self._size),
+ SLMap(0., 1., 'lin', 'damp', self._damp),
+ SLMap(0., 1., 'lin', 'bal', self._bal),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@@ -764,11 +801,11 @@ class Convolve(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- table : PyoTableObject
+ table: PyoTableObject
Table containning the impulse response.
- size : int
+ size: int
Length, in samples, of the convolution. Available at initialization
time only.
@@ -812,9 +849,9 @@ class Convolve(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -828,7 +865,7 @@ class Convolve(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -863,18 +900,18 @@ class WGVerb(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- feedback : float or PyoObject, optional
+ feedback: float or PyoObject, optional
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,
and 0.9 a large hall.
- cutoff : float or PyoObject, optional
+ cutoff: float or PyoObject, optional
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
+ bal: float or PyoObject, optional
Balance between wet and dry signal, between 0 and 1. 0 means no
reverb. Defaults to 0.5.
@@ -901,9 +938,9 @@ class WGVerb(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -917,7 +954,7 @@ class WGVerb(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `feedback` attribute.
"""
@@ -932,7 +969,7 @@ class WGVerb(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `cutoff` attribute.
"""
@@ -947,7 +984,7 @@ class WGVerb(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `bal` attribute.
"""
@@ -956,6 +993,13 @@ class WGVerb(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setMix(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., 1., 'lin', 'feedback', self._feedback),
SLMap(500., 15000., 'log', 'cutoff', self._cutoff),
@@ -1002,14 +1046,14 @@ class Chorus(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- depth : float or PyoObject, optional
+ depth: float or PyoObject, optional
Chorus depth, between 0 and 5. Defaults to 1.
- feedback : float or PyoObject, optional
+ feedback: float or PyoObject, optional
Amount of output signal sent back into the delay lines.
Defaults to 0.25.
- bal : float or PyoObject, optional
+ bal: float or PyoObject, optional
Balance between wet and dry signals, between 0 and 1. 0 means no
chorus. Defaults to 0.5.
@@ -1036,9 +1080,9 @@ class Chorus(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1052,7 +1096,7 @@ class Chorus(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `depth` attribute.
"""
@@ -1067,7 +1111,7 @@ class Chorus(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `feedback` attribute.
"""
@@ -1082,7 +1126,7 @@ class Chorus(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `bal` attribute.
"""
@@ -1091,6 +1135,13 @@ class Chorus(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setMix(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., 5., 'lin', 'depth', self._depth),
SLMap(0., 1., 'lin', 'feedback', self._feedback),
@@ -1134,14 +1185,14 @@ class Harmonizer(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- transpo : float or PyoObject, optional
+ transpo: float or PyoObject, optional
Transposition factor in semitone. Defaults to -7.0.
- feedback : float or PyoObject, optional
+ feedback: float or PyoObject, optional
Amount of output signal sent back into the delay line.
Defaults to 0.
- winsize : float, optional
+ winsize: float, optional
Window size in seconds (max = 1.0).
Defaults to 0.1.
@@ -1168,9 +1219,9 @@ class Harmonizer(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1184,7 +1235,7 @@ class Harmonizer(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `transpo` attribute.
"""
@@ -1199,7 +1250,7 @@ class Harmonizer(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `feedback` attribute.
"""
@@ -1214,7 +1265,7 @@ class Harmonizer(PyoObject):
:Args:
- x : float
+ x: float
New `winsize` attribute.
"""
@@ -1223,10 +1274,17 @@ class Harmonizer(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setWinsize(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(-24.0, 24.0, 'lin', 'transpo', self._transpo),
+ self._map_list = [SLMap(-24.0, 24.0, 'lin', 'transpo', self._transpo),
SLMap(0., 1., 'lin', 'feedback', self._feedback),
- SLMap(0.001, 1, 'log', 'winsize', self._winsize, dataOnly=True),
+ SLMap(0.001, 1, 'log', 'winsize', self._winsize, dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@@ -1266,7 +1324,7 @@ class Delay1(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
>>> s = Server().boot()
@@ -1294,9 +1352,9 @@ class Delay1(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1328,25 +1386,25 @@ class STRev(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- inpos : float or PyoObject, optional
+ inpos: float or PyoObject, optional
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
+ 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.
Defaults to 1.
- cutoff : float or PyoObject, optional
+ cutoff: float or PyoObject, optional
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
+ bal: float or PyoObject, optional
Balance between wet and dry signal, between 0 and 1. 0 means no
reverb. Defaults to 0.5.
- roomSize : float, optional
+ roomSize: float, optional
Delay line length scaler, between 0.25 and 4. Values higher than
1 make the delay lines longer and simulate larger rooms. Defaults to 1.
- firstRefGain : float, optional
+ firstRefGain: float, optional
Gain, in dB, of the first reflexions of the room. Defaults to -3.
>>> s = Server().boot()
@@ -1377,9 +1435,9 @@ class STRev(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1393,7 +1451,7 @@ class STRev(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `inpos` attribute.
"""
@@ -1408,7 +1466,7 @@ class STRev(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `revtime` attribute.
"""
@@ -1423,7 +1481,7 @@ class STRev(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `cutoff` attribute.
"""
@@ -1438,7 +1496,7 @@ class STRev(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `bal` attribute.
"""
@@ -1453,7 +1511,7 @@ class STRev(PyoObject):
:Args:
- x : float
+ x: float
Room size scaler, between 0.25 and 4.0.
"""
@@ -1468,7 +1526,7 @@ class STRev(PyoObject):
:Args:
- x : float
+ x: float
Gain, in dB, of the first reflexions.
"""
@@ -1477,12 +1535,19 @@ class STRev(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setFirstRefGain(wrap(x,i)) for i, obj in enumerate(self._base_players)]
+ def reset(self):
+ """
+ Reset the memory buffer to zeros.
+
+ """
+ [obj.reset() for obj in self._base_players]
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
- self._map_list = [SLMap(0., 1., 'lin', 'inpos', self._inpos),
- SLMap(0.01, 120., 'log', 'revtime', self._revtime),
- SLMap(500., 15000., 'log', 'cutoff', self._cutoff),
- SLMap(0., 1., 'lin', 'bal', self._bal),
- SLMap(0.25, 4., 'lin', 'roomSize', self._roomSize, dataOnly=True),
+ self._map_list = [SLMap(0., 1., 'lin', 'inpos', self._inpos),
+ SLMap(0.01, 120., 'log', 'revtime', self._revtime),
+ SLMap(500., 15000., 'log', 'cutoff', self._cutoff),
+ SLMap(0., 1., 'lin', 'bal', self._bal),
+ SLMap(0.25, 4., 'lin', 'roomSize', self._roomSize, dataOnly=True),
SLMap(-48, 12, 'lin', 'firstRefGain', self._firstRefGain, dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@@ -1547,17 +1612,17 @@ class SmoothDelay(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to delayed.
- delay : float or PyoObject, optional
+ delay: float or PyoObject, optional
Delay time in seconds. Defaults to 0.25.
- feedback : float or PyoObject, optional
+ feedback: float or PyoObject, optional
Amount of output signal sent back into the delay line.
Defaults to 0.
- crossfade : float, optional
+ crossfade: float, optional
Crossfade time, in seconds, between overlaped readers.
Defaults to 0.05.
- maxdelay : float, optional
+ maxdelay: float, optional
Maximum delay length in seconds. Available only at initialization.
Defaults to 1.
@@ -1597,9 +1662,9 @@ class SmoothDelay(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to delayed.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1613,7 +1678,7 @@ class SmoothDelay(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `delay` attribute.
"""
@@ -1628,7 +1693,7 @@ class SmoothDelay(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `feedback` attribute.
"""
@@ -1643,7 +1708,7 @@ class SmoothDelay(PyoObject):
:Args:
- x : float
+ x: float
New `crossfade` attribute.
"""
@@ -1660,7 +1725,7 @@ class SmoothDelay(PyoObject):
[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),
+ 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)]
@@ -1708,9 +1773,9 @@ class FreqShift(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- shift : float or PyoObject, optional
+ shift: float or PyoObject, optional
Amount of shifting in Hertz. Defaults to 100.
>>> s = Server().boot()
@@ -1772,9 +1837,9 @@ class FreqShift(PyoObject):
Parameters:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1788,7 +1853,7 @@ class FreqShift(PyoObject):
Parameters:
- x : float or PyoObject
+ x: float or PyoObject
New `shift` attribute.
"""
@@ -1814,4 +1879,4 @@ class FreqShift(PyoObject):
"""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
+ def shift(self, x): self.setShift(x)
diff --git a/pyolib/expression.py b/pyolib/expression.py
index f6adf66..e4cb58d 100644
--- a/pyolib/expression.py
+++ b/pyolib/expression.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
"""
Prefix expression evaluators.
@@ -87,20 +89,20 @@ Comments
--------
A comment starts with two slashs ( // ) and ends at the end of the line:
-
+
// This is a comment!
Input and Output signals
------------------------
-User has access to the last buffer size of input and output samples.
+User has access to the last buffer size of input and output samples.
To use samples from past input, use $x[n] notation, where n is the position
from the current time. $x[0] is the current input, $x[-1] is the previous
one and $x[-buffersize] is the last available input sample.
To use samples from past output, use $y[n] notation, where n is the position
-from the current time. $y[-1] is the previous output and $y[-buffersize] is
+from the current time. $y[-1] is the previous output and $y[-buffersize] is
the last available output sample.
Here an example of a first-order IIR lowpass filter expression:
@@ -116,8 +118,8 @@ The define keyword starts the definition of a custom function.
(define funcname (body))
-funcname is the name used to call the function in the expression and
-body is the sequence of functions to execute. Arguments of the function
+funcname is the name used to call the function in the expression and
+body is the sequence of functions to execute. Arguments of the function
are extracted directly from the body. They must be named $1, $2, $3, ..., $9.
Example of a sine wave function:
@@ -134,7 +136,7 @@ State variables
---------------
User can create state variable with the keyword "let". This is useful
-to set an intermediate state to be used in multiple places in the
+to set an intermediate state to be used in multiple places in the
processing chain. The syntax is:
(let #var (body))
@@ -159,11 +161,11 @@ The variable is private to a function if created inside a custom function.
)
* (+ (osc 1 #freq) (osc 2 #freq)) 0.2
-State variables can be used to do 1 sample feedback if used before created.
+State variables can be used to do 1 sample feedback if used before created.
Undefined variables are initialized to 0.
(define oscloop (
- (let #xsin
+ (let #xsin
(sin (+ (* (~ $1) (twopi)) (* #xsin $2))) // #xsin used before...
) // ... "let" statement finished!
#xsin // oscloop function outputs #xsin variable
@@ -175,23 +177,23 @@ Undefined variables are initialized to 0.
User variables
--------------
-User variables are created with the keyword "var".
+User variables are created with the keyword "var".
-(var #var (init))
+(var #var (init))
The variable name must begin with a "#".
They are computed only at initialization, but can be changed from the python
script with method calls (varname is a string and value is a float):
-obj.setVar(varname, value)
+obj.setVar(varname, value)
Library importation
-------------------
-Custom functions can be defined in an external file and imported with the
+Custom functions can be defined in an external file and imported with the
"load" function:
-
+
(load path/to/the/file)
The content of the file will be inserted where the load function is called
@@ -202,14 +204,14 @@ Examples
--------
A first-order IIR lowpass filter:
-
+
(var #sr 44100)
(var #cutoff 1000)
(let #coeff (exp (/ (* (* -2 (pi)) #cutoff) #sr)))
+ $x[0] (* (- $y[-1] $x[0]) #coeff)
A LFO'ed hyperbolic tangent distortion:
-
+
// $1 = lfo frequency, $2 = lfo depth
(define lfo (
(+ (* (sin (* (twopi) (~ $1))) (- $2 1)) $2)
@@ -218,7 +220,7 @@ A LFO'ed hyperbolic tangent distortion:
tanh (* $x[0] (lfo .25 10))
A triangle waveform generator (use Sig(0) as input argument to bypass input):
-
+
(var #freq 440)
// $1 = oscillator frequency
(define triangle (
@@ -249,34 +251,42 @@ 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
-from _core import *
-from _maps import *
-from _widgets import createExprEditorWindow
+
+import os, sys
+from ._core import *
+from ._maps import *
+from ._widgets import createExprEditorWindow
+
+if sys.version_info[0] < 3:
+ def to_unicode(s):
+ return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
+else:
+ def to_unicode(s):
+ return s
class Expr(PyoObject):
"""
Prefix audio expression evaluator.
- Expr implements a tiny functional programming language that can be
+ Expr implements a tiny functional programming language that can be
used to write synthesis or signal processing algorithms.
-
+
For documentation about the language, see the module's documentation.
:Parent: :py:class:`PyoObject`
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- expr : str, optional
+ expr: str, optional
Expression to evaluate as a string.
>>> s = Server().boot()
>>> s.start()
>>> proc = '''
>>> (var #boost 1)
- >>> (tanh (* $x[0] #boost))
+ >>> (tanh (* $x[0] #boost))
>>> '''
>>> sf = SfPlayer(SNDS_PATH + "/transparent.aif", loop=True)
>>> ex = Expr(sf, proc, mul=0.4).out()
@@ -295,7 +305,7 @@ class Expr(PyoObject):
expr = self._preproc(expr)
self._in_fader = InputFader(input)
in_fader, expr, mul, add, lmax = convertArgsToLists(self._in_fader, expr, mul, add)
- self._base_objs = [Expr_base(wrap(in_fader,i), wrap(expr,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+ self._base_objs = [Expr_base(wrap(in_fader,i), to_unicode(wrap(expr,i)), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setInput(self, x, fadetime=0.05):
"""
@@ -303,9 +313,9 @@ class Expr(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -319,7 +329,7 @@ class Expr(PyoObject):
:Args:
- x : string
+ x: string
New expression to process.
"""
@@ -328,6 +338,7 @@ class Expr(PyoObject):
if self._editor is not None:
self._editor.update(x)
x = self._preproc(x)
+ x = to_unicode(x)
x, lmax = convertArgsToLists(x)
[obj.setExpr(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
@@ -342,7 +353,7 @@ class Expr(PyoObject):
pyoArgsAssert(self, "sn", varname, value)
varname, value, lmax = convertArgsToLists(varname, value)
[obj.setVar(wrap(varname,j), wrap(value,j)) for i, obj in enumerate(self._base_objs) for j in range(lmax)]
-
+
def _get_matching_bracket_pos(self, x, p1):
count = 1
p2 = p1 + 1
@@ -434,7 +445,7 @@ class Expr(PyoObject):
x = x[:pos] + body2 + x[pos+len(key):]
pos = x.find(key, pos+1)
return x
-
+
def _change_var_names(self, funcname, funcbody):
d = {}
letpos = funcbody.find("let ")
@@ -452,7 +463,7 @@ class Expr(PyoObject):
for label, newlabel in d.items():
funcbody = funcbody.replace(label, newlabel)
return funcbody
-
+
def _preproc(self, x):
# replace load functions with file body
while "(load" in x:
@@ -471,7 +482,7 @@ class Expr(PyoObject):
start = x.find("//")
end = x.find("\n", start)
x = x[:start] + x[end:]
-
+
# expand defined functions
_defined = []
while "define" in x:
@@ -514,10 +525,10 @@ class Expr(PyoObject):
:Args:
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
diff --git a/pyolib/filters.py b/pyolib/filters.py
index 507be15..a280683 100644
--- a/pyolib/filters.py
+++ b/pyolib/filters.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+from __future__ import absolute_import
"""
Different kinds of audio filtering operations.
@@ -35,8 +37,8 @@ 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 *
+from ._core import *
+from ._maps import *
class Biquad(PyoObject):
"""
@@ -46,14 +48,14 @@ class Biquad(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Cutoff or center frequency of the filter. Defaults to 1000.
- q : float or PyoObject, optional
+ q: float or PyoObject, optional
Q of the filter, defined (for bandpass filters) as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
- type : int, optional
+ type: int, optional
Filter type. Five possible values :
0. lowpass (default)
1. highpass
@@ -85,9 +87,9 @@ class Biquad(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -101,7 +103,7 @@ class Biquad(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -116,7 +118,7 @@ class Biquad(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `q` attribute.
"""
@@ -131,7 +133,7 @@ class Biquad(PyoObject):
:Args:
- x : int
+ x: int
New `type` attribute.
0.lowpass
1. highpass
@@ -192,21 +194,21 @@ class Biquadx(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Cutoff or center frequency of the filter. Defaults to 1000.
- q : float or PyoObject, optional
+ q: float or PyoObject, optional
Q of the filter, defined (for bandpass filters) as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
- type : int, optional
+ type: int, optional
Filter type. Five possible values :
0. lowpass (default)
1. highpass
2. bandpass
3. bandstop
4. allpass
- stages : int, optional
+ stages: int, optional
The number of filtering stages in the filter stack. Defaults to 4.
>>> s = Server().boot()
@@ -234,9 +236,9 @@ class Biquadx(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -250,7 +252,7 @@ class Biquadx(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -265,7 +267,7 @@ class Biquadx(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `q` attribute.
"""
@@ -280,7 +282,7 @@ class Biquadx(PyoObject):
:Args:
- x : int
+ x: int
New `type` attribute.
0. lowpass
1. highpass
@@ -300,7 +302,7 @@ class Biquadx(PyoObject):
:Args:
- x : int
+ x: int
New `stages` attribute.
"""
@@ -371,19 +373,19 @@ class Biquada(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- b0 : float or PyoObject, optional
+ b0: float or PyoObject, optional
Amplitude of the current sample. Defaults to 0.005066.
- b1 : float or PyoObject, optional
+ b1: float or PyoObject, optional
Amplitude of the first input sample delayed. Defaults to 0.010132.
- b2 : float or PyoObject, optional
+ b2: float or PyoObject, optional
Amplitude of the second input sample delayed. Defaults to 0.005066.
- a0 : float or PyoObject, optional
+ a0: float or PyoObject, optional
Overall gain coefficient. Defaults to 1.070997.
- a1 : float or PyoObject, optional
+ a1: float or PyoObject, optional
Amplitude of the first output sample delayed. Defaults to -1.979735.
- a2 : float or PyoObject, optional
+ a2: float or PyoObject, optional
Amplitude of the second output sample delayed. Defaults to 0.929003.
>>> s = Server().boot()
@@ -413,9 +415,9 @@ class Biquada(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -429,7 +431,7 @@ class Biquada(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `b0` attribute.
"""
@@ -442,7 +444,7 @@ class Biquada(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `b1` attribute.
"""
@@ -455,7 +457,7 @@ class Biquada(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `b2` attribute.
"""
@@ -468,7 +470,7 @@ class Biquada(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `a0` attribute.
"""
@@ -481,7 +483,7 @@ class Biquada(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `a1` attribute.
"""
@@ -494,7 +496,7 @@ class Biquada(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `a2` attribute.
"""
@@ -507,17 +509,17 @@ class Biquada(PyoObject):
:Args:
- b0 : float or PyoObject, optional
+ b0: float or PyoObject, optional
New `b0` attribute.
- b1 : float or PyoObject, optional
+ b1: float or PyoObject, optional
New `b1` attribute.
- b2 : float or PyoObject, optional
+ b2: float or PyoObject, optional
New `b2` attribute.
- a0 : float or PyoObject, optional
+ a0: float or PyoObject, optional
New `a0` attribute.
- a1 : float or PyoObject, optional
+ a1: float or PyoObject, optional
New `a1` attribute.
- a2 : float or PyoObject, optional
+ a2: float or PyoObject, optional
New `a2` attribute.
"""
@@ -594,17 +596,17 @@ class EQ(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Cutoff or center frequency of the filter. Defaults to 1000.
- q : float or PyoObject, optional
+ q: float or PyoObject, optional
Q of the filter, defined as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
- boost : float or PyoObject, optional
+ boost: float or PyoObject, optional
Gain, expressed in dB, to add or remove at the center frequency.
Default to -3.
- type : int, optional
+ type: int, optional
Filter type. Three possible values :
0. peak/notch (default)
1. lowshelf
@@ -637,9 +639,9 @@ class EQ(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -653,7 +655,7 @@ class EQ(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -668,7 +670,7 @@ class EQ(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `q` attribute.
"""
@@ -683,7 +685,7 @@ class EQ(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `boost` attribute.
"""
@@ -698,7 +700,7 @@ class EQ(PyoObject):
:Args:
- x : int
+ x: int
New `type` attribute.
0. peak
1. lowshelf
@@ -760,9 +762,9 @@ class Tone(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Cutoff frequency of the filter in hertz. Default to 1000.
>>> s = Server().boot()
@@ -787,9 +789,9 @@ class Tone(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -803,7 +805,7 @@ class Tone(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -838,9 +840,9 @@ class Atone(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Cutoff frequency of the filter in hertz. Default to 1000.
>>> s = Server().boot()
@@ -865,9 +867,9 @@ class Atone(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -881,7 +883,7 @@ class Atone(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -919,13 +921,13 @@ class Port(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- risetime : float or PyoObject, optional
+ risetime: float or PyoObject, optional
Time to reach upward value in seconds. Defaults to 0.05.
- falltime : float or PyoObject, optional
+ falltime: float or PyoObject, optional
Time to reach downward value in seconds. Defaults to 0.05.
- init : float, optional
+ init: float, optional
Initial state of the internal memory. Available at intialization
time only. Defaults to 0.
@@ -956,9 +958,9 @@ class Port(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -972,7 +974,7 @@ class Port(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `risetime` attribute.
"""
@@ -987,7 +989,7 @@ class Port(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `falltime` attribute.
"""
@@ -997,8 +999,8 @@ class Port(PyoObject):
[obj.setFallTime(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.001, 10., 'lin', 'risetime', self._risetime),
- SLMap(0.001, 10., 'lin', 'falltime', self._falltime)]
+ self._map_list = [SLMap(0.001, 10., 'log', 'risetime', self._risetime),
+ SLMap(0.001, 10., 'log', 'falltime', self._falltime)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@property
@@ -1030,7 +1032,7 @@ class DCBlock(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
>>> s = Server().boot()
@@ -1054,9 +1056,9 @@ class DCBlock(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1084,18 +1086,18 @@ class BandSplit(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- num : int, optional
+ num: int, optional
Number of frequency bands created. Available at initialization
time only. Defaults to 6.
- min : float, optional
+ min: float, optional
Lowest frequency. Available at initialization time only.
Defaults to 20.
- max : float, optional
+ max: float, optional
Highest frequency. Available at initialization time only.
Defaults to 20000.
- q : float or PyoObject, optional
+ q: float or PyoObject, optional
Q of the filters, defined as center frequency / bandwidth.
Should be between 1 and 500. Defaults to 1.
@@ -1130,9 +1132,9 @@ class BandSplit(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1146,7 +1148,7 @@ class BandSplit(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `q` attribute.
"""
@@ -1187,16 +1189,16 @@ class FourBand(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq1 : float or PyoObject, optional
+ freq1: float or PyoObject, optional
First crossover frequency. First band will contain signal
from 0 Hz to `freq1` Hz. Defaults to 150.
- freq2 : float or PyoObject, optional
+ freq2: float or PyoObject, optional
Second crossover frequency. Second band will contain signal
from `freq1` Hz to `freq2`. `freq2` is the lower limit of the
third band signal. Defaults to 500.
- freq3 : float or PyoObject, optional
+ freq3: float or PyoObject, optional
Third crossover frequency. It's the upper limit of the third
band signal and fourth band will contain signal from `freq3`
to sr/2. Defaults to 2000.
@@ -1231,9 +1233,9 @@ class FourBand(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1247,7 +1249,7 @@ class FourBand(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq1` attribute.
"""
@@ -1262,7 +1264,7 @@ class FourBand(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq2` attribute.
"""
@@ -1277,7 +1279,7 @@ class FourBand(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq3` attribute.
"""
@@ -1342,7 +1344,7 @@ class Hilbert(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
.. note::
@@ -1400,10 +1402,10 @@ class Hilbert(PyoObject):
:Args:
- identifier : string {"real", "imag"}
+ identifier: string {"real", "imag"}
Address string parameter identifying audio stream.
Defaults to "real".
- all : boolean, optional
+ 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 stream will be returned as a float.
@@ -1421,9 +1423,9 @@ class Hilbert(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1450,14 +1452,14 @@ class Allpass(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- delay : float or PyoObject, optional
+ delay: float or PyoObject, optional
Delay time in seconds. Defaults to 0.01.
- feedback : float or PyoObject, optional
+ feedback: float or PyoObject, optional
Amount of output signal sent back into the delay line.
Defaults to 0.
- maxdelay : float, optional
+ maxdelay: float, optional
Maximum delay length in seconds. Available only at initialization.
Defaults to 1.
@@ -1492,9 +1494,9 @@ class Allpass(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1508,7 +1510,7 @@ class Allpass(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `delay` attribute.
"""
@@ -1523,7 +1525,7 @@ class Allpass(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `feedback` attribute.
"""
@@ -1533,7 +1535,7 @@ class Allpass(PyoObject):
[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(0.001, self._maxdelay, 'log', 'delay', self._delay),
+ self._map_list = [SLMap(0.001, self._maxdelay, 'log', 'delay', self._delay),
SLMap(0., 1., 'lin', 'feedback', self._feedback),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@@ -1571,11 +1573,11 @@ class Allpass2(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
- bw : float or PyoObject, optional
+ bw: float or PyoObject, optional
Bandwidth of the filter in Hertz. Defaults to 100.
>>> s = Server().boot()
@@ -1606,9 +1608,9 @@ class Allpass2(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1622,7 +1624,7 @@ class Allpass2(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -1637,7 +1639,7 @@ class Allpass2(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `bw` attribute.
"""
@@ -1682,18 +1684,18 @@ class Phaser(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Center frequency of the first notch. Defaults to 1000.
- spread : float or PyoObject, optional
+ spread: float or PyoObject, optional
Spreading factor for upper notch frequencies. Defaults to 1.1.
- q : float or PyoObject, optional
+ q: float or PyoObject, optional
Q of the filter as center frequency / bandwidth. Defaults to 10.
- feedback : float or PyoObject, optional
+ feedback: float or PyoObject, optional
Amount of output signal which is fed back into the input of the
allpass chain. Defaults to 0.
- num : int, optional
+ num: int, optional
The number of allpass stages in series. Defines the number of
notches in the spectrum. Defaults to 8.
@@ -1716,7 +1718,7 @@ class Phaser(PyoObject):
self._spread = spread
self._q = q
self._feedback = feedback
- self._num= num
+ self._num = num
self._in_fader = InputFader(input)
in_fader, freq, spread, q, feedback, num, mul, add, lmax = convertArgsToLists(self._in_fader, freq, spread, q, feedback, num, mul, add)
self._base_objs = [Phaser_base(wrap(in_fader,i), wrap(freq,i), wrap(spread,i), wrap(q,i), wrap(feedback,i), wrap(num,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
@@ -1727,9 +1729,9 @@ class Phaser(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1743,7 +1745,7 @@ class Phaser(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -1758,7 +1760,7 @@ class Phaser(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `spread` attribute.
"""
@@ -1773,7 +1775,7 @@ class Phaser(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `q` attribute.
"""
@@ -1788,7 +1790,7 @@ class Phaser(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `feedback` attribute.
"""
@@ -1855,27 +1857,27 @@ class Vocoder(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Spectral envelope. Gives the spectral properties of the bank of filters.
For best results, this signal must have a dynamic spectrum, both for
amplitudes and frequencies.
- input2 : PyoObject
+ input2: PyoObject
Exciter. Spectrum to filter. For best results, this signal must have a
broadband spectrum with few amplitude variations.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
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
+ spread: float or PyoObject, optional
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
+ q: float or PyoObject, optional
Q of the filters as `center frequency / bandwidth`. Higher values imply
more resonance around the center frequency. Defaults to 20.
- slope : float or PyoObject, optional
+ slope: float or PyoObject, optional
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
+ stages: int, optional
The number of bands in the filter bank. Defines the number of notches in
the spectrum. Defaults to 24.
@@ -1914,9 +1916,9 @@ class Vocoder(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
The spectral envelope.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1930,9 +1932,9 @@ class Vocoder(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
The exciter.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1946,7 +1948,7 @@ class Vocoder(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -1961,7 +1963,7 @@ class Vocoder(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `spread` attribute.
"""
@@ -1976,7 +1978,7 @@ class Vocoder(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `q` attribute.
"""
@@ -1991,7 +1993,7 @@ class Vocoder(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `slope` attribute.
"""
@@ -2006,7 +2008,7 @@ class Vocoder(PyoObject):
:Args:
- x : int
+ x: int
New `stages` attribute.
"""
@@ -2020,7 +2022,7 @@ class Vocoder(PyoObject):
SLMap(0.25, 2, "lin", "spread", self._spread),
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),
+ SLMap(2, 64, 'lin', 'stages', self._stages, res="int", dataOnly=True),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@@ -2086,21 +2088,21 @@ class IRWinSinc(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency cutoff for lowpass and highpass and center frequency for
bandjrect and bandpass filters, expressed in Hz. Defaults to 1000.
- bw : float or PyoObject, optional
+ bw: float or PyoObject, optional
Bandwidth, expressed in Hertz, for bandreject and bandpass filters.
Defaults to 500.
- type : int, optional
+ type: int, optional
Filter type. Four possible values :
0. lowpass (default)
1. highpass
2. bandreject
3. bandpass
- order : int {even number}, optional
+ order: int {even number}, optional
Length, in samples, of the filter kernel used for convolution. Available
at initialization time only. Defaults to 256.
@@ -2132,7 +2134,7 @@ class IRWinSinc(PyoObject):
self._type = type
if (order % 2) != 0:
order += 1
- print "order argument of IRWinSinc must be even, set to %i" % order
+ 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)
@@ -2144,9 +2146,9 @@ class IRWinSinc(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -2160,7 +2162,7 @@ class IRWinSinc(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -2175,7 +2177,7 @@ class IRWinSinc(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `bw` attribute.
"""
@@ -2190,7 +2192,7 @@ class IRWinSinc(PyoObject):
:Args:
- x : int
+ x: int
New `type` attribute.
0. lowpass
1. highpass
@@ -2252,9 +2254,9 @@ class IRAverage(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- order : int {even number}, optional
+ order: int {even number}, optional
Length, in samples, of the filter kernel used for convolution. Available
at initialization time only. Defaults to 256.
@@ -2280,7 +2282,7 @@ class IRAverage(PyoObject):
self._input = input
if (order % 2) != 0:
order += 1
- print "order argument of IRAverage must be even, set to %i" % order
+ 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)
@@ -2292,9 +2294,9 @@ class IRAverage(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -2323,21 +2325,21 @@ class IRPulse(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Fundamental frequency of the spikes in the filter's spectrum, expressed
in Hertz. Defaults to 500.
- bw : float or PyoObject, optional
+ bw: float or PyoObject, optional
Frequency, expressed in Hertz, of the first notch in the comb filtering.
Defaults to 2500.
- type : int, optional
+ type: int, optional
Filter type. Four possible values :
0. Pulse & comb (default)
1. Pulse & comb & lowpass
2. Pulse (odd harmonics) & comb
3. Pulse (odd harmonics) & comb & lowpass
- order : int {even number}, optional
+ order: int {even number}, optional
Length, in samples, of the filter kernel used for convolution. Available
at initialization time only. Defaults to 256.
@@ -2367,7 +2369,7 @@ class IRPulse(PyoObject):
self._type = type
if (order % 2) != 0:
order += 1
- print "order argument of IRPulse must be even, set to %i" % order
+ 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)
@@ -2379,9 +2381,9 @@ class IRPulse(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -2395,7 +2397,7 @@ class IRPulse(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -2410,7 +2412,7 @@ class IRPulse(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `bw` attribute.
"""
@@ -2425,7 +2427,7 @@ class IRPulse(PyoObject):
:Args:
- x : int
+ x: int
New `type` attribute. Filter type. Four possible values:
0. Pulse & comb (default)
1. Pulse & comb & lowpass
@@ -2485,17 +2487,17 @@ class IRFM(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- carrier : float or PyoObject, optional
+ carrier: float or PyoObject, optional
Carrier frequency in cycles per second. Defaults to 1000.
- ratio : float or PyoObject, optional
+ ratio: float or PyoObject, optional
A factor that, when multiplied by the `carrier` parameter,
gives the modulator frequency. Defaults to 0.5.
- index : float or PyoObject, optional
+ 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
+ order: int {even number}, optional
Length, in samples, of the filter kernel used for convolution.
Available at initialization time only. Defaults to 256.
@@ -2526,7 +2528,7 @@ class IRFM(PyoObject):
self._index = index
if (order % 2) != 0:
order += 1
- print "order argument of IRFM must be even, set to %i" % order
+ 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)
@@ -2538,9 +2540,9 @@ class IRFM(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -2554,7 +2556,7 @@ class IRFM(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `carrier` attribute.
"""
@@ -2569,7 +2571,7 @@ class IRFM(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `ratio` attribute.
"""
@@ -2584,7 +2586,7 @@ class IRFM(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `index` attribute.
"""
@@ -2635,17 +2637,17 @@ class SVF(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
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: float or PyoObject, optional
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
+ type: float or PyoObject, optional
This value, in the range 0 to 1, controls the filter type crossfade
on the continuum lowpass-bandpass-highpass.
@@ -2679,9 +2681,9 @@ class SVF(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2696,7 +2698,7 @@ class SVF(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -2711,7 +2713,7 @@ class SVF(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `q` attribute.
"""
@@ -2729,7 +2731,7 @@ class SVF(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `type` attribute.
"""
@@ -2786,9 +2788,9 @@ class Average(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- size : int, optional
+ size: int, optional
Filter kernel size, which is the number of samples used in the
moving average. Default to 10.
@@ -2814,9 +2816,9 @@ class Average(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -2830,7 +2832,7 @@ class Average(PyoObject):
:Args:
- x : int
+ x: int
New `size` attribute.
"""
@@ -2872,11 +2874,11 @@ class Reson(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
- q : float or PyoObject, optional
+ q: float or PyoObject, optional
Q of the filter, defined as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
@@ -2903,9 +2905,9 @@ class Reson(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2919,7 +2921,7 @@ class Reson(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -2934,7 +2936,7 @@ class Reson(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `q` attribute.
"""
@@ -2985,14 +2987,14 @@ class Resonx(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
- q : float or PyoObject, optional
+ q: float or PyoObject, optional
Q of the filter, defined as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
- stages : int, optional
+ stages: int, optional
The number of filtering stages in the filter stack. Defaults to 4.
>>> s = Server().boot()
@@ -3019,9 +3021,9 @@ class Resonx(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -3035,7 +3037,7 @@ class Resonx(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -3050,7 +3052,7 @@ class Resonx(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `q` attribute.
"""
@@ -3065,7 +3067,7 @@ class Resonx(PyoObject):
:Args:
- x : int
+ x: int
New `stages` attribute.
"""
@@ -3118,9 +3120,9 @@ class ButLP(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Cutoff frequency of the filter in hertz. Default to 1000.
>>> s = Server().boot()
@@ -3145,9 +3147,9 @@ class ButLP(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -3161,7 +3163,7 @@ class ButLP(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -3200,9 +3202,9 @@ class ButHP(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Cutoff frequency of the filter in hertz. Default to 1000.
>>> s = Server().boot()
@@ -3227,9 +3229,9 @@ class ButHP(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -3243,7 +3245,7 @@ class ButHP(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -3282,11 +3284,11 @@ class ButBP(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
- q : float or PyoObject, optional
+ q: float or PyoObject, optional
Q of the filter, defined as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
@@ -3313,9 +3315,9 @@ class ButBP(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -3329,7 +3331,7 @@ class ButBP(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -3344,7 +3346,7 @@ class ButBP(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `q` attribute.
"""
@@ -3391,11 +3393,11 @@ class ButBR(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
- q : float or PyoObject, optional
+ q: float or PyoObject, optional
Q of the filter, defined as freq/bandwidth.
Should be between 1 and 500. Defaults to 1.
@@ -3422,9 +3424,9 @@ class ButBR(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -3438,7 +3440,7 @@ class ButBR(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -3453,7 +3455,7 @@ class ButBR(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `q` attribute.
"""
@@ -3488,6 +3490,116 @@ class ButBR(PyoObject):
@q.setter
def q(self, x): self.setQ(x)
+class MoogLP(PyoObject):
+ """
+ A fourth-order resonant lowpass filter.
+
+ Digital approximation of the Moog VCF, giving a decay of 24dB/oct.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ input: PyoObject
+ Input signal to process.
+ freq: float or PyoObject, optional
+ Cutoff frequency of the filter. Defaults to 1000.
+ res: float or PyoObject, optional
+ Amount of Resonance of the filter, usually between 0 (no resonance)
+ and 1 (medium resonance). Self-oscillation occurs when the
+ resonance is >= 1. Can go up to 10. Defaults to 0.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> ph = Phasor(40)
+ >>> sqr = Round(ph, add=-0.5)
+ >>> lfo = Sine(freq=[.4, .5], mul=2000, add=2500)
+ >>> fil = MoogLP(sqr, freq=lfo, res=1.25).out()
+
+ """
+ def __init__(self, input, freq=1000, res=0, mul=1, add=0):
+ pyoArgsAssert(self, "oOOOO", input, freq, res, mul, add)
+ PyoObject.__init__(self, mul, add)
+ self._input = input
+ self._freq = freq
+ self._res = res
+ self._in_fader = InputFader(input)
+ in_fader, freq, res, mul, add, lmax = convertArgsToLists(self._in_fader, freq, res, mul, add)
+ self._base_objs = [MoogLP_base(wrap(in_fader,i), wrap(freq,i), wrap(res,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. 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)]
+
+ def setRes(self, x):
+ """
+ Replace the `res` attribute.
+
+ :Args:
+
+ x: float or PyoObject
+ New `res` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._res = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setRes(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", "res", self._res),
+ SLMapMul(self._mul)]
+ 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 freq(self):
+ """float or PyoObject. Cutoff frequency of the filter."""
+ return self._freq
+ @freq.setter
+ def freq(self, x): self.setFreq(x)
+
+ @property
+ def res(self):
+ """float or PyoObject. Amount of resonance of the filter."""
+ return self._res
+ @res.setter
+ def res(self, x): self.setRes(x)
+
class ComplexRes(PyoObject):
"""
Complex one-pole resonator filter.
@@ -3499,11 +3611,11 @@ class ComplexRes(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Center frequency of the filter. Defaults to 1000.
- decay : float or PyoObject, optional
+ decay: float or PyoObject, optional
Decay time, in seconds, for the filter's response.
Defaults to 0.25.
@@ -3532,9 +3644,9 @@ class ComplexRes(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -3548,7 +3660,7 @@ class ComplexRes(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute.
"""
@@ -3563,7 +3675,7 @@ class ComplexRes(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `decay` attribute.
"""
@@ -3596,4 +3708,4 @@ class ComplexRes(PyoObject):
"""float or PyoObject. Decay time of the filter's response."""
return self._decay
@decay.setter
- def decay(self, x): self.setDecay(x)
\ No newline at end of file
+ def decay(self, x): self.setDecay(x)
diff --git a/pyolib/fourier.py b/pyolib/fourier.py
index b30b25f..ae8c0a7 100644
--- a/pyolib/fourier.py
+++ b/pyolib/fourier.py
@@ -9,6 +9,8 @@ spectral domain.
"""
+from __future__ import division
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -28,8 +30,9 @@ 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 *
+
+from ._core import *
+from ._maps import *
class FFT(PyoObject):
"""
@@ -48,18 +51,18 @@ class FFT(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- size : int {pow-of-two > 4}, optional
+ 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.
- overlaps : int, optional
+ 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. Defaults to 4.
- wintype : int, optional
+ wintype: int, optional
Shape of the envelope used to filter each input frame.
Possible shapes are :
0. rectangular (no windowing)
@@ -112,7 +115,7 @@ class FFT(PyoObject):
self._base_players = []
for j in range(overlaps):
for i in range(lmax):
- hopsize = wrap(size,i) * j / overlaps
+ hopsize = wrap(size,i) * j // overlaps
self._base_players.append(FFTMain_base(wrap(in_fader,i), wrap(size,i), hopsize, wrap(wintype,i)))
self._real_objs = []
self._imag_objs = []
@@ -147,10 +150,10 @@ class FFT(PyoObject):
:Args:
- identifier : string {"real", "imag", "bin"}
+ identifier: string {"real", "imag", "bin"}
Address string parameter identifying audio stream.
Defaults to "real".
- all : boolean, optional
+ 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 stream will be returned as a float.
@@ -168,9 +171,9 @@ class FFT(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -202,17 +205,17 @@ class FFT(PyoObject):
:Args:
- x : int
+ x: int
new `size` attribute.
"""
pyoArgsAssert(self, "i", x)
self._size = x
x, lmax = convertArgsToLists(x)
- poly = len(self._base_players) / self._overlaps
+ poly = len(self._base_players) // self._overlaps
for j in range(self._overlaps):
for i in range(poly):
- hopsize = wrap(x,i) * j / self._overlaps
+ hopsize = wrap(x,i) * j // self._overlaps
self._base_players[j*poly+i].setSize(wrap(x,i), hopsize)
def setWinType(self, x):
@@ -221,7 +224,7 @@ class FFT(PyoObject):
:Args:
- x : int
+ x: int
new `wintype` attribute.
"""
@@ -266,22 +269,22 @@ class IFFT(PyoObject):
:Args:
- inreal : PyoObject
+ inreal: PyoObject
Input `real` signal.
- inimag : PyoObject
+ inimag: PyoObject
Input `imaginary` signal.
- size : int {pow-of-two > 4}, optional
+ 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`
attribute of the former FFT object. Defaults to 1024.
- overlaps : int, optional
+ 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`
atribute of the former FFT object. Defaults to 4.
- wintype : int, optional
+ wintype: int, optional
Shape of the envelope used to filter each output frame.
Possible shapes are :
0. rectangular (no windowing)
@@ -328,9 +331,9 @@ class IFFT(PyoObject):
self._in_fader2 = InputFader(inimag)
in_fader, in_fader2, size, wintype, mul, add, lmax = convertArgsToLists(self._in_fader, self._in_fader2, size, wintype, mul, add)
self._base_objs = []
- ratio = lmax / overlaps
+ ratio = lmax // overlaps
for i in range(lmax):
- hopsize = wrap(size,i) * ((i/ratio)%overlaps) / overlaps
+ hopsize = wrap(size,i) * ((i // ratio) % overlaps) // overlaps
self._base_objs.append(IFFT_base(wrap(in_fader,i), wrap(in_fader2,i), wrap(size,i), hopsize, wrap(wintype,i), wrap(mul,i), wrap(add,i)))
def __len__(self):
@@ -342,9 +345,9 @@ class IFFT(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New input `real` signal.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -358,9 +361,9 @@ class IFFT(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New input `imag` signal.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -374,16 +377,16 @@ class IFFT(PyoObject):
:Args:
- x : int
+ x: int
new `size` attribute.
"""
pyoArgsAssert(self, "i", x)
self._size = x
x, lmax = convertArgsToLists(x)
- ratio = len(self._base_objs) / self._overlaps
+ ratio = len(self._base_objs) // self._overlaps
for i, obj in enumerate(self._base_objs):
- hopsize = wrap(x,i) * ((i/ratio)%self._overlaps) / self._overlaps
+ hopsize = wrap(x,i) * ((i // ratio) % self._overlaps) // self._overlaps
self._base_objs[i].setSize(wrap(x,i), hopsize)
def setWinType(self, x):
@@ -392,7 +395,7 @@ class IFFT(PyoObject):
:Args:
- x : int
+ x: int
new `wintype` attribute.
"""
@@ -449,9 +452,9 @@ class CarToPol(PyoObject):
:Args:
- inreal : PyoObject
+ inreal: PyoObject
Real input signal.
- inimag : PyoObject
+ inimag: PyoObject
Imaginary input signal.
.. note::
@@ -518,10 +521,10 @@ class CarToPol(PyoObject):
:Args:
- identifier : string {"mag", "ang"}
+ identifier: string {"mag", "ang"}
Address string parameter identifying audio stream.
Defaults to "mag".
- all : boolean, optional
+ 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 stream will be returned as a float.
@@ -539,9 +542,9 @@ class CarToPol(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -555,9 +558,9 @@ class CarToPol(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -595,9 +598,9 @@ class PolToCar(PyoObject):
:Args:
- inmag : PyoObject
+ inmag: PyoObject
Magintude input signal.
- inang : PyoObject
+ inang: PyoObject
Angle input signal.
.. note::
@@ -664,10 +667,10 @@ class PolToCar(PyoObject):
:Args:
- identifier : string {"real", "imag"}
+ identifier: string {"real", "imag"}
Address string parameter identifying audio stream.
Defaults to "mag".
- all : boolean, optional
+ 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 stream will be returned as a float.
@@ -685,9 +688,9 @@ class PolToCar(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -701,9 +704,9 @@ class PolToCar(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -743,12 +746,12 @@ class FrameDelta(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Phase input signal, usually from an FFT analysis.
- framesize : int, optional
+ framesize: int, optional
Frame size in samples. Usually the same as the FFT size.
Defaults to 1024.
- overlaps : int, optional
+ overlaps: int, optional
Number of overlaps in incomming signal. Usually the same
as the FFT overlaps. Defaults to 4.
@@ -786,7 +789,7 @@ class FrameDelta(PyoObject):
self._overlaps = overlaps
self._in_fader = InputFader(input)
in_fader, framesize, overlaps, mul, add, lmax = convertArgsToLists(self._in_fader, framesize, overlaps, mul, add)
- num_of_mains = len(self._in_fader) / self._overlaps
+ num_of_mains = len(self._in_fader) // self._overlaps
self._base_players = []
for j in range(num_of_mains):
objs_list = []
@@ -797,7 +800,7 @@ class FrameDelta(PyoObject):
self._base_objs = []
for i in range(lmax):
base_player = i % num_of_mains
- overlap = i / num_of_mains
+ overlap = i // num_of_mains
self._base_objs.append(FrameDelta_base(self._base_players[base_player], overlap, wrap(mul,i), wrap(add,i)))
def out(self, chnl=0, inc=1, dur=0, delay=0):
@@ -809,9 +812,9 @@ class FrameDelta(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -825,7 +828,7 @@ class FrameDelta(PyoObject):
:Args:
- x : int
+ x: int
new `framesize` attribute.
"""
@@ -866,12 +869,12 @@ class FrameAccum(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Phase input signal.
- framesize : int, optional
+ framesize: int, optional
Frame size in samples. Usually same as the FFT size.
Defaults to 1024.
- overlaps : int, optional
+ overlaps: int, optional
Number of overlaps in incomming signal. Usually the same
as the FFT overlaps. Defaults to 4.
@@ -909,7 +912,7 @@ class FrameAccum(PyoObject):
self._overlaps = overlaps
self._in_fader = InputFader(input)
in_fader, framesize, overlaps, mul, add, lmax = convertArgsToLists(self._in_fader, framesize, overlaps, mul, add)
- num_of_mains = len(self._in_fader) / self._overlaps
+ num_of_mains = len(self._in_fader) // self._overlaps
self._base_players = []
for j in range(num_of_mains):
objs_list = []
@@ -920,7 +923,7 @@ class FrameAccum(PyoObject):
self._base_objs = []
for i in range(lmax):
base_player = i % num_of_mains
- overlap = i / num_of_mains
+ overlap = i // num_of_mains
self._base_objs.append(FrameAccum_base(self._base_players[base_player], overlap, wrap(mul,i), wrap(add,i)))
def out(self, chnl=0, inc=1, dur=0, delay=0):
@@ -932,9 +935,9 @@ class FrameAccum(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -948,7 +951,7 @@ class FrameAccum(PyoObject):
:Args:
- x : int
+ x: int
new `framesize` attribute.
"""
@@ -982,23 +985,23 @@ class Vectral(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Magnitude input signal, usually from an FFT analysis.
- framesize : int, optional
+ framesize: int, optional
Frame size in samples. Usually the same as the FFT size.
Defaults to 1024.
- overlaps : int, optional
+ overlaps: int, optional
Number of overlaps in incomming signal. Usually the same
as the FFT overlaps. Defaults to 4.
- up : float or PyoObject, optional
+ up: float or PyoObject, optional
Filter coefficient for increasing bins, between 0 and 1.
Lower values results in a longer ramp time for bin magnitude.
Defaults to 1.
- down : float or PyoObject, optional
+ down: float or PyoObject, optional
Filter coefficient for decreasing bins, between 0 and 1.
Lower values results in a longer decay time for bin magnitude.
Defaults to 0.7
- damp : float or PyoObject, optional
+ damp: float or PyoObject, optional
High frequencies damping factor, between 0 and 1. Lower values
mean more damping. Defaults to 0.9.
@@ -1030,7 +1033,7 @@ class Vectral(PyoObject):
self._damp = damp
self._in_fader = InputFader(input)
in_fader, framesize, overlaps, up, down, damp, mul, add, lmax = convertArgsToLists(self._in_fader, framesize, overlaps, up, down, damp, mul, add)
- num_of_mains = len(self._in_fader) / self._overlaps
+ num_of_mains = len(self._in_fader) // self._overlaps
self._base_players = []
for j in range(num_of_mains):
objs_list = []
@@ -1041,7 +1044,7 @@ class Vectral(PyoObject):
self._base_objs = []
for i in range(lmax):
base_player = i % num_of_mains
- overlap = i / num_of_mains
+ overlap = i // num_of_mains
self._base_objs.append(Vectral_base(self._base_players[base_player], overlap, wrap(mul,i), wrap(add,i)))
def out(self, chnl=0, inc=1, dur=0, delay=0):
@@ -1053,9 +1056,9 @@ class Vectral(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1069,7 +1072,7 @@ class Vectral(PyoObject):
:Args:
- x : int
+ x: int
new `framesize` attribute.
"""
@@ -1084,7 +1087,7 @@ class Vectral(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `up` attribute.
"""
@@ -1099,7 +1102,7 @@ class Vectral(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `down` attribute.
"""
@@ -1114,7 +1117,7 @@ class Vectral(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `damp` attribute.
"""
@@ -1177,20 +1180,20 @@ class CvlVerb(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- impulse : string, optional
+ impulse: string, optional
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
in pyolib SNDS_PATH folder.
- size : int {pow-of-two}, optional
+ size: int {pow-of-two}, optional
The size in samples of each partition of the impulse file. Small size means
smaller latency but more computation time. If not a power-of-2, the object
will find the next power-of-2 greater and use that as the actual partition size.
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
+ bal: float or PyoObject, optional
Balance between wet and dry signal, between 0 and 1. 0 means no
reverb. Defaults to 0.25.
@@ -1222,9 +1225,9 @@ class CvlVerb(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1238,7 +1241,7 @@ class CvlVerb(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `bal` attribute.
"""
@@ -1264,4 +1267,4 @@ class CvlVerb(PyoObject):
"""float or PyoObject. Wet / dry balance."""
return self._bal
@bal.setter
- def bal(self, x): self.setBal(x)
\ No newline at end of file
+ def bal(self, x): self.setBal(x)
diff --git a/pyolib/generators.py b/pyolib/generators.py
index d6f0f01..22464ac 100644
--- a/pyolib/generators.py
+++ b/pyolib/generators.py
@@ -6,6 +6,7 @@ processing chain or as parameter's modifiers.
"""
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -25,8 +26,8 @@ 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 *
+from ._core import *
+from ._maps import *
######################################################################
### Sources
@@ -39,9 +40,9 @@ class Sine(PyoObject):
:Args:
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency in cycles per second. Defaults to 1000.
- phase : float or PyoObject, optional
+ phase: float or PyoObject, optional
Phase of sampling, expressed as a fraction of a cycle (0 to 1).
Defaults to 0.
@@ -68,7 +69,7 @@ class Sine(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -83,7 +84,7 @@ class Sine(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `phase` attribute.
"""
@@ -99,7 +100,6 @@ class Sine(PyoObject):
"""
[obj.reset() for i, obj in enumerate(self._base_objs)]
-
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)
@@ -118,6 +118,107 @@ class Sine(PyoObject):
@phase.setter
def phase(self, x): self.setPhase(x)
+class FastSine(PyoObject):
+ """
+ A fast sine wave approximation using the formula of a parabola.
+
+ This object implements two sin approximations that are even faster
+ than a linearly interpolated table lookup. With `quality` set to 1,
+ the approximation is more accurate but also more expensive on the CPU
+ (still cheaper than a Sine object). With `quality` = 0, the algorithm
+ gives a worse approximation of the sin function but it is very fast
+ (and well suitable for generating LFO).
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ freq: float or PyoObject, optional
+ Frequency in cycles per second. Defaults to 1000.
+ initphase: float, optional
+ Initial phase of the oscillator, between 0 and 1. Available
+ at initialization time only. Defaults to 0.
+ quality: int, optional
+ Sets the approximation quality. 1 is more accurate but also
+ more expensive on the CPU. 0 is a cheaper algorithm but is
+ very fast. Defaults to 1.
+
+ .. seealso::
+
+ :py:class:`Sine`
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> lfo = FastSine(freq=[4,5], quality=0, mul=0.02, add=1)
+ >>> syn = FastSine(freq=500*lfo, quality=1, mul=0.4).out()
+
+ """
+ def __init__(self, freq=1000, initphase=0.0, quality=1, mul=1, add=0):
+ pyoArgsAssert(self, "OniOO", freq, initphase, quality, mul, add)
+ PyoObject.__init__(self, mul, add)
+ self._freq = freq
+ self._initphase = initphase
+ self._quality = quality
+ freq, initphase, quality, mul, add, lmax = convertArgsToLists(freq, initphase, quality, mul, add)
+ self._base_objs = [FastSine_base(wrap(freq,i), wrap(initphase,i), wrap(quality,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+
+ 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 setQuality(self, x):
+ """
+ Replace the `quality` attribute.
+
+ :Args:
+
+ x: int {0 or 1}
+ new `quality` attribute.
+
+ """
+ pyoArgsAssert(self, "i", x)
+ self._quality = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setQuality(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def reset(self):
+ """
+ Resets current phase to 0.
+
+ """
+ [obj.reset() 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", "quality", self._quality, res="int", dataOnly=True),
+ SLMapMul(self._mul)]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
+ @property
+ def freq(self):
+ """float or PyoObject. Frequency in cycles per second."""
+ return self._freq
+ @freq.setter
+ def freq(self, x): self.setFreq(x)
+
+ @property
+ def quality(self):
+ """int. Quality of the sin approximation."""
+ return self._quality
+ @quality.setter
+ def quality(self, x): self.setQuality(x)
+
class SineLoop(PyoObject):
"""
A simple sine wave oscillator with feedback.
@@ -129,9 +230,9 @@ class SineLoop(PyoObject):
:Args:
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency in cycles per second. Defaults to 1000.
- feedback : float or PyoObject, optional
+ feedback: float or PyoObject, optional
Amount of the output signal added to position increment, between 0 and 1.
Controls the brightness. Defaults to 0.
@@ -159,7 +260,7 @@ class SineLoop(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -174,7 +275,7 @@ class SineLoop(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `feedback` attribute.
"""
@@ -211,9 +312,9 @@ class Phasor(PyoObject):
:Args:
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency in cycles per second. Defaults to 100.
- phase : float or PyoObject, optional
+ phase: float or PyoObject, optional
Phase of sampling, expressed as a fraction of a cycle (0 to 1).
Defaults to 0.
@@ -241,7 +342,7 @@ class Phasor(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -256,7 +357,7 @@ class Phasor(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `phase` attribute.
"""
@@ -272,7 +373,6 @@ class Phasor(PyoObject):
"""
[obj.reset() for i, obj in enumerate(self._base_objs)]
-
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)
@@ -299,7 +399,7 @@ class Input(PyoObject):
:Args:
- chnl : int, optional
+ chnl: int, optional
Input channel to read from. Defaults to 0.
.. note::
@@ -347,7 +447,7 @@ class Noise(PyoObject):
:Args:
- x : int, {0, 1}
+ x: int, {0, 1}
0 uses the system rand() method to generate number. Used as default.
1 uses a simple linear congruential generator, cheaper than rand().
@@ -429,12 +529,12 @@ class FM(PyoObject):
:Args:
- carrier : float or PyoObject, optional
+ carrier: float or PyoObject, optional
Carrier frequency in cycles per second. Defaults to 100.
- ratio : float or PyoObject, optional
+ ratio: float or PyoObject, optional
A factor that, when multiplied by the `carrier` parameter,
gives the modulator frequency. Defaults to 0.5.
- index : float or PyoObject, optional
+ index: float or PyoObject, optional
The modulation index. This value multiplied by the modulator
frequency gives the modulator amplitude. Defaults to 5.
@@ -461,7 +561,7 @@ class FM(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `carrier` attribute.
"""
@@ -476,7 +576,7 @@ class FM(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `ratio` attribute.
"""
@@ -491,7 +591,7 @@ class FM(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `index` attribute.
"""
@@ -539,17 +639,17 @@ class CrossFM(PyoObject):
:Args:
- carrier : float or PyoObject, optional
+ carrier: float or PyoObject, optional
Carrier frequency in cycles per second. Defaults to 100.
- ratio : float or PyoObject, optional
+ ratio: float or PyoObject, optional
A factor that, when multiplied by the `carrier` parameter,
gives the modulator frequency. Defaults to 0.5.
- ind1 : float or PyoObject, optional
+ 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.
Defaults to 2.
- ind1 : float or PyoObject, optional
+ 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.
@@ -579,7 +679,7 @@ class CrossFM(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `carrier` attribute.
"""
@@ -594,7 +694,7 @@ class CrossFM(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `ratio` attribute.
"""
@@ -609,7 +709,7 @@ class CrossFM(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `ind1` attribute.
"""
@@ -624,7 +724,7 @@ class CrossFM(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `ind2` attribute.
"""
@@ -680,9 +780,9 @@ class Blit(PyoObject):
:Args:
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency in cycles per second. Defaults to 100.
- harms : float or PyoObject, optional
+ harms: float or PyoObject, optional
Number of harmonics in the generated spectrum. Defaults to 40.
>>> s = Server().boot()
@@ -706,7 +806,7 @@ class Blit(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -721,7 +821,7 @@ class Blit(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `harms` attribute.
"""
@@ -763,12 +863,12 @@ class Rossler(PyoObject):
:Args:
- pitch : float or PyoObject, optional
+ 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.
Defaults to 0.25.
- chaos : float or PyoObject, optional
+ chaos: float or PyoObject, optional
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
@@ -780,7 +880,7 @@ class Rossler(PyoObject):
.. seealso::
- :py:class:`Lorenz`
+ :py:class:`Lorenz`, :py:class:`ChenLee`
>>> s = Server().boot()
>>> s.start()
@@ -808,7 +908,7 @@ class Rossler(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pitch` attribute. {0. -> 1.}
"""
@@ -826,7 +926,7 @@ class Rossler(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `chaos` attribute. {0. -> 1.}
"""
@@ -870,12 +970,12 @@ class Lorenz(PyoObject):
:Args:
- pitch : float or PyoObject, optional
+ 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.
Defaults to 0.25.
- chaos : float or PyoObject, optional
+ chaos: float or PyoObject, optional
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
@@ -887,7 +987,7 @@ class Lorenz(PyoObject):
.. seealso::
- :py:class:`Rossler`
+ :py:class:`Rossler`, :py:class:`ChenLee`
>>> s = Server().boot()
>>> s.start()
@@ -915,7 +1015,7 @@ class Lorenz(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pitch` attribute. {0. -> 1.}
"""
@@ -933,7 +1033,114 @@ class Lorenz(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
+ new `chaos` attribute. {0. -> 1.}
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._chaos = x
+ x, lmax = convertArgsToLists(x)
+ if self._stereo:
+ [obj.setChaos(wrap(x,i)) for i, obj in enumerate(self._base_objs) if (i % 2) == 0]
+ else:
+ [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),
+ 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."""
+ return self._pitch
+ @pitch.setter
+ def pitch(self, x): self.setPitch(x)
+
+ @property
+ def chaos(self):
+ """float or PyoObject. Chaotic behavior."""
+ return self._chaos
+ @chaos.setter
+ def chaos(self, x): self.setChaos(x)
+
+class ChenLee(PyoObject):
+ """
+ Chaotic attractor for the Chen-Lee system.
+
+ The ChenLee 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.
+ Defaults to 0.25.
+ chaos: float or PyoObject, optional
+ 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
+ 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
+ the Y signal is slightly out-of-phase. Useful to create alternating LFOs.
+ Available at initialization only. Defaults to False.
+
+ .. seealso::
+
+ :py:class:`Rossler`, :py:class:`Lorenz`
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> a = ChenLee(pitch=.001, chaos=0.2, stereo=True, mul=.5, add=.5)
+ >>> b = ChenLee(pitch=1, chaos=a, mul=0.5).out()
+
+ """
+ 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
+ self._stereo = stereo
+ pitch, chaos, mul, add, lmax = convertArgsToLists(pitch, chaos, mul, add)
+ self._base_objs = []
+ self._alt_objs = []
+ for i in range(lmax):
+ self._base_objs.append(ChenLee_base(wrap(pitch,i), wrap(chaos,i), wrap(mul,i), wrap(add,i)))
+ if self._stereo:
+ self._base_objs.append(ChenLeeAlt_base(self._base_objs[-1], wrap(mul,i), wrap(add,i)))
+
+ def setPitch(self, x):
+ """
+ Replace the `pitch` attribute.
+
+ :Args:
+
+ x: float or PyoObject
+ new `pitch` attribute. {0. -> 1.}
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._pitch = x
+ x, lmax = convertArgsToLists(x)
+ if self._stereo:
+ [obj.setPitch(wrap(x,i)) for i, obj in enumerate(self._base_objs) if (i % 2) == 0]
+ else:
+ [obj.setPitch(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def setChaos(self, x):
+ """
+ Replace the `chaos` attribute.
+
+ :Args:
+
+ x: float or PyoObject
new `chaos` attribute. {0. -> 1.}
"""
@@ -972,12 +1179,13 @@ class LFO(PyoObject):
:Args:
- freq : float or PyoObject, optional
- Oscillator frequency in cycles per second. Defaults to 100.
- sharp : float or PyoObject, optional
+ freq: float or PyoObject, optional
+ Oscillator frequency in cycles per second. The frequency is
+ internally clamped between 0.00001 and sr/4. Defaults to 100.
+ sharp: float or PyoObject, optional
Sharpness factor between 0 and 1. Sharper waveform results
in more harmonics in the spectrum. Defaults to 0.5.
- type : int, optional
+ type: int, optional
Waveform type. eight possible values :
0. Saw up (default)
1. Saw down
@@ -1011,7 +1219,7 @@ class LFO(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `freq` attribute, in cycles per seconds.
"""
@@ -1026,7 +1234,7 @@ class LFO(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `sharp` attribute, in the range 0 -> 1.
"""
@@ -1041,7 +1249,7 @@ class LFO(PyoObject):
:Args:
- x : int
+ x: int
New `type` attribute. Choices are :
0. Saw up
1. Saw down
@@ -1066,9 +1274,8 @@ class LFO(PyoObject):
"""
[obj.reset() 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 = [SLMap(0.1, self.getSamplingRate()*0.25, "log", "freq", self._freq),
SLMap(0., 1., "lin", "sharp", self._sharp),
SLMap(0, 7, "lin", "type", self._type, "int", dataOnly=True),
SLMapMul(self._mul)]
@@ -1118,13 +1325,13 @@ class SumOsc(PyoObject):
:Args:
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Base frequency in cycles per second. Defaults to 100.
- ratio : float or PyoObject, optional
+ ratio: float or PyoObject, optional
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
+ index: float or PyoObject, optional
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 0.5.
@@ -1152,7 +1359,7 @@ class SumOsc(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -1167,7 +1374,7 @@ class SumOsc(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `ratio` attribute.
"""
@@ -1182,7 +1389,7 @@ class SumOsc(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `index` attribute.
"""
@@ -1232,13 +1439,13 @@ class SuperSaw(PyoObject):
:Args:
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency in cycles per second. Defaults to 100.
- detune : float or PyoObject, optional
+ 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.
- bal : float or PyoObject, optional
+ bal: float or PyoObject, optional
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.
@@ -1269,7 +1476,7 @@ class SuperSaw(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -1284,7 +1491,7 @@ class SuperSaw(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `detune` attribute.
"""
@@ -1299,7 +1506,7 @@ class SuperSaw(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `bal` attribute.
"""
@@ -1346,9 +1553,9 @@ class RCOsc(PyoObject):
:Args:
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency in cycles per second. Defaults to 100.
- sharp : float or PyoObject, optional
+ sharp: float or PyoObject, optional
Slope of the attack and decay of the waveform, between 0 and 1.
A value of 0 gives a triangular waveform and 1 gives almost a
square wave. Defaults to 0.25.
@@ -1377,7 +1584,7 @@ class RCOsc(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -1392,7 +1599,7 @@ class RCOsc(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `sharp` attribute.
"""
@@ -1424,4 +1631,4 @@ class RCOsc(PyoObject):
"""float or PyoObject. Sharpness of the waveform."""
return self._sharp
@sharp.setter
- def sharp(self, x): self.setSharp(x)
\ No newline at end of file
+ def sharp(self, x): self.setSharp(x)
diff --git a/pyolib/listener.py b/pyolib/listener.py
index ba210c6..b16b732 100644
--- a/pyolib/listener.py
+++ b/pyolib/listener.py
@@ -1,4 +1,5 @@
-from _core import *
+from __future__ import absolute_import
+from ._core import *
import time
import threading
@@ -10,25 +11,30 @@ class MidiListener(threading.Thread):
of the audio server (mainly to be able to receive Midi data even
when the audio server is stopped). Although it runs in a separated
thread, the same device can't be used by this object and the audio
- server at the same time. It is adviced to call the deactivateMidi()
+ server at the same time. It is adviced to call the deactivateMidi()
method on the audio server to avoid conflicts.
:Parent: threading.Thread
:Args:
- function : Python function (can't be a list)
- Function that will be called when a new midi event is available.
- This function is called with the incoming midi data as
+ function: Python function (can't be a list)
+ Function that will be called when a new midi event is available.
+ This function is called with the incoming midi data as
arguments. The signature of the function must be:
-
+
def myfunc(status, data1, data2)
- mididev : int, optional
- Sets the midi input device (see `pm_list_devices()` for the
+ mididev: int, optional
+ Sets the midi input device (see `pm_list_devices()` for the
available devices). The default, -1, means the system default
- device. A number greater than the highest portmidi device index
- will open all available input devices.
+ device. A number greater than the highest portmidi device index
+ will open all available input devices.
+
+ .. note::
+
+ This object is available only if pyo is built with portmidi support
+ (see withPortmidi function).
>>> s = Server().boot()
>>> s.deactivateMidi()
@@ -44,11 +50,11 @@ class MidiListener(threading.Thread):
self._function = WeakMethod(function)
self._mididev = mididev
self._listener = MidiListener_base(self._function, self._mididev)
-
+
def run(self):
"""
Starts the process. The thread runs as daemon, so no need to stop it.
-
+
"""
self._listener.play()
while True:
@@ -65,21 +71,21 @@ class OscListener(threading.Thread):
This object allows to setup an OSC server that is independent
of the audio server (mainly to be able to receive OSC data even
- when the audio server is stopped).
+ when the audio server is stopped).
:Parent: threadind.Thread
:Args:
- function : Python function (can't be a list)
- Function that will be called when a new OSC event is available.
- This function is called with the incoming address and values as
+ function: Python function (can't be a list)
+ Function that will be called when a new OSC event is available.
+ This function is called with the incoming address and values as
arguments. The signature of the function must be:
-
+
def myfunc(address, *args)
- port : int, optional
- The OSC port on which the values are received. Defaults to 9000.
+ port: int, optional
+ The OSC port on which the values are received. Defaults to 9000.
>>> s = Server().boot()
>>> def call(address, *args):
@@ -102,7 +108,7 @@ class OscListener(threading.Thread):
def run(self):
"""
Starts the process. The thread runs as daemon, so no need to stop it.
-
+
"""
while True:
self._listener.get()
diff --git a/pyolib/matrix.py b/pyolib/matrix.py
index 3ddee00..bdcda56 100644
--- a/pyolib/matrix.py
+++ b/pyolib/matrix.py
@@ -1,3 +1,4 @@
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -17,8 +18,8 @@ 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 *
+from ._core import *
+from ._maps import *
######################################################################
### Matrix
@@ -36,11 +37,11 @@ class NewMatrix(PyoMatrixObject):
:Args:
- width : int
+ width: int
Desired matrix width in samples.
- height : int
+ height: int
Desired matrix height in samples.
- init : list of list of floats, optional
+ init: list of list of floats, optional
Initial matrix. Defaults to None.
.. seealso::
@@ -63,7 +64,7 @@ class NewMatrix(PyoMatrixObject):
pyoArgsAssert(self, "IIL", width, height, init)
PyoMatrixObject.__init__(self)
self._size = (width, height)
- if init == None:
+ if init is None:
self._base_objs = [NewMatrix_base(width, height)]
else:
self._base_objs = [NewMatrix_base(width, height, init)]
@@ -74,7 +75,7 @@ class NewMatrix(PyoMatrixObject):
:Args:
- x : list of list of floats
+ x: list of list of floats
New matrix. Must be of the same size as the actual matrix.
"""
@@ -96,14 +97,14 @@ class NewMatrix(PyoMatrixObject):
:Args:
- freq : float
+ freq: float
Frequency of sinusoids used to created the terrain.
Defaults to 1.
- phase : float
+ phase: float
Phase deviation between rows of the terrain. Should be in
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()
\ No newline at end of file
+ self.refreshView()
diff --git a/pyolib/matrixprocess.py b/pyolib/matrixprocess.py
index 9b721a0..6b971b3 100644
--- a/pyolib/matrixprocess.py
+++ b/pyolib/matrixprocess.py
@@ -7,6 +7,7 @@ are done by giving row and column positions.
"""
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -26,9 +27,8 @@ 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 *
-from types import SliceType
+from ._core import *
+from ._maps import *
class MatrixRec(PyoObject):
"""
@@ -46,14 +46,14 @@ class MatrixRec(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal to write in the matrix.
- matrix : PyoMatrixObject
+ matrix: PyoMatrixObject
The matrix where to write samples.
- fadetime : float, optional
+ fadetime: float, optional
Fade time at the beginning and the end of the recording
in seconds. Defaults to 0.
- delay : int, optional
+ delay: int, optional
Delay time, in samples, before the recording begins.
Available at initialization time only. Defaults to 0.
@@ -63,7 +63,7 @@ class MatrixRec(PyoObject):
MatrixRec has no `mul` and `add` attributes.
- MatrixRec will sends a trigger signal at the end of the recording.
+ MatrixRec will send 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.
@@ -111,9 +111,9 @@ class MatrixRec(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -127,7 +127,7 @@ class MatrixRec(PyoObject):
:Args:
- x : NewMatrix
+ x: NewMatrix
new `matrix` attribute.
"""
@@ -163,9 +163,9 @@ class MatrixRecLoop(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal to write in the matrix.
- matrix : PyoMatrixObject
+ matrix: PyoMatrixObject
The matrix where to write samples.
.. note::
@@ -174,7 +174,7 @@ class MatrixRecLoop(PyoObject):
MatrixRecLoop has no `mul` and `add` attributes.
- MatrixRecLoop will sends a trigger signal when reaching the end
+ MatrixRecLoop will send 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.
@@ -221,9 +221,9 @@ class MatrixRecLoop(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -237,7 +237,7 @@ class MatrixRecLoop(PyoObject):
:Args:
- x : NewMatrix
+ x: NewMatrix
new `matrix` attribute.
"""
@@ -268,11 +268,11 @@ class MatrixPointer(PyoObject):
:Args:
- matrix : PyoMatrixObject
+ matrix: PyoMatrixObject
Matrix containing the waveform samples.
- x : PyoObject
+ x: PyoObject
Normalized X position in the matrix between 0 and 1.
- y : PyoObject
+ y: PyoObject
Normalized Y position in the matrix between 0 and 1.
>>> s = Server().boot()
@@ -305,7 +305,7 @@ class MatrixPointer(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `matrix` attribute.
"""
@@ -320,7 +320,7 @@ class MatrixPointer(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
new `x` attribute.
"""
@@ -335,7 +335,7 @@ class MatrixPointer(PyoObject):
:Args:
- y : PyoObject
+ y: PyoObject
new `y` attribute.
"""
@@ -382,12 +382,12 @@ class MatrixMorph(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Morphing index between 0 and 1. 0 is the first matrix in the list
and 1 is the last.
- matrix : NewMatrix
+ matrix: NewMatrix
The matrix where to write morphed function.
- sources : list of PyoMatrixObject
+ sources: list of PyoMatrixObject
List of matrices to interpolate from.
.. note::
@@ -436,9 +436,9 @@ class MatrixMorph(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -452,7 +452,7 @@ class MatrixMorph(PyoObject):
:Args:
- x : NewMatrix
+ x: NewMatrix
new `matrix` attribute.
"""
@@ -467,7 +467,7 @@ class MatrixMorph(PyoObject):
:Args:
- x : list of PyoMatrixObject
+ x: list of PyoMatrixObject
new `sources` attribute.
"""
@@ -495,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)
\ No newline at end of file
+ def sources(self, x): self.setSources(x)
diff --git a/pyolib/midi.py b/pyolib/midi.py
index 588fc88..549234d 100644
--- a/pyolib/midi.py
+++ b/pyolib/midi.py
@@ -8,6 +8,7 @@ used as controls and can't be sent to the output soundcard.
"""
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -28,8 +29,8 @@ 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 ._core import *
+from ._maps import *
######################################################################
### MIDI
@@ -45,15 +46,15 @@ class Midictl(PyoObject):
:Args:
- ctlnumber : int
+ ctlnumber: int
Controller number.
- minscale : float, optional
+ minscale: float, optional
Low range value for mapping. Defaults to 0.
- maxscale : float, optional
+ maxscale: float, optional
High range value for mapping. Defaults to 1.
- init : float, optional
+ init: float, optional
Initial value. Defaults to 0.
- channel : int, optional
+ channel: int, optional
Midi channel. 0 means all channels. Defaults to 0.
.. note::
@@ -89,7 +90,7 @@ class Midictl(PyoObject):
:Args:
- x : int
+ x: int
new `ctlnumber` attribute.
"""
@@ -104,7 +105,7 @@ class Midictl(PyoObject):
:Args:
- x : float
+ x: float
new `minscale` attribute.
"""
@@ -119,7 +120,7 @@ class Midictl(PyoObject):
:Args:
- x : float
+ x: float
new `maxscale` attribute.
"""
@@ -134,7 +135,7 @@ class Midictl(PyoObject):
:Args:
- x : int
+ x: int
new `channel` attribute.
"""
@@ -149,7 +150,7 @@ class Midictl(PyoObject):
:Args:
- x : float
+ x: float
new current value.
"""
@@ -163,7 +164,7 @@ class Midictl(PyoObject):
:Args:
- x : boolean
+ x: boolean
True activates the interpolation, False deactivates it.
"""
@@ -171,6 +172,14 @@ class Midictl(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setInterpolation(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, 127, 'lin', 'ctlnumber', self._ctlnumber, res="int", dataOnly=True),
+ SLMap(-1.0, 0.0, 'lin', 'minscale', self._minscale, dataOnly=True),
+ SLMap(0.0, 1.0, 'lin', 'maxscale', self._maxscale, dataOnly=True),
+ SLMap(0, 16, 'lin', 'channel', self._channel, res="int", dataOnly=True)
+ ]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
@property
def ctlnumber(self):
"""int. Controller number."""
@@ -215,14 +224,14 @@ class CtlScan(PyoObject):
:Args:
- function : Python function (can't be a list)
+ 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.:
def ctl_scan(ctlnum):
print ctlnum
- toprint : boolean, optional
+ toprint: boolean, optional
If True, controller number and value will be print to
the console.
@@ -275,7 +284,7 @@ class CtlScan(PyoObject):
:Args:
- x : Python function
+ x: Python function
new `function` attribute.
"""
@@ -289,7 +298,7 @@ class CtlScan(PyoObject):
:Args:
- x : int
+ x: int
new `toprint` attribute.
"""
@@ -325,7 +334,7 @@ class CtlScan2(PyoObject):
:Args:
- function : Python function (can't be a list)
+ 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.:
@@ -333,7 +342,7 @@ class CtlScan2(PyoObject):
def ctl_scan(ctlnum, midichnl):
print ctlnum, midichnl
- toprint : boolean, optional
+ toprint: boolean, optional
If True, controller number and value will be print to
the console.
@@ -386,7 +395,7 @@ class CtlScan2(PyoObject):
:Args:
- x : Python function
+ x: Python function
new `function` attribute.
"""
@@ -400,7 +409,7 @@ class CtlScan2(PyoObject):
:Args:
- x : int
+ x: int
new `toprint` attribute.
"""
@@ -437,9 +446,9 @@ class Notein(PyoObject):
:Args:
- poly : int, optional
+ poly: int, optional
Number of streams of polyphony generated. Defaults to 10.
- scale : int, optional
+ scale: int, optional
Pitch output format.
0. Midi
1. Hertz
@@ -449,11 +458,11 @@ class Notein(PyoObject):
there is no transposition) is (`first` + `last`) / 2.
The central key can be changed with the setCentralKey method.
- first : int, optional
+ first: int, optional
Lowest Midi value. Defaults to 0.
- last : int, optional
+ last: int, optional
Highest Midi value. Defaults to 127.
- channel : int, optional
+ channel: int, optional
Midi channel. 0 means all channels. Defaults to 0.
.. note::
@@ -520,13 +529,55 @@ class Notein(PyoObject):
self._trigoff_dummy.append(Dummy([self._trig_objs[i*2+1] for i in range(self._poly)]))
return self._trigoff_dummy[-1]
+ def setScale(self, x):
+ """
+ Replace the `scale` attribute.
+
+ :Args:
+
+ x: int
+ new `scale` attribute. 0 = midi, 1 = hertz, 2 = transpo.
+
+ """
+ pyoArgsAssert(self, "I", x)
+ self._scale = x
+ self._base_handler.setScale(x)
+
+ def setFirst(self, x):
+ """
+ Replace the `first` attribute.
+
+ :Args:
+
+ x: int
+ new `first` attribute, between 0 and 127.
+
+ """
+ pyoArgsAssert(self, "I", x)
+ self._first = x
+ self._base_handler.setFirst(x)
+
+ def setLast(self, x):
+ """
+ Replace the `last` attribute.
+
+ :Args:
+
+ x: int
+ new `last` attribute, between 0 and 127.
+
+ """
+ pyoArgsAssert(self, "I", x)
+ self._last = x
+ self._base_handler.setLast(x)
+
def setChannel(self, x):
"""
Replace the `channel` attribute.
:Args:
- x : int
+ x: int
new `channel` attribute.
"""
@@ -543,7 +594,7 @@ class Notein(PyoObject):
:Args:
- x : int
+ x: int
new centralkey value.
"""
@@ -560,7 +611,7 @@ class Notein(PyoObject):
:Args:
- x : boolean
+ x: boolean
True for stealing mode, False for non-stealing.
"""
@@ -578,10 +629,10 @@ class Notein(PyoObject):
:Args:
- identifier : string {"pitch", "velocity"}
+ identifier: string {"pitch", "velocity"}
Address string parameter identifying audio stream.
Defaults to "pitch".
- all : boolean, optional
+ all: boolean, optional
If True, the first value of each object's stream
will be returned as a list.
@@ -605,6 +656,35 @@ class Notein(PyoObject):
self._base_handler.stop()
return PyoObject.stop(self)
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ self._map_list = [SLMap(0, 2, 'lin', 'scale', self._scale, res="int", dataOnly=True),
+ SLMap(0, 127, 'lin', 'first', self._first, res="int", dataOnly=True),
+ SLMap(0, 127, 'lin', 'last', self._last, res="int", dataOnly=True),
+ SLMap(0, 16, 'lin', 'channel', self._channel, res="int", dataOnly=True)
+ ]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
+ @property
+ def scale(self):
+ """int. Output format. 0 = midi, 1 = hertz, 2 = transpo."""
+ return self._scale
+ @scale.setter
+ def scale(self, x): self.setScale(x)
+
+ @property
+ def first(self):
+ """int. Lowest midi value."""
+ return self._first
+ @first.setter
+ def first(self, x): self.setFirst(x)
+
+ @property
+ def last(self):
+ """int. Highest midi value."""
+ return self._last
+ @last.setter
+ def last(self, x): self.setLast(x)
+
@property
def channel(self):
"""int. Midi channel. 0 means all channels."""
@@ -624,17 +704,17 @@ class Bendin(PyoObject):
:Args:
- brange : float, optional
+ brange: float, optional
Bipolar range of the pitch bend in semitones. Defaults to 2.
-brange <= value < brange.
- scale : int, optional
+ scale: int, optional
Output format. Defaults to 0.
0. Midi
1. transpo.
The transpo mode is useful if you want to transpose values that
are in a frequency (Hz) format.
- channel : int, optional
+ channel: int, optional
Midi channel. 0 means all channels. Defaults to 0.
.. note::
@@ -670,7 +750,7 @@ class Bendin(PyoObject):
:Args:
- x : float
+ x: float
new `brange` attribute.
"""
@@ -685,7 +765,7 @@ class Bendin(PyoObject):
:Args:
- x : int
+ x: int
new `scale` attribute.
"""
@@ -700,7 +780,7 @@ class Bendin(PyoObject):
:Args:
- x : int
+ x: int
new `channel` attribute.
"""
@@ -709,6 +789,13 @@ class Bendin(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setChannel(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.0, 12.0, 'lin', 'brange', self._brange, dataOnly=True),
+ SLMap(0, 1, 'lin', 'scale', self._scale, res="int", dataOnly=True),
+ SLMap(0, 16, 'lin', 'channel', self._channel, res="int", dataOnly=True)
+ ]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
@property
def brange(self):
"""float. Bipolar range of the pitch bend in semitones."""
@@ -741,13 +828,13 @@ class Touchin(PyoObject):
:Args:
- minscale : float, optional
+ minscale: float, optional
Low range value for mapping. Defaults to 0.
- maxscale : float, optional
+ maxscale: float, optional
High range value for mapping. Defaults to 1.
- init : float, optional
+ init: float, optional
Initial value. Defaults to 0.
- channel : int, optional
+ channel: int, optional
Midi channel. 0 means all channels. Defaults to 0.
.. note::
@@ -783,7 +870,7 @@ class Touchin(PyoObject):
:Args:
- x : float
+ x: float
new `minscale` attribute.
"""
@@ -798,7 +885,7 @@ class Touchin(PyoObject):
:Args:
- x : float
+ x: float
new `maxscale` attribute.
"""
@@ -813,7 +900,7 @@ class Touchin(PyoObject):
:Args:
- x : int
+ x: int
new `channel` attribute.
"""
@@ -822,6 +909,13 @@ class Touchin(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setChannel(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.0, 0.0, 'lin', 'minscale', self._minscale, dataOnly=True),
+ SLMap(0.0, 1.0, 'lin', 'maxscale', self._maxscale, dataOnly=True),
+ SLMap(0, 16, 'lin', 'channel', self._channel, res="int", dataOnly=True)
+ ]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
@property
def minscale(self):
"""float. Minimum value for scaling."""
@@ -856,7 +950,7 @@ class Programin(PyoObject):
:Args:
- channel : int, optional
+ channel: int, optional
Midi channel. 0 means all channels. Defaults to 0.
.. note::
@@ -890,7 +984,7 @@ class Programin(PyoObject):
:Args:
- x : int
+ x: int
new `channel` attribute.
"""
@@ -899,6 +993,10 @@ class Programin(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setChannel(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, 16, 'lin', 'channel', self._channel, res="int", dataOnly=True)]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
@property
def channel(self):
"""int. Midi channel. 0 means all channels."""
@@ -922,24 +1020,27 @@ class MidiAdsr(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal used to trigger the envelope. A positive value
sets the peak amplitude and starts the envelope. A 0 starts
the release part of the envelope.
- attack : float, optional
+ attack: float, optional
Duration of the attack phase in seconds. Defaults to 0.01.
- decay : float, optional
+ decay: float, optional
Duration of the decay phase in seconds. Defaults to 0.05.
- sustain : float, optional
+ sustain: float, optional
Amplitude of the sustain phase, as a fraction of the peak
amplitude at the start of the envelope. Defaults to 0.7.
- release : float, optional
+ release: float, optional
Duration of the release phase in seconds. Defaults to 0.1.
.. note::
The out() method is bypassed. MidiAdsr's signal can not be sent to audio outs.
+ As of version 0.8.0, exponential or logarithmic envelopes can be created
+ with the exponent factor (see setExp() method).
+
>>> s = Server().boot()
>>> s.start()
>>> mid = Notein(scale=1)
@@ -956,6 +1057,7 @@ class MidiAdsr(PyoObject):
self._decay = decay
self._sustain = sustain
self._release = release
+ self._exp = 1.0;
self._in_fader = InputFader(input)
in_fader, attack, decay, sustain, release, mul, add, lmax = convertArgsToLists(self._in_fader, attack, decay, sustain, release, mul, add)
self._base_objs = [MidiAdsr_base(wrap(in_fader,i), wrap(attack,i), wrap(decay,i), wrap(sustain,i), wrap(release,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
@@ -969,9 +1071,9 @@ class MidiAdsr(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal used to trigger the envelope.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -985,7 +1087,7 @@ class MidiAdsr(PyoObject):
:Args:
- x : float
+ x: float
new `attack` attribute.
"""
@@ -1000,7 +1102,7 @@ class MidiAdsr(PyoObject):
:Args:
- x : float
+ x: float
new `decay` attribute.
"""
@@ -1015,7 +1117,7 @@ class MidiAdsr(PyoObject):
:Args:
- x : float
+ x: float
new `sustain` attribute.
"""
@@ -1030,7 +1132,7 @@ class MidiAdsr(PyoObject):
:Args:
- x : float
+ x: float
new `sustain` attribute.
"""
@@ -1039,6 +1141,34 @@ class MidiAdsr(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setRelease(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ def setExp(self, x):
+ """
+ Sets an exponent factor to create exponential or logarithmic envelopes.
+
+ The default value is 1.0, which means linear segments. A value
+ higher than 1.0 will produce exponential segments while a value
+ between 0 and 1 will produce logarithmic segments. Must be > 0.0.
+
+ :Args:
+
+ x: float
+ 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)]
+
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ self._map_list = [SLMap(0.0, 1.0, 'lin', 'attack', self._attack, dataOnly=True),
+ SLMap(0.0, 1.0, 'lin', 'decay', self._decay, dataOnly=True),
+ SLMap(0.0, 1.0, 'lin', 'sustain', self._sustain, dataOnly=True),
+ SLMap(0.0, 1.0, 'lin', 'release', self._release, dataOnly=True),
+ SLMap(0.1, 10.0, 'log', 'exp', self._exp, dataOnly=True),
+ ]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
@property
def attack(self):
"""float. Duration of the attack phase in seconds."""
@@ -1067,6 +1197,13 @@ class MidiAdsr(PyoObject):
@release.setter
def release(self, x): self.setRelease(x)
+ @property
+ def exp(self):
+ """float. Exponent factor of the envelope."""
+ return self._exp
+ @exp.setter
+ def exp(self, x): self.setExp(x)
+
class MidiDelAdsr(PyoObject):
"""
Midi triggered ADSR envelope generator with pre-delay.
@@ -1082,21 +1219,21 @@ class MidiDelAdsr(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal used to trigger the envelope. A positive value
sets the peak amplitude and starts the envelope. A 0 starts
the release part of the envelope.
- delay : float, optional
+ delay: float, optional
Duration of the delay phase, before calling the envelope
in seconds. Defaults to 0.
- attack : float, optional
+ attack: float, optional
Duration of the attack phase in seconds. Defaults to 0.01.
- decay : float, optional
+ decay: float, optional
Duration of the decay phase in seconds. Defaults to 0.05.
- sustain : float, optional
+ sustain: float, optional
Amplitude of the sustain phase, as a fraction of the peak
amplitude at the start of the envelope. Defaults to 0.7.
- release : float, optional
+ release: float, optional
Duration of the release phase in seconds. Defaults to 0.1.
.. note::
@@ -1104,6 +1241,9 @@ class MidiDelAdsr(PyoObject):
The out() method is bypassed. MidiDelAdsr's signal can not be sent
to audio outs.
+ As of version 0.8.0, exponential or logarithmic envelopes can be created
+ with the exponent factor (see setExp() method).
+
>>> s = Server().boot()
>>> s.start()
>>> mid = Notein(scale=1)
@@ -1121,6 +1261,7 @@ class MidiDelAdsr(PyoObject):
self._decay = decay
self._sustain = sustain
self._release = release
+ self._exp = 1.0;
self._in_fader = InputFader(input)
in_fader, delay, attack, decay, sustain, release, mul, add, lmax = convertArgsToLists(self._in_fader, delay, attack, decay, sustain, release, mul, add)
self._base_objs = [MidiDelAdsr_base(wrap(in_fader,i), wrap(delay,i), wrap(attack,i), wrap(decay,i), wrap(sustain,i), wrap(release,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
@@ -1134,9 +1275,9 @@ class MidiDelAdsr(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal used to trigger the envelope.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1150,7 +1291,7 @@ class MidiDelAdsr(PyoObject):
:Args:
- x : float
+ x: float
new `delay` attribute.
"""
@@ -1165,7 +1306,7 @@ class MidiDelAdsr(PyoObject):
:Args:
- x : float
+ x: float
new `attack` attribute.
"""
@@ -1180,7 +1321,7 @@ class MidiDelAdsr(PyoObject):
:Args:
- x : float
+ x: float
new `decay` attribute.
"""
@@ -1195,7 +1336,7 @@ class MidiDelAdsr(PyoObject):
:Args:
- x : float
+ x: float
new `sustain` attribute.
"""
@@ -1210,7 +1351,7 @@ class MidiDelAdsr(PyoObject):
:Args:
- x : float
+ x: float
new `sustain` attribute.
"""
@@ -1219,6 +1360,35 @@ class MidiDelAdsr(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setRelease(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ def setExp(self, x):
+ """
+ Sets an exponent factor to create exponential or logarithmic envelope.
+
+ The default value is 1.0, which means linear segments. A value
+ higher than 1.0 will produce exponential segments while a value
+ between 0 and 1 will produce logarithmic segments. Must be > 0.0.
+
+ :Args:
+
+ x: float
+ 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)]
+
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ self._map_list = [SLMap(0.0, 1.0, 'lin', 'delay', self._delay, dataOnly=True),
+ SLMap(0.0, 1.0, 'lin', 'attack', self._attack, dataOnly=True),
+ SLMap(0.0, 1.0, 'lin', 'decay', self._decay, dataOnly=True),
+ SLMap(0.0, 1.0, 'lin', 'sustain', self._sustain, dataOnly=True),
+ SLMap(0.0, 1.0, 'lin', 'release', self._release, dataOnly=True),
+ SLMap(0.1, 10.0, 'log', 'exp', self._exp, dataOnly=True),
+ ]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
@property
def delay(self):
"""float. Duration of the delay phase in seconds."""
@@ -1254,18 +1424,25 @@ class MidiDelAdsr(PyoObject):
@release.setter
def release(self, x): self.setRelease(x)
+ @property
+ def exp(self):
+ """float. Exponent factor of the envelope."""
+ return self._exp
+ @exp.setter
+ def exp(self, x): self.setExp(x)
+
class RawMidi(PyoObject):
"""
Raw Midi handler.
- This object calls a python function for each raw midi data
+ 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: 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.:
@@ -1314,7 +1491,7 @@ class RawMidi(PyoObject):
:Args:
- x : Python function
+ x: Python function
new `function` attribute.
"""
diff --git a/pyolib/opensndctrl.py b/pyolib/opensndctrl.py
index 075bf39..4860b01 100644
--- a/pyolib/opensndctrl.py
+++ b/pyolib/opensndctrl.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+from __future__ import absolute_import
"""
Objects to manage values on an Open Sound Control port.
@@ -10,6 +12,9 @@ input port.
The audio streams of these objects are essentially intended to be
controls and can't be sent to the output soundcard.
+These objects are available only if pyo is built with OSC (Open Sound
+Control) support.
+
"""
"""
@@ -31,9 +36,17 @@ 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 *
-from types import ListType, StringType, UnicodeType
+from ._core import *
+from ._maps import *
+
+def assertOSCSupport(obj):
+ if not withOSC():
+ raise Exception("Pyo built without OSC support! '%s' objects is not available." % obj.__class__.__name__)
+
+### TODO - Know bugs:
+### OscListReceive.setValue(address, value) make the program segfault on quit (python 2.7 and 3.5).
+### OscSend/OscReceive don't work with unicode on python 2.7 (ok on python 3.5)
+###
######################################################################
### Open Sound Control
@@ -50,15 +63,15 @@ class OscSend(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal.
- port : int
+ port: int
Port on which values are sent. Receiver should listen on the
same port.
- address : string
+ address: string
Address used on the port to identify values. Address is in
the form of a Unix path (ex.: '/pitch').
- host : string, optional
+ host: string, optional
IP address of the target computer. The default, '127.0.0.1',
is the localhost.
@@ -76,6 +89,7 @@ class OscSend(PyoObject):
"""
def __init__(self, input, port, address, host="127.0.0.1"):
+ assertOSCSupport(self)
pyoArgsAssert(self, "oiss", input, port, address, host)
PyoObject.__init__(self)
self._input = input
@@ -89,9 +103,9 @@ class OscSend(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -114,7 +128,7 @@ class OscSend(PyoObject):
:Args:
- x : int
+ x: int
Changes the data output frequency in multiples of the buffer size.
Should be greater or equal to 1.
@@ -141,7 +155,7 @@ class OscReceive(PyoObject):
:Args:
- port : int
+ port: int
Port on which values are received. Sender should output on
the same port.
@@ -149,7 +163,7 @@ class OscReceive(PyoObject):
object.
Available at initialization time only.
- address : string
+ address: string
Address used on the port to identify values. Address is in
the form of a Unix path (ex.: '/pitch').
@@ -171,6 +185,7 @@ class OscReceive(PyoObject):
"""
def __init__(self, port, address, mul=1, add=0):
+ assertOSCSupport(self)
pyoArgsAssert(self, "IsOO", port, address, mul, add)
PyoObject.__init__(self, mul, add)
address, mul, add, lmax = convertArgsToLists(address, mul, add)
@@ -179,12 +194,12 @@ class OscReceive(PyoObject):
self._base_objs = [OscReceive_base(self._mainReceiver, wrap(address,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def __getitem__(self, i):
- if type(i) in [StringType, UnicodeType]:
+ if type(i) in [bytes_t, unicode_t]:
return self._base_objs[self._address.index(i)]
elif i < len(self._base_objs):
return self._base_objs[i]
else:
- print "'i' too large!"
+ print("'i' too large!")
def getAddresses(self):
"""
@@ -199,11 +214,11 @@ class OscReceive(PyoObject):
:Args:
- path : string or list of strings
+ path: string or list of strings
New path(s) to receive from.
- mul : float or PyoObject
+ mul: float or PyoObject
Multiplication factor. Defaults to 1.
- add : float or PyoObject
+ add: float or PyoObject
Addition factor. Defaults to 0.
"""
@@ -222,7 +237,7 @@ class OscReceive(PyoObject):
:Args:
- path : string or list of strings
+ path: string or list of strings
Path(s) to remove.
"""
@@ -240,7 +255,7 @@ class OscReceive(PyoObject):
:Args:
- x : boolean
+ x: boolean
True activates the interpolation, False deactivates it.
"""
@@ -253,9 +268,9 @@ class OscReceive(PyoObject):
:Args:
- path : string
+ path: string
Address to which the value should be attributed.
- value : float
+ value: float
Value to attribute to the given address.
"""
@@ -266,7 +281,7 @@ class OscReceive(PyoObject):
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):
"""
@@ -279,11 +294,11 @@ class OscReceive(PyoObject):
:Args:
- identifier : string
+ identifier: string
Address string parameter identifying audio stream.
Defaults to None, useful when `all` is True to
retreive all streams values.
- all : boolean, optional
+ 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 stream will be returned as a float.
@@ -310,30 +325,30 @@ class OscDataSend(PyoObject):
:Args:
- types : str
+ types: str
String specifying the types sequence of the message to be sent.
Possible values are:
- - "i" : integer
- - "h" : long integer
- - "f" : float
- - "d" : double
+ - "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)
+ - "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: int
Port on which values are sent. Receiver should listen on the
same port.
- address : string
+ address: string
Address used on the port to identify values. Address is in
the form of a Unix path (ex.: '/pitch').
- host : string, optional
+ host: string, optional
IP address of the target computer. The default, '127.0.0.1',
is the localhost.
@@ -364,6 +379,7 @@ class OscDataSend(PyoObject):
"""
def __init__(self, types, port, address, host="127.0.0.1"):
+ assertOSCSupport(self)
pyoArgsAssert(self, "siss", types, port, address, host)
PyoObject.__init__(self)
types, port, address, host, lmax = convertArgsToLists(types, port, address, host)
@@ -386,7 +402,7 @@ class OscDataSend(PyoObject):
Returns the addresses managed by the object.
"""
- return self._addresses.keys()
+ return list(self._addresses.keys())
def addAddress(self, types, port, address, host="127.0.0.1"):
"""
@@ -394,24 +410,30 @@ class OscDataSend(PyoObject):
:Args:
- types : str
+ 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: int
Port on which values are sent. Receiver should listen on the
same port.
- address : string
+ address: string
Address used on the port to identify values. Address is in
the form of a Unix path (ex.: '/pitch').
- host : string, optional
+ host: string, optional
IP address of the target computer. The default, '127.0.0.1',
is the localhost.
@@ -429,7 +451,7 @@ class OscDataSend(PyoObject):
:Args:
- path : string or list of strings
+ path: string or list of strings
Path(s) to remove.
"""
@@ -446,16 +468,16 @@ class OscDataSend(PyoObject):
:Args:
- msg : list
+ msg: list
List of values to send. Types of values in list
must be of the kind defined of `types` argument
given at the object's initialization.
- address : string, optional
+ address: string, optional
Address destination to send values. If None, values
will be sent to all addresses managed by the object.
"""
- if address == None:
+ if address is None:
pyoArgsAssert(self, "l", msg)
[obj.send(msg) for obj in self._base_objs]
else:
@@ -475,16 +497,16 @@ class OscDataReceive(PyoObject):
:Args:
- port : int
+ 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
time only.
- address : string
+ address: string
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 (can't be a list)
+ 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
OscDataReceive object. Available at initialization time only.
@@ -522,6 +544,7 @@ class OscDataReceive(PyoObject):
"""
def __init__(self, port, address, function):
+ assertOSCSupport(self)
pyoArgsAssert(self, "IsC", port, address, function)
PyoObject.__init__(self)
self._port = port
@@ -552,7 +575,7 @@ class OscDataReceive(PyoObject):
:Args:
- path : string or list of strings
+ path: string or list of strings
New path(s) to receive from.
"""
@@ -569,7 +592,7 @@ class OscDataReceive(PyoObject):
:Args:
- path : string or list of strings
+ path: string or list of strings
Path(s) to remove.
"""
@@ -593,15 +616,15 @@ class OscListReceive(PyoObject):
:Args:
- port : int
+ 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
only.
- address : string
+ address: string
Address used on the port to identify values. Address is in
the form of a Unix path (ex.: '/pitch').
- num : int, optional
+ 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
@@ -626,6 +649,7 @@ class OscListReceive(PyoObject):
"""
def __init__(self, port, address, num=8, mul=1, add=0):
+ assertOSCSupport(self)
pyoArgsAssert(self, "IsIOO", port, address, num, mul, add)
PyoObject.__init__(self, mul, add)
self._num = num
@@ -636,14 +660,14 @@ class OscListReceive(PyoObject):
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) in [StringType, UnicodeType]:
+ if type(i) in [bytes_t, unicode_t]:
first = self._address.index(i) * self._num
return self._base_objs[first:first+self._num]
elif i < len(self._base_objs):
first = i * self._num
return self._base_objs[first:first+self._num]
else:
- print "'i' too large!"
+ print("'i' too large!")
def getAddresses(self):
"""
@@ -658,11 +682,11 @@ class OscListReceive(PyoObject):
:Args:
- path : string or list of strings
+ path: string or list of strings
New path(s) to receive from.
- mul : float or PyoObject
+ mul: float or PyoObject
Multiplication factor. Defaults to 1.
- add : float or PyoObject
+ add: float or PyoObject
Addition factor. Defaults to 0.
"""
@@ -681,7 +705,7 @@ class OscListReceive(PyoObject):
:Args:
- path : string or list of strings
+ path: string or list of strings
Path(s) to remove.
"""
@@ -692,7 +716,7 @@ class OscListReceive(PyoObject):
for ind in reversed(indexes):
self._address.pop(ind)
first = ind * self._num
- for i in reversed(range(first, first+self._num)):
+ for i in reversed(list(range(first, first+self._num))):
obj = self._base_objs.pop(i)
def setInterpolation(self, x):
@@ -701,7 +725,7 @@ class OscListReceive(PyoObject):
:Args:
- x : boolean
+ x: boolean
True activates the interpolation, False deactivates it.
"""
@@ -714,9 +738,9 @@ class OscListReceive(PyoObject):
:Args:
- path : string
+ path: string
Address to which the value should be attributed.
- value : list of floats
+ value: list of floats
List of values to attribute to the given address.
"""
@@ -725,16 +749,16 @@ class OscListReceive(PyoObject):
for i in range(lmax):
p = wrap(path,i)
if p in self._address:
- if type(value[0]) == ListType:
+ if type(value[0]) == list:
val = wrap(value,i)
else:
val = value
if len(val) == self._num:
self._mainReceiver.setValue(p, val)
else:
- print 'Error: OscListReceive.setValue, value must be of the same length as the `num` attribute.'
+ 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):
"""
@@ -747,11 +771,11 @@ class OscListReceive(PyoObject):
:Args:
- identifier : string
+ identifier: string
Address string parameter identifying audio stream.
Defaults to None, useful when `all` is True to
retreive all streams values.
- all : boolean, optional
+ 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
@@ -770,4 +794,4 @@ class OscListReceive(PyoObject):
return outlist
def out(self, chnl=0, inc=1, dur=0, delay=0):
- return self.play(dur, delay)
\ No newline at end of file
+ return self.play(dur, delay)
diff --git a/pyolib/pan.py b/pyolib/pan.py
index 9bf4900..a48549f 100644
--- a/pyolib/pan.py
+++ b/pyolib/pan.py
@@ -1,3 +1,6 @@
+from __future__ import division
+from __future__ import print_function
+from __future__ import absolute_import
"""
Set of objects to manage audio voice routing and spread of a sound
signal into a new stereo or multi-channel sound field.
@@ -24,9 +27,8 @@ 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
+from ._core import *
+from ._maps import *
class Pan(PyoObject):
"""
@@ -36,15 +38,15 @@ class Pan(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- outs : int, optional
+ outs: int, optional
Number of channels on the panning circle. Available at
initialization time only. Defaults to 2.
- pan : float or PyoObject
+ pan: float or PyoObject
Position of the sound on the panning circle, between 0 and 1.
Defaults to 0.5.
- spread : float or PyoObject
+ spread: float or PyoObject
Amount of sound leaking to the surrounding channels,
between 0 and 1. Defaults to 0.5.
@@ -76,9 +78,9 @@ class Pan(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -92,7 +94,7 @@ class Pan(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pan` attribute.
"""
@@ -107,7 +109,7 @@ class Pan(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `spread` attribute.
"""
@@ -151,12 +153,12 @@ class SPan(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- outs : int, optional
+ outs: int, optional
Number of channels on the panning circle. Available at
initialization time only. Defaults to 2.
- pan : float or PyoObject
+ pan: float or PyoObject
Position of the sound on the panning circle, between 0 and 1.
Defaults to 0.5.
@@ -187,9 +189,9 @@ class SPan(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -203,7 +205,7 @@ class SPan(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pan` attribute.
"""
@@ -244,12 +246,12 @@ class Switch(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- outs : int, optional
+ outs: int, optional
Number of outputs. Available at initialization time only.
Defaults to 2.
- voice : float or PyoObject
+ voice: float or PyoObject
Voice position pointer, between 0 and (outs-1) / len(input).
Defaults to 0.
@@ -283,9 +285,9 @@ class Switch(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -299,7 +301,7 @@ class Switch(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `voice` attribute.
"""
@@ -337,9 +339,9 @@ class Selector(PyoObject):
:Args:
- inputs : list of PyoObject
+ inputs: list of PyoObject
Audio objects to interpolate from.
- voice : float or PyoObject, optional
+ voice: float or PyoObject, optional
Voice position pointer, between 0 and len(inputs)-1.
Defaults to 0.
@@ -381,7 +383,7 @@ class Selector(PyoObject):
:Args:
- x : list of PyoObject
+ x: list of PyoObject
new `inputs` attribute.
"""
@@ -403,7 +405,7 @@ class Selector(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `voice` attribute.
"""
@@ -411,7 +413,7 @@ class Selector(PyoObject):
self._voice = x
x, lmax = convertArgsToLists(x)
for i, obj in enumerate(self._base_objs):
- obj.setVoice(wrap(x, i/self._length))
+ obj.setVoice(wrap(x, i // self._length))
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0, len(self._inputs)-1, "lin", "voice", self._voice), SLMapMul(self._mul)]
@@ -452,9 +454,9 @@ class VoiceManager(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Trigger stream asking for new voice numbers.
- triggers : PyoObject or list of PyoObject, optional
+ 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.
@@ -479,8 +481,8 @@ class VoiceManager(PyoObject):
self._triggers = triggers
self._in_fader = InputFader(input)
in_fader, mul, add, lmax = convertArgsToLists(self._in_fader, mul, add)
- if triggers != None:
- if type(triggers) == ListType:
+ if triggers is not None:
+ if type(triggers) == list:
try:
t_streams = [obj[0] for obj in triggers]
except TypeError:
@@ -499,9 +501,9 @@ class VoiceManager(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -515,14 +517,14 @@ class VoiceManager(PyoObject):
: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:
+ if x is not None:
+ if type(x) == list:
try:
t_streams = [obj[0] for obj in x]
except TypeError:
@@ -560,13 +562,13 @@ class Mixer(PyoObject):
:Args:
- outs : int, optional
+ outs: int, optional
Number of outputs of the mixer. Available at initialization
time only. Defaults to 2.
- chnls : int, optional
+ chnls: int, optional
Number of channels per output. Available at initialization
time only. Defaults to 1.
- time : float, optional
+ time: float, optional
Duration, in seconds, of a portamento applied on
a new amplitude value for a mixing channel.
Defaults to 0.025.
@@ -604,12 +606,12 @@ class Mixer(PyoObject):
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)]
+ if type(x) == slice:
+ return [self._base_objs[j*self._chnls+i] for j in range(x.start or 0, x.stop or sys.maxsize, 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):
"""
@@ -617,7 +619,7 @@ class Mixer(PyoObject):
:Args:
- x : float
+ x: float
New portamento duration.
"""
@@ -634,20 +636,20 @@ class Mixer(PyoObject):
:Args:
- voice : int or string
+ voice: int or string
Key in the mixer dictionary for this input. If None, a unique key
between 0 and 32767 will be automatically generated.
- input : PyoObject
+ input: PyoObject
Audio object to add to the mixer.
"""
pyoArgsAssert(self, "o", input)
- if voice == None:
+ if voice is None:
voice = random.randint(0, 32767)
- while self._inputs.has_key(voice):
+ while voice in self._inputs:
voice = random.randint(0, 32767)
- if self._inputs.has_key(voice):
- print >> sys.stderr, "Mixer has already a key named %s" % voice
+ if voice in self._inputs:
+ print("Mixer has already a key named %s" % voice, file=sys.stderr)
return
self._inputs[voice] = input
input, lmax = convertArgsToLists(input)
@@ -660,11 +662,11 @@ class Mixer(PyoObject):
:Args:
- voice : int or string
+ voice: int or string
Key in the mixer dictionary assigned to the input to remove.
"""
- if self._inputs.has_key(voice):
+ if voice in self._inputs:
del self._inputs[voice]
[obj.delInput(str(voice)) for i, obj in enumerate(self._base_players)]
@@ -674,15 +676,15 @@ class Mixer(PyoObject):
:Args:
- vin : int or string
+ vin: int or string
Key in the mixer dictionary of the desired input.
- vout : int
+ vout: int
Ouput channel where to send the signal.
- amp : float
+ amp: float
Amplitude value for this mixing channel.
"""
- if self._inputs.has_key(vin) and vout < self._outs:
+ if vin in self._inputs and vout < self._outs:
[obj.setAmp(str(vin), vout, amp) for i, obj in enumerate(self._base_players)]
def getChannels(self):
@@ -697,7 +699,7 @@ class Mixer(PyoObject):
Returns the list of current keys in the Mixer's channels dictionary.
"""
- return self._inputs.keys()
+ return list(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),
@@ -709,4 +711,4 @@ class Mixer(PyoObject):
"""float. Portamento."""
return self._time
@time.setter
- def time(self, x): self.setTime(x)
\ No newline at end of file
+ def time(self, x): self.setTime(x)
diff --git a/pyolib/pattern.py b/pyolib/pattern.py
index 8147c41..fd07313 100644
--- a/pyolib/pattern.py
+++ b/pyolib/pattern.py
@@ -4,6 +4,7 @@ Useful for event sequencing.
"""
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -23,8 +24,8 @@ 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 *
+from ._core import *
+from ._maps import *
class Pattern(PyoObject):
"""
@@ -37,10 +38,13 @@ class Pattern(PyoObject):
:Args:
- function : Python function
+ function: Python function
Python function to be called periodically.
- time : float or PyoObject, optional
+ time: float or PyoObject, optional
Time, in seconds, between each call. Default to 1.
+ arg: anything, optional
+ Argument sent to the function's call. If None, the function
+ will be called without argument. Defaults to None.
.. note::
@@ -48,6 +52,16 @@ class Pattern(PyoObject):
Pattern has no `mul` and `add` attributes.
+ If `arg` is None, the function must be defined without argument:
+
+ >>> def tocall():
+ >>> # function's body
+
+ If `arg` is not None, the function must be defined with one argument:
+
+ >>> def tocall(arg):
+ >>> print arg
+
>>> s = Server().boot()
>>> s.start()
>>> t = HarmTable([1,0,.33,0,.2,0,.143,0,.111])
@@ -59,13 +73,14 @@ class Pattern(PyoObject):
>>> p.play()
"""
- def __init__(self, function, time=1):
+ def __init__(self, function, time=1, arg=None):
pyoArgsAssert(self, "cO", function, time)
PyoObject.__init__(self)
self._function = getWeakMethodRef(function)
self._time = time
- function, time, lmax = convertArgsToLists(function, time)
- self._base_objs = [Pattern_base(WeakMethod(wrap(function,i)), wrap(time,i)) for i in range(lmax)]
+ self._arg = arg
+ function, time, arg, lmax = convertArgsToLists(function, time, arg)
+ self._base_objs = [Pattern_base(WeakMethod(wrap(function,i)), wrap(time,i), wrap(arg,i)) for i in range(lmax)]
def setFunction(self, x):
"""
@@ -73,7 +88,7 @@ class Pattern(PyoObject):
:Args:
- x : Python function
+ x: Python function
new `function` attribute.
"""
@@ -88,7 +103,7 @@ class Pattern(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `time` attribute.
"""
@@ -97,6 +112,20 @@ class Pattern(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ def setArg(self, x):
+ """
+ Replace the `arg` attribute.
+
+ :Args:
+
+ x: Anything
+ new `arg` attribute.
+
+ """
+ self._arg = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setArg(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)
@@ -129,6 +158,13 @@ class Pattern(PyoObject):
return self._time
@time.setter
def time(self, x): self.setTime(x)
+ @property
+ def arg(self):
+ """Anything. Callable's argument."""
+ return self._arg
+ @arg.setter
+ def arg(self, x):
+ self.setArg(x)
class Score(PyoObject):
"""
@@ -146,10 +182,10 @@ class Score(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal. Must contains integer numbers. Integer must change
before calling its function again.
- fname : string, optional
+ fname: string, optional
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.
@@ -201,9 +237,9 @@ class Score(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -227,11 +263,11 @@ class CallAfter(PyoObject):
:Args:
- function : Python function
+ function: Python function
Python callable execute after `time` seconds.
- time : float, optional
+ time: float, optional
Time, in seconds, before the call. Default to 1.
- arg : any Python object, optional
+ arg: any Python object, optional
Argument sent to the called function. Default to None.
.. note::
@@ -240,6 +276,16 @@ class CallAfter(PyoObject):
CallAfter has no `mul` and `add` attributes.
+ If `arg` is None, the function must be defined without argument:
+
+ >>> def tocall():
+ >>> # function's body
+
+ If `arg` is not None, the function must be defined with one argument:
+
+ >>> def tocall(arg):
+ >>> print arg
+
The object is not deleted after the call. The user must delete it himself.
>>> s = Server().boot()
@@ -272,4 +318,4 @@ class CallAfter(PyoObject):
pass
def setDiv(self, x):
- pass
\ No newline at end of file
+ pass
diff --git a/pyolib/phasevoc.py b/pyolib/phasevoc.py
index ae988d2..7997797 100644
--- a/pyolib/phasevoc.py
+++ b/pyolib/phasevoc.py
@@ -7,6 +7,7 @@ time scaling, pitch transposition, and myriad other modifications of sounds.
"""
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -26,10 +27,10 @@ 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 *
-from _widgets import createSpectrumWindow
-from pattern import Pattern
+from ._core import *
+from ._maps import *
+from ._widgets import createSpectrumWindow
+from .pattern import Pattern
class PVAnal(PyoPVObject):
"""
@@ -47,21 +48,21 @@ class PVAnal(PyoPVObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- size : int {pow-of-two > 4}, optional
+ size: int {pow-of-two > 4}, optional
FFT size. Must be a power of two greater than 4.
Defaults to 1024.
The FFT size is the number of samples used in each
analysis frame.
- overlaps : int, optional
+ 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
synthesis but it is also more CPU expensive.
- wintype : int, optional
+ wintype: int, optional
Shape of the envelope used to filter each input frame.
Possible shapes are:
0. rectangular (no windowing)
@@ -98,9 +99,9 @@ class PVAnal(PyoPVObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -114,7 +115,7 @@ class PVAnal(PyoPVObject):
:Args:
- x : int
+ x: int
new `size` attribute.
"""
@@ -129,7 +130,7 @@ class PVAnal(PyoPVObject):
:Args:
- x : int
+ x: int
new `overlaps` attribute.
"""
@@ -144,7 +145,7 @@ class PVAnal(PyoPVObject):
:Args:
- x : int
+ x: int
new `wintype` attribute.
"""
@@ -193,9 +194,9 @@ class PVSynth(PyoObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- wintype : int, optional
+ wintype: int, optional
Shape of the envelope used to filter each input frame.
Possible shapes are:
0. rectangular (no windowing)
@@ -229,7 +230,7 @@ class PVSynth(PyoObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -244,7 +245,7 @@ class PVSynth(PyoObject):
:Args:
- x : int
+ x: int
new `wintype` attribute.
"""
@@ -284,17 +285,17 @@ class PVAddSynth(PyoObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- pitch : float or PyoObject, optional
+ pitch: float or PyoObject, optional
Transposition factor. Defaults to 1.
- num : int, optional
+ num: int, optional
Number of oscillators used to synthesize the
output sound. Defaults to 100.
- first : int, optional
+ first: int, optional
The first bin to synthesize, starting from 0.
Defaults to 0.
- inc : int, optional
+ inc: int, optional
Starting from bin `first`, resynthesize bins
`inc` apart. Defaults to 1.
@@ -323,7 +324,7 @@ class PVAddSynth(PyoObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -338,7 +339,7 @@ class PVAddSynth(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pitch` attribute.
"""
@@ -353,7 +354,7 @@ class PVAddSynth(PyoObject):
:Args:
- x : int
+ x: int
new `num` attribute.
"""
@@ -368,7 +369,7 @@ class PVAddSynth(PyoObject):
:Args:
- x : int
+ x: int
new `first` attribute.
"""
@@ -383,7 +384,7 @@ class PVAddSynth(PyoObject):
:Args:
- x : int
+ x: int
new `inc` attribute.
"""
@@ -440,9 +441,9 @@ class PVTranspose(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- transpo : float or PyoObject, optional
+ transpo: float or PyoObject, optional
Transposition factor. Defaults to 1.
>>> s = Server().boot()
@@ -468,7 +469,7 @@ class PVTranspose(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -483,7 +484,7 @@ class PVTranspose(PyoPVObject):
:Args:
- x : int
+ x: int
new `transpo` attribute.
"""
@@ -518,12 +519,12 @@ class PVVerb(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- revtime : float or PyoObject, optional
+ revtime: float or PyoObject, optional
Reverberation factor, between 0 and 1.
Defaults to 0.75.
- damp : float or PyoObject, optional
+ damp: float or PyoObject, optional
High frequency damping factor, between 0 and 1.
1 means no damping and 0 is the most damping.
Defaults to 0.75.
@@ -553,7 +554,7 @@ class PVVerb(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -568,7 +569,7 @@ class PVVerb(PyoPVObject):
:Args:
- x : int
+ x: int
new `revtime` attribute.
"""
@@ -583,7 +584,7 @@ class PVVerb(PyoPVObject):
:Args:
- x : int
+ x: int
new `damp` attribute.
"""
@@ -626,13 +627,18 @@ class PVGate(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- thresh : float or PyoObject, optional
+ thresh: float or PyoObject, optional
Threshold factor in dB. Bins below that threshold
will be scaled by `damp` factor. Defaults to -20.
- damp : float or PyoObject, optional
+ damp: float or PyoObject, optional
Damping factor for low amplitude bins. Defaults to 0.
+ inverse: boolean, optional
+ If True, the damping factor will be applied to the bins
+ with amplitude above the given threshold. If False, the
+ damping factor is applied to bins with amplitude below
+ the given threshold. Defaults to False.
>>> s = Server().boot()
>>> s.start()
@@ -642,14 +648,15 @@ class PVGate(PyoPVObject):
>>> pvs = PVSynth(pvg).mix(2).out()
"""
- def __init__(self, input, thresh=-20, damp=0.):
- pyoArgsAssert(self, "pOO", input, thresh, damp)
+ def __init__(self, input, thresh=-20, damp=0., inverse=False):
+ pyoArgsAssert(self, "pOOb", input, thresh, damp, inverse)
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)]
+ self._inverse = inverse
+ input, thresh, damp, inverse, lmax = convertArgsToLists(self._input, thresh, damp, inverse)
+ self._base_objs = [PVGate_base(wrap(input,i), wrap(thresh,i), wrap(damp,i), wrap(inverse,i)) for i in range(lmax)]
def setInput(self, x):
"""
@@ -657,7 +664,7 @@ class PVGate(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -672,7 +679,7 @@ class PVGate(PyoPVObject):
:Args:
- x : int
+ x: int
new `thresh` attribute.
"""
@@ -687,7 +694,7 @@ class PVGate(PyoPVObject):
:Args:
- x : int
+ x: int
new `damp` attribute.
"""
@@ -696,6 +703,21 @@ class PVGate(PyoPVObject):
x, lmax = convertArgsToLists(x)
[obj.setDamp(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+ def setInverse(self, x):
+ """
+ Replace the `inverse` attribute.
+
+ :Args:
+
+ x: boolean
+ 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)]
+
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(-120, 18, "lin", "thresh", self._thresh),
SLMap(0, 2, "lin", "damp", self._damp)]
@@ -722,6 +744,13 @@ class PVGate(PyoPVObject):
@damp.setter
def damp(self, x): self.setDamp(x)
+ @property
+ def inverse(self):
+ """boolean. If True, the gate is applied to high amplitude bins."""
+ return self._inverse
+ @inverse.setter
+ def inverse(self, x): self.setInverse(x)
+
class PVCross(PyoPVObject):
"""
Performs cross-synthesis between two phase vocoder streaming object.
@@ -733,13 +762,13 @@ class PVCross(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process. Frequencies from
this pv stream are used to compute the output signal.
- input2 : PyoPVObject
+ input2: 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
+ 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`.
Defaults to 1.
@@ -784,7 +813,7 @@ class PVCross(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -799,7 +828,7 @@ class PVCross(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -814,7 +843,7 @@ class PVCross(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `fade` attribute.
"""
@@ -856,10 +885,10 @@ class PVMult(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process. Frequencies from
this pv stream are used to compute the output signal.
- input2 : PyoPVObject
+ input2: PyoPVObject
Phase vocoder streaming object which gives the second set of
magnitudes. Frequencies from this pv stream are not used.
@@ -902,7 +931,7 @@ class PVMult(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -917,7 +946,7 @@ class PVMult(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -952,13 +981,13 @@ class PVMorph(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object which gives the first set of
magnitudes and frequencies.
- input2 : PyoPVObject
+ input2: PyoPVObject
Phase vocoder streaming object which gives the second set of
magnitudes and frequencies.
- fade : float or PyoObject, optional
+ fade: float or PyoObject, optional
Scaling factor for the output amplitudes and frequencies,
between 0 and 1. 0 is `input` and 1 in `input2`. Defaults to 0.5.
@@ -1002,7 +1031,7 @@ class PVMorph(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -1017,7 +1046,7 @@ class PVMorph(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -1032,7 +1061,7 @@ class PVMorph(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `fade` attribute.
"""
@@ -1078,16 +1107,16 @@ class PVFilter(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- table : PyoTableObject
+ table: PyoTableObject
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: float or PyoObject, optional
Gain of the filter applied to the input spectrum.
Defaults to 1.
- mode : int, optional
+ mode: int, optional
Table scanning mode. Defaults to 0.
If 0, bin indexes outside table size are set to 0.
@@ -1118,7 +1147,7 @@ class PVFilter(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -1133,7 +1162,7 @@ class PVFilter(PyoPVObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -1148,7 +1177,7 @@ class PVFilter(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `gain` attribute.
"""
@@ -1163,7 +1192,7 @@ class PVFilter(PyoPVObject):
:Args:
- x : int
+ x: int
new `mode` attribute.
"""
@@ -1216,23 +1245,23 @@ class PVDelay(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- deltable : PyoTableObject
+ deltable: PyoTableObject
Table containing delay times, as integer multipliers
of the FFT hopsize (fftsize / overlaps).
If the table length is smaller than fftsize/2,
remaining bins will be set to 0.
- feedtable : PyoTableObject
+ feedtable: PyoTableObject
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
+ maxdelay: float, optional
Maximum delay time in seconds. Available at initialization
time only. Defaults to 1.0.
- mode : int, optional
+ mode: int, optional
Tables scanning mode. Defaults to 0.
If 0, bin indexes outside table size are set to 0.
@@ -1271,7 +1300,7 @@ class PVDelay(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -1286,7 +1315,7 @@ class PVDelay(PyoPVObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `deltable` attribute.
"""
@@ -1301,7 +1330,7 @@ class PVDelay(PyoPVObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `feedtable` attribute.
"""
@@ -1316,7 +1345,7 @@ class PVDelay(PyoPVObject):
:Args:
- x : int
+ x: int
new `mode` attribute.
"""
@@ -1364,14 +1393,14 @@ class PVBuffer(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- index : PyoObject
+ index: PyoObject
Playback position, as audio stream, normalized
between 0 and 1.
- pitch : float or PyoObject, optional
+ pitch: float or PyoObject, optional
Transposition factor. Defaults to 1.
- length : float, optional
+ length: float, optional
Memory length in seconds. Available at initialization
time only. Defaults to 1.0.
@@ -1407,7 +1436,7 @@ class PVBuffer(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -1422,7 +1451,7 @@ class PVBuffer(PyoPVObject):
:Args:
- x : PyoObject
+ x: PyoObject
new `index` attribute.
"""
@@ -1437,7 +1466,7 @@ class PVBuffer(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pitch` attribute.
"""
@@ -1482,9 +1511,9 @@ class PVShift(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- shift : float or PyoObject, optional
+ shift: float or PyoObject, optional
Frequency shift factor. Defaults to 0.
>>> s = Server().boot()
@@ -1509,7 +1538,7 @@ class PVShift(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -1524,7 +1553,7 @@ class PVShift(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `shift` attribute.
"""
@@ -1571,12 +1600,12 @@ class PVAmpMod(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- basefreq : float or PyoObject, optional
+ basefreq: float or PyoObject, optional
Base modulation frequency, in Hertz.
Defaults to 1.
- spread : float or PyoObject, optional
+ spread: float or PyoObject, optional
Spreading factor for oscillator frequencies, between
-1 and 1. 0 means every oscillator has the same frequency.
@@ -1603,7 +1632,7 @@ class PVAmpMod(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -1618,7 +1647,7 @@ class PVAmpMod(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `basefreq` attribute.
"""
@@ -1633,7 +1662,7 @@ class PVAmpMod(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `spread` attribute.
"""
@@ -1695,15 +1724,15 @@ class PVFreqMod(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- basefreq : float or PyoObject, optional
+ basefreq: float or PyoObject, optional
Base modulation frequency, in Hertz.
Defaults to 1.
- spread : float or PyoObject, optional
+ 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
+ depth: float or PyoObject, optional
Amplitude of the modulating oscillators, between 0 and 1.
Defaults to 0.1.
@@ -1731,7 +1760,7 @@ class PVFreqMod(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -1746,7 +1775,7 @@ class PVFreqMod(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `basefreq` attribute.
"""
@@ -1761,7 +1790,7 @@ class PVFreqMod(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `spread` attribute.
"""
@@ -1776,7 +1805,7 @@ class PVFreqMod(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `depth` attribute.
"""
@@ -1838,13 +1867,13 @@ class PVBufLoops(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- low : float or PyoObject, optional
+ low: float or PyoObject, optional
Lowest bin speed factor. Defaults to 1.0.
- high : float or PyoObject, optional
+ high: float or PyoObject, optional
Highest bin speed factor. Defaults to 1.0.
- mode : int, optional
+ mode: int, optional
Speed distribution algorithm. Available algorithms are:
0. linear, line between `low` and `high` (default)
1. exponential, exponential line between `low` and `high`
@@ -1854,7 +1883,7 @@ class PVBufLoops(PyoPVObject):
5. rand expon max, exponential random from `high` to `low`
6. rand bi-expon, bipolar exponential random between `low` and `high`
- length : float, optional
+ length: float, optional
Memory length in seconds. Available at initialization
time only. Defaults to 1.0.
@@ -1890,7 +1919,7 @@ class PVBufLoops(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -1905,7 +1934,7 @@ class PVBufLoops(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `low` attribute.
"""
@@ -1920,7 +1949,7 @@ class PVBufLoops(PyoPVObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `high` attribute.
"""
@@ -1935,7 +1964,7 @@ class PVBufLoops(PyoPVObject):
:Args:
- x : int
+ x: int
new `mode` attribute.
"""
@@ -1996,11 +2025,11 @@ class PVBufTabLoops(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object to process.
- speed : PyoTableObject
+ speed: PyoTableObject
Table which specify the speed of bin playback readers.
- length : float, optional
+ length: float, optional
Memory length in seconds. Available at initialization
time only. Defaults to 1.0.
@@ -2035,7 +2064,7 @@ class PVBufTabLoops(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -2050,7 +2079,7 @@ class PVBufTabLoops(PyoPVObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `speed` attribute.
"""
@@ -2088,9 +2117,9 @@ class PVMix(PyoPVObject):
:Args:
- input : PyoPVObject
+ input: PyoPVObject
Phase vocoder streaming object 1.
- input2 : PyoPVObject
+ input2: PyoPVObject
Phase vocoder streaming object 2.
.. note::
@@ -2132,7 +2161,7 @@ class PVMix(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -2147,7 +2176,7 @@ class PVMix(PyoPVObject):
:Args:
- x : PyoPVObject
+ x: PyoPVObject
New signal to process.
"""
@@ -2168,4 +2197,4 @@ class PVMix(PyoPVObject):
"""PyoPVObject. Phase vocoder streaming object 2."""
return self._input2
@input2.setter
- def input2(self, x): self.setInput2(x)
\ No newline at end of file
+ def input2(self, x): self.setInput2(x)
diff --git a/pyolib/players.py b/pyolib/players.py
index 525bac9..8d4bd42 100644
--- a/pyolib/players.py
+++ b/pyolib/players.py
@@ -1,3 +1,6 @@
+from __future__ import division
+from __future__ import print_function
+from __future__ import absolute_import
"""
Play soundfiles from the disk.
@@ -24,10 +27,9 @@ 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 *
+from ._core import *
+from ._maps import *
import aifc
-from types import ListType
class SfPlayer(PyoObject):
"""
@@ -42,9 +44,9 @@ class SfPlayer(PyoObject):
:Args:
- path : string
+ path: string
Full path name of the sound to read.
- speed : float or PyoObject, optional
+ speed: float or PyoObject, optional
Transpose the pitch of input sound by this factor.
Defaults to 1.
@@ -55,12 +57,12 @@ class SfPlayer(PyoObject):
Although the `speed` attribute accepts audio
rate signal, its value is updated only once per buffer size.
- loop : bool, optional
+ loop: bool, optional
If set to True, sound will play in loop. Defaults to False.
- offset : float, optional
+ offset: float, optional
Time in seconds of input sound to be skipped, assuming speed = 1.
Defaults to 0.
- interp : int, optional
+ interp: int, optional
Interpolation type. Defaults to 2.
1. no interpolation
2. linear
@@ -69,15 +71,15 @@ class SfPlayer(PyoObject):
.. note::
- SfPlayer will sends a trigger signal at the end of the playback if
+ SfPlayer will send 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'])
-
- Note that the object will send as many trigs as there is channels
- in the sound file. If you want to retrieve only one trig, only give
+
+ Note that the object will send as many trigs as there is channels
+ in the sound file. If you want to retrieve only one trig, only give
the first stream to the next object:
>>> def printing():
@@ -120,16 +122,16 @@ class SfPlayer(PyoObject):
:Args:
- path : string
+ path: string
Full path of the new sound.
"""
pyoArgsAssert(self, "s", path)
- if type(self._path) == ListType:
+ if type(self._path) == list:
curNchnls = sndinfo(self._path[0])[3]
else:
curNchnls = sndinfo(self._path)[3]
- if type(path) == ListType:
+ if type(path) == list:
p = path[0]
else:
p = path
@@ -138,7 +140,7 @@ class SfPlayer(PyoObject):
except:
return
if _snd_chnls != curNchnls:
- print "Soundfile must contains exactly %d channels." % curNchnls
+ print("Soundfile must contains exactly %d channels." % curNchnls)
return
self._path = path
@@ -154,7 +156,7 @@ class SfPlayer(PyoObject):
:Args:
- path : string
+ path: string
Full path of the new sound.
"""
@@ -166,7 +168,7 @@ class SfPlayer(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `speed` attribute.
"""
@@ -181,7 +183,7 @@ class SfPlayer(PyoObject):
:Args:
- x : bool {True, False}
+ x: bool {True, False}
new `loop` attribute.
"""
@@ -198,7 +200,7 @@ class SfPlayer(PyoObject):
:Args:
- x : float
+ x: float
new `offset` attribute.
"""
@@ -213,7 +215,7 @@ class SfPlayer(PyoObject):
:Args:
- x : int {1, 2, 3, 4}
+ x: int {1, 2, 3, 4}
new `interp` attribute.
"""
@@ -288,10 +290,10 @@ class SfMarkerShuffler(PyoObject):
:Args:
- path : string
+ path: string
Full path name of the sound to read. Can't e changed after
initialization.
- speed : float or PyoObject, optional
+ speed: float or PyoObject, optional
Transpose the pitch of input sound by this factor.
Defaults to 1.
@@ -302,7 +304,7 @@ class SfMarkerShuffler(PyoObject):
Although the `speed` attribute accepts audio
rate signal, its value is updated only once per buffer size.
- interp : int, optional
+ interp: int, optional
Choice of the interpolation method. Defaults to 2.
1. no interpolation
2. linear
@@ -333,7 +335,7 @@ class SfMarkerShuffler(PyoObject):
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
+ j = i // self._snd_chnls
self._base_objs.append(SfMarkerShuffle_base(wrap(self._base_players,j), i % self._snd_chnls, wrap(mul,j), wrap(add,j)))
def setSpeed(self, x):
@@ -342,7 +344,7 @@ class SfMarkerShuffler(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `speed` attribute.
"""
@@ -357,7 +359,7 @@ class SfMarkerShuffler(PyoObject):
:Args:
- x : int {1, 2, 3, 4}
+ x: int {1, 2, 3, 4}
new `interp` attribute.
"""
@@ -410,9 +412,9 @@ class SfMarkerLooper(PyoObject):
:Args:
- path : string
+ path: string
Full path name of the sound to read.
- speed : float or PyoObject, optional
+ speed: float or PyoObject, optional
Transpose the pitch of input sound by this factor.
Defaults to 1.
@@ -423,10 +425,10 @@ class SfMarkerLooper(PyoObject):
Although the `speed` attribute accepts audio
rate signal, its value is updated only once per buffer size.
- mark : float or PyoObject, optional
+ mark: float or PyoObject, optional
Integer denoting the marker to loop, in the range
0 -> len(getMarkers()). Defaults to 0.
- interp : int, optional
+ interp: int, optional
Choice of the interpolation method. Defaults to 2.
1. no interpolation
2. linear
@@ -460,7 +462,7 @@ class SfMarkerLooper(PyoObject):
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
+ j = i // self._snd_chnls
self._base_objs.append(SfMarkerLoop_base(wrap(self._base_players,j), i % self._snd_chnls, wrap(mul,j), wrap(add,j)))
def setSpeed(self, x):
@@ -469,7 +471,7 @@ class SfMarkerLooper(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `speed` attribute.
"""
@@ -484,7 +486,7 @@ class SfMarkerLooper(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `mark` attribute.
"""
@@ -499,7 +501,7 @@ class SfMarkerLooper(PyoObject):
:Args:
- x : int {1, 2, 3, 4}
+ x: int {1, 2, 3, 4}
new `interp` attribute.
"""
@@ -541,4 +543,4 @@ class SfMarkerLooper(PyoObject):
"""int {1, 2, 3, 4}. Interpolation method."""
return self._interp
@interp.setter
- def interp(self, x): self.setInterp(x)
\ No newline at end of file
+ def interp(self, x): self.setInterp(x)
diff --git a/pyolib/randoms.py b/pyolib/randoms.py
index f3e3f68..c39e6a0 100644
--- a/pyolib/randoms.py
+++ b/pyolib/randoms.py
@@ -2,6 +2,7 @@
Set of objects that implement different kinds of random noise generators.
"""
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -21,9 +22,8 @@ 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 *
-from types import StringType, ListType
+from ._core import *
+from ._maps import *
class Randi(PyoObject):
"""
@@ -37,11 +37,11 @@ class Randi(PyoObject):
:Args:
- min : float or PyoObject, optional
+ min: float or PyoObject, optional
Minimum value for the random generation. Defaults to 0.
- max : float or PyoObject, optional
+ max: float or PyoObject, optional
Maximum value for the random generation. Defaults to 1.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Polling frequency. Defaults to 1.
>>> s = Server().boot()
@@ -66,7 +66,7 @@ class Randi(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `min` attribute.
"""
@@ -81,7 +81,7 @@ class Randi(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `max` attribute.
"""
@@ -96,7 +96,7 @@ class Randi(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -146,11 +146,11 @@ class Randh(PyoObject):
:Args:
- min : float or PyoObject, optional
+ min: float or PyoObject, optional
Minimum value for the random generation. Defaults to 0.
- max : float or PyoObject, optional
+ max: float or PyoObject, optional
Maximum value for the random generation. Defaults to 1.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Polling frequency. Defaults to 1.
>>> s = Server().boot()
@@ -175,7 +175,7 @@ class Randh(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `min` attribute.
"""
@@ -190,7 +190,7 @@ class Randh(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `max` attribute.
"""
@@ -205,7 +205,7 @@ class Randh(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -255,9 +255,9 @@ class Choice(PyoObject):
:Args:
- choice : list of floats or list of lists of floats
+ choice: list of floats or list of lists of floats
Possible values for the random generation.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Polling frequency. Defaults to 1.
>>> s = Server().boot()
@@ -273,7 +273,7 @@ class Choice(PyoObject):
self._choice = choice
self._freq = freq
freq, mul, add, lmax = convertArgsToLists(freq, mul, add)
- if type(choice[0]) != ListType:
+ if type(choice[0]) != list:
self._base_objs = [Choice_base(choice, wrap(freq,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
else:
choicelen = len(choice)
@@ -286,13 +286,13 @@ class Choice(PyoObject):
:Args:
- x : list of floats or list of lists of floats
+ 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:
+ if type(x[0]) != list:
[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)]
@@ -303,7 +303,7 @@ class Choice(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -343,9 +343,9 @@ class RandInt(PyoObject):
:Args:
- max : float or PyoObject, optional
+ max: float or PyoObject, optional
Maximum value for the random generation. Defaults to 100.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Polling frequency. Defaults to 1.
>>> s = Server().boot()
@@ -369,7 +369,7 @@ class RandInt(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `max` attribute.
"""
@@ -384,7 +384,7 @@ class RandInt(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -426,9 +426,9 @@ class RandDur(PyoObject):
:Args:
- min : float or PyoObject, optional
+ min: float or PyoObject, optional
Minimum value for the random generation. Defaults to 0.
- max : float or PyoObject, optional
+ max: float or PyoObject, optional
Maximum value for the random generation. Defaults to 1.
>>> s = Server().boot()
@@ -455,7 +455,7 @@ class RandDur(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `min` attribute.
"""
@@ -470,7 +470,7 @@ class RandDur(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `max` attribute.
"""
@@ -511,13 +511,13 @@ class Xnoise(PyoObject):
:Args:
- dist : string or int, optional
+ dist: string or int, optional
Distribution type. Defaults to 0.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Polling frequency. Defaults to 1.
- x1 : float or PyoObject, optional
+ x1: float or PyoObject, optional
First parameter. Defaults to 0.5.
- x2 : float or PyoObject, optional
+ x2: float or PyoObject, optional
Second parameter. Defaults to 0.5.
.. note::
@@ -542,44 +542,44 @@ class Xnoise(PyoObject):
parameter):
0. uniform
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
1. linear_min
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
2. linear_max
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
3. triangle
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
4. expon_min
- - x1 : slope {0 = no slope -> 10 = sharp slope}
- - x2 : not used
+ - x1: slope {0 = no slope -> 10 = sharp slope}
+ - x2: not used
5. expon_max
- - x1 : slope {0 = no slope -> 10 = sharp slope}
- - x2 : not used
+ - x1: slope {0 = no slope -> 10 = sharp slope}
+ - x2: not used
6. biexpon
- - x1 : bandwidth {0 = huge bandwidth -> 10 = narrow bandwidth}
- - x2 : not used
+ - x1: bandwidth {0 = huge bandwidth -> 10 = narrow bandwidth}
+ - x2: not used
7. cauchy
- - x1 : bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
- - x2 : not used
+ - x1: bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
+ - x2: not used
8. weibull
- - x1 : mean location {0 -> 1}
- - x2 : shape {0.5 = linear min, 1.5 = expon min, 3.5 = gaussian}
+ - x1: mean location {0 -> 1}
+ - x2: shape {0.5 = linear min, 1.5 = expon min, 3.5 = gaussian}
9. gaussian
- - x1 : mean location {0 -> 1}
- - x2 : bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
+ - x1: mean location {0 -> 1}
+ - x2: bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
10. poisson
- - x1 : gravity center {0 = low values -> 10 = high values}
- - x2 : compress/expand range {0.1 = full compress -> 4 full expand}
+ - x1: gravity center {0 = low values -> 10 = high values}
+ - x2: compress/expand range {0.1 = full compress -> 4 full expand}
11. walker
- - x1 : maximum value {0.1 -> 1}
- - x2 : maximum step {0.1 -> 1}
+ - x1: maximum value {0.1 -> 1}
+ - x2: maximum step {0.1 -> 1}
12. loopseg
- - x1 : maximum value {0.1 -> 1}
- - x2 : maximum step {0.1 -> 1}
+ - x1: maximum value {0.1 -> 1}
+ - x2: maximum step {0.1 -> 1}
>>> s = Server().boot()
>>> s.start()
@@ -598,7 +598,7 @@ class Xnoise(PyoObject):
self._x2 = x2
dist, freq, x1, x2, mul, add, lmax = convertArgsToLists(dist, freq, x1, x2, mul, add)
for i, t in enumerate(dist):
- if type(t) == StringType: dist[i] = XNOISE_DICT.get(t, 0)
+ if type(t) in [bytes_t, unicode_t]: dist[i] = XNOISE_DICT.get(t, 0)
self._base_objs = [Xnoise_base(wrap(dist,i), wrap(freq,i), wrap(x1,i), wrap(x2,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setDist(self, x):
@@ -607,14 +607,14 @@ class Xnoise(PyoObject):
:Args:
- x : string or int
+ x: string or int
new `dist` attribute.
"""
self._dist = x
x, lmax = convertArgsToLists(x)
for i, t in enumerate(x):
- if type(t) == StringType: x[i] = XNOISE_DICT.get(t, 0)
+ if type(t) in [bytes_t, unicode_t]: x[i] = XNOISE_DICT.get(t, 0)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setX1(self, x):
@@ -623,7 +623,7 @@ class Xnoise(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `x1` attribute.
"""
@@ -638,7 +638,7 @@ class Xnoise(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `x2` attribute.
"""
@@ -653,7 +653,7 @@ class Xnoise(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -713,20 +713,20 @@ class XnoiseMidi(PyoObject):
:Args:
- dist : string or int, optional
+ dist: string or int, optional
Distribution type. Defaults to 0.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Polling frequency. Defaults to 1.
- x1 : float or PyoObject, optional
+ x1: float or PyoObject, optional
First parameter. Defaults to 0.5.
- x2 : float or PyoObject, optional
+ x2: float or PyoObject, optional
Second parameter. Defaults to 0.5.
- scale : int {0, 1, 2}, optional
+ 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
is no transposition) is (`minrange` + `maxrange`) / 2. Defaults
to 0.
- mrange : tuple of int, optional
+ mrange: tuple of int, optional
Minimum and maximum possible values, in Midi notes. Available
only at initialization time. Defaults to (0, 127).
@@ -752,44 +752,44 @@ class XnoiseMidi(PyoObject):
parameter):
0. uniform
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
1. linear_min
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
2. linear_max
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
3. triangle
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
4. expon_min
- - x1 : slope {0 = no slope -> 10 = sharp slope}
- - x2 : not used
+ - x1: slope {0 = no slope -> 10 = sharp slope}
+ - x2: not used
5. expon_max
- - x1 : slope {0 = no slope -> 10 = sharp slope}
- - x2 : not used
+ - x1: slope {0 = no slope -> 10 = sharp slope}
+ - x2: not used
6. biexpon
- - x1 : bandwidth {0 = huge bandwidth -> 10 = narrow bandwidth}
- - x2 : not used
+ - x1: bandwidth {0 = huge bandwidth -> 10 = narrow bandwidth}
+ - x2: not used
7. cauchy
- - x1 : bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
- - x2 : not used
+ - x1: bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
+ - x2: not used
8. weibull
- - x1 : mean location {0 -> 1}
- - x2 : shape {0.5 = linear min, 1.5 = expon min, 3.5 = gaussian}
+ - x1: mean location {0 -> 1}
+ - x2: shape {0.5 = linear min, 1.5 = expon min, 3.5 = gaussian}
9. gaussian
- - x1 : mean location {0 -> 1}
- - x2 : bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
+ - x1: mean location {0 -> 1}
+ - x2: bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
10. poisson
- - x1 : gravity center {0 = low values -> 10 = high values}
- - x2 : compress/expand range {0.1 = full compress -> 4 full expand}
+ - x1: gravity center {0 = low values -> 10 = high values}
+ - x2: compress/expand range {0.1 = full compress -> 4 full expand}
11. walker
- - x1 : maximum value {0.1 -> 1}
- - x2 : maximum step {0.1 -> 1}
+ - x1: maximum value {0.1 -> 1}
+ - x2: maximum step {0.1 -> 1}
12. loopseg
- - x1 : maximum value {0.1 -> 1}
- - x2 : maximum step {0.1 -> 1}
+ - x1: maximum value {0.1 -> 1}
+ - x2: maximum step {0.1 -> 1}
>>> s = Server().boot()
>>> s.start()
@@ -811,7 +811,7 @@ class XnoiseMidi(PyoObject):
self._mrange = mrange
dist, freq, x1, x2, scale, mrange, mul, add, lmax = convertArgsToLists(dist, freq, x1, x2, scale, mrange, mul, add)
for i, t in enumerate(dist):
- if type(t) == StringType: dist[i] = XNOISE_DICT.get(t, 0)
+ if type(t) in [bytes_t, unicode_t]: dist[i] = XNOISE_DICT.get(t, 0)
self._base_objs = [XnoiseMidi_base(wrap(dist,i), wrap(freq,i), wrap(x1,i), wrap(x2,i), wrap(scale,i), wrap(mrange,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setDist(self, x):
@@ -820,14 +820,14 @@ class XnoiseMidi(PyoObject):
:Args:
- x : string or int
+ x: string or int
new `dist` attribute.
"""
self._dist = x
x, lmax = convertArgsToLists(x)
for i, t in enumerate(x):
- if type(t) == StringType: x[i] = XNOISE_DICT.get(t, 0)
+ if type(t) in [bytes_t, unicode_t]: x[i] = XNOISE_DICT.get(t, 0)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setScale(self, x):
@@ -841,7 +841,7 @@ class XnoiseMidi(PyoObject):
:Args:
- x : int {0, 1, 2}
+ x: int {0, 1, 2}
new `scale` attribute.
"""
@@ -856,9 +856,9 @@ class XnoiseMidi(PyoObject):
:Args:
- mini : int
+ mini: int
minimum output midi range.
- maxi : int
+ maxi: int
maximum output midi range.
"""
@@ -873,7 +873,7 @@ class XnoiseMidi(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `x1` attribute.
"""
@@ -888,7 +888,7 @@ class XnoiseMidi(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `x2` attribute.
"""
@@ -903,7 +903,7 @@ class XnoiseMidi(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -970,16 +970,16 @@ class XnoiseDur(PyoObject):
:Args:
- dist : string or int, optional
+ dist: string or int, optional
Distribution type. Can be the name of the distribution as a string
or its associated number. Defaults to 0.
- min : float or PyoObject, optional
+ min: float or PyoObject, optional
Minimum value for the random generation. Defaults to 0.
- max : float or PyoObject, optional
+ max: float or PyoObject, optional
Maximum value for the random generation. Defaults to 1.
- x1 : float or PyoObject, optional
+ x1: float or PyoObject, optional
First parameter. Defaults to 0.5.
- x2 : float or PyoObject, optional
+ x2: float or PyoObject, optional
Second parameter. Defaults to 0.5.
.. note::
@@ -1004,44 +1004,44 @@ class XnoiseDur(PyoObject):
parameter):
0. uniform
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
1. linear_min
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
2. linear_max
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
3. triangle
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
4. expon_min
- - x1 : slope {0 = no slope -> 10 = sharp slope}
- - x2 : not used
+ - x1: slope {0 = no slope -> 10 = sharp slope}
+ - x2: not used
5. expon_max
- - x1 : slope {0 = no slope -> 10 = sharp slope}
- - x2 : not used
+ - x1: slope {0 = no slope -> 10 = sharp slope}
+ - x2: not used
6. biexpon
- - x1 : bandwidth {0 = huge bandwidth -> 10 = narrow bandwidth}
- - x2 : not used
+ - x1: bandwidth {0 = huge bandwidth -> 10 = narrow bandwidth}
+ - x2: not used
7. cauchy
- - x1 : bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
- - x2 : not used
+ - x1: bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
+ - x2: not used
8. weibull
- - x1 : mean location {0 -> 1}
- - x2 : shape {0.5 = linear min, 1.5 = expon min, 3.5 = gaussian}
+ - x1: mean location {0 -> 1}
+ - x2: shape {0.5 = linear min, 1.5 = expon min, 3.5 = gaussian}
9. gaussian
- - x1 : mean location {0 -> 1}
- - x2 : bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
+ - x1: mean location {0 -> 1}
+ - x2: bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
10. poisson
- - x1 : gravity center {0 = low values -> 10 = high values}
- - x2 : compress/expand range {0.1 = full compress -> 4 full expand}
+ - x1: gravity center {0 = low values -> 10 = high values}
+ - x2: compress/expand range {0.1 = full compress -> 4 full expand}
11. walker
- - x1 : maximum value {0.1 -> 1}
- - x2 : maximum step {0.1 -> 1}
+ - x1: maximum value {0.1 -> 1}
+ - x2: maximum step {0.1 -> 1}
12. loopseg
- - x1 : maximum value {0.1 -> 1}
- - x2 : maximum step {0.1 -> 1}
+ - x1: maximum value {0.1 -> 1}
+ - x2: maximum step {0.1 -> 1}
>>> s = Server().boot()
>>> s.start()
@@ -1063,7 +1063,7 @@ class XnoiseDur(PyoObject):
self._x2 = x2
dist, min, max, x1, x2, mul, add, lmax = convertArgsToLists(dist, min, max, x1, x2, mul, add)
for i, t in enumerate(dist):
- if type(t) == StringType: dist[i] = XNOISE_DICT.get(t, 0)
+ if type(t) in [bytes_t, unicode_t]: dist[i] = XNOISE_DICT.get(t, 0)
self._base_objs = [XnoiseDur_base(wrap(dist,i), wrap(min,i), wrap(max,i), wrap(x1,i), wrap(x2,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setDist(self, x):
@@ -1072,14 +1072,14 @@ class XnoiseDur(PyoObject):
:Args:
- x : string or int
+ x: string or int
new `dist` attribute.
"""
self._dist = x
x, lmax = convertArgsToLists(x)
for i, t in enumerate(x):
- if type(t) == StringType: x[i] = XNOISE_DICT.get(t, 0)
+ if type(t) in [bytes_t, unicode_t]: x[i] = XNOISE_DICT.get(t, 0)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setMin(self, x):
@@ -1088,7 +1088,7 @@ class XnoiseDur(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `min` attribute.
"""
@@ -1103,7 +1103,7 @@ class XnoiseDur(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `max` attribute.
"""
@@ -1118,7 +1118,7 @@ class XnoiseDur(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `x1` attribute.
"""
@@ -1133,7 +1133,7 @@ class XnoiseDur(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `x2` attribute.
"""
@@ -1201,14 +1201,14 @@ class Urn(PyoObject):
:Args:
- max : int, optional
+ max: int, optional
Maximum value for the random generation. Defaults to 100.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Polling frequency. Defaults to 1.
.. note::
- Urn will sends a trigger signal when the pool is empty.
+ Urn will send a trigger signal when the pool is empty.
User can retreive the trigger streams by calling obj['trig'].
Useful to synchronize other processes.
@@ -1239,7 +1239,7 @@ class Urn(PyoObject):
:Args:
- x : int
+ x: int
new `max` attribute.
"""
@@ -1254,7 +1254,7 @@ class Urn(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -1282,4 +1282,106 @@ class Urn(PyoObject):
return self._freq
@freq.setter
def freq(self, x):
- self.setFreq(x)
\ No newline at end of file
+ self.setFreq(x)
+
+class LogiMap(PyoObject):
+ """
+ Random generator based on the logistic map.
+
+ The logistic equation (sometimes called the Verhulst model or logistic
+ growth curve) is a model of population growth first published by Pierre
+ Verhulst (1845, 1847). The logistic map is a discrete quadratic recurrence
+ equation derived from the logistic equation that can be effectively used
+ as a number generator that exibit chaotic behavior. This object uses the
+ following equation:
+
+ x[n] = (r + 3) * x[n-1] * (1.0 - x[n-1])
+
+ where 'r' is the randomization factor between 0 and 1.
+
+ :Parent: :py:class:`PyoObject`
+
+ :Args:
+
+ chaos: float or PyoObject, optional
+ Randomization factor, 0.0 < chaos < 1.0. Defaults to 0.6.
+ freq: float or PyoObject, optional
+ Polling frequency. Defaults to 1.
+ init: float, optional
+ Initial value, 0.0 < init < 1.0. Defaults to 0.5.
+
+ .. note::
+
+ The method play() resets the internal state to the initial value.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> val = LogiMap([0.6,0.65], [4,8])
+ >>> mid = Round(Scale(val, 0, 1, [36,48], [72,84]))
+ >>> hz = Snap(mid, [0,2,4,5,7,9,11], 1)
+ >>> env = CosTable([(0,0), (32,1), (4064,1), (4096,0), (8192,0)])
+ >>> amp = TrigEnv(Change(val), table=env, dur=[.25,.125], mul=0.3)
+ >>> osc = RCOsc(hz, mul=amp).out()
+
+ """
+ def __init__(self, chaos=0.6, freq=1.0, init=0.5, mul=1, add=0):
+ pyoArgsAssert(self, "OOnOO", chaos, freq, init, mul, add)
+ PyoObject.__init__(self, mul, add)
+ self._chaos = chaos
+ self._freq = freq
+ chaos, freq, init, mul, add, lmax = convertArgsToLists(chaos, freq, init, mul, add)
+ self._base_objs = [LogiMap_base(wrap(chaos,i), wrap(freq,i), wrap(init,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+
+ def out(self, chnl=0, inc=1, dur=0, delay=0):
+ return self
+
+ def setChaos(self, x):
+ """
+ Replace the `chaos` attribute.
+
+ :Args:
+
+ x: float or PyoObject
+ new `chaos` attribute.
+
+ """
+ pyoArgsAssert(self, "O", x)
+ self._chaos = x
+ x, lmax = convertArgsToLists(x)
+ [obj.setChaos(wrap(x,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)]
+
+ def ctrl(self, map_list=None, title=None, wxnoserver=False):
+ self._map_list = [SLMap(0.001, 0.999, 'lin', 'chaos', self._chaos),
+ SLMap(0.1, 20., 'lin', 'freq', self._freq),
+ SLMapMul(self._mul)]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
+ @property
+ def chaos(self):
+ """float or PyoObject. Randomization factor."""
+ return self._chaos
+ @chaos.setter
+ def chaos(self, x):
+ self.setChaos(x)
+ @property
+ def freq(self):
+ """float or PyoObject. Polling frequency."""
+ return self._freq
+ @freq.setter
+ def freq(self, x):
+ self.setFreq(x)
diff --git a/pyolib/server.py b/pyolib/server.py
index 5d8ce25..cce7050 100644
--- a/pyolib/server.py
+++ b/pyolib/server.py
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
+from __future__ import print_function
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -19,8 +21,8 @@ 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
+from ._core import *
+from ._widgets import createServerGUI
######################################################################
### Proxy of Server object
@@ -38,13 +40,13 @@ class Server(object):
:Args:
- sr : int, optional
+ sr: int, optional
Sampling rate used by Portaudio and the Server to compute samples.
Defaults to 44100.
- nchnls : int, optional
+ nchnls: int, optional
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
+ buffersize: int, optional
Number of samples that Portaudio will request from the callback loop.
Defaults to 256.
@@ -52,10 +54,10 @@ class Server(object):
to compute) and on the latency of the system.
Latency is `buffer size / sampling rate` in seconds.
- duplex : int {0, 1}, optional
+ duplex: int {0, 1}, optional
Input - output mode. 0 is output only and 1 is both ways.
Defaults to 1.
- audio : string {'portaudio', 'pa', 'jack', 'coreaudio', 'offline', 'offline_nb', 'embedded'}, optional
+ audio: string {'portaudio', 'pa', 'jack', 'coreaudio', 'offline', 'offline_nb', 'embedded'}, 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,
@@ -70,30 +72,37 @@ class Server(object):
It is the responsibility of the user to make sure that the program doesn't exit before
the computation is done.
- jackname : string, optional
+
+ 'embedded' should be used when pyo is embedded inside an host environment via its C api.
+
+ If 'jack' is selected but jackd is not already started when the program is executed, pyo
+ will ask jack to start in the background. Note that pyo never ask jack to close. It is
+ the user's responsability to manage the audio configuration of its system.
+ jackname: string, optional
Name of jack client. Defaults to 'pyo'
- ichnls : int, optional
+ ichnls: int, optional
Number of input channels if different of output channels. If None (default), ichnls = nchnls.
.. note::
The following methods must be called **before** booting the server
- - setInOutDevice(x) : Set both input and output devices. See `pa_list_devices()`.
- - setInputDevice(x) : Set the audio input device number. See `pa_list_devices()`.
- - setOutputDevice(x) : Set the audio output device number. See `pa_list_devices()`.
- - setInputOffset(x) : Set the first physical input channel.
- - setOutputOffset(x) : Set the first physical output channel.
- - setInOutOffset(x) : Set the first physical input and output channels.
- - setMidiInputDevice(x) : Set the MIDI input device number. See `pm_list_devices()`.
- - 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 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.
+ - setInOutDevice(x): Set both input and output devices. See `pa_list_devices()`.
+ - setInputDevice(x): Set the audio input device number. See `pa_list_devices()`.
+ - setOutputDevice(x): Set the audio output device number. See `pa_list_devices()`.
+ - setInputOffset(x): Set the first physical input channel.
+ - setOutputOffset(x): Set the first physical output channel.
+ - setInOutOffset(x): Set the first physical input and output channels.
+ - setMidiInputDevice(x): Set the MIDI input device number. See `pm_list_devices()`.
+ - 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 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.
+ - deactivateMidi(): Deactivate Midi callback.
>>> # For an 8 channels server in duplex mode with
>>> # a sampling rate of 48000 Hz and buffer size of 512
@@ -103,11 +112,11 @@ class Server(object):
"""
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:
+ if "PYO_SERVER_AUDIO" in os.environ 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:
+ if ichnls is None:
self._ichnls = nchnls
else:
self._ichnls = ichnls
@@ -143,7 +152,7 @@ class Server(object):
"""
self._gui_frame = None
self._nchnls = nchnls
- if ichnls == None:
+ if ichnls is None:
self._ichnls = nchnls
else:
self._ichnls = ichnls
@@ -158,30 +167,43 @@ class Server(object):
self._resampling = 1
self._server.__init__(sr, nchnls, buffersize, duplex, audio, jackname, self._ichnls)
+ def setCallback(self, callback):
+ """
+ Register a custom process callback.
+
+ The function given as argument will be called every computation
+ block, just before the computation of the audio object tree.
+ Inside the callback, one can process the data of a table with
+ numpy calls for example.
+
+ """
+ if callable(callback):
+ self._server.setCallback(callback)
+
def gui(self, locals=None, meter=True, timer=True, exit=True):
"""
Show the server's user interface.
:Args:
- locals : locals namespace {locals(), None}, optional
+ 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
+ meter: boolean, optinal
If True, the interface will show a vumeter of the global output signal.
Defaults to True.
- timer : boolean, optional
+ timer: boolean, optional
If True, the interface will show a clock of the current time.
Defaults to True.
- exit : boolean, optional
+ 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.
"""
- self._gui_frame, win = createServerGUI(self._nchnls, self.start, self.stop,
- self.recstart, self.recstop, self.setAmp,
- self.getIsStarted(), locals, self.shutdown,
+ self._gui_frame, win = createServerGUI(self._nchnls, self.start, self.stop,
+ self.recstart, self.recstop, self.setAmp,
+ self.getIsStarted(), locals, self.shutdown,
meter, timer, self._amp, exit)
if meter:
self._server.setAmpCallable(self._gui_frame)
@@ -190,7 +212,7 @@ class Server(object):
try:
win.mainloop()
except:
- if win != None:
+ if win is not None:
win.MainLoop()
def closeGui(self):
@@ -205,13 +227,13 @@ class Server(object):
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
+
+ func: python callable
Python function or method to call with current time as argument.
"""
@@ -221,12 +243,12 @@ class Server(object):
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
+
+ func: python callable
Python function or method to call with current rms values as argument.
"""
@@ -236,13 +258,13 @@ class Server(object):
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
+
+ meter: python object
Python object with a `setRms` method.
"""
@@ -254,7 +276,7 @@ class Server(object):
:Args:
- x : int
+ x: int
Number of the audio input and output devices.
"""
@@ -266,7 +288,7 @@ class Server(object):
:Args:
- x : int
+ x: int
Number of the audio device listed by Portaudio.
"""
@@ -278,7 +300,7 @@ class Server(object):
:Args:
- x : int
+ x: int
Number of the audio device listed by Portaudio.
"""
@@ -294,7 +316,7 @@ class Server(object):
:Args:
- x : int
+ x: int
Channel number.
"""
@@ -310,7 +332,7 @@ class Server(object):
:Args:
- x : int
+ x: int
Channel number.
"""
@@ -325,7 +347,7 @@ class Server(object):
:Args:
- x : int
+ x: int
Channel number.
"""
@@ -341,7 +363,7 @@ class Server(object):
:Args:
- x : int
+ x: int
Number of the Midi device listed by Portmidi.
"""
@@ -353,7 +375,7 @@ class Server(object):
:Args:
- x : int
+ x: int
Number of the Midi device listed by Portmidi.
"""
@@ -365,7 +387,7 @@ class Server(object):
:Args:
- x : int
+ x: int
New sampling rate, must be supported by the soundcard.
"""
@@ -377,7 +399,7 @@ class Server(object):
:Args:
- x : int
+ x: int
New buffer size.
"""
@@ -389,7 +411,7 @@ class Server(object):
:Args:
- x : int
+ x: int
New number of channels.
"""
@@ -402,7 +424,7 @@ class Server(object):
:Args:
- x : int
+ x: int
New number of input channels.
"""
@@ -415,7 +437,7 @@ class Server(object):
:Args:
- x : int {0 or 1}
+ x: int {0 or 1}
New mode. 0 is output only, 1 is both ways.
"""
@@ -427,7 +449,7 @@ class Server(object):
:Args:
- x : int
+ x: int
A sum of values to display different levels:
- 1 = error
- 2 = message
@@ -444,9 +466,9 @@ class Server(object):
:Args:
- xin : boolean
+ xin: boolean
Input Auto-connection switch. True is enabled (default) and False is disabled.
- xout : boolean
+ xout: boolean
Output Auto-connection switch. True is enabled (default) and False is disabled.
"""
@@ -458,8 +480,11 @@ class Server(object):
:Args:
- ports : string or list of strings
- Name of the Jack port(s) to auto-connect. Regular Expressions are allowed.
+ ports: list of list of strings
+ Name of the Jack ports to auto-connect to pyo input channels.
+ There must be exactly one list of port(s) for each pyo input channel.
+
+ [['ports', 'to', 'channel', '1'], ['ports', 'to', 'channel', '2'], ...]
"""
ports, lmax = convertArgsToLists(ports)
@@ -471,8 +496,11 @@ class Server(object):
:Args:
- ports : string or list of strings
- Name of the Jack port(s) to auto-connect. Regular Expressions are allowed.
+ ports: list of list of strings
+ Name of the Jack ports to auto-connect to pyo output channels.
+ There must be exactly one list of port(s) for each pyo output channel.
+
+ [['ports', 'to', 'channel', '1'], ['ports', 'to', 'channel', '2'], ...]
"""
ports, lmax = convertArgsToLists(ports)
@@ -484,7 +512,7 @@ class Server(object):
:Args:
- x : int
+ x: int
A positive integer that will be used as the seed by random objects.
If zero, randoms will be seeded with the system clock current value.
@@ -500,7 +528,7 @@ class Server(object):
:Args:
- x : float
+ x: float
Starting time of the real-time processing.
"""
@@ -513,7 +541,7 @@ class Server(object):
:Args:
- x : float
+ x: float
New amplitude.
"""
@@ -522,22 +550,22 @@ class Server(object):
def beginResamplingBlock(self, x):
"""
- Starts a resampling block.
-
- This factor must be a power-of-two. A positive value means
- upsampling and a negative value means downsampling. After this
- call, every PyoObject will be created with an internal sampling
- rate and buffer size relative to the resampling factor. The method
- `endResamplingBlock()` should be called at the end of the code
+ Starts a resampling block.
+
+ This factor must be a power-of-two. A positive value means
+ upsampling and a negative value means downsampling. After this
+ call, every PyoObject will be created with an internal sampling
+ rate and buffer size relative to the resampling factor. The method
+ `endResamplingBlock()` should be called at the end of the code
block using the resampling factor.
-
- The `Resample` object can be used inside the resampling block to
- perform up or down resampling of audio signal created before the
- block.
+
+ The `Resample` object can be used inside the resampling block to
+ perform up or down resampling of audio signal created before the
+ block.
:Args:
- x : int, power-of-two
+ x: int, power-of-two
Resampling factor. Must be a power-of-two. A positive
value starts an upsampling block while a negative value
starts a downsampling block.
@@ -549,23 +577,23 @@ class Server(object):
self._resampling = realx
self._server.beginResamplingBlock(realx)
else:
- print "Resampling factor must be a power-of-two (positive or negative)."
+ print("Resampling factor must be a power-of-two (positive or negative).")
def endResamplingBlock(self):
"""
- Ends a resampling block.
-
+ Ends a resampling block.
+
This call ends a code block using a sample rate different from
the current sampling rate of the system.
- The `Resample` object can be used after the resampling blick to
- perform up or down resampling of audio signal created inside the
- block.
+ The `Resample` object can be used after the resampling blick to
+ perform up or down resampling of audio signal created inside the
+ block.
"""
self._resampling = 1
self._server.endResamplingBlock()
-
+
def shutdown(self):
"""
Shut down and clear the server. This method will erase all objects
@@ -583,7 +611,7 @@ class Server(object):
:Args:
- newBuffer : bool
+ 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.
@@ -612,20 +640,20 @@ class Server(object):
"""
self._server.stop()
- def recordOptions(self, dur=-1, filename=None, fileformat=0, sampletype=0):
+ def recordOptions(self, dur=-1, filename=None, fileformat=0, sampletype=0, quality=0.4):
"""
Sets options for soundfile created by offline rendering or global recording.
:Args:
- dur : float
+ dur: float
Duration, in seconds, of the recorded file. Only used by
offline rendering. Must be positive. Defaults to -1.
- filename : string
+ filename: string
Full path of the file to create. If None, a file called
`pyo_rec.wav` will be created in the user's home directory.
Defaults to None.
- fileformat : int, optional
+ fileformat: int, optional
Format type of the audio file. This function will first try to
set the format from the filename extension.
@@ -638,7 +666,7 @@ class Server(object):
5. FLAC - FLAC lossless file format {.flac}
6. CAF - Core Audio File format {.caf}
7. OGG - Xiph OGG container {.ogg}
- sampletype : int, optional
+ sampletype: int, optional
Bit depth encoding of the audio file.
SD2 and FLAC only support 16 or 24 bit int. Supported types are:
@@ -649,25 +677,29 @@ class Server(object):
4. 64 bits float
5. U-Law encoded
6. A-Law encoded
+ quality: float, optional
+ The encoding quality value, between 0.0 (lowest quality) and
+ 1.0 (highest quality). This argument has an effect only with
+ FLAC and OGG compressed formats. Defaults to 0.4.
"""
self._dur = dur
- if filename == None:
+ if filename is None:
filename = os.path.join(os.path.expanduser("~"), "pyo_rec.wav")
self._filename = filename
ext = filename.rsplit('.')
if len(ext) >= 2:
ext = ext[-1].lower()
- if FILE_FORMATS.has_key(ext):
+ if ext in FILE_FORMATS:
fileformat = FILE_FORMATS[ext]
else:
- print 'Warning: Unknown file extension. Using fileformat value.'
+ print('Warning: Unknown file extension. Using fileformat value.')
else:
- print 'Warning: Filename has no extension. Using fileformat value.'
+ print('Warning: Filename has no extension. Using fileformat value.')
self._fileformat = fileformat
self._sampletype = sampletype
- self._server.recordOptions(dur, filename, fileformat, sampletype)
+ self._server.recordOptions(dur, filename, fileformat, sampletype, quality)
def recstart(self, filename=None):
"""
@@ -679,19 +711,19 @@ class Server(object):
:Args:
- filename : string, optional
+ filename: string, optional
Name of the file to be created. Defaults to None.
"""
- if filename == None:
- if self._filename != None:
+ if filename is None:
+ if self._filename is not None:
filename = self._filename
else:
filename = os.path.join(os.path.expanduser("~"), "pyo_rec.wav")
ext = filename.rsplit('.')
if len(ext) >= 2:
ext = ext[-1].lower()
- if FILE_FORMATS.has_key(ext):
+ if ext in FILE_FORMATS:
fileformat = FILE_FORMATS[ext]
if fileformat != self._fileformat:
self._fileformat = fileformat
@@ -715,16 +747,16 @@ class Server(object):
:Args:
- pitch : int
+ pitch: int
Midi pitch, between 0 and 127.
- velocity : int
+ 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
+ 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
+ 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.
@@ -741,15 +773,15 @@ class Server(object):
:Args:
- pitch : int
+ pitch: int
Midi key pressed down, between 0 and 127.
- velocity : int
+ velocity: int
Velocity of the pressure, between 0 and 127.
- channel : int, optional
+ 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
+ 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.
@@ -766,15 +798,15 @@ class Server(object):
:Args:
- ctlnum : int
+ ctlnum: int
Controller number, between 0 and 127.
- value : int
+ value: int
Value of the controller, between 0 and 127.
- channel : int, optional
+ 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
+ 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.
@@ -791,13 +823,13 @@ class Server(object):
:Args:
- value : int
+ value: int
New program number, between 0 and 127.
- channel : int, optional
+ 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
+ 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.
@@ -814,13 +846,13 @@ class Server(object):
:Args:
- value : int
+ value: int
Single greatest pressure value, between 0 and 127.
- channel : int, optional
+ 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
+ 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.
@@ -837,14 +869,14 @@ class Server(object):
:Args:
- value : int
+ 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
+ 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
+ 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.
@@ -852,33 +884,53 @@ class Server(object):
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 sysexout(self, msg, timestamp=0):
+ """
+ Send a system exclusive message to the selected midi output device.
+
+ Arguments can be list of values/messages to generate multiple events
+ in one call.
+
+ :Args:
+
+ msg: str
+ A valid system exclusive message as a string. The first byte
+ must be 0xf0 and the last one must be 0xf7.
+ 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.
+ """
+ msg, timestamp, lmax = convertArgsToLists(msg, timestamp)
+ [self._server.sysexout(wrap(msg,i), wrap(timestamp,i)) for i in range(lmax)]
+
def addMidiEvent(self, status, data1=0, data2=0):
"""
Add a MIDI event in the server processing loop.
- This method can be used to programatically simulate incomming
+ This method can be used to programatically simulate incomming
MIDI events. In an embedded framework (ie. pyo inside puredata,
openframeworks, etc.), this is useful to control a MIDI-driven
- script from the host program. Arguments can be list of values to
+ script from the host program. Arguments can be list of values to
generate multiple events in one call.
:Args:
- status : int
+ status: int
The status byte, indicating the type of event and the
MIDI channel. Typical event type are:
- 128 -> 143 : Noteoff
- 144 -> 159 : Noteon
- 176 -> 191 : Control change
- 192 -> 207 : Program change
- 209 -> 223 : After touch
- 224 -> 239 : Pitch bend
- data1 : int, optional
- The first data byte (pitch for a midi note, controller
- number for a control change). Defaults to 0.
- data2 : int, optional
- The second data byte (velocity for a midi note, value
- for a control change). Defaults to 0.
+ 128 -> 143: Noteoff
+ 144 -> 159: Noteon
+ 176 -> 191: Control change
+ 192 -> 207: Program change
+ 209 -> 223: After touch
+ 224 -> 239: Pitch bend
+ data1: int, optional
+ The first data byte (pitch for a midi note, controller
+ number for a control change). Defaults to 0.
+ data2: int, optional
+ The second data byte (velocity for a midi note, value
+ for a control change). Defaults to 0.
"""
status, data1, data2, lmax = convertArgsToLists(status, data1, data2)
@@ -935,7 +987,7 @@ class Server(object):
def deactivateMidi(self):
"""
- Deactivate Midi callback. Must be called before the start() method.
+ Deactivate Midi callback. Must be called before the boot() method.
"""
self._server.deactivateMidi()
@@ -1003,6 +1055,18 @@ class Server(object):
"""
return self._server.getEmbedICallbackAddr()
+ def getCurrentTime(self):
+ """
+ Return the current time as a formatted string.
+ """
+ return self._server.getCurrentTime()
+
+ def getCurrentAmp(self):
+ """
+ Return the current amplitudes as a tuple of `nchnls` length.
+ """
+ return self._server.getCurrentAmp()
+
@property
def amp(self):
"""float. Overall amplitude."""
@@ -1037,4 +1101,4 @@ class Server(object):
if (type(x) == int):
self.setGlobalSeed(x)
else:
- raise Exception("global seed must be an integer")
\ No newline at end of file
+ raise Exception("global seed must be an integer")
diff --git a/pyolib/tableprocess.py b/pyolib/tableprocess.py
index 38c85c0..e7c78aa 100644
--- a/pyolib/tableprocess.py
+++ b/pyolib/tableprocess.py
@@ -6,6 +6,7 @@ store audio samples or algorithmic sequences for future uses.
"""
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -25,9 +26,8 @@ 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 *
-from types import SliceType
+from ._core import *
+from ._maps import *
class Osc(PyoObject):
"""
@@ -37,14 +37,14 @@ class Osc(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency in cycles per second. Defaults to 1000.
- phase : float or PyoObject, optional
+ phase: float or PyoObject, optional
Phase of sampling, expressed as a fraction of a cycle (0 to 1).
Defaults to 0.
- interp : int, optional
+ interp: int, optional
Choice of the interpolation method. Defaults to 2.
1. no interpolation
2. linear
@@ -77,7 +77,7 @@ class Osc(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -92,7 +92,7 @@ class Osc(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -107,7 +107,7 @@ class Osc(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `phase` attribute.
"""
@@ -122,7 +122,7 @@ class Osc(PyoObject):
:Args:
- x : int {1, 2, 3, 4}
+ x: int {1, 2, 3, 4}
new `interp` attribute.
"""
@@ -186,11 +186,11 @@ class OscLoop(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency in cycles per second. Defaults to 1000.
- feedback : float or PyoObject, optional
+ feedback: float or PyoObject, optional
Amount of the output signal added to position increment, between 0 and 1.
Controls the brightness. Defaults to 0.
@@ -220,7 +220,7 @@ class OscLoop(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -235,7 +235,7 @@ class OscLoop(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -250,7 +250,7 @@ class OscLoop(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `feedback` attribute.
"""
@@ -294,17 +294,17 @@ class OscTrig(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- trig : PyoObject
+ trig: PyoObject
Trigger signal. Reset the table pointer position to zero on
each trig.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency in cycles per second. Defaults to 1000.
- phase : float or PyoObject, optional
+ phase: float or PyoObject, optional
Phase of sampling, expressed as a fraction of a cycle (0 to 1).
Defaults to 0.
- interp : int, optional
+ interp: int, optional
Choice of the interpolation method. Defaults to 2.
1. no interpolation
2. linear
@@ -340,7 +340,7 @@ class OscTrig(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -355,7 +355,7 @@ class OscTrig(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
new `trig` attribute.
"""
@@ -370,7 +370,7 @@ class OscTrig(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -385,7 +385,7 @@ class OscTrig(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `phase` attribute.
"""
@@ -400,7 +400,7 @@ class OscTrig(PyoObject):
:Args:
- x : int {1, 2, 3, 4}
+ x: int {1, 2, 3, 4}
new `interp` attribute.
"""
@@ -476,40 +476,40 @@ class OscBank(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Base frequency in cycles per second. Defaults to 100.
- spread : float or PyoObject, optional
+ 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.
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
+ 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
(slope ** n), i.e. strength values trace an exponential curve.
Defaults to 1.
- frndf : float or PyoObject, optional
+ frndf: float or PyoObject, optional
Frequency, in cycle per second, of the frequency modulations.
Defaults to 1.
- frnda : float or PyoObject, optional
+ frnda: float or PyoObject, optional
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
deactivates the frequency deviations. Defaults to 0.
- arndf : float or PyoObject, optional
+ arndf: float or PyoObject, optional
Frequency, in cycle per second, of the amplitude modulations.
Defaults to 1.
- arnda : float or PyoObject, optional
+ arnda: float or PyoObject, optional
Amount of amplitude deviation. 0 deactivates the amplitude
modulations and 1 gives full amplitude modulations.
Defaults to 0.
- num : int, optional
+ num: int, optional
Number of oscillators. Available at initialization only.
Defaults to 24.
- fjit : boolean, optional
+ fjit: boolean, optional
If True, a small jitter is added to the frequency of each partial.
For a large number of oscillators and a very small `spread`, the
periodicity between partial frequencies can cause very strange
@@ -556,7 +556,7 @@ class OscBank(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -571,7 +571,7 @@ class OscBank(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -586,7 +586,7 @@ class OscBank(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `spread` attribute.
"""
@@ -601,7 +601,7 @@ class OscBank(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `slope` attribute.
"""
@@ -616,7 +616,7 @@ class OscBank(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `frndf` attribute.
"""
@@ -631,7 +631,7 @@ class OscBank(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `frnda` attribute.
"""
@@ -646,7 +646,7 @@ class OscBank(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `arndf` attribute.
"""
@@ -661,7 +661,7 @@ class OscBank(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `arnda` attribute.
"""
@@ -676,7 +676,7 @@ class OscBank(PyoObject):
:Args:
- x : boolean
+ x: boolean
new `fjit` attribute.
"""
@@ -772,14 +772,14 @@ class TableRead(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency in cycles per second. Defaults to 1.
- loop : int {0, 1}, optional
+ loop: int {0, 1}, optional
Looping mode, 0 means off, 1 means on.
Defaults to 0.
- interp : int, optional
+ interp: int, optional
Choice of the interpolation method. Defaults to 2.
1. no interpolation
2. linear
@@ -788,12 +788,12 @@ class TableRead(PyoObject):
.. note::
- TableRead will sends a trigger signal at the end of the playback if
+ TableRead will send 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'])
+ >>> trig = TrigRand(tabr['trig'])
.. seealso::
@@ -823,7 +823,7 @@ class TableRead(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -838,7 +838,7 @@ class TableRead(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -853,7 +853,7 @@ class TableRead(PyoObject):
:Args:
- x : int {0, 1}
+ x: int {0, 1}
new `loop` attribute.
"""
@@ -868,7 +868,7 @@ class TableRead(PyoObject):
:Args:
- x : int {1, 2, 3, 4}
+ x: int {1, 2, 3, 4}
new `interp` attribute.
"""
@@ -884,7 +884,6 @@ class TableRead(PyoObject):
"""
[obj.reset() for i, obj in enumerate(self._base_objs)]
-
def ctrl(self, map_list=None, title=None, wxnoserver=False):
self._map_list = [SLMap(0.0001, 1000, 'log', 'freq', self._freq),
SLMap(0, 1, 'lin', 'loop', self._loop, res="int", dataOnly=True),
@@ -935,19 +934,19 @@ class Pulsar(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- env : PyoTableObject
+ env: PyoTableObject
Table containing the envelope samples.
- freq : float or PyoObject, optional
+ freq: float or PyoObject, optional
Frequency in cycles per second. Defaults to 100.
- frac : float or PyoObject, optional
+ frac: float or PyoObject, optional
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: float or PyoObject, optional
Phase of sampling, expressed as a fraction of a cycle (0 to 1).
Defaults to 0.
- interp : int, optional
+ interp: int, optional
Choice of the interpolation method. Defaults to 2.
1. no interpolation
2. linear
@@ -984,7 +983,7 @@ class Pulsar(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -999,7 +998,7 @@ class Pulsar(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `env` attribute.
"""
@@ -1014,7 +1013,7 @@ class Pulsar(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `freq` attribute.
"""
@@ -1029,7 +1028,7 @@ class Pulsar(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `frac` attribute.
"""
@@ -1044,7 +1043,7 @@ class Pulsar(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `phase` attribute.
"""
@@ -1059,7 +1058,7 @@ class Pulsar(PyoObject):
:Args:
- x : int {1, 2, 3, 4}
+ x: int {1, 2, 3, 4}
Choice of the interpolation method.
1. no interpolation
2. linear
@@ -1130,9 +1129,9 @@ class Pointer(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- index : PyoObject
+ index: PyoObject
Normalized position in the table between 0 and 1.
>>> s = Server().boot()
@@ -1157,7 +1156,7 @@ class Pointer(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -1172,7 +1171,7 @@ class Pointer(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
new `index` attribute.
"""
@@ -1207,17 +1206,17 @@ class Pointer2(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- index : PyoObject
+ index: PyoObject
Normalized position in the table between 0 and 1.
- interp : int {1, 2, 3, 4}, optional
+ interp: int {1, 2, 3, 4}, optional
Choice of the interpolation method. Defaults to 4.
1. no interpolation
2. linear
3. cosinus
4. cubic
- autosmooth : boolean, optional
+ autosmooth: boolean, optional
If True, a lowpass filter, following the pitch, is applied on
the output signal to reduce the quantization noise produced
@@ -1248,7 +1247,7 @@ class Pointer2(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -1263,7 +1262,7 @@ class Pointer2(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
new `index` attribute.
"""
@@ -1278,7 +1277,7 @@ class Pointer2(PyoObject):
:Args:
- x : int {1, 2, 3, 4}
+ x: int {1, 2, 3, 4}
new `interp` attribute.
1. no interpolation
2. linear interpolation
@@ -1301,7 +1300,7 @@ class Pointer2(PyoObject):
:Args:
- x : boolean
+ x: boolean
new `autosmooth` attribute.
"""
@@ -1350,9 +1349,9 @@ class TableIndex(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the samples.
- index : PyoObject
+ index: PyoObject
Position in the table, as integer audio stream,
between 0 and table's size - 1.
@@ -1380,7 +1379,7 @@ class TableIndex(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -1395,7 +1394,7 @@ class TableIndex(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
new `index` attribute.
"""
@@ -1435,9 +1434,9 @@ class Lookup(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the transfert function.
- index : PyoObject
+ index: PyoObject
Audio signal, between -1 and 1, internally converted to be
used as the index position in the table.
@@ -1463,7 +1462,7 @@ class Lookup(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -1478,7 +1477,7 @@ class Lookup(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
new `index` attribute.
"""
@@ -1521,11 +1520,11 @@ class TableRec(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal to write in the table.
- table : NewTable
+ table: NewTable
The table where to write samples.
- fadetime : float, optional
+ fadetime: float, optional
Fade time at the beginning and the end of the recording
in seconds. Defaults to 0.
@@ -1535,7 +1534,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 send 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:
@@ -1597,9 +1596,9 @@ class TableRec(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1613,7 +1612,7 @@ class TableRec(PyoObject):
:Args:
- x : NewTable
+ x: NewTable
new `table` attribute.
"""
@@ -1643,7 +1642,7 @@ class TableWrite(PyoObject):
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.
+ them at a normalized or raw 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.
@@ -1652,13 +1651,21 @@ class TableWrite(PyoObject):
:Args:
- input : PyoObject
+ 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
+ pos: PyoObject
+ Audio signal specifying the position where to write the
+ `input` samples. It is a normalized position (in the range
+ 0 to 1) in mode=0 or the raw position (in samples) for any
+ other value of mode.
+ table: NewTable
The table where to write samples.
+ mode: int, optional
+ Sets the writing pointer mode. If 0, the position must be
+ normalized between 0 (beginning of the table) and 1 (end
+ of the table). For any other value, the position must be
+ in samples between 0 and the length of the table. Available
+ at initialization time only.
.. note::
@@ -1680,15 +1687,16 @@ class TableWrite(PyoObject):
>>> pat = Pattern(tab.refreshView, 0.05).play()
"""
- def __init__(self, input, pos, table):
- pyoArgsAssert(self, "oot", input, pos, table)
+ def __init__(self, input, pos, table, mode=0):
+ pyoArgsAssert(self, "ooti", input, pos, table, mode)
PyoObject.__init__(self)
self._input = input
self._pos = pos
self._table = table
+ self._mode = mode
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))]
+ in_fader, pos, table, mode, lmax = convertArgsToLists(self._in_fader, pos, table, mode)
+ self._base_objs = [TableWrite_base(wrap(in_fader,i), wrap(pos,i), wrap(table,i), wrap(mode,i)) for i in range(len(table))]
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
@@ -1705,9 +1713,9 @@ class TableWrite(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1721,7 +1729,7 @@ class TableWrite(PyoObject):
:Args:
- x : NewTable
+ x: NewTable
new `table` attribute.
"""
@@ -1736,7 +1744,7 @@ class TableWrite(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
new `pos` attribute.
"""
@@ -1779,12 +1787,12 @@ class TableMorph(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Morphing index between 0 and 1. 0 is the first table in the list
and 1 is the last.
- table : NewTable
+ table: NewTable
The table where to write morphed waveform.
- sources : list of PyoTableObject
+ sources: list of PyoTableObject
List of tables to interpolate from.
.. note::
@@ -1829,9 +1837,9 @@ class TableMorph(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1845,7 +1853,7 @@ class TableMorph(PyoObject):
:Args:
- x : NewTable
+ x: NewTable
new `table` attribute.
"""
@@ -1860,7 +1868,7 @@ class TableMorph(PyoObject):
:Args:
- x : list of PyoTableObject
+ x: list of PyoTableObject
new `sources` attribute.
"""
@@ -1898,25 +1906,25 @@ class Granulator(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- env : PyoTableObject
+ env: PyoTableObject
Table containing the grain envelope.
- pitch : float or PyoObject, optional
+ pitch: float or PyoObject, optional
Overall pitch of the granulator. This value transpose the
pitch of all grains. Defaults to 1.
- pos : float or PyoObject, optional
+ 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
+ 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.
- grains : int, optional
+ grains: int, optional
Number of grains. Defaults to 8.
- basedur : float, optional
+ 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
the `dur` parameter, transposition per grain can be generated.
@@ -1952,7 +1960,7 @@ class Granulator(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -1967,7 +1975,7 @@ class Granulator(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `env` attribute.
"""
@@ -1982,7 +1990,7 @@ class Granulator(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pitch` attribute.
"""
@@ -1997,7 +2005,7 @@ class Granulator(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pos` attribute.
"""
@@ -2012,7 +2020,7 @@ class Granulator(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `dur` attribute.
"""
@@ -2027,7 +2035,7 @@ class Granulator(PyoObject):
:Args:
- x : int
+ x: int
new `grains` attribute.
"""
@@ -2042,7 +2050,7 @@ class Granulator(PyoObject):
:Args:
- x : float
+ x: float
new `basedur` attribute.
"""
@@ -2121,13 +2129,13 @@ class TrigTableRec(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal to write in the table.
- trig : PyoObject
+ trig: PyoObject
Audio signal sending triggers.
- table : NewTable
+ table: NewTable
The table where to write samples.
- fadetime : float, optional
+ fadetime: float, optional
Fade time at the beginning and the end of the recording
in seconds. Defaults to 0.
@@ -2137,7 +2145,7 @@ class TrigTableRec(PyoObject):
TrigTableRec has no `mul` and `add` attributes.
- TrigTableRec will sends a trigger signal at the end of the recording.
+ TrigTableRec will send 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,
@@ -2192,9 +2200,9 @@ class TrigTableRec(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2208,9 +2216,9 @@ class TrigTableRec(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New trigger signal.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2224,7 +2232,7 @@ class TrigTableRec(PyoObject):
:Args:
- x : NewTable
+ x: NewTable
new `table` attribute.
"""
@@ -2266,51 +2274,56 @@ class Looper(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- pitch : float or PyoObject, optional
+ pitch: float or PyoObject, optional
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
+ start: float or PyoObject, optional
Starting point, in seconds, of the loop, updated only once per loop cycle.
Defaults to 0.
- dur : float or PyoObject, optional
+ dur: float or PyoObject, optional
Duration, in seconds, of the loop, updated only once per loop cycle.
Defaults to 1.
- xfade : float or PyoObject {0 -> 50}, optional
+ xfade: float or PyoObject {0 -> 50}, optional
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
+ mode: int {0, 1, 2, 3}, optional
Loop modes. Defaults to 1.
0. no loop
1. forward
2. backward
3. back-and-forth
- xfadeshape : int {0, 1, 2}, optional
+ xfadeshape: int {0, 1, 2}, optional
Crossfade envelope shape. Defaults to 0.
0. linear
1. equal power
2. sigmoid
- startfromloop : boolean, optional
+ startfromloop: boolean, optional
If True, reading will begin directly at the loop start point. Otherwise, it
begins at the beginning of the table. Defaults to False.
- interp : int {1, 2, 3, 4}, optional
+ interp: int {1, 2, 3, 4}, optional
Choice of the interpolation method. Defaults to 2.
1. no interpolation
2. linear
3. cosinus
4. cubic
- autosmooth : boolean, optional
+ autosmooth: boolean, optional
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 False.
.. note::
- Looper will sends a trigger signal every new playback starting point
+ Looper will send a trigger signal every new playback starting point
(i.e. when the object is activated and at the beginning of the crossfade
of a loop. User can retrieve the trigger streams by calling obj['trig'].
+ Looper also outputs a time stream, given the current position of the
+ reading pointer, normalized between 0.0 and 1.0 (1.0 means the beginning
+ of the crossfade), inside the loop. User can retrieve the trigger streams
+ by calling obj['time']. New in version 0.8.1.
+
.. seealso::
:py:class:`Granulator`, :py:class:`Pointer`
@@ -2327,6 +2340,9 @@ 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._time_dummy = []
+ self._appendfade = 0
+ self._fadeinseconds = 0
self._table = table
self._pitch = pitch
self._start = start
@@ -2342,6 +2358,13 @@ class Looper(PyoObject):
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)]
self._trig_objs = Dummy([TriggerDummy_base(obj) for obj in self._base_objs])
+ self._time_objs = [LooperTimeStream_base(obj) for obj in self._base_objs]
+
+ def __getitem__(self, i):
+ if i == 'time':
+ self._time_dummy.append(Dummy([obj for obj in self._time_objs]))
+ return self._time_dummy[-1]
+ return PyoObject.__getitem__(self, i)
def setTable(self, x):
"""
@@ -2349,7 +2372,7 @@ class Looper(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -2364,7 +2387,7 @@ class Looper(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pitch` attribute.
"""
@@ -2379,7 +2402,7 @@ class Looper(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `start` attribute.
"""
@@ -2394,7 +2417,7 @@ class Looper(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `dur` attribute.
"""
@@ -2409,7 +2432,7 @@ class Looper(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `xfade` attribute.
"""
@@ -2424,7 +2447,7 @@ class Looper(PyoObject):
:Args:
- x : int
+ x: int
new `xfadeshape` attribute.
"""
@@ -2439,7 +2462,7 @@ class Looper(PyoObject):
:Args:
- x : boolean
+ x: boolean
new `startfromloop` attribute.
"""
@@ -2454,7 +2477,7 @@ class Looper(PyoObject):
:Args:
- x : int
+ x: int
new `mode` attribute.
"""
@@ -2469,7 +2492,7 @@ class Looper(PyoObject):
:Args:
- x : int
+ x: int
new `interp` attribute.
"""
@@ -2484,7 +2507,7 @@ class Looper(PyoObject):
:Args:
- x : boolean
+ x: boolean
new `autosmooth` attribute.
"""
@@ -2500,6 +2523,53 @@ class Looper(PyoObject):
"""
[obj.reset() for obj in self._base_objs]
+ def loopnow(self):
+ """
+ Sarts a new loop immediately.
+
+ """
+ [obj.loopnow() for obj in self._base_objs]
+
+ def appendFadeTime(self, x):
+ """
+ Change the position of the crossfade regarding loop duration.
+
+ :Args:
+
+ x: boolean
+ If 0 (the default), the crossfade duration lies inside the
+ loop duration, producing a loop that is shorter than the
+ `dur` value.
+
+ If 1, the crossfade starts after the loop duration, expecting
+ samples after the loop to perform the fadeout. This mode gives
+ a loop of a length of the `dur` value.
+
+ """
+ pyoArgsAssert(self, "b", x)
+ self._appendfade = x
+ x, lmax = convertArgsToLists(x)
+ [obj.appendFadeTime(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
+
+ def fadeInSeconds(self, x):
+ """
+ Change the crossfade time unit (`xfade` unit type).
+
+ :Args:
+
+ x: boolean
+ If 0 (the default), the crossfade duration (`xfade` value) is
+ a percent of the loop time, between 0 and 50.
+
+ If 1, the crossfade duration (`xfade` value) is set in seconds,
+ between 0 and half the loop length.
+
+ """
+ pyoArgsAssert(self, "b", x)
+ self._fadeinseconds = x
+ x, lmax = convertArgsToLists(x)
+ [obj.fadeInSeconds(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, 2., 'lin', 'pitch', self._pitch),
SLMap(0., self._table.getDur(), 'lin', 'start', self._start),
@@ -2601,9 +2671,9 @@ class TablePut(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal to write in the table.
- table : DataTable
+ table: DataTable
The table where to write values.
.. note::
@@ -2612,7 +2682,7 @@ class TablePut(PyoObject):
TablePut has no `mul` and `add` attributes.
- TablePut will sends a trigger signal at the end of the recording.
+ TablePut will send a trigger signal at the end of the recording.
User can retrieve the trigger streams by calling obj['trig'].
.. seealso::
@@ -2655,9 +2725,9 @@ class TablePut(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2671,7 +2741,7 @@ class TablePut(PyoObject):
:Args:
- x : DataTable
+ x: DataTable
new `table` attribute.
"""
@@ -2705,21 +2775,21 @@ class Granule(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- env : PyoTableObject
+ env: PyoTableObject
Table containing the grain envelope.
- dens : float or PyoObject, optional
+ dens: float or PyoObject, optional
Density of grains per second. Defaults to 50.
- pitch : float or PyoObject, optional
+ pitch: float or PyoObject, optional
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
+ 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
+ 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.
@@ -2755,7 +2825,7 @@ class Granule(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -2770,7 +2840,7 @@ class Granule(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `env` attribute.
"""
@@ -2785,7 +2855,7 @@ class Granule(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `dens` attribute.
"""
@@ -2800,7 +2870,7 @@ class Granule(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pitch` attribute.
"""
@@ -2815,7 +2885,7 @@ class Granule(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pos` attribute.
"""
@@ -2830,7 +2900,7 @@ class Granule(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `dur` attribute.
"""
@@ -2845,7 +2915,7 @@ class Granule(PyoObject):
:Args:
- x : boolean
+ x: boolean
True means synchronous granulation (the default)
while False means asynchronous.
@@ -2916,9 +2986,9 @@ class TableScale(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the original values.
- outtable : PyoTableObject
+ outtable: PyoTableObject
Table where to write the scaled values.
>>> s = Server().boot()
@@ -2948,7 +3018,7 @@ class TableScale(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -2963,7 +3033,7 @@ class TableScale(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `outtable` attribute.
"""
@@ -2998,35 +3068,35 @@ class Particle(PyoObject):
:Args:
- table : PyoTableObject
+ table: PyoTableObject
Table containing the waveform samples.
- env : PyoTableObject
+ env: PyoTableObject
Table containing the grain envelope.
- dens : float or PyoObject, optional
+ dens: float or PyoObject, optional
Density of grains per second. Defaults to 50.
- pitch : float or PyoObject, optional
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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.
@@ -3075,7 +3145,7 @@ class Particle(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -3090,7 +3160,7 @@ class Particle(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `env` attribute.
"""
@@ -3105,7 +3175,7 @@ class Particle(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `dens` attribute.
"""
@@ -3120,7 +3190,7 @@ class Particle(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pitch` attribute.
"""
@@ -3135,7 +3205,7 @@ class Particle(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pos` attribute.
"""
@@ -3150,7 +3220,7 @@ class Particle(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `dur` attribute.
"""
@@ -3165,7 +3235,7 @@ class Particle(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `dev` attribute.
"""
@@ -3180,7 +3250,7 @@ class Particle(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `pan` attribute.
"""
@@ -3254,4 +3324,4 @@ class Particle(PyoObject):
"""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
+ def pan(self, x): self.setPan(x)
diff --git a/pyolib/tables.py b/pyolib/tables.py
index e182910..190786a 100644
--- a/pyolib/tables.py
+++ b/pyolib/tables.py
@@ -1,3 +1,6 @@
+from __future__ import division
+from __future__ import print_function
+from __future__ import absolute_import
"""
Copyright 2009-2015 Olivier Belanger
@@ -17,10 +20,9 @@ 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 *
-from _widgets import createGraphWindow, createDataGraphWindow, createSndViewTableWindow
-from types import ListType
+from ._core import *
+from ._maps import *
+from ._widgets import createGraphWindow, createDataGraphWindow, createSndViewTableWindow
from math import pi
import copy
@@ -38,10 +40,10 @@ class HarmTable(PyoTableObject):
:Args:
- list : list, optional
+ list: list, optional
Relative strengths of the fixed harmonic partial numbers 1,2,3, etc.
Defaults to [1].
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
>>> s = Server().boot()
@@ -54,9 +56,25 @@ class HarmTable(PyoTableObject):
def __init__(self, list=[1., 0.], size=8192):
pyoArgsAssert(self, "lI", list, size)
PyoTableObject.__init__(self, size)
+ self._auto_normalize = False
self._list = copy.deepcopy(list)
self._base_objs = [HarmTable_base(self._list, size)]
+ def autoNormalize(self, x):
+ """
+ Activate/deactivate automatic normalization when harmonics changed.
+
+ :Args:
+
+ x: boolean
+ True for activating automatic normalization, False for
+ deactivating it.
+
+ """
+ self._auto_normalize = x
+ if self._auto_normalize:
+ self.normalize()
+
def replace(self, list):
"""
Redraw the waveform according to a new set of harmonics
@@ -64,7 +82,7 @@ class HarmTable(PyoTableObject):
:Args:
- list : list
+ list: list
Relative strengths of the fixed harmonic partial
numbers 1,2,3, etc.
@@ -72,8 +90,45 @@ class HarmTable(PyoTableObject):
pyoArgsAssert(self, "l", list)
self._list = list
[obj.replace(list) for obj in self._base_objs]
+ if self._auto_normalize:
+ self.normalize()
self.refreshView()
+ def _get_current_data(self):
+ # internal that returns the data to draw in a DataTableGrapher.
+ return self._list
+
+ def graph(self, yrange=(-1.0, 1.0), title=None, wxnoserver=False):
+ """
+ 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.
+
+ :Args:
+
+ yrange: tuple, optional
+ 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
+ class is used.
+ 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.
+
+ .. note::
+
+ The number of bars in the graph is initialized to the length
+ of the list of relative strentghs at the time the graph is
+ created.
+
+ """
+ createDataGraphWindow(self, yrange, title, wxnoserver)
+
@property
def list(self):
"""list. Relative strengths of the fixed harmonic partial numbers."""
@@ -91,10 +146,10 @@ class SawTable(PyoTableObject):
:Args:
- order : int, optional
+ order: int, optional
Number of harmonics sawtooth is made of.
Defaults to 10.
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
>>> s = Server().boot()
@@ -107,7 +162,7 @@ class SawTable(PyoTableObject):
pyoArgsAssert(self, "II", order, size)
PyoTableObject.__init__(self, size)
self._order = order
- list = [1./i for i in range(1,(order+1))]
+ list = [1. / i for i in range(1,(order+1))]
self._base_objs = [HarmTable_base(list, size)]
def setOrder(self, x):
@@ -116,13 +171,13 @@ class SawTable(PyoTableObject):
:Args:
- x : int
+ x: int
New number of harmonics
"""
pyoArgsAssert(self, "I", x)
self._order = x
- list = [1./i for i in range(1,(self._order+1))]
+ list = [1. / i for i in range(1,(self._order+1))]
[obj.replace(list) for obj in self._base_objs]
self.refreshView()
@@ -143,10 +198,10 @@ class SquareTable(PyoTableObject):
:Args:
- order : int, optional
+ order: int, optional
Number of harmonics square waveform is made of. The waveform will
contains `order` odd harmonics. Defaults to 10.
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
>>> s = Server().boot()
@@ -162,7 +217,7 @@ class SquareTable(PyoTableObject):
list = []
for i in range(1,(order*2)):
if i%2 == 1:
- list.append(1./i)
+ list.append(1. / i)
else:
list.append(0.)
self._base_objs = [HarmTable_base(list, size)]
@@ -173,7 +228,7 @@ class SquareTable(PyoTableObject):
:Args:
- x : int
+ x: int
New number of harmonics
"""
@@ -182,7 +237,7 @@ class SquareTable(PyoTableObject):
list = []
for i in range(1,(self._order*2)):
if i%2 == 1:
- list.append(1./i)
+ list.append(1. / i)
else:
list.append(0.)
[obj.replace(list) for obj in self._base_objs]
@@ -207,11 +262,11 @@ class ChebyTable(PyoTableObject):
:Args:
- list : list, optional
+ 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
function table. Up to 12 partials can be specified. Defaults to [1].
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
>>> s = Server().boot()
@@ -225,9 +280,25 @@ class ChebyTable(PyoTableObject):
def __init__(self, list=[1., 0.], size=8192):
pyoArgsAssert(self, "lI", list, size)
PyoTableObject.__init__(self, size)
+ self._auto_normalize = False
self._list = copy.deepcopy(list)
self._base_objs = [ChebyTable_base(self._list, size)]
+ def autoNormalize(self, x):
+ """
+ Activate/deactivate automatic normalization when harmonics changed.
+
+ :Args:
+
+ x: boolean
+ True for activating automatic normalization, False for
+ deactivating it.
+
+ """
+ self._auto_normalize = x
+ if self._auto_normalize:
+ self.normalize()
+
def replace(self, list):
"""
Redraw the waveform according to a new set of harmonics
@@ -236,7 +307,7 @@ class ChebyTable(PyoTableObject):
:Args:
- list : list
+ list: list
Relative strengths of the fixed harmonic partial
numbers 1,2,3, ..., 12. Up to 12 partials can be specified.
@@ -244,6 +315,8 @@ class ChebyTable(PyoTableObject):
pyoArgsAssert(self, "l", list)
self._list = list
[obj.replace(list) for obj in self._base_objs]
+ if self._auto_normalize:
+ self.normalize()
self.refreshView()
def getNormTable(self):
@@ -258,6 +331,41 @@ class ChebyTable(PyoTableObject):
data = self._base_objs[0].getNormTable(1)
return DataTable(size=len(data), init=data).normalize()
+ def _get_current_data(self):
+ # internal that returns the data to draw in a DataTableGrapher.
+ return self._list
+
+ def graph(self, yrange=(-1.0, 1.0), title=None, wxnoserver=False):
+ """
+ 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.
+
+ :Args:
+
+ yrange: tuple, optional
+ 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
+ class is used.
+ 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.
+
+ .. note::
+
+ The number of bars in the graph is initialized to the length
+ of the list of relative strentghs at the time the graph is
+ created.
+
+ """
+ createDataGraphWindow(self, yrange, title, wxnoserver)
+
@property
def list(self):
"""list. Relative strengths of the fixed harmonic partial numbers."""
@@ -273,7 +381,7 @@ class HannTable(PyoTableObject):
:Args:
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
>>> s = Server().boot()
@@ -297,11 +405,11 @@ class SincTable(PyoTableObject):
:Args:
- freq : float, optional
+ freq: float, optional
Frequency, in radians, of the sinc function. Defaults to pi*2.
- windowed : boolean, optional
+ windowed: boolean, optional
If True, an hanning window is applied on the sinc function. Defaults to False.
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
>>> import math
@@ -324,7 +432,7 @@ class SincTable(PyoTableObject):
:Args:
- x : float
+ x: float
New frequency in radians.
"""
@@ -339,7 +447,7 @@ class SincTable(PyoTableObject):
:Args:
- x : boolean
+ x: boolean
New windowed flag.
"""
@@ -369,7 +477,7 @@ class WinTable(PyoTableObject):
:Args:
- type : int, optional
+ type: int, optional
Windowing function. Possible choices are:
0. Rectangular (no window)
1. Hamming
@@ -380,7 +488,7 @@ class WinTable(PyoTableObject):
6. Blackman-Harris 7-term
7. Tuckey (alpha = 0.66)
8. Sine (half-sine window)
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
>>> s = Server().boot()
@@ -403,7 +511,7 @@ class WinTable(PyoTableObject):
:Args:
- type : int {0 -> 8}
+ type: int {0 -> 8}
Windowing function.
"""
@@ -430,7 +538,7 @@ class ParaTable(PyoTableObject):
:Args:
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
>>> s = Server().boot()
@@ -454,12 +562,12 @@ class LinTable(PyoTableObject):
:Args:
- list : list, optional
+ 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
table (size - 1). Location must be an integer.
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
.. note::
@@ -479,8 +587,8 @@ class LinTable(PyoTableObject):
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"
+ 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(copy.deepcopy(list), size)]
@@ -491,7 +599,7 @@ class LinTable(PyoTableObject):
:Args:
- list : list
+ list: list
List of tuples indicating location and value of each points
in the table. Location must be integer.
@@ -512,9 +620,9 @@ class LinTable(PyoTableObject):
:Args:
- filename : string
+ filename: string
Full path of an automation recording file.
- tolerance : float, optional
+ tolerance: float, optional
Tolerance of the filter. A higher value will eliminate more points.
Defaults to 0.02.
@@ -555,13 +663,13 @@ class LinTable(PyoTableObject):
:Args:
- yrange : tuple, optional
+ yrange: tuple, optional
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -586,12 +694,12 @@ class LogTable(PyoTableObject):
:Args:
- list : list, optional
+ 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
the table (size - 1). Location must be an integer.
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
.. note::
@@ -612,8 +720,8 @@ class LogTable(PyoTableObject):
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"
+ 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(copy.deepcopy(list), size)]
@@ -624,7 +732,7 @@ class LogTable(PyoTableObject):
:Args:
- list : list
+ list: list
List of tuples indicating location and value of each points
in the table. Location must be integer.
@@ -645,9 +753,9 @@ class LogTable(PyoTableObject):
:Args:
- filename : string
+ filename: string
Full path of an automation recording file.
- tolerance : float, optional
+ tolerance: float, optional
Tolerance of the filter. A higher value will eliminate more points.
Defaults to 0.02.
@@ -688,13 +796,13 @@ class LogTable(PyoTableObject):
:Args:
- yrange : tuple, optional
+ yrange: tuple, optional
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -719,12 +827,12 @@ class CosLogTable(PyoTableObject):
:Args:
- list : list, optional
+ 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
the table (size - 1). Location must be an integer.
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
.. note::
@@ -745,8 +853,8 @@ class CosLogTable(PyoTableObject):
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"
+ 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(copy.deepcopy(list), size)]
@@ -757,7 +865,7 @@ class CosLogTable(PyoTableObject):
:Args:
- list : list
+ list: list
List of tuples indicating location and value of each points
in the table. Location must be integer.
@@ -778,9 +886,9 @@ class CosLogTable(PyoTableObject):
:Args:
- filename : string
+ filename: string
Full path of an automation recording file.
- tolerance : float, optional
+ tolerance: float, optional
Tolerance of the filter. A higher value will eliminate more points.
Defaults to 0.02.
@@ -821,13 +929,13 @@ class CosLogTable(PyoTableObject):
:Args:
- yrange : tuple, optional
+ yrange: tuple, optional
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -852,12 +960,12 @@ class CosTable(PyoTableObject):
:Args:
- list : list, optional
+ 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
table (size - 1). Location must be an integer.
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
.. note::
@@ -877,8 +985,8 @@ class CosTable(PyoTableObject):
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"
+ 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(copy.deepcopy(list), size)]
@@ -889,7 +997,7 @@ class CosTable(PyoTableObject):
:Args:
- list : list
+ list: list
List of tuples indicating location and value of each points
in the table. Location must be integer.
@@ -910,9 +1018,9 @@ class CosTable(PyoTableObject):
:Args:
- filename : string
+ filename: string
Full path of an automation recording file.
- tolerance : float, optional
+ tolerance: float, optional
Tolerance of the filter. A higher value will eliminate more points.
Defaults to 0.02.
@@ -953,13 +1061,13 @@ class CosTable(PyoTableObject):
:Args:
- yrange : tuple, optional
+ yrange: tuple, optional
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -990,19 +1098,19 @@ class CurveTable(PyoTableObject):
:Args:
- list : list, optional
+ 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
table (size - 1). Location must be an integer.
- tension : float, optional
+ tension: float, optional
Curvature at the known points. 1 is high, 0 normal, -1 is low.
Defaults to 0.
- bias : float, optional
+ bias: float, optional
Curve attraction (for each segments) toward bundary points.
0 is even, positive is towards first point, negative is towards
the second point. Defaults to 0.
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
.. note::
@@ -1025,8 +1133,8 @@ class CurveTable(PyoTableObject):
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."
- print " Increased size to last point position + 1"
+ print("CurveTable warning: size smaller than last point position.")
+ print(" Increased size to last point position + 1")
size = list[-1][0] + 1
self._size = size
self._tension = tension
@@ -1041,7 +1149,7 @@ class CurveTable(PyoTableObject):
:Args:
- x : float
+ x: float
New `tension` attribute.
"""
@@ -1059,7 +1167,7 @@ class CurveTable(PyoTableObject):
:Args:
- x : float
+ x: float
New `bias` attribute.
"""
@@ -1074,7 +1182,7 @@ class CurveTable(PyoTableObject):
:Args:
- list : list
+ list: list
List of tuples indicating location and value of each points
in the table. Location must be integer.
@@ -1095,9 +1203,9 @@ class CurveTable(PyoTableObject):
:Args:
- filename : string
+ filename: string
Full path of an automation recording file.
- tolerance : float, optional
+ tolerance: float, optional
Tolerance of the filter. A higher value will eliminate more points.
Defaults to 0.02.
@@ -1138,13 +1246,13 @@ class CurveTable(PyoTableObject):
:Args:
- yrange : tuple, optional
+ yrange: tuple, optional
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -1183,18 +1291,18 @@ class ExpTable(PyoTableObject):
:Args:
- list : list, optional
+ 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
the table. Location must be an integer.
- exp : float, optional
+ exp: float, optional
Exponent factor. Used to control the slope of the curve.
Defaults to 10.
- inverse : boolean, optional
+ inverse: boolean, optional
If True, downward slope will be inversed. Useful to create
biexponential curves. Defaults to True.
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
.. note::
@@ -1213,8 +1321,8 @@ class ExpTable(PyoTableObject):
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."
- print " Increased size to last point position + 1"
+ print("ExpTable warning: size smaller than last point position.")
+ print(" Increased size to last point position + 1")
size = list[-1][0] + 1
self._size = size
self._exp = exp
@@ -1227,7 +1335,7 @@ class ExpTable(PyoTableObject):
:Args:
- x : float
+ x: float
New `exp` attribute.
"""
@@ -1242,7 +1350,7 @@ class ExpTable(PyoTableObject):
:Args:
- x : boolean
+ x: boolean
New `inverse` attribute.
"""
@@ -1257,7 +1365,7 @@ class ExpTable(PyoTableObject):
:Args:
- list : list
+ list: list
List of tuples indicating location and value of each points
in the table. Location must be integer.
@@ -1278,9 +1386,9 @@ class ExpTable(PyoTableObject):
:Args:
- filename : string
+ filename: string
Full path of an automation recording file.
- tolerance : float, optional
+ tolerance: float, optional
Tolerance of the filter. A higher value will eliminate more points.
Defaults to 0.02.
@@ -1321,13 +1429,13 @@ class ExpTable(PyoTableObject):
:Args:
- yrange : tuple, optional
+ yrange: tuple, optional
Set the min and max values of the Y axis of the graph.
Defaults to (0.0, 1.0).
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -1367,16 +1475,16 @@ class SndTable(PyoTableObject):
:Args:
- path : string, optional
+ path: string, optional
Full path name of the sound. The defaults, None, creates an empty
table.
- chnl : int, optional
+ chnl: int, optional
Channel number to read in. Available at initialization time only.
The default (None) reads all channels.
- start : float, optional
+ start: float, optional
Begins reading at `start` seconds into the file. Available at
initialization time only. Defaults to 0.
- stop : float, optional
+ stop: float, optional
Stops reading at `stop` seconds into the file. Available at
initialization time only. The default (None) means the end of
the file.
@@ -1399,18 +1507,18 @@ class SndTable(PyoTableObject):
self._dur = []
self._base_objs = []
path, lmax = convertArgsToLists(path)
- if self._path == None:
+ if self._path is None:
self._base_objs = [SndTable_base("", 0, 0) for i in range(initchnls)]
else:
for p in path:
_size, _dur, _snd_sr, _snd_chnls, _format, _type = sndinfo(p)
- if chnl == None:
- if stop == None:
+ if chnl is None:
+ if stop is None:
self._base_objs.extend([SndTable_base(p, i, start) for i in range(_snd_chnls)])
else:
self._base_objs.extend([SndTable_base(p, i, start, stop) for i in range(_snd_chnls)])
else:
- if stop == None:
+ if stop is None:
self._base_objs.append(SndTable_base(p, chnl, start))
else:
self._base_objs.append(SndTable_base(p, chnl, start, stop))
@@ -1431,17 +1539,17 @@ class SndTable(PyoTableObject):
:Args:
- path : string
+ path: string
Full path of the new sound.
- start : float, optional
+ start: float, optional
Begins reading at `start` seconds into the file. Defaults to 0.
- stop : float, optional
+ stop: float, optional
Stops reading at `stop` seconds into the file. The default (None)
means the end of the file.
"""
self._path = path
- if type(path) == ListType:
+ if type(path) == list:
self._size = []
self._dur = []
path, lmax = convertArgsToLists(path)
@@ -1450,7 +1558,7 @@ class SndTable(PyoTableObject):
_size, _dur, _snd_sr, _snd_chnls, _format, _type = sndinfo(p)
self._size.append(_size)
self._dur.append(_dur)
- if stop == None:
+ if stop is None:
obj.setSound(p, 0, start)
else:
obj.setSound(p, 0, start, stop)
@@ -1458,7 +1566,7 @@ class SndTable(PyoTableObject):
_size, _dur, _snd_sr, _snd_chnls, _format, _type = sndinfo(path)
self._size = _size
self._dur = _dur
- if stop == None:
+ if stop is None:
[obj.setSound(path, (i%_snd_chnls), start) for i, obj in enumerate(self._base_objs)]
else:
[obj.setSound(path, (i%_snd_chnls), start, stop) for i, obj in enumerate(self._base_objs)]
@@ -1476,19 +1584,19 @@ class SndTable(PyoTableObject):
:Args:
- path : string
+ path: string
Full path of the new sound.
- crossfade : float, optional
+ crossfade: float, optional
Crossfade time, in seconds, between the sound already in the table
and the new one. Defaults to 0.
- start : float, optional
+ start: float, optional
Begins reading at `start` seconds into the file. Defaults to 0.
- stop : float, optional
+ stop: float, optional
Stops reading at `stop` seconds into the file. The default, None,
means the end of the file.
"""
- if type(path) == ListType:
+ if type(path) == list:
self._size = []
self._dur = []
path, lmax = convertArgsToLists(path)
@@ -1497,7 +1605,7 @@ class SndTable(PyoTableObject):
_size, _dur, _snd_sr, _snd_chnls, _format, _type = sndinfo(p)
self._size.append(_size)
self._dur.append(_dur)
- if stop == None:
+ if stop is None:
obj.append(p, crossfade, 0, start)
else:
obj.append(p, crossfade, 0, start, stop)
@@ -1505,7 +1613,7 @@ class SndTable(PyoTableObject):
_size, _dur, _snd_sr, _snd_chnls, _format, _type = sndinfo(path)
self._size = _size
self._dur = _dur
- if stop == None:
+ if stop is None:
[obj.append(path, crossfade, (i%_snd_chnls), start) for i, obj in enumerate(self._base_objs)]
else:
[obj.append(path, crossfade, (i%_snd_chnls), start, stop) for i, obj in enumerate(self._base_objs)]
@@ -1525,22 +1633,22 @@ class SndTable(PyoTableObject):
:Args:
- path : string
+ path: string
Full path of the new sound.
- pos : float, optional
+ pos: float, optional
Position in the table, in seconds, where to insert the new sound.
Defaults to 0.
- crossfade : float, optional
+ crossfade: float, optional
Crossfade time, in seconds, between the sound already in the table
and the new one. Defaults to 0.
- start : float, optional
+ start: float, optional
Begins reading at `start` seconds into the file. Defaults to 0.
- stop : float, optional
+ stop: float, optional
Stops reading at `stop` seconds into the file. The default, None,
means the end of the file.
"""
- if type(path) == ListType:
+ if type(path) == list:
self._size = []
self._dur = []
path, lmax = convertArgsToLists(path)
@@ -1549,7 +1657,7 @@ class SndTable(PyoTableObject):
_size, _dur, _snd_sr, _snd_chnls, _format, _type = sndinfo(p)
self._size.append(_size)
self._dur.append(_dur)
- if stop == None:
+ if stop is None:
obj.insert(p, pos, crossfade, 0, start)
else:
obj.insert(p, pos, crossfade, 0, start, stop)
@@ -1557,22 +1665,37 @@ class SndTable(PyoTableObject):
_size, _dur, _snd_sr, _snd_chnls, _format, _type = sndinfo(path)
self._size = _size
self._dur = _dur
- if stop == None:
+ if stop is None:
[obj.insert(path, pos, crossfade, (i%_snd_chnls), start) for i, obj in enumerate(self._base_objs)]
else:
[obj.insert(path, pos, crossfade, (i%_snd_chnls), start, stop) for i, obj in enumerate(self._base_objs)]
self.refreshView()
- def getRate(self):
+ def getRate(self, all=True):
"""
Return the frequency in cps at which the sound will be read at its
original pitch.
+ :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:
- return [obj.getRate() for obj in self._base_objs]
+ if type(self._path) == list:
+ _rate = [obj.getRate() for obj in self._base_objs]
else:
- return self._base_objs[0].getRate()
+ _rate = self._base_objs[0].getRate()
+
+ if all:
+ return _rate
+ else:
+ if type(_rate) == list:
+ return _rate[0]
+ else:
+ return _rate
def getDur(self, all=True):
"""
@@ -1580,13 +1703,13 @@ class SndTable(PyoTableObject):
:Args:
- all : boolean
+ 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:
+ if type(self._path) == list:
_dur = [1./obj.getRate() for obj in self._base_objs]
else:
_dur = 1./self._base_objs[0].getRate()
@@ -1594,13 +1717,13 @@ class SndTable(PyoTableObject):
if all:
return _dur
else:
- if type(_dur) == ListType:
+ if type(_dur) == list:
return _dur[0]
else:
return _dur
def setSize(self, x):
- print "SndTable has no setSize method!"
+ print("SndTable has no setSize method!")
def getSize(self, all=True):
"""
@@ -1608,7 +1731,7 @@ class SndTable(PyoTableObject):
:Args:
- all : boolean
+ all: boolean
If the table contains more than one sound and `all` is True,
returns a list of all sizes. Otherwise, returns only the
first size as an int.
@@ -1622,7 +1745,7 @@ class SndTable(PyoTableObject):
if all:
return _size
else:
- if type(_size) == ListType:
+ if type(_size) == list:
return _size[0]
else:
return _size
@@ -1634,12 +1757,12 @@ class SndTable(PyoTableObject):
:Args:
- size : tuple
+ size: tuple
Size, (X, Y) pixel values, of the waveform container window.
- begin : float, optional
+ begin: float, optional
First position in the the table, in seconds, where to get samples.
Defaults to 0.
- end : float, optional
+ end: float, optional
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.
@@ -1648,9 +1771,9 @@ class SndTable(PyoTableObject):
w, h = size
chnls = len(self._base_objs)
img = []
- imgHeight = h/chnls
+ imgHeight = h // chnls
for i in range(chnls):
- off = h/chnls*i
+ off = h // chnls * i
img.append(self._base_objs[i].getViewTable((w, imgHeight), begin, end, off))
return img
@@ -1663,7 +1786,7 @@ class SndTable(PyoTableObject):
:Args:
- points : int
+ points: int
Number of points of the amplitude analysis.
"""
@@ -1675,12 +1798,12 @@ class SndTable(PyoTableObject):
:Args:
- title : string, optional
+ title: string, optional
Window title. Defaults to "Table waveform".
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
- mouse_callback : callable
+ mouse_callback: callable
If provided, this function will be called with the mouse
position, inside the frame, as argument. Defaults to None.
@@ -1691,11 +1814,11 @@ class SndTable(PyoTableObject):
createSndViewTableWindow(self, title, wxnoserver, self.__class__.__name__, mouse_callback)
def refreshView(self):
- if self.viewFrame != None:
+ if self.viewFrame is not None:
self.viewFrame.update()
def _resetView(self):
- if self.viewFrame != None:
+ if self.viewFrame is not None:
if hasattr(self.viewFrame, "_setZoom"):
self.viewFrame._setZoom()
@@ -1718,27 +1841,27 @@ class SndTable(PyoTableObject):
"""int. Channel to read in."""
return self._chnl
@chnl.setter
- def chnl(self, x): print "'chnl' attribute is read-only."
+ def chnl(self, x): print("'chnl' attribute is read-only.")
@property
def start(self):
"""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."
+ def start(self, x): print("'start' attribute is read-only.")
@property
def stop(self):
"""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."
+ def stop(self, x): print("SndTable 'stop' attribute is read-only.")
@property
def size(self):
return self._size
@size.setter
- def size(self, x): print "SndTable 'size' attribute is read-only."
+ def size(self, x): print("SndTable 'size' attribute is read-only.")
class NewTable(PyoTableObject):
"""
@@ -1750,16 +1873,16 @@ class NewTable(PyoTableObject):
:Args:
- length : float
+ length: float
Length of the table in seconds.
- chnls : int, optional
+ chnls: int, optional
Number of channels that will be handled by the table.
Defaults to 1.
- init : list of floats, optional
+ 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.
Defaults to None.
- feedback : float, optional
+ feedback: float, optional
Amount of old data to mix with a new recording. Defaults to 0.0.
.. seealso::
@@ -1785,10 +1908,10 @@ class NewTable(PyoTableObject):
self._chnls = chnls
self._init = init
self._feedback = feedback
- if init == None:
+ if init is None:
self._base_objs = [NewTable_base(length, None, feedback) for i in range(chnls)]
else:
- if type(init[0]) != ListType:
+ if type(init[0]) != list:
init = [init]
self._base_objs = [NewTable_base(length, wrap(init,i), feedback) for i in range(chnls)]
self._size = self._base_objs[0].getSize()
@@ -1799,7 +1922,7 @@ class NewTable(PyoTableObject):
:Args:
- x : list of floats
+ 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,
@@ -1807,7 +1930,7 @@ class NewTable(PyoTableObject):
"""
pyoArgsAssert(self, "l", x)
- if type(x[0]) != ListType:
+ if type(x[0]) != list:
x = [x]
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
self.refreshView()
@@ -1818,7 +1941,7 @@ class NewTable(PyoTableObject):
:Args:
- x : float
+ x: float
New `feedback` value.
"""
@@ -1858,12 +1981,12 @@ class NewTable(PyoTableObject):
:Args:
- size : tuple
+ size: tuple
Size, (X, Y) pixel values, of the waveform container window.
- begin : float, optional
+ begin: float, optional
First position in the the table, in seconds, where to get samples.
Defaults to 0.
- end : float, optional
+ end: float, optional
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.
@@ -1872,9 +1995,9 @@ class NewTable(PyoTableObject):
w, h = size
chnls = len(self._base_objs)
img = []
- imgHeight = h/chnls
+ imgHeight = h // chnls
for i in range(chnls):
- off = h/chnls*i
+ off = h // chnls * i
img.append(self._base_objs[i].getViewTable((w, imgHeight), begin, end, off))
return img
@@ -1884,12 +2007,12 @@ class NewTable(PyoTableObject):
:Args:
- title : string, optional
+ title: string, optional
Window title. Defaults to "Table waveform".
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
- mouse_callback : callable
+ mouse_callback: callable
If provided, this function will be called with the mouse
position, inside the frame, as argument. Defaults to None.
@@ -1900,7 +2023,7 @@ class NewTable(PyoTableObject):
createSndViewTableWindow(self, title, wxnoserver, self.__class__.__name__, mouse_callback)
def refreshView(self):
- if self.viewFrame != None:
+ if self.viewFrame is not None:
self.viewFrame.update()
@property
@@ -1908,21 +2031,21 @@ class NewTable(PyoTableObject):
"""float. Length of the table in seconds."""
return self._length
@length.setter
- def length(self, x): print "'length' attribute is read-only."
+ 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."""
return self._chnls
@chnls.setter
- def chnls(self, x): print "'chnls' attribute is read-only."
+ def chnls(self, x): print("'chnls' attribute is read-only.")
@property
def init(self):
"""list of floats. Initial table."""
return self._init
@init.setter
- def init(self, x): print "'init' attribute is read-only."
+ def init(self, x): print("'init' attribute is read-only.")
@property
def feedback(self):
@@ -1935,7 +2058,7 @@ class NewTable(PyoTableObject):
def size(self):
return self._size
@size.setter
- def size(self, x): print "NewTable 'size' attribute is read-only."
+ def size(self, x): print("NewTable 'size' attribute is read-only.")
class DataTable(PyoTableObject):
"""
@@ -1947,12 +2070,12 @@ class DataTable(PyoTableObject):
:Args:
- size : int
+ size: int
Size of the table in samples.
- chnls : int, optional
+ chnls: int, optional
Number of channels that will be handled by the table.
Defaults to 1.
- init : list of floats, optional
+ 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.
@@ -1975,10 +2098,10 @@ class DataTable(PyoTableObject):
PyoTableObject.__init__(self, size)
self._chnls = chnls
self._init = init
- if init == None:
+ if init is None:
self._base_objs = [DataTable_base(size) for i in range(chnls)]
else:
- if type(init[0]) != ListType:
+ if type(init[0]) != list:
init = [init]
self._base_objs = [DataTable_base(size, wrap(init,i)) for i in range(chnls)]
@@ -1988,7 +2111,7 @@ class DataTable(PyoTableObject):
:Args:
- x : list of floats
+ 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,
@@ -1996,7 +2119,7 @@ class DataTable(PyoTableObject):
"""
pyoArgsAssert(self, "l", x)
- if type(x[0]) != ListType:
+ if type(x[0]) != list:
x = [x]
[obj.setTable(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
self.refreshView()
@@ -2009,6 +2132,10 @@ class DataTable(PyoTableObject):
"""
return self._base_objs[0].getRate()
+ def _get_current_data(self):
+ # internal that returns the data to draw in a DataTableGrapher.
+ return self.getTable()
+
def graph(self, yrange=(0.0, 1.0), title=None, wxnoserver=False):
"""
Opens a multislider window to control the data values.
@@ -2018,13 +2145,13 @@ class DataTable(PyoTableObject):
:Args:
- yrange : tuple, optional
+ yrange: tuple, optional
Set the min and max values of the Y axis of the multislider.
Defaults to (0.0, 1.0).
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -2039,21 +2166,21 @@ class DataTable(PyoTableObject):
"""int. Length of the table in samples."""
return self._size
@size.setter
- def size(self, x): print "DataTable 'size' attribute is read-only."
+ 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."""
return self._chnls
@chnls.setter
- def chnls(self, x): print "'chnls' attribute is read-only."
+ def chnls(self, x): print("'chnls' attribute is read-only.")
@property
def init(self):
"""list of floats. Initial table."""
return self._init
@init.setter
- def init(self, x): print "'init' attribute is read-only."
+ def init(self, x): print("'init' attribute is read-only.")
class AtanTable(PyoTableObject):
"""
@@ -2067,9 +2194,9 @@ class AtanTable(PyoTableObject):
:Args:
- slope : float, optional
+ slope: float, optional
Slope of the arctangent function, between 0 and 1. Defaults to 0.5.
- size : int, optional
+ size: int, optional
Table size in samples. Defaults to 8192.
>>> import math
@@ -2092,7 +2219,7 @@ class AtanTable(PyoTableObject):
:Args:
- x : float
+ x: float
New slope between 0 and 1.
"""
@@ -2126,9 +2253,9 @@ class PartialTable(PyoTableObject):
[(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
+ 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):
@@ -2139,11 +2266,11 @@ class PartialTable(PyoTableObject):
:Args:
- list : list of tuple, optional
+ 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
+ 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.
@@ -2185,7 +2312,7 @@ class PartialTable(PyoTableObject):
:Args:
- list : list of tuples
+ list: list of tuples
Each tuple contains the partial number, as a float,
and its strength.
@@ -2201,4 +2328,246 @@ class PartialTable(PyoTableObject):
"""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
+ def list(self, x): self.replace(x)
+
+class PadSynthTable(PyoTableObject):
+ """
+ Generates wavetable with the PadSynth algorithm from Nasca Octavian Paul.
+
+ This object generates a wavetable with the PadSynth algorithm describe here:
+
+ http://zynaddsubfx.sourceforge.net/doc/PADsynth/PADsynth.htm
+
+ This algorithm generates some large wavetables that can played at
+ different speeds to get the desired sound. This algorithm describes
+ only how these wavetables are generated. The result is a perfectly
+ looped wavetable.
+
+ To get the desired pitch from the table, the playback speed must be
+ `sr / table size`. This speed can be transposed to obtain different
+ pitches from a single wavetable.
+
+ :Parent: :py:class:`PyoTableObject`
+
+ :Args:
+
+ basefreq: float, optional
+ The base frequencyof the algorithm in Hz. If the spreading factor
+ is near 1.0, this frequency is the fundamental of the spectrum.
+ Defaults to 440.
+ spread: float, optional
+ The spreading factor for the harmonics. Each harmonic real frequency
+ is computed as `basefreq * pow(n, spread)` where `n` is the harmonic
+ order. Defaults to 1.
+ bw: float, optional
+ The bandwidth of the first harmonic in cents. The bandwidth allows
+ to control the harmonic profile using a gaussian distribution (bell
+ shape). Defaults to 50.
+ bwscl: float, optional
+ The bandswidth scale specifies how much the bandwidth of the
+ harmonic increase according to its frequency. Defaults to 1.
+ nharms: int, optional
+ The number of harmonics in the generated wavetable. Higher
+ numbers of harmonics take more time to generate the wavetable.
+ Defaults to 64.
+ damp: float, optional
+ The amplitude damping factor specifies how much the amplitude
+ of the harmonic decrease according to its order. It uses a
+ simple power serie, `amp = pow(damp, n)` where `n` is the
+ harmonic order. Defaults to 0.7.
+ size: int, optional
+ Table size in samples. Must be a power-of-two, usually a big one!
+ Defaults to 262144.
+
+ .. note::
+
+ Many thanks to Nasca Octavian Paul for making this beautiful algorithm
+ and releasing it under Public Domain.
+
+ >>> s = Server().boot()
+ >>> s.start()
+ >>> f = s.getSamplingRate() / 262144
+ >>> t = PadSynthTable(basefreq=midiToHz(48), spread=1.205, bw=10, bwscl=1.5)
+ >>> a = Osc(table=t, freq=f, phase=[0, 0.5], mul=0.5).out()
+
+ """
+ def __init__(self, basefreq=440, spread=1, bw=50, bwscl=1, nharms=64, damp=0.7, size=262144):
+ pyoArgsAssert(self, "NNNNINI", basefreq, spread, bw, bwscl, nharms, damp, size)
+ PyoTableObject.__init__(self, size)
+ self._basefreq = basefreq
+ self._spread = spread
+ self._bw = bw
+ self._bwscl = bwscl
+ self._nharms = nharms
+ self._damp = damp
+ self._base_objs = [PadSynthTable_base(basefreq, spread, bw, bwscl, nharms, damp, size)]
+
+ def setBaseFreq(self, x, generate=True):
+ """
+ Change the base frequency of the algorithm.
+
+ :Args:
+
+ x: float
+ New base frequency in Hz.
+ generate: boolean, optional
+ If True, a new table will be computed with changed value.
+
+ """
+ pyoArgsAssert(self, "NB", x, generate)
+ self._basefreq = x
+ [obj.setBaseFreq(x, generate) for obj in self._base_objs]
+ if generate:
+ self.refreshView()
+
+ def setSpread(self, x, generate=True):
+ """
+ Change the frequency spreading factor of the algorithm.
+
+ :Args:
+
+ x: float
+ New spread factor.
+ generate: boolean, optional
+ If True, a new table will be computed with changed value.
+
+ """
+ pyoArgsAssert(self, "NB", x, generate)
+ self._spread = x
+ [obj.setSpread(x, generate) for obj in self._base_objs]
+ if generate:
+ self.refreshView()
+
+ def setBw(self, x, generate=True):
+ """
+ Change the bandwidth of the first harmonic.
+
+ :Args:
+
+ x: float
+ New bandwidth in cents.
+ generate: boolean, optional
+ If True, a new table will be computed with changed value.
+
+ """
+ pyoArgsAssert(self, "NB", x, generate)
+ self._bw = x
+ [obj.setBw(x, generate) for obj in self._base_objs]
+ if generate:
+ self.refreshView()
+
+ def setBwScl(self, x, generate=True):
+ """
+ Change the bandwidth scaling factor.
+
+ :Args:
+
+ x: float
+ New bandwidth scaling factor.
+ generate: boolean, optional
+ If True, a new table will be computed with changed value.
+
+ """
+ pyoArgsAssert(self, "NB", x, generate)
+ self._bwscl = x
+ [obj.setBwScl(x, generate) for obj in self._base_objs]
+ if generate:
+ self.refreshView()
+
+ def setNharms(self, x, generate=True):
+ """
+ Change the number of harmonics.
+
+ :Args:
+
+ x: int
+ New number of harmonics.
+ generate: boolean, optional
+ If True, a new table will be computed with changed value.
+
+ """
+ pyoArgsAssert(self, "IB", x, generate)
+ self._nharms = x
+ [obj.setNharms(x, generate) for obj in self._base_objs]
+ if generate:
+ self.refreshView()
+
+ def setDamp(self, x, generate=True):
+ """
+ Change the amplitude damping factor.
+
+ :Args:
+
+ x: float
+ New amplitude damping factor.
+ generate: boolean, optional
+ If True, a new table will be computed with changed value.
+
+ """
+ pyoArgsAssert(self, "NB", x, generate)
+ self._damp = x
+ [obj.setDamp(x, generate) for obj in self._base_objs]
+ if generate:
+ self.refreshView()
+
+ def setSize(self, size, generate=True):
+ """
+ Change the size of the table.
+
+ This will erase the previously drawn waveform.
+
+ :Args:
+
+ size: int
+ New table size in samples. Must be a power-of-two.
+ generate: boolean, optional
+ If True, a new table will be computed with changed value.
+
+ """
+ pyoArgsAssert(self, "IB", size, generate)
+ self._size = size
+ [obj.setSize(size, generate) for obj in self._base_objs]
+ if generate:
+ self.refreshView()
+
+ @property
+ def basefreq(self):
+ """float. Base frequency in Hz."""
+ return self._basefreq
+ @basefreq.setter
+ def basefreq(self, x): self.setBaseFreq(x)
+
+ @property
+ def spread(self):
+ """float. Frequency spreading factor."""
+ return self._spread
+ @spread.setter
+ def spread(self, x): self.setSpread(x)
+
+ @property
+ def bw(self):
+ """float. Bandwitdh of the first harmonic in cents."""
+ return self._bw
+ @bw.setter
+ def bw(self, x): self.setBw(x)
+
+ @property
+ def bwscl(self):
+ """float. Bandwitdh scaling factor."""
+ return self._bwscl
+ @bwscl.setter
+ def bwscl(self, x): self.setBwScl(x)
+
+ @property
+ def nharms(self):
+ """int. Number of harmonics."""
+ return self._nharms
+ @nharms.setter
+ def nharms(self, x): self.setNharms(x)
+
+ @property
+ def damp(self):
+ """float. Amplitude damping factor."""
+ return self._damp
+ @damp.setter
+ def damp(self, x): self.setDamp(x)
diff --git a/pyolib/triggers.py b/pyolib/triggers.py
index 2e74fa9..b366178 100644
--- a/pyolib/triggers.py
+++ b/pyolib/triggers.py
@@ -1,3 +1,6 @@
+from __future__ import division
+from __future__ import print_function
+from __future__ import absolute_import
"""
Set of objects to manage triggers streams.
@@ -7,7 +10,6 @@ TrigXXX objects use this kind of signal to generate different
processes with sampling rate time accuracy.
"""
-
"""
Copyright 2009-2015 Olivier Belanger
@@ -27,10 +29,9 @@ 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 *
-from _widgets import createGraphWindow
-from types import SliceType, ListType, TupleType
+from ._core import *
+from ._maps import *
+from ._widgets import createGraphWindow
import weakref
class Trig(PyoObject):
@@ -89,9 +90,9 @@ class Metro(PyoObject):
:Args:
- time : float or PyoObject, optional
+ time: float or PyoObject, optional
Time between each trigger in seconds. Defaults to 1.
- poly : int, optional
+ poly: int, optional
Metronome polyphony. Denotes how many independent streams are
generated by the metronome, allowing overlapping processes.
@@ -118,7 +119,7 @@ class Metro(PyoObject):
self._time = time
self._poly = poly
time, lmax = convertArgsToLists(time)
- self._base_objs = [Metro_base(wrap(time,i)*poly, (float(j)/poly)) for i in range(lmax) for j in range(poly)]
+ self._base_objs = [Metro_base(wrap(time,i)*poly, (float(j) / poly)) for i in range(lmax) for j in range(poly)]
def setTime(self, x):
"""
@@ -126,7 +127,7 @@ class Metro(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `time` attribute.
"""
@@ -174,11 +175,11 @@ class Seq(PyoObject):
:Args:
- time : float or PyoObject, optional
+ time: float or PyoObject, optional
Base time between each trigger in seconds. Defaults to 1.
- seq : list of ints, optional
+ seq: list of ints, optional
Sequence of beat durations in time's unit. Defaults to [1].
- poly : int, optional
+ poly: int, optional
Seq polyphony. Denotes how many independent streams are
generated by the metronome, allowing overlapping processes.
@@ -206,7 +207,7 @@ class Seq(PyoObject):
self._seq = seq
self._poly = poly
time, lmax = convertArgsToLists(time)
- if type(seq[0]) != ListType:
+ if type(seq[0]) != list:
self._base_players = [Seqer_base(wrap(time,i), seq, poly) for i in range(lmax)]
else:
seqlen = len(seq)
@@ -220,7 +221,7 @@ class Seq(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `time` attribute.
"""
@@ -235,13 +236,13 @@ class Seq(PyoObject):
:Args:
- x : list of ints
+ x: list of ints
New `seq` attribute.
"""
pyoArgsAssert(self, "l", x)
self._seq = x
- if type(x[0]) != ListType:
+ if type(x[0]) != list:
[obj.setSeq(x) for i, obj in enumerate(self._base_players)]
else:
[obj.setSeq(wrap(x,i)) for i, obj in enumerate(self._base_players)]
@@ -294,9 +295,9 @@ class Cloud(PyoObject):
:Args:
- density : float or PyoObject, optional
+ density: float or PyoObject, optional
Average number of triggers per second. Defaults to 10.
- poly : int, optional
+ poly: int, optional
Cloud polyphony. Denotes how many independent streams are
generated by the object, allowing overlapping processes.
@@ -332,7 +333,7 @@ class Cloud(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `density` attribute.
"""
@@ -392,17 +393,17 @@ class Beat(PyoObject):
:Args:
- time : float or PyoObject, optional
+ time: float or PyoObject, optional
Time, in seconds, between each beat of the pattern. Defaults to 0.125.
- taps : int, optional
+ taps: int, optional
Number of beats in the generated pattern, max = 64. Defaults to 16.
- w1 : int {0 -> 100}, optional
+ w1: int {0 -> 100}, optional
Probability for down beats. Defaults to 80.
- w2 : int {0 -> 100}, optional
+ w2: int {0 -> 100}, optional
Probability for up beats. Defaults to 50.
- w3 : int {0 -> 100}, optional
+ w3: int {0 -> 100}, optional
Probability for the weakest beats. Defaults to 30.
- poly : int, optional
+ poly: int, optional
Beat polyphony. Denotes how many independent streams are
generated by the object, allowing overlapping processes.
@@ -467,12 +468,12 @@ class Beat(PyoObject):
if i == 'end':
self._end_dummy.append(Dummy([obj for obj in self._end_objs]))
return self._end_dummy[-1]
- if type(i) == SliceType:
+ if type(i) == slice:
return self._base_objs[i]
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,10 +486,10 @@ class Beat(PyoObject):
:Args:
- identifier : string {"tap", "amp", "dur"}
+ identifier: string {"tap", "amp", "dur"}
Address string parameter identifying audio stream.
Defaults to "amp".
- all : boolean, optional
+ all: boolean, optional
If True, the first value of each object's stream
will be returned as a list.
@@ -528,7 +529,7 @@ class Beat(PyoObject):
:Args:
- x : int
+ x: int
Memory number. 0 <= x < 32.
"""
@@ -541,7 +542,7 @@ class Beat(PyoObject):
:Args:
- x : int
+ x: int
Memory number. 0 <= x < 32.
"""
@@ -564,7 +565,7 @@ class Beat(PyoObject):
:Args:
- x : list
+ x: list
List of presets.
"""
@@ -580,7 +581,7 @@ class Beat(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `time` attribute.
"""
@@ -595,7 +596,7 @@ class Beat(PyoObject):
:Args:
- x : int
+ x: int
New `taps` attribute.
"""
@@ -610,7 +611,7 @@ class Beat(PyoObject):
:Args:
- x : int
+ x: int
New `w1` attribute.
"""
@@ -623,7 +624,7 @@ class Beat(PyoObject):
:Args:
- x : int
+ x: int
New `w2` attribute.
"""
@@ -636,7 +637,7 @@ class Beat(PyoObject):
:Args:
- x : int
+ x: int
New `w3` attribute.
"""
@@ -651,17 +652,17 @@ class Beat(PyoObject):
:Args:
- w1 : int, optional
+ w1: int, optional
New `w1` attribute. Defaults to None.
- w2 : int, optional
+ w2: int, optional
New `w2` attribute. Defaults to None.
- w3 : int, optional
+ w3: int, optional
New `w3` attribute. Defaults to None.
"""
- if w1 != None: self._w1 = w1
- if w2 != None: self._w2 = w2
- if w3 != None: self._w3 = w3
+ if w1 is not None: self._w1 = w1
+ if w2 is not None: self._w2 = w2
+ if w3 is not None: self._w3 = w3
w1, w2, w3, lmax = convertArgsToLists(w1, w2, w3)
[obj.setWeights(wrap(w1,i), wrap(w2,i), wrap(w3,i)) for i, obj in enumerate(self._base_players)]
@@ -750,9 +751,9 @@ class TrigRandInt(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- max : float or PyoObject, optional
+ max: float or PyoObject, optional
Maximum value for the random generation. Defaults to 100.
.. note::
@@ -784,9 +785,9 @@ class TrigRandInt(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -800,7 +801,7 @@ class TrigRandInt(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `max` attribute.
"""
@@ -844,15 +845,15 @@ class TrigRand(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- min : float or PyoObject, optional
+ min: float or PyoObject, optional
Minimum value for the random generation. Defaults to 0.
- max : float or PyoObject, optional
+ max: float or PyoObject, optional
Maximum value for the random generation. Defaults to 1.
- port : float, optional
+ port: float, optional
Portamento. Time to reach a new value. Defaults to 0.
- init : float, optional
+ init: float, optional
Initial value. Available at initialization time only.
Defaults to 0.
@@ -882,9 +883,9 @@ class TrigRand(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -898,7 +899,7 @@ class TrigRand(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `min` attribute.
"""
@@ -913,7 +914,7 @@ class TrigRand(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `max` attribute.
"""
@@ -928,7 +929,7 @@ class TrigRand(PyoObject):
:Args:
- x : float
+ x: float
new `port` attribute.
"""
@@ -984,13 +985,13 @@ class TrigChoice(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- choice : list of floats
+ choice: list of floats
Possible values for the random generation.
- port : float, optional
+ port: float, optional
Portamento. Time to reach a new value. Defaults to 0.
- init : float, optional
+ init: float, optional
Initial value. Available at initialization time only.
Defaults to 0.
@@ -1011,7 +1012,7 @@ class TrigChoice(PyoObject):
self._port = port
self._in_fader = InputFader(input)
in_fader, port, init, mul, add, lmax = convertArgsToLists(self._in_fader, port, init, mul, add)
- if type(choice[0]) != ListType:
+ if type(choice[0]) != list:
self._base_objs = [TrigChoice_base(wrap(in_fader,i), choice, wrap(port,i), wrap(init,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
else:
choicelen = len(choice)
@@ -1024,9 +1025,9 @@ class TrigChoice(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1040,13 +1041,13 @@ class TrigChoice(PyoObject):
:Args:
- x : list of floats
+ x: list of floats
new `choice` attribute.
"""
pyoArgsAssert(self, "l", x)
self._choice = x
- if type(x[0]) != ListType:
+ if type(x[0]) != list:
[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)]
@@ -1057,7 +1058,7 @@ class TrigChoice(PyoObject):
:Args:
- x : float
+ x: float
new `port` attribute.
"""
@@ -1099,11 +1100,11 @@ class TrigFunc(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- function : Python function
+ function: Python function
Function to be called.
- arg : anything, optional
+ arg: anything, optional
Argument sent to the function's call. If None, the function
will be called without argument. Defaults to None.
@@ -1155,9 +1156,9 @@ class TrigFunc(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1171,7 +1172,7 @@ class TrigFunc(PyoObject):
:Args:
- x : Python function
+ x: Python function
new `function` attribute.
"""
@@ -1186,7 +1187,7 @@ class TrigFunc(PyoObject):
:Args:
- x : Anything
+ x: Anything
new `arg` attribute.
"""
@@ -1227,13 +1228,13 @@ class TrigEnv(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- table : PyoTableObject
+ table: PyoTableObject
Table containing the envelope.
- dur : float or PyoObject, optional
+ dur: float or PyoObject, optional
Duration in seconds of the envelope. Defaults to 1.
- interp : int, optional
+ interp: int, optional
Choice of the interpolation method. Defaults to 2.
1. no interpolation
2. linear
@@ -1242,7 +1243,7 @@ class TrigEnv(PyoObject):
.. note::
- TrigEnv will sends a trigger signal at the end of the playback.
+ TrigEnv will send a trigger signal at the end of the playback.
User can retreive the trigger streams by calling obj['trig'].
Useful to synchronize other processes.
@@ -1273,9 +1274,9 @@ class TrigEnv(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1289,7 +1290,7 @@ class TrigEnv(PyoObject):
:Args:
- x : PyoTableObject
+ x: PyoTableObject
new `table` attribute.
"""
@@ -1304,7 +1305,7 @@ class TrigEnv(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `dur` attribute.
"""
@@ -1319,7 +1320,7 @@ class TrigEnv(PyoObject):
:Args:
- x : int {1, 2, 3, 4}
+ x: int {1, 2, 3, 4}
new `interp` attribute.
"""
@@ -1372,9 +1373,9 @@ class TrigLinseg(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- list : list of tuples
+ list: list of tuples
Points used to construct the line segments. Each tuple is a
new point in the form (time, value).
@@ -1382,7 +1383,7 @@ class TrigLinseg(PyoObject):
.. note::
- TrigLinseg will sends a trigger signal at the end of the playback.
+ TrigLinseg will send a trigger signal at the end of the playback.
User can retreive the trigger streams by calling obj['trig'].
Useful to synchronize other processes.
@@ -1415,9 +1416,9 @@ class TrigLinseg(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1431,7 +1432,7 @@ class TrigLinseg(PyoObject):
:Args:
- x : list of tuples
+ x: list of tuples
new `list` attribute.
"""
@@ -1445,7 +1446,7 @@ class TrigLinseg(PyoObject):
:Args:
- x : list of tuples
+ x: list of tuples
new `list` attribute.
"""
@@ -1470,18 +1471,18 @@ class TrigLinseg(PyoObject):
:Args:
- xlen : float, optional
+ xlen: float, optional
Set the maximum value of the X axis of the graph. If None, the
maximum value is retrieve from the current list of points.
Defaults to None.
- yrange : tuple, optional
+ yrange: tuple, optional
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.
Defaults to None.
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -1489,11 +1490,11 @@ class TrigLinseg(PyoObject):
the server GUI before showing the controller window.
"""
- if xlen == None:
+ if xlen is None:
xlen = float(self._list[-1][0])
else:
xlen = float(xlen)
- if yrange == None:
+ if yrange is None:
ymin = float(min([x[1] for x in self._list]))
ymax = float(max([x[1] for x in self._list]))
if ymin == ymax:
@@ -1528,23 +1529,23 @@ class TrigExpseg(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- list : list of tuples
+ list: list of tuples
Points used to construct the line segments. Each tuple is a
new point in the form (time, value).
Times are given in seconds and must be in increasing order.
- exp : float, optional
+ exp: float, optional
Exponent factor. Used to control the slope of the curves.
Defaults to 10.
- inverse : boolean, optional
+ inverse: boolean, optional
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.
+ TrigExpseg will send a trigger signal at the end of the playback.
User can retreive the trigger streams by calling obj['trig'].
Useful to synchronize other processes.
@@ -1579,9 +1580,9 @@ class TrigExpseg(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1595,7 +1596,7 @@ class TrigExpseg(PyoObject):
:Args:
- x : list of tuples
+ x: list of tuples
new `list` attribute.
"""
@@ -1609,7 +1610,7 @@ class TrigExpseg(PyoObject):
:Args:
- x : float
+ x: float
new `exp` attribute.
"""
@@ -1624,7 +1625,7 @@ class TrigExpseg(PyoObject):
:Args:
- x : boolean
+ x: boolean
new `inverse` attribute.
"""
@@ -1639,7 +1640,7 @@ class TrigExpseg(PyoObject):
:Args:
- x : list of tuples
+ x: list of tuples
new `list` attribute.
"""
@@ -1664,18 +1665,18 @@ class TrigExpseg(PyoObject):
:Args:
- xlen : float, optional
+ xlen: float, optional
Set the maximum value of the X axis of the graph. If None, the
maximum value is retrieve from the current list of points.
Defaults to None.
- yrange : tuple, optional
+ yrange: tuple, optional
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.
Defaults to None.
- title : string, optional
+ title: string, optional
Title of the window. If none is provided, the name of the
class is used.
- wxnoserver : boolean, optional
+ wxnoserver: boolean, optional
With wxPython graphical toolkit, if True, tells the
interpreter that there will be no server window.
@@ -1683,11 +1684,11 @@ class TrigExpseg(PyoObject):
the server GUI before showing the controller window.
"""
- if xlen == None:
+ if xlen is None:
xlen = float(self._list[-1][0])
else:
xlen = float(xlen)
- if yrange == None:
+ if yrange is None:
ymin = float(min([x[1] for x in self._list]))
ymax = float(max([x[1] for x in self._list]))
if ymin == ymax:
@@ -1737,13 +1738,13 @@ class TrigXnoise(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- dist : string or int, optional
+ dist: string or int, optional
Distribution type. Defaults to 0.
- x1 : float or PyoObject, optional
+ x1: float or PyoObject, optional
First parameter. Defaults to 0.5.
- x2 : float or PyoObject, optional
+ x2: float or PyoObject, optional
Second parameter. Defaults to 0.5.
.. note::
@@ -1768,44 +1769,44 @@ class TrigXnoise(PyoObject):
parameter):
0. uniform
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
1. linear_min
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
2. linear_max
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
3. triangle
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
4. expon_min
- - x1 : slope {0 = no slope -> 10 = sharp slope}
- - x2 : not used
+ - x1: slope {0 = no slope -> 10 = sharp slope}
+ - x2: not used
5. expon_max
- - x1 : slope {0 = no slope -> 10 = sharp slope}
- - x2 : not used
+ - x1: slope {0 = no slope -> 10 = sharp slope}
+ - x2: not used
6. biexpon
- - x1 : bandwidth {0 = huge bandwidth -> 10 = narrow bandwidth}
- - x2 : not used
+ - x1: bandwidth {0 = huge bandwidth -> 10 = narrow bandwidth}
+ - x2: not used
7. cauchy
- - x1 : bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
- - x2 : not used
+ - x1: bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
+ - x2: not used
8. weibull
- - x1 : mean location {0 -> 1}
- - x2 : shape {0.5 = linear min, 1.5 = expon min, 3.5 = gaussian}
+ - x1: mean location {0 -> 1}
+ - x2: shape {0.5 = linear min, 1.5 = expon min, 3.5 = gaussian}
9. gaussian
- - x1 : mean location {0 -> 1}
- - x2 : bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
+ - x1: mean location {0 -> 1}
+ - x2: bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
10. poisson
- - x1 : gravity center {0 = low values -> 10 = high values}
- - x2 : compress/expand range {0.1 = full compress -> 4 full expand}
+ - x1: gravity center {0 = low values -> 10 = high values}
+ - x2: compress/expand range {0.1 = full compress -> 4 full expand}
11. walker
- - x1 : maximum value {0.1 -> 1}
- - x2 : maximum step {0.1 -> 1}
+ - x1: maximum value {0.1 -> 1}
+ - x2: maximum step {0.1 -> 1}
12. loopseg
- - x1 : maximum value {0.1 -> 1}
- - x2 : maximum step {0.1 -> 1}
+ - x1: maximum value {0.1 -> 1}
+ - x2: maximum step {0.1 -> 1}
>>> s = Server().boot()
>>> s.start()
@@ -1827,7 +1828,7 @@ class TrigXnoise(PyoObject):
self._in_fader = InputFader(input)
in_fader, dist, x1, x2, mul, add, lmax = convertArgsToLists(self._in_fader, dist, x1, x2, mul, add)
for i, t in enumerate(dist):
- if type(t) == StringType: dist[i] = XNOISE_DICT.get(t, 0)
+ if type(t) in [bytes_t, unicode_t]: dist[i] = XNOISE_DICT.get(t, 0)
self._base_objs = [TrigXnoise_base(wrap(in_fader,i), wrap(dist,i), wrap(x1,i), wrap(x2,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setInput(self, x, fadetime=0.05):
@@ -1836,9 +1837,9 @@ class TrigXnoise(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1852,14 +1853,14 @@ class TrigXnoise(PyoObject):
:Args:
- x : int
+ x: int
new `dist` attribute.
"""
self._dist = x
x, lmax = convertArgsToLists(x)
for i, t in enumerate(x):
- if type(t) == StringType: x[i] = XNOISE_DICT.get(t, 0)
+ if type(t) in [bytes_t, unicode_t]: x[i] = XNOISE_DICT.get(t, 0)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setX1(self, x):
@@ -1868,7 +1869,7 @@ class TrigXnoise(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `x1` attribute.
"""
@@ -1883,7 +1884,7 @@ class TrigXnoise(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `x2` attribute.
"""
@@ -1892,6 +1893,13 @@ class TrigXnoise(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setX2(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, 12, "lin", "dist", self._dist, res="int", dataOnly=True),
+ SLMap(0.01, 10.0, "log", "x1", self._x1, dataOnly=True),
+ SLMap(0.01, 10.0, "log", "x2", self._x2, dataOnly=True),
+ SLMapMul(self._mul)]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
@property
def input(self):
"""PyoObject. Audio trigger signal."""
@@ -1935,21 +1943,21 @@ class TrigXnoiseMidi(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- dist : string of int, optional
+ dist: string of int, optional
Distribution type. Defaults to 0.
- x1 : float or PyoObject, optional
+ x1: float or PyoObject, optional
First parameter. Defaults to 0.5.
- x2 : float or PyoObject, optional
+ x2: float or PyoObject, optional
Second parameter. Defaults to 0.5.
- scale : int {0, 1, 2}, optional
+ scale: int {0, 1, 2}, optional
Output format. 0 = MIDI, 1 = Hertz, 2 = transposition factor.
Defaults to 0.
In the transposition mode, the central key (the key where there
is no transposition) is (`minrange` + `maxrange`) / 2.
- mrange : tuple of int, optional
+ mrange: tuple of int, optional
Minimum and maximum possible values, in Midi notes. Available
only at initialization time. Defaults to (0, 127).
@@ -1975,44 +1983,44 @@ class TrigXnoiseMidi(PyoObject):
parameter):
0. uniform
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
1. linear_min
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
2. linear_max
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
3. triangle
- - x1 : not used
- - x2 : not used
+ - x1: not used
+ - x2: not used
4. expon_min
- - x1 : slope {0 = no slope -> 10 = sharp slope}
- - x2 : not used
+ - x1: slope {0 = no slope -> 10 = sharp slope}
+ - x2: not used
5. expon_max
- - x1 : slope {0 = no slope -> 10 = sharp slope}
- - x2 : not used
+ - x1: slope {0 = no slope -> 10 = sharp slope}
+ - x2: not used
6. biexpon
- - x1 : bandwidth {0 = huge bandwidth -> 10 = narrow bandwidth}
- - x2 : not used
+ - x1: bandwidth {0 = huge bandwidth -> 10 = narrow bandwidth}
+ - x2: not used
7. cauchy
- - x1 : bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
- - x2 : not used
+ - x1: bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
+ - x2: not used
8. weibull
- - x1 : mean location {0 -> 1}
- - x2 : shape {0.5 = linear min, 1.5 = expon min, 3.5 = gaussian}
+ - x1: mean location {0 -> 1}
+ - x2: shape {0.5 = linear min, 1.5 = expon min, 3.5 = gaussian}
9. gaussian
- - x1 : mean location {0 -> 1}
- - x2 : bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
+ - x1: mean location {0 -> 1}
+ - x2: bandwidth {0 = narrow bandwidth -> 10 = huge bandwidth}
10. poisson
- - x1 : gravity center {0 = low values -> 10 = high values}
- - x2 : compress/expand range {0.1 = full compress -> 4 full expand}
+ - x1: gravity center {0 = low values -> 10 = high values}
+ - x2: compress/expand range {0.1 = full compress -> 4 full expand}
11. walker
- - x1 : maximum value {0.1 -> 1}
- - x2 : maximum step {0.1 -> 1}
+ - x1: maximum value {0.1 -> 1}
+ - x2: maximum step {0.1 -> 1}
12. loopseg
- - x1 : maximum value {0.1 -> 1}
- - x2 : maximum step {0.1 -> 1}
+ - x1: maximum value {0.1 -> 1}
+ - x2: maximum step {0.1 -> 1}
>>> s = Server().boot()
>>> s.start()
@@ -2036,7 +2044,7 @@ class TrigXnoiseMidi(PyoObject):
self._in_fader = InputFader(input)
in_fader, dist, x1, x2, scale, mrange, mul, add, lmax = convertArgsToLists(self._in_fader, dist, x1, x2, scale, mrange, mul, add)
for i, t in enumerate(dist):
- if type(t) == StringType: dist[i] = XNOISE_DICT.get(t, 0)
+ if type(t) in [bytes_t, unicode_t]: dist[i] = XNOISE_DICT.get(t, 0)
self._base_objs = [TrigXnoiseMidi_base(wrap(in_fader,i), wrap(dist,i), wrap(x1,i), wrap(x2,i), wrap(scale,i), wrap(mrange,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
def setInput(self, x, fadetime=0.05):
@@ -2045,9 +2053,9 @@ class TrigXnoiseMidi(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2061,14 +2069,14 @@ class TrigXnoiseMidi(PyoObject):
:Args:
- x : int
+ x: int
new `dist` attribute.
"""
self._dist = x
x, lmax = convertArgsToLists(x)
for i, t in enumerate(x):
- if type(t) == StringType: x[i] = XNOISE_DICT.get(t, 0)
+ if type(t) in [bytes_t, unicode_t]: x[i] = XNOISE_DICT.get(t, 0)
[obj.setType(wrap(x,i)) for i, obj in enumerate(self._base_objs)]
def setScale(self, x):
@@ -2082,7 +2090,7 @@ class TrigXnoiseMidi(PyoObject):
:Args:
- x : int {0, 1, 2}
+ x: int {0, 1, 2}
new `scale` attribute.
"""
@@ -2097,9 +2105,9 @@ class TrigXnoiseMidi(PyoObject):
:Args:
- mini : int
+ mini: int
minimum output midi range.
- maxi : int
+ maxi: int
maximum output midi range.
"""
@@ -2114,7 +2122,7 @@ class TrigXnoiseMidi(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `x1` attribute.
"""
@@ -2129,7 +2137,7 @@ class TrigXnoiseMidi(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `x2` attribute.
"""
@@ -2138,6 +2146,13 @@ class TrigXnoiseMidi(PyoObject):
x, lmax = convertArgsToLists(x)
[obj.setX2(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, 12, "lin", "dist", self._dist, res="int", dataOnly=True),
+ SLMap(0.01, 10.0, "log", "x1", self._x1, dataOnly=True),
+ SLMap(0.01, 10.0, "log", "x2", self._x2, dataOnly=True),
+ SLMapMul(self._mul)]
+ PyoObject.ctrl(self, map_list, title, wxnoserver)
+
@property
def input(self):
"""PyoObject. Audio trigger signal."""
@@ -2187,14 +2202,14 @@ class Counter(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- min : int, optional
+ min: int, optional
Minimum value of the count, included in the count. Defaults to 0.
- max : int, optional
+ max: int, optional
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
+ dir: int {0, 1, 2}, optional
Direction of the count. Defaults to 0. Three possible values:
0. up
1. down
@@ -2236,9 +2251,9 @@ class Counter(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2252,7 +2267,7 @@ class Counter(PyoObject):
:Args:
- x : int
+ x: int
new `min` attribute.
"""
@@ -2267,7 +2282,7 @@ class Counter(PyoObject):
:Args:
- x : int
+ x: int
new `max` attribute.
"""
@@ -2282,7 +2297,7 @@ class Counter(PyoObject):
:Args:
- x : int {0, 1, 2}
+ x: int {0, 1, 2}
new `dir` attribute.
"""
@@ -2298,11 +2313,12 @@ class Counter(PyoObject):
:Args:
- value : int, optional
+ value: int, optional
Value where to reset the count. Defaults to None.
"""
- pyoArgsAssert(self, "i", x)
+ if value is not None:
+ pyoArgsAssert(self, "i", value)
value, lmax = convertArgsToLists(value)
[obj.reset(wrap(value,i)) for i, obj in enumerate(self._base_objs)]
@@ -2355,9 +2371,9 @@ class Select(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal. Must contains integer numbers.
- value : int, optional
+ value: int, optional
Value to be matched to send a trigger. Defaults to 0.
.. note::
@@ -2398,9 +2414,9 @@ class Select(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2414,7 +2430,7 @@ class Select(PyoObject):
:Args:
- x : int
+ x: int
new `value` attribute.
"""
@@ -2450,7 +2466,7 @@ class Change(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal. Must contains integer numbers.
.. note::
@@ -2484,9 +2500,9 @@ class Change(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2514,11 +2530,11 @@ class Thresh(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- threshold : float or PyoObject, optional
+ threshold: float or PyoObject, optional
Threshold value. Defaults to 0.
- dir : int {0, 1, 2}, optional
+ dir: int {0, 1, 2}, optional
There are three modes of using Thresh:
0. down-up (default)
sends a trigger when current value is higher than the
@@ -2564,9 +2580,9 @@ class Thresh(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2580,7 +2596,7 @@ class Thresh(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `threshold` attribute.
"""
@@ -2595,7 +2611,7 @@ class Thresh(PyoObject):
:Args:
- x : int {0, 1, 2}
+ x: int {0, 1, 2}
new `dir` attribute.
"""
@@ -2637,9 +2653,9 @@ class Percent(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- percent : float or PyoObject, optional
+ percent: float or PyoObject, optional
How much percentage of triggers to let pass,
between 0 and 100. Defaults to 50.
@@ -2677,9 +2693,9 @@ class Percent(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2693,7 +2709,7 @@ class Percent(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `percent` attribute.
"""
@@ -2733,9 +2749,9 @@ class Timer(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Trigger signal. Stops the timer and reports elapsed time.
- input2 : PyoObject
+ input2: PyoObject
Trigger signal. Starts the timer if not already started.
.. note::
@@ -2771,9 +2787,9 @@ class Timer(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -2787,9 +2803,9 @@ class Timer(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -2822,14 +2838,24 @@ class Iter(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- choice : list of floats
- Sequence of values over which to iterate.
- init : float, optional
+ choice: list of floats or PyoObjects
+ Sequence of values over which to iterate. If a PyoObject with
+ more than one audio streams is given, the streams will be
+ flattened and inserted in the main list. See setChoice method
+ for more details.
+ init: float, optional
Initial value. Available at initialization time only.
Defaults to 0.
+ .. note::
+
+ Iter will send a trigger signal when the iterator hits the
+ last value of the list `choice`. User can retreive the trigger
+ streams by calling obj['trig']. Useful to synchronize other
+ processes.
+
>>> s = Server().boot()
>>> s.start()
>>> l1 = [300, 350, 400, 450, 500, 550]
@@ -2848,12 +2874,14 @@ class Iter(PyoObject):
self._choice = choice
self._in_fader = InputFader(input)
in_fader, init, mul, add, lmax = convertArgsToLists(self._in_fader, init, mul, add)
- if type(choice[0]) != ListType:
- self._base_objs = [Iter_base(wrap(in_fader,i), choice, wrap(init,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+ x = self._flatten(choice)
+ if type(x[0]) != list:
+ self._base_objs = [Iter_base(wrap(in_fader,i), x, wrap(init,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
else:
- choicelen = len(choice)
+ choicelen = len(x)
lmax = max(choicelen, lmax)
- self._base_objs = [Iter_base(wrap(in_fader,i), wrap(choice,i), wrap(init,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+ self._base_objs = [Iter_base(wrap(in_fader,i), wrap(x,i), wrap(init,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
+ self._trig_objs = Dummy([TriggerDummy_base(obj) for obj in self._base_objs])
def setInput(self, x, fadetime=0.05):
"""
@@ -2861,9 +2889,9 @@ class Iter(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -2871,22 +2899,53 @@ class Iter(PyoObject):
self._input = x
self._in_fader.setInput(x, fadetime)
+ def _flatten(self, x):
+ if type(x[0]) != list:
+ lst = []
+ for ob in x:
+ if isinstance(ob, PyoObject):
+ lst.extend(ob.getBaseObjects())
+ else:
+ lst.append(ob)
+ else:
+ lst = []
+ for sub in x:
+ sublst = []
+ for ob in sub:
+ if isinstance(ob, PyoObject):
+ sublst.extend(ob.getBaseObjects())
+ else:
+ sublst.append(ob)
+ lst.append(sublst)
+ return lst
+
def setChoice(self, x):
"""
Replace the `choice` attribute.
+ `x` is a sequence of values over which to iterate. If a PyoObject
+ with more than one audio streams is given, the streams will be
+ flattened and inserted in the main list. For example, the choices:
+
+ [100, Randi(100,200,4), 200, Sig(250, mul=[1, 2])]
+
+ will expand to:
+
+ [100, rand_val, 200, 250, 500] # the last two are audio streams.
+
:Args:
- x : list of floats
+ x: list of floats or PyoObjects
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)]
+ x = self._flatten(x)
+ if type(x[0]) != list:
+ [obj.setChoice(x) for i, obj in enumerate(self._base_objs)]
else:
- [obj.setChoice(wrap(self._choice,i)) for i, obj in enumerate(self._base_objs)]
+ [obj.setChoice(wrap(x, i)) for i, obj in enumerate(self._base_objs)]
def reset(self, x=0):
"""
@@ -2894,7 +2953,7 @@ class Iter(PyoObject):
:Args:
- x : int, optional
+ x: int, optional
Value where to reset the count. Defaults to 0.
"""
@@ -2910,7 +2969,7 @@ class Iter(PyoObject):
self.setInput(x)
@property
def choice(self):
- """list of floats. Possible values."""
+ """list of floats or PyoObjects. Possible values."""
return self._choice
@choice.setter
def choice(self, x):
@@ -2927,11 +2986,11 @@ class Count(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Trigger signal. Start or Restart the count.
- min : int, optional
+ min: int, optional
Minimum value of the count, included in the count. Defaults to 0.
- max : int, optional
+ 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
@@ -2960,9 +3019,9 @@ class Count(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New input signal.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -2976,7 +3035,7 @@ class Count(PyoObject):
:Args:
- x : int
+ x: int
new `min` attribute.
"""
@@ -2991,7 +3050,7 @@ class Count(PyoObject):
:Args:
- x : int
+ x: int
new `max` attribute.
"""
@@ -3039,9 +3098,9 @@ class NextTrig(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Trigger signal. Trigger stream waiting for the gate to be opened.
- input2 : PyoObject
+ input2: PyoObject
Trigger signal. Trigger stream opening the gate.
.. note::
@@ -3075,9 +3134,9 @@ class NextTrig(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -3091,9 +3150,9 @@ class NextTrig(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -3127,11 +3186,11 @@ class TrigVal(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Audio signal sending triggers.
- value : float or PyoObject, optional
+ value: float or PyoObject, optional
Next value. Defaults to 0.
- init : float, optional
+ init: float, optional
Initial value. Defaults to 0.
.. note::
@@ -3164,9 +3223,9 @@ class TrigVal(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -3180,7 +3239,7 @@ class TrigVal(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
new `value` attribute.
"""
@@ -3228,15 +3287,15 @@ class Euclide(PyoObject):
:Args:
- time : float or PyoObject, optional
+ time: float or PyoObject, optional
Time, in seconds, between each beat of the pattern. Defaults to 0.125.
- taps : int, optional
+ taps: int, optional
Number of beats in the generated pattern (measure length), max = 64.
Defaults to 16.
- onsets : int, optional
+ onsets: int, optional
Number of onsets (a positive tap) in the generated pattern.
Defaults to 10.
- poly : int, optional
+ poly: int, optional
Beat polyphony. Denotes how many independent streams are
generated by the object, allowing overlapping processes.
@@ -3296,6 +3355,8 @@ class Euclide(PyoObject):
in a measure of length `k` (number of taps).
Looping implementation, faster than recursive.
"""
+ if m < 1: m = 1
+ if k < 1: k = 1
if m > k: m = k
k -= m
mv, kv = [1], [0]
@@ -3321,12 +3382,12 @@ class Euclide(PyoObject):
if i == 'end':
self._end_dummy.append(Dummy([obj for obj in self._end_objs]))
return self._end_dummy[-1]
- if type(i) == SliceType:
+ if type(i) == slice:
return self._base_objs[i]
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):
"""
@@ -3339,10 +3400,10 @@ class Euclide(PyoObject):
:Args:
- identifier : string {"tap", "amp", "dur"}
+ identifier: string {"tap", "amp", "dur"}
Address string parameter identifying audio stream.
Defaults to "amp".
- all : boolean, optional
+ all: boolean, optional
If True, the first value of each object's stream
will be returned as a list.
@@ -3361,7 +3422,7 @@ class Euclide(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `time` attribute.
"""
@@ -3376,7 +3437,7 @@ class Euclide(PyoObject):
:Args:
- x : int
+ x: int
New `taps` attribute.
"""
@@ -3394,7 +3455,7 @@ class Euclide(PyoObject):
:Args:
- x : int
+ x: int
New `onsets` attribute.
"""
@@ -3485,19 +3546,19 @@ class TrigBurst(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal sending triggers.
- time : float or PyoObject, optional
+ time: float or PyoObject, optional
Base time, in seconds, between each trig of the serie. Defaults to 0.25.
- count : int, optional
+ count: int, optional
Number of trigs generated (length of the serie). Defaults to 10.
- expand : float, optional
+ 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
+ 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
+ poly: int, optional
Voice polyphony. Denotes how many independent streams are
generated by the object, allowing overlapping processes.
@@ -3563,12 +3624,12 @@ class TrigBurst(PyoObject):
if i == 'end':
self._end_dummy.append(Dummy([obj for obj in self._end_objs]))
return self._end_dummy[-1]
- if type(i) == SliceType:
+ if type(i) == slice:
return self._base_objs[i]
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):
"""
@@ -3581,10 +3642,10 @@ class TrigBurst(PyoObject):
:Args:
- identifier : string {"tap", "amp", "dur"}
+ identifier: string {"tap", "amp", "dur"}
Address string parameter identifying audio stream.
Defaults to "amp".
- all : boolean, optional
+ all: boolean, optional
If True, the first value of each object's stream
will be returned as a list.
@@ -3603,9 +3664,9 @@ class TrigBurst(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -3619,7 +3680,7 @@ class TrigBurst(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `time` attribute.
"""
@@ -3634,7 +3695,7 @@ class TrigBurst(PyoObject):
:Args:
- x : int
+ x: int
New `count` attribute.
"""
@@ -3649,7 +3710,7 @@ class TrigBurst(PyoObject):
:Args:
- x : float
+ x: float
New `expand` attribute.
"""
@@ -3664,7 +3725,7 @@ class TrigBurst(PyoObject):
:Args:
- x : float
+ x: float
New `ampfade` attribute.
"""
@@ -3743,4 +3804,4 @@ class TrigBurst(PyoObject):
"""float. Amplitude's power expansion factor."""
return self._ampfade
@ampfade.setter
- def ampfade(self, x): self.setAmpfade(x)
\ No newline at end of file
+ def ampfade(self, x): self.setAmpfade(x)
diff --git a/pyolib/utils.py b/pyolib/utils.py
index 619dbb8..0e8b27d 100644
--- a/pyolib/utils.py
+++ b/pyolib/utils.py
@@ -1,3 +1,5 @@
+from __future__ import print_function
+from __future__ import absolute_import
"""
Miscellaneous objects.
@@ -22,9 +24,8 @@ 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 *
-from types import SliceType
+from ._core import *
+from ._maps import *
import threading, time
class Clean_objects(threading.Thread):
@@ -35,10 +36,10 @@ class Clean_objects(threading.Thread):
:Args:
- time : float
+ time: float
Time, in seconds, to wait before calling stop on the given
objects and deleting them.
- *args : PyoObject(s)
+ *args: PyoObject(s)
Objects to delete.
>>> s = Server().boot()
@@ -71,16 +72,16 @@ class Print(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to filter.
- method : int {0, 1}, optional
+ method: int {0, 1}, optional
There is two methods to set when a value is printed (Defaults to 0):
0. at a periodic interval.
1. everytime the value changed.
- interval : float, optional
+ interval: float, optional
Interval, in seconds, between each print. Used by method 0.
Defaults to 0.25.
- message : str, optional
+ message: str, optional
Message to print before the current value. Defaults to "".
.. note::
@@ -114,9 +115,9 @@ class Print(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -130,7 +131,7 @@ class Print(PyoObject):
:Args:
- x : int {0, 1}
+ x: int {0, 1}
New `method` attribute.
"""
@@ -145,7 +146,7 @@ class Print(PyoObject):
:Args:
- x : float
+ x: float
New `interval` attribute.
"""
@@ -160,7 +161,7 @@ class Print(PyoObject):
:Args:
- x : str
+ x: str
New `message` attribute.
"""
@@ -216,11 +217,11 @@ class Snap(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Incoming Midi notes as an audio stream.
- choice : list of floats
+ choice: list of floats
Possible values, as midi notes, for output.
- scale : int {0, 1, 2}, optional
+ scale: int {0, 1, 2}, optional
Pitch output format.
0. MIDI (default)
1. Hertz
@@ -248,7 +249,7 @@ class Snap(PyoObject):
self._scale = scale
self._in_fader = InputFader(input)
in_fader, scale, mul, add, lmax = convertArgsToLists(self._in_fader, scale, mul, add)
- if type(choice[0]) != ListType:
+ if type(choice[0]) != list:
self._base_objs = [Snap_base(wrap(in_fader,i), choice, wrap(scale,i), wrap(mul,i), wrap(add,i)) for i in range(lmax)]
else:
choicelen = len(choice)
@@ -261,9 +262,9 @@ class Snap(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -277,7 +278,7 @@ class Snap(PyoObject):
:Args:
- x : list of floats
+ x: list of floats
new `choice` attribute.
"""
@@ -296,7 +297,7 @@ class Snap(PyoObject):
:Args:
- x : int {0, 1, 2}
+ x: int {0, 1, 2}
new `scale` attribute.
"""
@@ -335,11 +336,11 @@ class Interp(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
First input signal.
- input2 : PyoObject
+ input2: PyoObject
Second input signal.
- interp : float or PyoObject, optional
+ interp: float or PyoObject, optional
Averaging value. 0 means only first signal, 1 means only second
signal. Default to 0.5.
@@ -368,9 +369,9 @@ class Interp(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -384,9 +385,9 @@ class Interp(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -400,7 +401,7 @@ class Interp(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `interp` attribute.
"""
@@ -446,11 +447,11 @@ class SampHold(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal.
- controlsig : PyoObject
+ controlsig: PyoObject
Controls when to sample the signal.
- value : float or PyoObject, optional
+ value: float or PyoObject, optional
Sampling target value. Default to 0.0.
>>> s = Server().boot()
@@ -478,9 +479,9 @@ class SampHold(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -494,9 +495,9 @@ class SampHold(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New control signal.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -510,7 +511,7 @@ class SampHold(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `value` attribute.
"""
@@ -551,13 +552,13 @@ class Record(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to record.
- filename : string
+ filename: string
Full path of the file to create.
- chnls : int, optional
+ chnls: int, optional
Number of channels in the audio file. Defaults to 2.
- fileformat : int, optional
+ fileformat: int, optional
Format type of the audio file. Defaults to 0.
Record will first try to set the format from the filename extension.
@@ -571,7 +572,7 @@ class Record(PyoObject):
5. FLAC - FLAC lossless file format {.flac}
6. CAF - Core Audio File format {.caf}
7. OGG - Xiph OGG container {.ogg}
- sampletype : int, optional
+ sampletype: int, optional
Bit depth encoding of the audio file.
SD2 and FLAC only support 16 or 24 bit int. Supported types are:
@@ -582,11 +583,15 @@ class Record(PyoObject):
4. 64 bits float
5. U-Law encoded
6. A-Law encoded
- buffering : int, optional
+ buffering: int, optional
Number of bufferSize to wait before writing samples to disk.
High buffering uses more memory but improves performance.
Defaults to 4.
+ quality: float, optional
+ The encoding quality value, between 0.0 (lowest quality) and
+ 1.0 (highest quality). This argument has an effect only with
+ FLAC and OGG compressed formats. Defaults to 0.4.
.. note::
@@ -614,21 +619,21 @@ class Record(PyoObject):
>>> clean.start()
"""
- def __init__(self, input, filename, chnls=2, fileformat=0, sampletype=0, buffering=4):
- pyoArgsAssert(self, "oSIIII", input, filename, chnls, fileformat, sampletype, buffering)
+ def __init__(self, input, filename, chnls=2, fileformat=0, sampletype=0, buffering=4, quality=0.4):
+ pyoArgsAssert(self, "oSIIIIN", input, filename, chnls, fileformat, sampletype, buffering, quality)
PyoObject.__init__(self)
self._input = input
self._in_fader = InputFader(input)
ext = filename.rsplit('.')
if len(ext) >= 2:
ext = ext[-1].lower()
- if FILE_FORMATS.has_key(ext):
+ if ext in FILE_FORMATS:
fileformat = FILE_FORMATS[ext]
else:
- print 'Warning: Unknown file extension. Using fileformat value.'
+ print('Warning: Unknown file extension. Using fileformat value.')
else:
- print 'Warning: Filename has no extension. Using fileformat value.'
- self._base_objs = [Record_base(self._in_fader.getBaseObjects(), filename, chnls, fileformat, sampletype, buffering)]
+ print('Warning: Filename has no extension. Using fileformat value.')
+ self._base_objs = [Record_base(self._in_fader.getBaseObjects(), filename, chnls, fileformat, sampletype, buffering, quality)]
def out(self, chnl=0, inc=1, dur=0, delay=0):
return self.play(dur, delay)
@@ -639,9 +644,9 @@ class Record(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -668,7 +673,7 @@ class Denorm(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
>>> s = Server().boot()
@@ -693,9 +698,9 @@ class Denorm(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -728,9 +733,9 @@ class ControlRec(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to sample.
- filename : string
+ filename: string
Full path (without extension) used to create the files.
"_000" will be added to file's names with increasing digits
@@ -738,9 +743,9 @@ class ControlRec(PyoObject):
The same filename can be passed to a ControlRead object to
read all related files.
- rate : int, optional
+ rate: int, optional
Rate at which the input values are sampled. Defaults to 1000.
- dur : float, optional
+ dur: float, optional
Duration of the recording, in seconds. If 0.0, the recording
won't stop until the end of the performance.
@@ -811,7 +816,7 @@ class ControlRead(PyoObject):
:Args:
- filename : string
+ filename: string
Full path (without extension) used to create the files.
Usually the same filename as the one given to a ControlRec
@@ -819,12 +824,12 @@ class ControlRead(PyoObject):
The directory will be scaned and all files
named "filename_xxx" will add a new stream in the object.
- rate : int, optional
+ rate: int, optional
Rate at which the values are sampled. Defaults to 1000.
- loop : boolean, optional
+ loop: boolean, optional
Looping mode, False means off, True means on.
Defaults to False.
- interp : int, optional
+ interp: int, optional
Choice of the interpolation method.
1. no interpolation
2. linear (default)
@@ -833,7 +838,7 @@ class ControlRead(PyoObject):
.. note::
- ControlRead will sends a trigger signal at the end of the playback if
+ ControlRead will send 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']:
@@ -885,7 +890,7 @@ class ControlRead(PyoObject):
:Args:
- x : int
+ x: int
new `rate` attribute.
"""
@@ -900,7 +905,7 @@ class ControlRead(PyoObject):
:Args:
- x : boolean
+ x: boolean
new `loop` attribute.
"""
@@ -915,7 +920,7 @@ class ControlRead(PyoObject):
:Args:
- x : int {1, 2, 3, 4}
+ x: int {1, 2, 3, 4}
new `interp` attribute.
"""
@@ -963,9 +968,9 @@ class NoteinRec(PyoObject):
:Args:
- input : Notein
+ input: Notein
Notein signal to sample.
- filename : string
+ filename: string
Full path (without extension) used to create the files.
"_000" will be added to file's names with increasing digits
@@ -1030,7 +1035,7 @@ class NoteinRead(PyoObject):
:Args:
- filename : string
+ filename: string
Full path (without extension) used to create the files.
Usually the same filename as the one given to a NoteinRec
@@ -1038,13 +1043,13 @@ class NoteinRead(PyoObject):
The directory will be scaned and all files
named "filename_xxx" will add a new stream in the object.
- loop : boolean, optional
+ loop: boolean, optional
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
+ NoteinRead will send 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']:
@@ -1115,10 +1120,10 @@ class NoteinRead(PyoObject):
:Args:
- identifier : string {"pitch", "velocity"}
+ identifier: string {"pitch", "velocity"}
Address string parameter identifying audio stream.
Defaults to "pitch".
- all : boolean, optional
+ all: boolean, optional
If True, the first value of each object's stream
will be returned as a list.
@@ -1140,7 +1145,7 @@ class NoteinRead(PyoObject):
:Args:
- x : boolean
+ x: boolean
new `loop` attribute.
"""
@@ -1168,7 +1173,7 @@ class DBToA(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal, decibel value.
>>> s = Server().boot()
@@ -1194,9 +1199,9 @@ class DBToA(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1223,7 +1228,7 @@ class AToDB(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal, amplitude value.
>>> s = Server().boot()
@@ -1250,9 +1255,9 @@ class AToDB(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1279,17 +1284,17 @@ class Scale(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- inmin : float or PyoObject, optional
+ inmin: float or PyoObject, optional
Minimum input value. Defaults to 0.
- inmax : float or PyoObject, optional
+ inmax: float or PyoObject, optional
Maximum input value. Defaults to 1.
- outmin : float or PyoObject, optional
+ outmin: float or PyoObject, optional
Minimum output value. Defaults to 0.
- outmax : float or PyoObject, optional
+ outmax: float or PyoObject, optional
Maximum output value. Defaults to 1.
- exp : float, optional
+ exp: float, optional
Exponent value, specifies the nature of the scaling curve.
Values between 0 and 1 give a reversed curve. Defaults to 1.0.
@@ -1322,9 +1327,9 @@ class Scale(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1338,7 +1343,7 @@ class Scale(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `inmin` attribute.
"""
@@ -1353,7 +1358,7 @@ class Scale(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `inmax` attribute.
"""
@@ -1368,7 +1373,7 @@ class Scale(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `outmin` attribute.
"""
@@ -1383,7 +1388,7 @@ class Scale(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `outmax` attribute.
"""
@@ -1398,7 +1403,7 @@ class Scale(PyoObject):
:Args:
- x : float
+ x: float
New `exp` attribute.
"""
@@ -1408,11 +1413,11 @@ class Scale(PyoObject):
[obj.setExp(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., 127., 'lin', 'inmin', self._inmin),
- SLMap(0., 127., 'lin', 'inmax', self._inmax),
- SLMap(0., 127., 'lin', 'outmin', self._outmin),
- SLMap(0., 127., 'lin', 'outmax', self._outmax),
- SLMap(1., 10., 'lin', 'exp', self._exp),
+ self._map_list = [SLMap(0., 127., 'lin', 'inmin', self._inmin),
+ SLMap(0., 127., 'lin', 'inmax', self._inmax),
+ SLMap(0., 127., 'lin', 'outmin', self._outmin),
+ SLMap(0., 127., 'lin', 'outmax', self._outmax),
+ SLMap(1., 10., 'lin', 'exp', self._exp),
SLMapMul(self._mul)]
PyoObject.ctrl(self, map_list, title, wxnoserver)
@@ -1468,7 +1473,7 @@ class CentsToTranspo(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal, cents value.
>>> s = Server().boot()
@@ -1494,9 +1499,9 @@ class CentsToTranspo(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1521,7 +1526,7 @@ class TranspoToCents(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal, transposition factor.
>>> s = Server().boot()
@@ -1548,9 +1553,9 @@ class TranspoToCents(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1576,7 +1581,7 @@ class MToF(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal as midi note.
>>> s = Server().boot()
@@ -1602,9 +1607,9 @@ class MToF(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1630,7 +1635,7 @@ class FToM(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal as frequency in Hz.
>>> s = Server().boot()
@@ -1659,9 +1664,9 @@ class FToM(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1687,9 +1692,9 @@ class MToT(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal as midi note.
- centralkey : float, optional
+ centralkey: float, optional
The midi note that returns a transposition factor of 1,
that is to say no transposition. Defaults to 60.
@@ -1720,9 +1725,9 @@ class MToT(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1736,7 +1741,7 @@ class MToT(PyoObject):
:Args:
- x : float
+ x: float
New `centralkey` attribute.
"""
@@ -1769,11 +1774,11 @@ class Between(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to process.
- min : float or PyoObject, optional
+ min: float or PyoObject, optional
Minimum range value. Defaults to 0.
- max : float or PyoObject, optional
+ max: float or PyoObject, optional
Maximum range value. Defaults to 1.
>>> s = Server().boot()
@@ -1800,9 +1805,9 @@ class Between(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Defaults to 0.05.
"""
@@ -1816,7 +1821,7 @@ class Between(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `min` attribute.
"""
@@ -1831,7 +1836,7 @@ class Between(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `max` attribute.
"""
@@ -1879,11 +1884,11 @@ class TrackHold(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal.
- controlsig : PyoObject
+ controlsig: PyoObject
Controls when to sample the signal.
- value : float or PyoObject, optional
+ value: float or PyoObject, optional
Sampling target value. Default to 0.0.
>>> s = Server().boot()
@@ -1911,9 +1916,9 @@ class TrackHold(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New signal to process.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1927,9 +1932,9 @@ class TrackHold(PyoObject):
:Args:
- x : PyoObject
+ x: PyoObject
New control signal.
- fadetime : float, optional
+ fadetime: float, optional
Crossfade time between old and new input. Default to 0.05.
"""
@@ -1943,7 +1948,7 @@ class TrackHold(PyoObject):
:Args:
- x : float or PyoObject
+ x: float or PyoObject
New `value` attribute.
"""
@@ -1978,15 +1983,15 @@ class Resample(PyoObject):
Realtime upsampling or downsampling of an audio signal.
This object should be used in the context of a resampling block
- created with the Server's methods `beginResamplingBlock` and
- `EndResamplingBlock`.
-
- If used inside the block, it will resample its input signal according
- to the resampling factor given to `beginResamplingFactor`. If the factor
- is a negative value, the new virtual sampling rate will be
- `current sr / abs(factor)`. If the factor is a postive value, the new
- virtual sampling rate will be `current sr * factor`.
-
+ created with the Server's methods `beginResamplingBlock` and
+ `EndResamplingBlock`.
+
+ If used inside the block, it will resample its input signal according
+ to the resampling factor given to `beginResamplingFactor`. If the factor
+ is a negative value, the new virtual sampling rate will be
+ `current sr / abs(factor)`. If the factor is a postive value, the new
+ virtual sampling rate will be `current sr * factor`.
+
If used after `endResamplingBlock`, it will resample its input signal
to the current sampling rate of the server.
@@ -1997,24 +2002,24 @@ class Resample(PyoObject):
:Args:
- input : PyoObject
+ input: PyoObject
Input signal to resample.
- mode : int, optional
+ mode: int, optional
The interpolation/decimation mode. Defaults to 1.
For the upsampling process, possible values are:
- 0 : zero-padding
- 1 : sample-and-hold
- 2 or higher : the formula `mode * resampling factor` gives
+ 0: zero-padding
+ 1: sample-and-hold
+ 2 or higher: the formula `mode * resampling factor` gives
the FIR lowpass kernel length used to interpolate.
For the downsampling process, possible values are:
- 0 or 1 : discard extra samples
- 2 or higher : the formula `mode * abs(resampling factor)`
+ 0 or 1: discard extra samples
+ 2 or higher: the formula `mode * abs(resampling factor)`
gives the FIR lowpass kernel length used for the decimation.
Available at initialization time only.
>>> s = Server().boot()
>>> s.start()
- >>> drv = Sine(.5, phase=[0, 0.5], mul=0.49, add=0.5)
+ >>> drv = Sine(.5, phase=[0, 0.5], mul=0.49, add=0.5)
>>> sig = SfPlayer(SNDS_PATH+"/transparent.aif", loop=True)
>>> s.beginResamplingBlock(8)
>>> sigup = Resample(sig, mode=32)
diff --git a/pyolib/wxgui.py b/pyolib/wxgui.py
index 08bae20..6821400 100644
--- a/pyolib/wxgui.py
+++ b/pyolib/wxgui.py
@@ -1,41 +1,52 @@
"""
-The classes in this module are based on internal classes that where
+The classes in this module are based on internal classes that where
originally designed to help the creation of graphical tools for the
control and the visualization of audio signals. WxPython must be installed
under the current Python distribution to access these classes.
"""
-from _widgets import PYO_USE_WX
+from __future__ import absolute_import
+from ._widgets import PYO_USE_WX
if not PYO_USE_WX:
NO_WX_MESSAGE = "WxPython must be installed on the system to use pyo's wx widgets."
class PyoGuiControlSlider:
+
def __init__(self, *args, **kwargs):
raise Exception(NO_WX_MESSAGE)
class PyoGuiVuMeter:
+
def __init__(self, *args, **kwargs):
raise Exception(NO_WX_MESSAGE)
class PyoGuiGrapher:
+
def __init__(self, *args, **kwargs):
raise Exception(NO_WX_MESSAGE)
class PyoGuiMultiSlider:
+
def __init__(self, *args, **kwargs):
raise Exception(NO_WX_MESSAGE)
class PyoGuiSpectrum:
+
def __init__(self, *args, **kwargs):
raise Exception(NO_WX_MESSAGE)
class PyoGuiScope:
+
def __init__(self, *args, **kwargs):
raise Exception(NO_WX_MESSAGE)
class PyoGuiSndView:
+
def __init__(self, *args, **kwargs):
raise Exception(NO_WX_MESSAGE)
else:
import wx
import wx.lib.newevent
- from _wxwidgets import ControlSlider, VuMeter, Grapher, DataMultiSlider
- from _wxwidgets import SpectrumPanel, ScopePanel, SndViewTablePanel, HRangeSlider
-
+ from ._wxwidgets import ControlSlider, VuMeter, Grapher, DataMultiSlider
+ from ._wxwidgets import SpectrumPanel, ScopePanel, SndViewTablePanel, HRangeSlider
+
+ if "phoenix" not in wx.version():
+ wx.QueueEvent = wx.PostEvent
+
# Custom events
PyoGuiControlSliderEvent, EVT_PYO_GUI_CONTROL_SLIDER = wx.lib.newevent.NewEvent()
PyoGuiGrapherEvent, EVT_PYO_GUI_GRAPHER = wx.lib.newevent.NewEvent()
@@ -48,56 +59,56 @@ else:
Floating-point control slider.
:Parent: wx.Panel
-
+
:Events:
-
+
EVT_PYO_GUI_CONTROL_SLIDER
- Sent after any change of the slider position. The current
- value of the slider can be retrieve with the `value`
+ Sent after any change of the slider position. The current
+ value of the slider can be retrieve with the `value`
attribute of the generated event.
:Args:
- parent : wx.Window
+ parent: wx.Window
The parent window.
- minvalue : float
+ minvalue: float
The minimum value of the slider.
- maxvalue : float
+ maxvalue: float
The maximum value of the slider.
- init : float, optional
+ init: float, optional
The initial value of the slider. If None, the slider
inits to the minimum value. Defaults to None.
- pos : tuple, optional
+ pos: tuple, optional
The slider's position in pixel (x, y). Defaults to (0, 0).
- size : tuple, optional
+ size: tuple, optional
The slider's size in pixel (x, y). Defaults to (200, 16).
- log : boolean, optional
+ log: boolean, optional
If True, creates a logarithmic slider (minvalue must be
greater than 0). Defaults to False.
- integer : boolean, optional
+ integer: boolean, optional
If True, creates an integer slider. Defaults to False.
- powoftwo : boolean, optional
+ powoftwo: boolean, optional
If True, creates a power-of-two slider (log is automatically
False and integer is True). If True, minvalue and maxvalue
must be exponents to base 2 but init is a real power-of-two
value. Defaults to False.
- orient : {wx.HORIZONTAL or wx.VERTICAL}, optional
+ orient: {wx.HORIZONTAL or wx.VERTICAL}, optional
The slider's orientation. Defaults to wx.HORIZONTAL.
-
+
"""
def __init__(self, parent, minvalue, maxvalue, init=None, pos=(0, 0),
size=(200, 16), log=False, integer=False, powoftwo=False,
orient=wx.HORIZONTAL):
- super(PyoGuiControlSlider, self).__init__(parent, minvalue, maxvalue,
+ super(PyoGuiControlSlider, self).__init__(parent, minvalue, maxvalue,
init, pos, size, log,
- self._outFunction, integer,
- powoftwo,
- parent.GetBackgroundColour(),
+ self._outFunction, integer,
+ powoftwo,
+ parent.GetBackgroundColour(),
orient)
def _outFunction(self, value):
evt = PyoGuiControlSliderEvent(value=value)
- wx.PostEvent(self, evt)
+ wx.QueueEvent(self, evt)
def enable(self):
"""
@@ -109,7 +120,7 @@ else:
def disable(self):
"""
Disable the slider for user input.
-
+
"""
super(PyoGuiControlSlider, self).Disable()
@@ -119,23 +130,23 @@ else:
:Args:
- x : int or float
+ x: int or float
The controller number.
- propagate : boolean, optional
+ propagate: boolean, optional
If True, an event will be sent after the call.
"""
super(PyoGuiControlSlider, self).SetValue(x, propagate)
-
+
def setMidiCtl(self, x, propagate=True):
"""
Sets the midi controller number to show on the slider.
:Args:
- x : int
+ x: int
The controller number.
- propagate : boolean, optional
+ propagate: boolean, optional
If True, an event will be sent after the call.
"""
@@ -147,9 +158,9 @@ else:
:Args:
- minvalue : int or float
+ minvalue: int or float
The new minimum value.
- maxvalue : int or float
+ maxvalue: int or float
The new maximum value.
"""
@@ -158,92 +169,92 @@ else:
def getValue(self):
"""
Returns the current value of the slider.
-
+
"""
return super(PyoGuiControlSlider, self).GetValue()
def getMidiCtl(self):
"""
Returns the midi controller number, if any, assigned to the slider.
-
+
"""
return super(PyoGuiControlSlider, self).getMidiCtl()
def getMinValue(self):
"""
Returns the current minimum value.
-
+
"""
return super(PyoGuiControlSlider, self).getMinValue()
def getMaxValue(self):
"""
Returns the current maximum value.
-
+
"""
return super(PyoGuiControlSlider, self).getMaxValue()
def getInit(self):
"""
Returns the initial value.
-
+
"""
return super(PyoGuiControlSlider, self).getInit()
def getRange(self):
"""
Returns minimum and maximum values as a list.
-
+
"""
return super(PyoGuiControlSlider, self).getRange()
def isInteger(self):
"""
Returns True if the slider manage only integer, False otherwise.
-
+
"""
return self.integer
def isLog(self):
"""
Returns True if the slider is logarithmic, False otherwise.
-
+
"""
return self.log
def isPowOfTwo(self):
"""
Returns True if the slider manage only power-of-two values, False otherwise.
-
+
"""
return self.powoftwo
class PyoGuiVuMeter(VuMeter):
"""
Multi-channels Vu Meter.
-
+
When registered as the Server's meter, its internal method `setRms`
will be called each buffer size with a list of normalized amplitudes
- as argument. The `setRms` method can also be registered as the
+ as argument. The `setRms` method can also be registered as the
function callback of a PeakAmp object.
:Parent: wx.Panel
:Args:
- parent : wx.Window
+ parent: wx.Window
The parent window.
- nchnls : int, optional
+ nchnls: int, optional
The initial number of channels of the meter. Defaults to 2.
- pos : wx.Point, optional
+ pos: wx.Point, optional
Window position in pixels. Defaults to (0, 0).
- size : tuple, optional
+ size: tuple, optional
The meter's size in pixels (x, y). Defaults to (200, 11).
- orient : {wx.HORIZONTAL or wx.VERTICAL}, optional
+ orient: {wx.HORIZONTAL or wx.VERTICAL}, optional
The meter's orientation. Defaults to wx.HORIZONTAL.
- style : int, optional
+ style: int, optional
Window style (see wx.Window documentation). Defaults to 0.
-
+
"""
def __init__(self, parent, nchnls=2, pos=(0, 0), size=(200, 11),
orient=wx.HORIZONTAL, style=0):
@@ -256,7 +267,7 @@ else:
:Args:
- nchnls : int
+ nchnls: int
The number of channels.
"""
@@ -267,29 +278,29 @@ else:
Multi-modes break-points function editor.
:Parent: wx.Panel
-
+
:Events:
-
+
EVT_PYO_GUI_GRAPHER
- Sent after any change of the grapher function. The current
- list of points of the grapher can be retrieve with the `value`
+ Sent after any change of the grapher function. The current
+ list of points of the grapher can be retrieve with the `value`
attribute of the generated event.
:Args:
- parent : wx.Window
+ parent: wx.Window
The parent window.
- xlen : int, optional
+ xlen: int, optional
The length, in samples, of the grapher. Defaults to 8192.
- yrange : two-values tuple, optional
+ yrange: two-values tuple, optional
A tuple indicating the minimum and maximum values of the Y-axis.
Defaults to (0, 1).
- init : list of two-values tuples, optional
- The initial break-points function set as normalized values.
- A point is defined with its X and Y positions as a tuple.
+ init: list of two-values tuples, optional
+ The initial break-points function set as normalized values.
+ A point is defined with its X and Y positions as a tuple.
Defaults to [(0.0, 0.0), (1.0, 1.0)].
- mode : int, optional
- The grapher mode definning how line segments will be draw.
+ mode: int, optional
+ The grapher mode definning how line segments will be draw.
Possible modes are:
0. linear (default)
1. cosine
@@ -297,23 +308,23 @@ else:
3. curve (uses `tension` and `bias` arguments)
4. logarithmic
5. logarithmic cosine
- exp : int or float, optional
+ exp: int or float, optional
The exponent factor for an exponential graph. Defaults to 10.0.
- inverse : boolean, optional
+ inverse: boolean, optional
If True, downward slope will be inversed. Useful to create
biexponential curves. Defaults to True.
- tension : int or float, optional
+ tension: int or float, optional
Curvature at the known points. 1 is high, 0 normal, -1 is low.
Defaults to 0.
- bias : int or float, optional
+ bias: int or float, optional
Curve attraction (for each segments) toward bundary points.
0 is even, positive is towards first point, negative is towards
the second point. Defaults to 0.
- pos : wx.Point, optional
+ pos: wx.Point, optional
Window position in pixels. Defaults to (0, 0).
- size : wx.Size, optional
+ size: wx.Size, optional
Window size in pixels. Defaults to (300, 200).
- style : int, optional
+ style: int, optional
Window style (see wx.Window documentation). Defaults to 0.
"""
@@ -321,12 +332,12 @@ else:
mode=0, exp=10, inverse=True, tension=0, bias=0, pos=(0, 0),
size=(300, 200), style=0):
super(PyoGuiGrapher, self).__init__(parent, xlen, yrange, init, mode,
- exp, inverse, tension, bias,
+ exp, inverse, tension, bias,
self._outFunction, pos, size, style)
def _outFunction(self, value):
evt = PyoGuiGrapherEvent(value=value)
- wx.PostEvent(self, evt)
+ wx.QueueEvent(self, evt)
def _refresh(self):
self.Refresh()
@@ -342,14 +353,14 @@ else:
def getPoints(self):
"""
Returns the current normalized points of the grapher.
-
+
"""
return super(PyoGuiGrapher, self).getPoints()
def getValues(self):
"""
Returns the current points, according to Y-axis range, of the grapher.
-
+
"""
return super(PyoGuiGrapher, self).getValues()
@@ -359,7 +370,7 @@ else:
:Args:
- pts : list of two-values tuples
+ pts: list of two-values tuples
New normalized (between 0 and 1) points.
"""
@@ -372,7 +383,7 @@ else:
:Args:
- vals : list of two-values tuples
+ vals: list of two-values tuples
New real points.
"""
@@ -385,7 +396,7 @@ else:
:Args:
- yrange : two-values tuple
+ yrange: two-values tuple
New Y-axis range.
"""
@@ -399,7 +410,7 @@ else:
:Args:
- pts : list of two-values tuples
+ pts: list of two-values tuples
New normalized (between 0 and 1) initial points.
"""
@@ -411,7 +422,7 @@ else:
:Args:
- x : int
+ x: int
New mode. Possible modes are:
0. linear (default)
1. cosine
@@ -430,7 +441,7 @@ else:
:Args:
- x : float
+ x: float
New exponent factor.
"""
@@ -443,7 +454,7 @@ else:
:Args:
- x : boolean
+ x: boolean
New inverse factor.
"""
@@ -456,7 +467,7 @@ else:
:Args:
- x : float
+ x: float
New tension factor.
"""
@@ -469,7 +480,7 @@ else:
:Args:
- x : float
+ x: float
New bias factor.
"""
@@ -481,32 +492,32 @@ else:
Data multi-sliders editor.
:Parent: wx.Panel
-
+
:Events:
-
+
EVT_PYO_GUI_MULTI_SLIDER
- Sent after any change of the multi-sliders values. The current
- list of values of the multi-sliders can be retrieve with the
+ Sent after any change of the multi-sliders values. The current
+ list of values of the multi-sliders can be retrieve with the
`value` attribute of the generated event.
:Args:
- parent : wx.Window
+ parent: wx.Window
The parent window.
- xlen : int, optional
+ xlen: int, optional
The number of sliders in the multi-sliders. Defaults to 16.
- yrange : two-values tuple
+ yrange: two-values tuple
A tuple indicating the minimum and maximum values of the Y-axis.
Defaults to (0, 1).
- init : list values, optional
- The initial list of values of the multi-sliders.
- Defaults to None, meaning all sliders initialized to the
+ init: list values, optional
+ The initial list of values of the multi-sliders.
+ Defaults to None, meaning all sliders initialized to the
minimum value.
- pos : wx.Point, optional
+ pos: wx.Point, optional
Window position in pixels. Defaults to (0, 0).
- size : wx.Size, optional
+ size: wx.Size, optional
Window size in pixels. Defaults to (300, 200).
- style : int, optional
+ style: int, optional
Window style (see wx.Window documentation). Defaults to 0.
"""
@@ -519,25 +530,25 @@ else:
init += [yrange[0]] * (xlen - len(init))
elif len(init) > xlen:
init = init[:xlen]
- super(PyoGuiMultiSlider, self).__init__(parent, init, yrange,
+ super(PyoGuiMultiSlider, self).__init__(parent, init, yrange,
self._outFunction, pos,
size, style)
def _outFunction(self, value):
evt = PyoGuiMultiSliderEvent(value=value)
- wx.PostEvent(self, evt)
+ wx.QueueEvent(self, evt)
def reset(self):
"""
Resets the sliders to their initial state.
-
+
"""
super(PyoGuiMultiSlider, self).reset()
def getValues(self):
"""
Returns the current values of the sliders.
-
+
"""
return [v for v in self.values]
@@ -547,7 +558,7 @@ else:
:Args:
- vals : list of values
+ vals: list of values
New values.
"""
@@ -559,7 +570,7 @@ else:
:Args:
- yrange : two-values tuple
+ yrange: two-values tuple
New Y-axis range.
"""
@@ -570,75 +581,75 @@ else:
"""
Frequency spectrum display.
- This widget should be used with the Spectrum object, which measures
- the magnitude of an input signal versus frequency within a user
- defined range. It can show both magnitude and frequency on linear
+ This widget should be used with the Spectrum object, which 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.
-
+
To create the bridge between the analyzer and the display, the
Spectrum object must be registered in the PyoGuiSpectrum object
- with the setAnalyzer(obj) method. The Spectrum object will
+ with the setAnalyzer(obj) method. The Spectrum object will
automatically call the update(points) method to refresh the display.
:Parent: wx.Panel
:Args:
- parent : wx.Window
+ parent: wx.Window
The parent window.
- lowfreq : int or float, optional
+ lowfreq: int or float, optional
The lowest frequency, in Hz, to display on the X-axis.
Defaults to 0.
- highfreq : int or float, optional
+ highfreq: int or float, optional
The highest frequency, in Hz, to display on the X-axis.
Defaults to 22050.
- fscaling : int, optional
- The frequency scaling on the X-axis. 0 means linear, 1 means
+ fscaling: int, optional
+ The frequency scaling on the X-axis. 0 means linear, 1 means
logarithmic. Defaults to 0.
- mscaling : int, optional
- The magnitude scaling on the Y-axis. 0 means linear, 1 means
+ mscaling: int, optional
+ The magnitude scaling on the Y-axis. 0 means linear, 1 means
logarithmic. Defaults to 0.
- pos : wx.Point, optional
+ pos: wx.Point, optional
Window position in pixels. Defaults to (0, 0).
- size : wx.Size, optional
+ size: wx.Size, optional
Window size in pixels. Defaults to (300, 200).
- style : int, optional
+ style: int, optional
Window style (see wx.Window documentation). Defaults to 0.
"""
- def __init__(self, parent, lowfreq=0, highfreq=22050, fscaling=0,
+ def __init__(self, parent, lowfreq=0, highfreq=22050, fscaling=0,
mscaling=0, pos=(0, 0), size=(300, 200), style=0):
- super(PyoGuiSpectrum, self).__init__(parent, 1, lowfreq, highfreq,
+ super(PyoGuiSpectrum, self).__init__(parent, 1, lowfreq, highfreq,
fscaling, mscaling, pos, size, style)
def update(self, points):
"""
Display updating method.
-
+
This method is automatically called by the audio analyzer
object (Spectrum) with points to draw as arguments. The points
are already formatted for the current drawing surface to save
CPU cycles.
-
+
The method setAnalyzer(obj) must be used to register the audio
analyzer object.
-
+
:Args:
-
- points : list of list of tuples
+
+ points: list of list of tuples
A list containing n-channels list of tuples. A tuple
is a point (X-Y coordinates) to draw.
"""
wx.CallAfter(self.setImage, points)
-
+
def setAnalyzer(self, object):
"""
Register an audio analyzer object (Spectrum).
:Args:
-
- object : Spectrum object
+
+ object: Spectrum object
The audio object performing the frequency analysis.
"""
@@ -656,8 +667,8 @@ else:
This method propagates the value to the audio analyzer.
:Args:
-
- x : int or float
+
+ x: int or float
New lowest frequency.
"""
@@ -672,8 +683,8 @@ else:
This method propagates the value to the audio analyzer.
:Args:
-
- x : int or float
+
+ x: int or float
New highest frequency.
"""
@@ -688,8 +699,8 @@ else:
This method propagates the value to the audio analyzer.
:Args:
-
- x : int
+
+ x: int
0 means linear scaling, 1 means logarithmic scaling.
"""
@@ -704,8 +715,8 @@ else:
This method propagates the value to the audio analyzer.
:Args:
-
- x : int
+
+ x: int
0 means linear scaling, 1 means logarithmic scaling.
"""
@@ -718,34 +729,34 @@ else:
Oscilloscope display.
This widget should be used with the Scope object, which computes
- the waveform of an input signal to display on a GUI.
-
+ the waveform of an input signal to display on a GUI.
+
To create the bridge between the analyzer and the display, the
- Scope object must be registered in the PyoGuiScope object with
- the setAnalyzer(obj) method. The Scope object will automatically
+ Scope object must be registered in the PyoGuiScope object with
+ the setAnalyzer(obj) method. The Scope object will automatically
call the update(points) method to refresh the display.
:Parent: wx.Panel
:Args:
- parent : wx.Window
+ parent: wx.Window
The parent window.
- length : float, optional
+ length: float, optional
Length, in seconds, of the waveform segment displayed on
the window. Defaults to 0.05.
- gain : float, optional
+ gain: float, optional
Linear gain applied to the signal to be displayed.
Defaults to 0.67.
- pos : wx.Point, optional
+ pos: wx.Point, optional
Window position in pixels. Defaults to (0, 0).
- size : wx.Size, optional
+ size: wx.Size, optional
Window size in pixels. Defaults to (300, 200).
- style : int, optional
+ style: int, optional
Window style (see wx.Window documentation). Defaults to 0.
"""
- def __init__(self, parent, length=0.05, gain=0.67, pos=(0, 0),
+ def __init__(self, parent, length=0.05, gain=0.67, pos=(0, 0),
size=(300, 200), style=0):
super(PyoGuiScope, self).__init__(parent, None, pos, size, style)
super(PyoGuiScope, self).setLength(length)
@@ -754,31 +765,31 @@ else:
def update(self, points):
"""
Display updating method.
-
+
This method is automatically called by the audio analyzer
object (Scope) with points to draw as arguments. The points
are already formatted for the current drawing surface to save
CPU cycles.
-
+
The method setAnalyzer(obj) must be used to register the audio
analyzer object.
-
+
:Args:
-
- points : list of list of tuples
+
+ points: list of list of tuples
A list containing n-channels list of tuples. A tuple
is a point (X-Y coordinates) to draw.
"""
wx.CallAfter(self.setImage, points)
-
+
def setAnalyzer(self, object):
"""
Register an audio analyzer object (Scope).
:Args:
-
- object : Scope object
+
+ object: Scope object
The audio object performing the waveform analysis.
"""
@@ -794,8 +805,8 @@ else:
This method propagates the value to the audio analyzer.
:Args:
-
- x : float
+
+ x: float
New segment length in seconds.
"""
@@ -810,8 +821,8 @@ else:
This method propagates the value to the audio analyzer.
:Args:
-
- x : float
+
+ x: float
New linear gain.
"""
@@ -828,44 +839,44 @@ else:
Soundfile display.
This widget should be used with the SndTable object, which keeps
- soundfile in memory and computes the waveform to display on the GUI.
-
+ soundfile in memory and computes the waveform to display on the GUI.
+
To create the bridge between the audio memory and the display, the
- SndTable object must be registered in the PyoGuiSndView object with
- the setTable(object) method.
-
- The SndTable object will automatically call the update() method to
+ SndTable object must be registered in the PyoGuiSndView object with
+ the setTable(object) method.
+
+ The SndTable object will automatically call the update() method to
refresh the display when the table is modified.
:Parent: wx.Panel
:Events:
-
+
EVT_PYO_GUI_SNDVIEW_MOUSE_POSITION
Sent when the mouse is moving on the panel with the left
button pressed. The `value` attribute of the event will
hold the normalized position of the mouse into the sound.
For X-axis value, 0.0 is the beginning of the sound and 1.0
- is the end of the sound. For the Y-axis, 0.0 is the bottom
+ is the end of the sound. For the Y-axis, 0.0 is the bottom
of the panel and 1.0 is the top.
EVT_PYO_GUI_SNDVIEW_SELECTION
- Sent when a new region is selected on the panel. A new
- selection is created with a Right-click and drag on the panel.
- The current selection can be moved with Shift+Right-click and
+ Sent when a new region is selected on the panel. A new
+ selection is created with a Right-click and drag on the panel.
+ The current selection can be moved with Shift+Right-click and
drag. Ctrl+Right-click (Cmd on OSX) remove the selected region.
- The `value` attribute of the event will hold the normalized
- selection as a tuple (min, max). 0.0 means the beginning of
+ The `value` attribute of the event will hold the normalized
+ selection as a tuple (min, max). 0.0 means the beginning of
the sound and 1.0 means the end of the sound.
:Args:
- parent : wx.Window
+ parent: wx.Window
The parent window.
- pos : wx.Point, optional
+ pos: wx.Point, optional
Window position in pixels. Defaults to (0, 0).
- size : wx.Size, optional
+ size: wx.Size, optional
Window size in pixels. Defaults to (300, 200).
- style : int, optional
+ style: int, optional
Window style (see wx.Window documentation). Defaults to 0.
"""
@@ -873,11 +884,11 @@ else:
wx.Panel.__init__(self, parent, pos=pos, size=size, style=style)
box = wx.BoxSizer(wx.VERTICAL)
self._curzoom = (0.0, 1.0)
- self.sndview = SndViewTablePanel(self, None,
- self._position_callback,
+ self.sndview = SndViewTablePanel(self, None,
+ self._position_callback,
self._select_callback)
box.Add(self.sndview, 1, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5)
- self.zoom = HRangeSlider(self, minvalue=0, maxvalue=1,
+ self.zoom = HRangeSlider(self, minvalue=0, maxvalue=1,
valtype='float', function=self._setZoom,
backColour=parent.GetBackgroundColour())
box.Add(self.zoom, 0, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
@@ -894,38 +905,37 @@ else:
def _position_callback(self, pos):
evt = PyoGuiSndViewMousePositionEvent(value=pos)
- wx.PostEvent(self, evt)
+ wx.QueueEvent(self, evt)
def _select_callback(self, selection):
selection = (max(0.0, min(selection)), min(max(selection), 1.0))
evt = PyoGuiSndViewSelectionEvent(value=selection)
- wx.PostEvent(self, evt)
+ wx.QueueEvent(self, evt)
def __del__(self):
if self.sndview.obj is not None:
self.sndview.obj._setViewFrame(None)
- self.Destroy()
def update(self):
"""
Display updating method.
-
+
This method is automatically called by the audio memory
object (SndTable) when the table is modified.
-
+
The method setTable(obj) must be used to register the audio
memory object.
"""
wx.CallAfter(self.sndview.setImage)
-
+
def setTable(self, object):
"""
Register an audio memory object (SndTable).
:Args:
-
- object : SndTable object
+
+ object: SndTable object
The audio table keeping the sound in memory.
"""
@@ -944,25 +954,25 @@ else:
with a tuple (start, stop) as value.
:Args:
-
- start : float
+
+ start: float
The starting point of the selected region. This value
must be normalized between 0 and 1 (0 is the beginning
of the sound, 1 is the end).
- stop : float
+ stop: float
The ending point of the selected region. This value
must be normalized between 0 and 1 (0 is the beginning
of the sound, 1 is the end).
"""
self.sndview.setSelection(start, stop)
-
+
def resetSelection(self):
"""
Removes the selected region.
-
+
This method will trigger a EVT_PYO_GUI_SNDVIEW_SELECTION event
with a tuple (0.0, 1.0) as value.
"""
- self.sndview.resetSelection()
\ No newline at end of file
+ self.sndview.resetSelection()
diff --git a/scripts/compile_win.bat b/scripts/compile_win.bat
index 39bde38..a8e0ae6 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
+
+echo *** Compile for python3.5-32 ***
+C:\Users\olivier\AppData\Local\Programs\Python\Python35-32\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 *** Build E-Pyo for python3.5-32 ***
+C:\Users\olivier\AppData\Local\Programs\Python\Python35-32\python.exe epyo_builder_win32.py
diff --git a/scripts/get_dependencies.sh b/scripts/get_dependencies.sh
deleted file mode 100644
index beea096..0000000
--- a/scripts/get_dependencies.sh
+++ /dev/null
@@ -1,46 +0,0 @@
-if cd /usr/local/include;
-then
- pwd;
-else
- sudo mkdir /usr/local/include
- cd /usr/local/include;
-fi
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/portaudio.h -o "portaudio.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/portmidi.h -o "portmidi.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/porttime.h -o "porttime.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/sndfile.h -o "sndfile.h"
-
-
-if cd lo;
-then
- pwd;
-else
- sudo mkdir lo
- cd lo;
-fi
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/lo/lo_endian.h -o "lo_endian.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/lo/lo_errors.h -o "lo_errors.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/lo/lo_lowlevel.h -o "lo_lowlevel.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/lo/lo_macros.h -o "lo_macros.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/lo/lo_osc_types.h -o "lo_osc_types.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/lo/lo_throw.h -o "lo_throw.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/lo/lo_types.h -o "lo_types.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers/lo/lo.h -o "lo.h"
-
-if cd /usr/local/lib;
-then
- pwd;
-else
- sudo mkdir /usr/local/lib
- cd /usr/local/lib;
-fi
-sudo curl http://www.iact.umontreal.ca/pyo_deps/liblo.0.dylib -o "liblo.0.dylib"
-sudo curl http://www.iact.umontreal.ca/pyo_deps/libportaudio.2.dylib -o "libportaudio.2.dylib"
-sudo curl http://www.iact.umontreal.ca/pyo_deps/libportmidi.dylib -o "libportmidi.dylib"
-sudo curl http://www.iact.umontreal.ca/pyo_deps/libsndfile.1.dylib -o "libsndfile.1.dylib"
-sudo rm libsndfile.dylib
-sudo ln -s libsndfile.1.dylib libsndfile.dylib
-sudo rm liblo.dylib
-sudo ln -s liblo.0.dylib liblo.dylib
-sudo rm libportaudio.dylib
-sudo ln -s libportaudio.2.dylib libportaudio.dylib
diff --git a/scripts/get_dependencies_x86_64.sh b/scripts/get_dependencies_x86_64.sh
deleted file mode 100644
index 81626d0..0000000
--- a/scripts/get_dependencies_x86_64.sh
+++ /dev/null
@@ -1,46 +0,0 @@
-if cd /usr/local/include;
-then
- pwd;
-else
- sudo mkdir /usr/local/include
- cd /usr/local/include;
-fi
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/portaudio.h -o "portaudio.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/portmidi.h -o "portmidi.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/porttime.h -o "porttime.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/sndfile.h -o "sndfile.h"
-
-
-if cd lo;
-then
- pwd;
-else
- sudo mkdir lo
- cd lo;
-fi
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/lo/lo_endian.h -o "lo_endian.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/lo/lo_errors.h -o "lo_errors.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/lo/lo_lowlevel.h -o "lo_lowlevel.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/lo/lo_macros.h -o "lo_macros.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/lo/lo_osc_types.h -o "lo_osc_types.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/lo/lo_throw.h -o "lo_throw.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/lo/lo_types.h -o "lo_types.h"
-sudo curl http://www.iact.umontreal.ca/pyo_dep_headers_x86_64/lo/lo.h -o "lo.h"
-
-if cd /usr/local/lib;
-then
- pwd;
-else
- sudo mkdir /usr/local/lib
- cd /usr/local/lib;
-fi
-sudo curl http://www.iact.umontreal.ca/pyo_deps_x86_64/liblo.7.dylib -o "liblo.7.dylib"
-sudo curl http://www.iact.umontreal.ca/pyo_deps_x86_64/libportaudio.2.dylib -o "libportaudio.2.dylib"
-sudo curl http://www.iact.umontreal.ca/pyo_deps_x86_64/libportmidi.dylib -o "libportmidi.dylib"
-sudo curl http://www.iact.umontreal.ca/pyo_deps_x86_64/libsndfile.1.dylib -o "libsndfile.1.dylib"
-sudo rm libsndfile.dylib
-sudo ln -s libsndfile.1.dylib libsndfile.dylib
-sudo rm liblo.dylib
-sudo ln -s liblo.7.dylib liblo.dylib
-sudo rm libportaudio.dylib
-sudo ln -s libportaudio.2.dylib libportaudio.dylib
diff --git a/scripts/html_man.py b/scripts/html_man.py
index ba0c575..08e8baf 100644
--- a/scripts/html_man.py
+++ b/scripts/html_man.py
@@ -18,7 +18,6 @@ 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
from pyo import *
#######################################################
@@ -212,7 +211,7 @@ creation of sophisticated signal processing chains with all the benefits of a ma
for key in ['Server', 'Stream', 'TableStream', 'PyoObjectBase', 'Map', 'functions']:
f.write('\chapter[%s</A> : %s]{%s}\n\n' % (key, getDocFirstLine(key), key))
f.write(getDoc(key))
- if type(OBJECTS_TREE[key]) == ListType:
+ if type(OBJECTS_TREE[key]) == list:
for obj in OBJECTS_TREE[key]:
f.write('\section[%s</A> : %s]{%s}\n\n' % (obj, getDocFirstLine(obj), obj))
f.write(getDoc(obj))
@@ -222,7 +221,7 @@ for key in ['Server', 'Stream', 'TableStream', 'PyoObjectBase', 'Map', 'function
for key2 in key2list:
f.write('\section[%s</A> : %s]{%s}\n\n' % (key2, getDocFirstLine(key2), key2))
f.write(getDoc(key2))
- if type(OBJECTS_TREE[key][key2]) == ListType:
+ if type(OBJECTS_TREE[key][key2]) == list:
for obj in OBJECTS_TREE[key][key2]:
f.write('\subsection[%s</A> : %s]{%s}\n\n' % (obj, getDocFirstLine(obj), obj))
f.write(getDoc(obj))
diff --git a/scripts/release_doc_src.sh b/scripts/release_doc_src.sh
index 964ec49..103c3bd 100755
--- 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.7.9
+version=0.8.1
replace=XXX
doc_rep=pyo_XXX-doc
diff --git a/scripts/win/windows-7-build-routine.txt b/scripts/win/windows-7-build-routine.txt
index 84e74ec..241a9c1 100644
--- a/scripts/win/windows-7-build-routine.txt
+++ b/scripts/win/windows-7-build-routine.txt
@@ -85,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. (nothing to do here)
+the DirectSound, WMME, WDMKS and ASIO drivers. (nothing to do here)
--- Need to removed "volatile" from function definitions in MinGW/include/winbase.h
@@ -117,6 +117,7 @@ commonEnvironment.Append(CPPFLAGS = Split('''
-DPA_USE_DS
-DPA_USE_ASIO
-DPA_USE_WASAPI
+-DPA_USE_WDMKS
'''))
commonEnvironment.Append(CPPPATH = [".", "src/common", "src/hostapi", "src/os", "src/os/win", "include",
@@ -159,6 +160,7 @@ src/hostapi/dsound/pa_win_ds.c
src/hostapi/dsound/pa_win_ds_dynlink.c
src/hostapi/wmme/pa_win_wmme.c
src/hostapi/skeleton/pa_hostapi_skeleton.c
+src/hostapi/wdmks/pa_win_wdmks.c
src/os/win/pa_win_hostapis.c
src/os/win/pa_win_util.c
src/os/win/pa_win_waveformat.c
@@ -264,6 +266,6 @@ Depends(test, portmidi)
compiler = mingw32
=== STEP 13 ===
---- Download pyo sources from svn and build it with:
+--- Download pyo sources from git and build it with:
python setup.py install
diff --git a/setup.py b/setup.py
index f9456f2..664cb53 100644
--- a/setup.py
+++ b/setup.py
@@ -18,40 +18,31 @@ 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 distutils.sysconfig import get_python_lib
from distutils.core import setup, Extension
-import os, sys, getopt
-import time
+import os, sys, py_compile
-pyo_version = "0.7.9"
-build_osx_with_jack_support = False
+pyo_version = "0.8.1"
+build_with_jack_support = False
compile_externals = False
macros = []
extension_names = ['_pyo']
main_modules = ['pyo']
extra_macros_per_extension = [[]]
+
+if '--use-double' in sys.argv:
+ sys.argv.remove('--use-double')
+ if not '--only-double' in sys.argv:
+ extension_names.append('_pyo64')
+ main_modules.append('pyo64')
+ extra_macros_per_extension.append([('USE_DOUBLE',None)])
+
if '--only-double' in sys.argv:
sys.argv.remove('--only-double')
extension_names = ['_pyo64']
main_modules = ['pyo64']
extra_macros_per_extension = [[('USE_DOUBLE',None)]]
-
-if '--use-double' in sys.argv and not '--only-double' in sys.argv:
- sys.argv.remove('--use-double')
- extension_names.append('_pyo64')
- main_modules.append('pyo64')
- extra_macros_per_extension.append([('USE_DOUBLE',None)])
-
-if '--use-jack' in sys.argv:
- sys.argv.remove('--use-jack')
- if sys.platform == "darwin":
- build_osx_with_jack_support = True
- macros.append(('USE_JACK',None))
-
-if '--use-coreaudio' in sys.argv:
- sys.argv.remove('--use-coreaudio')
- macros.append(('USE_COREAUDIO',None))
if '--no-messages' in sys.argv:
sys.argv.remove('--no-messages')
@@ -62,70 +53,131 @@ if '--compile-externals' in sys.argv:
sys.argv.remove('--compile-externals')
macros.append(('COMPILE_EXTERNALS',None))
+if '--debug' in sys.argv:
+ sys.argv.remove('--debug')
+ gflag = "-g3"
+else:
+ gflag = "-g0"
+
+if '--fast-compile' in sys.argv:
+ sys.argv.remove('--fast-compile')
+ oflag = "-O0"
+else:
+ oflag = "-O3"
+
+# Specific audio drivers source files to compile
+ad_files = []
+obj_files = []
+
+# Special flag to build without portaudio, portmidi and liblo deps.
+if '--minimal' in sys.argv:
+ minimal_build = True
+ sys.argv.remove('--minimal')
+ libraries = []
+else:
+ minimal_build = False
+ # portaudio
+ macros.append(('USE_PORTAUDIO', None))
+ ad_files.append("ad_portaudio.c")
+ libraries = ["portaudio"]
+ # portmidi
+ macros.append(('USE_PORTMIDI', None))
+ ad_files.append("md_portmidi.c")
+ ad_files.append("midilistenermodule.c")
+ libraries += ["portmidi"]
+ # liblo
+ macros.append(('USE_OSC', None))
+ ad_files.append("osclistenermodule.c")
+ obj_files.append("oscmodule.c")
+ libraries += ["lo"]
+
+# Optional Audio / Midi drivers
+if '--use-jack' in sys.argv:
+ sys.argv.remove('--use-jack')
+ build_with_jack_support = True
+ macros.append(('USE_JACK',None))
+ ad_files.append("ad_jack.c")
+
+if '--use-coreaudio' in sys.argv:
+ sys.argv.remove('--use-coreaudio')
+ macros.append(('USE_COREAUDIO',None))
+ ad_files.append("ad_coreaudio.c")
+
if sys.platform == "darwin":
macros.append(('_OSX_', None))
-path = 'src/engine/'
-files = ['pyomodule.c', 'listenermodule.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 = ['exprmodule.c', 'utilsmodule.c', 'granulatormodule.c', 'tablemodule.c', 'wgverbmodule.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',
- 'metromodule.c', 'trigmodule.c', 'patternmodule.c', 'bandsplitmodule.c', 'hilbertmodule.c', 'panmodule.c',
- 'selectmodule.c', 'compressmodule.c', 'freeverbmodule.c', 'phasevocmodule.c', 'fftmodule.c',
- 'convolvemodule.c', 'arithmeticmodule.c', 'sigmodule.c',
- 'matrixprocessmodule.c', 'harmonizermodule.c', 'chorusmodule.c']
+path = 'src/engine'
+files = ['pyomodule.c', 'streammodule.c', 'servermodule.c', 'pvstreammodule.c',
+ 'dummymodule.c', 'mixmodule.c', 'inputfadermodule.c', 'interpolation.c',
+ 'fft.c', "wind.c"] + ad_files
+source_files = [os.path.join(path, f) for f in files]
+
+path = 'src/objects'
+files = ['filtremodule.c', 'arithmeticmodule.c', 'oscilmodule.c',
+ 'randommodule.c', 'analysismodule.c', 'sfplayermodule.c',
+ 'oscbankmodule.c', 'lfomodule.c', 'exprmodule.c', 'utilsmodule.c',
+ 'granulatormodule.c', 'matrixmodule.c', 'noisemodule.c', 'distomodule.c',
+ 'tablemodule.c', 'wgverbmodule.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', 'freeverbmodule.c',
+ 'phasevocmodule.c', 'fftmodule.c', 'convolvemodule.c', 'sigmodule.c',
+ 'matrixprocessmodule.c', 'harmonizermodule.c', 'chorusmodule.c'] + obj_files
if compile_externals:
- source_files = source_files + ["externals/externalmodule.c"] + [path + f for f in files]
+ source_files = source_files + \
+ ["externals/externalmodule.c"] + \
+ [os.path.join(path, f) for f in files]
else:
- source_files = source_files + [path + f for f in files]
+ source_files = source_files + [os.path.join(path, f) for f in files]
# Platform-specific build settings for the pyo extension(s).
if sys.platform == "win32":
- 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 (x86)/Mega-Nerd/libsndfile/bin', 'C:\portmidi', 'C:\liblo', 'C:\pthreads\lib']
- libraries = ['portaudio', 'portmidi', 'porttime', 'libsndfile-1', 'lo', 'pthreadVC2']
+ include_dirs = ['C:\portaudio\include', 'C:\portmidi\pm_common', 'include',
+ 'C:\Program Files (x86)\Mega-Nerd\libsndfile\include',
+ 'C:\liblo', 'C:\pthreads\include', 'C:\portmidi\porttime']
+ library_dirs = ['C:\portaudio', 'C:\portmidi', 'C:\liblo', 'C:\pthreads\lib',
+ 'C:/Program Files (x86)/Mega-Nerd/libsndfile/bin']
+ libraries += ['libsndfile-1', 'pthreadVC2']
+ if 'portmidi' in libraries:
+ libraries.append('porttime')
else:
- tsrt = time.strftime('"%d %b %Y %H:%M:%S"', time.localtime())
- macros.append(('TIMESTAMP', tsrt))
include_dirs = ['include', '/usr/local/include']
if sys.platform == "darwin":
include_dirs.append('/opt/local/include')
library_dirs = []
- libraries = ['portaudio', 'portmidi', 'sndfile', 'lo']
- if build_osx_with_jack_support:
+ libraries += ['sndfile']
+ if build_with_jack_support:
libraries.append('jack')
+libraries += ['m']
+extra_compile_args = ['-Wno-strict-prototypes', '-Wno-strict-aliasing', oflag, gflag]
+
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', '-Wno-strict-aliasing'],
+ extensions.append(Extension(extension_name, source_files, libraries=libraries,
+ library_dirs=library_dirs, include_dirs=include_dirs,
+ extra_compile_args=extra_compile_args,
define_macros=macros + extra_macros))
if compile_externals:
include_dirs.append('externals')
os.system('cp externals/external.py pyolib')
+soundfiles = [f for f in os.listdir('pyolib/snds') if f[-3:] in ['aif', 'wav']]
+ldesc = "Python module written in C to help digital signal processing script creation."
setup( name = "pyo",
author = "Olivier Belanger",
author_email = "belangeo at gmail.com",
version = pyo_version,
description = "Python dsp module.",
- long_description = "pyo is a Python module written in C to help digital signal processing script creation.",
+ long_description = ldesc,
url = "https://github.com/belangeo/pyo",
license = "LGPLv3+",
packages = ['pyolib', 'pyolib.snds'],
py_modules = main_modules,
- package_data = {'pyolib.snds': [f for f in os.listdir('pyolib/snds') if f.endswith('aif') or f.endswith('wav')]},
- ext_modules = extensions )
+ package_data = {'pyolib.snds': soundfiles},
+ ext_modules = extensions)
if compile_externals:
os.system('rm pyolib/external.py')
diff --git a/src/engine/dummymodule.c b/src/engine/dummymodule.c
index 1aeaa31..c10158a 100644
--- a/src/engine/dummymodule.c
+++ b/src/engine/dummymodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -107,7 +108,7 @@ Dummy_dealloc(Dummy* self)
{
pyo_DEALLOC
Dummy_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
PyObject *
@@ -198,7 +199,7 @@ static PyNumberMethods Dummy_as_number = {
(binaryfunc)Dummy_add, /*nb_add*/
(binaryfunc)Dummy_sub, /*nb_subtract*/
(binaryfunc)Dummy_multiply, /*nb_multiply*/
- (binaryfunc)Dummy_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -212,16 +213,16 @@ static PyNumberMethods Dummy_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Dummy_inplace_add, /*inplace_add*/
(binaryfunc)Dummy_inplace_sub, /*inplace_subtract*/
(binaryfunc)Dummy_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Dummy_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -230,15 +231,14 @@ static PyNumberMethods Dummy_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Dummy_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Dummy_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject DummyType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Dummy_base", /*tp_name*/
sizeof(Dummy), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -246,7 +246,7 @@ PyTypeObject DummyType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Dummy_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -368,7 +368,7 @@ TriggerDummy_dealloc(TriggerDummy* self)
{
pyo_DEALLOC
TriggerDummy_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -442,7 +442,7 @@ static PyNumberMethods TriggerDummy_as_number = {
(binaryfunc)TriggerDummy_add, /*nb_add*/
(binaryfunc)TriggerDummy_sub, /*nb_subtract*/
(binaryfunc)TriggerDummy_multiply, /*nb_multiply*/
- (binaryfunc)TriggerDummy_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -456,16 +456,16 @@ static PyNumberMethods TriggerDummy_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TriggerDummy_inplace_add, /*inplace_add*/
(binaryfunc)TriggerDummy_inplace_sub, /*inplace_subtract*/
(binaryfunc)TriggerDummy_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)TriggerDummy_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -474,15 +474,14 @@ static PyNumberMethods TriggerDummy_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TriggerDummy_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TriggerDummy_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TriggerDummyType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TriggerDummy_base", /*tp_name*/
sizeof(TriggerDummy), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -490,7 +489,7 @@ PyTypeObject TriggerDummyType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TriggerDummy_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/engine/inputfadermodule.c b/src/engine/inputfadermodule.c
index 7a59fab..1ee5d4d 100644
--- a/src/engine/inputfadermodule.c
+++ b/src/engine/inputfadermodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -140,7 +141,7 @@ InputFader_dealloc(InputFader* self)
{
pyo_DEALLOC
InputFader_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -251,8 +252,7 @@ static PyMethodDef InputFader_methods[] = {
};
PyTypeObject InputFaderType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.InputFader_base", /*tp_name*/
sizeof(InputFader), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -260,7 +260,7 @@ PyTypeObject InputFaderType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/engine/listenermodule.c b/src/engine/listenermodule.c
deleted file mode 100644
index 18e86ab..0000000
--- a/src/engine/listenermodule.c
+++ /dev/null
@@ -1,480 +0,0 @@
-/**************************************************************************
- * 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"
-#include <math.h>
-#include "pyomodule.h"
-#include "portmidi.h"
-#include "porttime.h"
-#include "lo/lo.h"
-
-static void error(int num, const char *msg, const char *path)
-{
- printf("liblo server error %d in path %s: %s\n", num, path, msg);
-}
-
-typedef struct {
- PyObject_HEAD
- PyObject *osccallable;
- lo_server osc_server;
- int oscport;
-} OscListener;
-
-static PyObject *
-OscListener_get(OscListener *self)
-{
- while (lo_server_recv_noblock(self->osc_server, 0) != 0) {};
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-int process_osc(const char *path, const char *types, lo_arg **argv, int argc,
- void *data, void *user_data)
-{
- OscListener *server = (OscListener *)user_data;
- PyObject *tup;
- lo_blob *blob = NULL;
- char *blobdata = NULL;
- uint32_t blobsize = 0;
- PyObject *charlist = NULL;
- tup = PyTuple_New(argc+1);
- int i, j = 0;
-
- PyGILState_STATE s = PyGILState_Ensure();
- PyTuple_SET_ITEM(tup, 0, PyString_FromString(path));
- for (i=0; i<argc; i++) {
- switch (types[i]) {
- case LO_INT32:
- PyTuple_SET_ITEM(tup, i+1, PyInt_FromLong(argv[i]->i));
- break;
- case LO_INT64:
- PyTuple_SET_ITEM(tup, i+1, PyLong_FromLong(argv[i]->h));
- break;
- case LO_FLOAT:
- PyTuple_SET_ITEM(tup, i+1, PyFloat_FromDouble(argv[i]->f));
- break;
- case LO_DOUBLE:
- PyTuple_SET_ITEM(tup, i+1, PyFloat_FromDouble(argv[i]->d));
- break;
- case LO_STRING:
- 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;
- }
- }
- PyObject_Call((PyObject *)server->osccallable, tup, NULL);
- PyGILState_Release(s);
- Py_XDECREF(tup);
-
- return 0;
-}
-
-static int
-OscListener_traverse(OscListener *self, visitproc visit, void *arg)
-{
- Py_VISIT(self->osccallable);
- return 0;
-}
-
-static int
-OscListener_clear(OscListener *self)
-{
- Py_CLEAR(self->osccallable);
- return 0;
-}
-
-static void
-OscListener_dealloc(OscListener* self)
-{
- lo_server_free(self->osc_server);
- OscListener_clear(self);
- self->ob_type->tp_free((PyObject*)self);
-}
-
-static PyObject *
-OscListener_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- char buf[20];
- PyObject *osccalltmp=NULL;
- OscListener *self;
-
- self = (OscListener *)type->tp_alloc(type, 0);
-
- static char *kwlist[] = {"osccallable", "port", NULL};
-
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi", kwlist, &osccalltmp, &self->oscport))
- Py_RETURN_NONE;
-
- if (osccalltmp) {
- PyObject_CallMethod((PyObject *)self, "setOscFunction", "O", osccalltmp);
- }
-
- sprintf(buf, "%i", self->oscport);
- self->osc_server = lo_server_new(buf, error);
- lo_server_add_method(self->osc_server, NULL, NULL, process_osc, (void *)self);
-
- return (PyObject *)self;
-}
-
-static PyObject *
-OscListener_setOscFunction(OscListener *self, PyObject *arg)
-{
- PyObject *tmp;
-
- if (arg == Py_None) {
- Py_INCREF(Py_None);
- return Py_None;
- }
-
- 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->osccallable);
- Py_INCREF(tmp);
- self->osccallable = tmp;
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyMemberDef OscListener_members[] = {
- {NULL} /* Sentinel */
-};
-
-static PyMethodDef OscListener_methods[] = {
- {"get", (PyCFunction)OscListener_get, METH_NOARGS, "Check for new osc messages."},
- {"setOscFunction", (PyCFunction)OscListener_setOscFunction, METH_O, "Sets the function to be called."},
- {NULL} /* Sentinel */
-};
-
-PyTypeObject OscListenerType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.OscListener_base", /*tp_name*/
- sizeof(OscListener), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)OscListener_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*/
- "OscListener objects. Calls a function with OSC data as arguments.", /* tp_doc */
- (traverseproc)OscListener_traverse, /* tp_traverse */
- (inquiry)OscListener_clear, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- OscListener_methods, /* tp_methods */
- OscListener_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 */
- OscListener_new, /* tp_new */
-};
-
-typedef struct {
- PyObject_HEAD
- PyObject *midicallable;
- PmStream *midiin[64];
- int mididev;
- int midicount;
- int active;
-} MidiListener;
-
-void process_midi(PtTimestamp timestamp, void *userData)
-{
- PmError result;
- PmEvent buffer; /* just one message at a time */
- int i, status, data1, data2;
- PyObject *tup = NULL;
- MidiListener *server = (MidiListener *)userData;
-
- if (server->active == 0) return;
-
- PyGILState_STATE s = PyGILState_Ensure();
- do {
- for (i=0; i<server->midicount; i++) {
- result = Pm_Poll(server->midiin[i]);
- if (result) {
- if (Pm_Read(server->midiin[i], &buffer, 1) == pmBufferOverflow)
- continue;
- status = Pm_MessageStatus(buffer.message);
- data1 = Pm_MessageData1(buffer.message);
- data2 = Pm_MessageData2(buffer.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 *)server->midicallable, tup, NULL);
- }
- }
- } while (result);
-
- PyGILState_Release(s);
- Py_XDECREF(tup);
-}
-
-static int
-MidiListener_traverse(MidiListener *self, visitproc visit, void *arg)
-{
- Py_VISIT(self->midicallable);
- return 0;
-}
-
-static int
-MidiListener_clear(MidiListener *self)
-{
- Py_CLEAR(self->midicallable);
- return 0;
-}
-
-static void
-MidiListener_dealloc(MidiListener* self)
-{
- if (self->active == 1)
- PyObject_CallMethod((PyObject *)self, "stop", NULL);
- MidiListener_clear(self);
- self->ob_type->tp_free((PyObject*)self);
-}
-
-static PyObject *
-MidiListener_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- PyObject *midicalltmp=NULL;
- MidiListener *self;
-
- self = (MidiListener *)type->tp_alloc(type, 0);
-
- self->active = self->midicount = 0;
- self->mididev = -1;
-
- static char *kwlist[] = {"midicallable", "mididevice", NULL};
-
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "Oi", kwlist, &midicalltmp, &self->mididev))
- Py_RETURN_NONE;
-
- if (midicalltmp) {
- PyObject_CallMethod((PyObject *)self, "setMidiFunction", "O", midicalltmp);
- }
-
- return (PyObject *)self;
-}
-
-static PyObject * MidiListener_play(MidiListener *self) {
- int i, num_devices;
- PmError pmerr;
-
- /* always start the timer before you start midi */
- Pt_Start(1, &process_midi, (void *)self);
-
- pmerr = Pm_Initialize();
- if (pmerr) {
- printf("Portmidi warning: could not initialize Portmidi: %s\n", Pm_GetErrorText(pmerr));
- }
-
- num_devices = Pm_CountDevices();
- if (num_devices > 0) {
- if (self->mididev < num_devices) {
- if (self->mididev == -1)
- self->mididev = Pm_GetDefaultInputDeviceID();
- const PmDeviceInfo *info = Pm_GetDeviceInfo(self->mididev);
- if (info != NULL) {
- if (info->input) {
- pmerr = Pm_OpenInput(&self->midiin[0], self->mididev, NULL, 100, NULL, NULL);
- if (pmerr) {
- printf("Portmidi warning: could not open midi input %d (%s): %s\n",
- self->mididev, info->name, Pm_GetErrorText(pmerr));
- }
- else {
- self->midicount = 1;
- }
- }
- }
- }
- else if (self->mididev >= num_devices) {
- self->midicount = 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->midicount], i, NULL, 100, NULL, NULL);
- if (pmerr) {
- printf("Portmidi warning: could not open midi input %d (%s): %s\n",
- i, info->name, Pm_GetErrorText(pmerr));
- }
- else {
- self->midicount++;
- }
- }
- }
- }
- }
- }
-
- for (i=0; i<self->midicount; i++) {
- Pm_SetFilter(self->midiin[i], PM_FILT_ACTIVE | PM_FILT_CLOCK);
- }
-
- if (self->midicount > 0)
- self->active = 1;
-
- Py_INCREF(Py_None);
- return Py_None;
-};
-
-static PyObject * MidiListener_stop(MidiListener *self) {
- int i;
- Pt_Stop();
- for (i=0; i<self->midicount; i++) {
- Pm_Close(self->midiin[i]);
- }
- Pm_Terminate();
- self->active = 0;
- Py_INCREF(Py_None);
- return Py_None;
-};
-
-static PyObject *
-MidiListener_setMidiFunction(MidiListener *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->midicallable);
- Py_INCREF(tmp);
- self->midicallable = tmp;
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyMemberDef MidiListener_members[] = {
- {NULL} /* Sentinel */
-};
-
-static PyMethodDef MidiListener_methods[] = {
- {"play", (PyCFunction)MidiListener_play, METH_NOARGS, "Starts computing without sending sound to soundcard."},
- {"stop", (PyCFunction)MidiListener_stop, METH_NOARGS, "Stops computing."},
- {"setMidiFunction", (PyCFunction)MidiListener_setMidiFunction, METH_O, "Sets the function to be called."},
- {NULL} /* Sentinel */
-};
-
-PyTypeObject MidiListenerType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.MidiListener_base", /*tp_name*/
- sizeof(MidiListener), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)MidiListener_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*/
- "MidiListener objects. Calls a function with midi data as arguments.", /* tp_doc */
- (traverseproc)MidiListener_traverse, /* tp_traverse */
- (inquiry)MidiListener_clear, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- MidiListener_methods, /* tp_methods */
- MidiListener_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 */
- MidiListener_new, /* tp_new */
-};
diff --git a/src/engine/mixmodule.c b/src/engine/mixmodule.c
index 6353431..509f453 100644
--- a/src/engine/mixmodule.c
+++ b/src/engine/mixmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -127,7 +128,7 @@ Mix_dealloc(Mix* self)
{
pyo_DEALLOC
Mix_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -215,7 +216,7 @@ static PyNumberMethods Mix_as_number = {
(binaryfunc)Mix_add, /*nb_add*/
(binaryfunc)Mix_sub, /*nb_subtract*/
(binaryfunc)Mix_multiply, /*nb_multiply*/
- (binaryfunc)Mix_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -229,16 +230,16 @@ static PyNumberMethods Mix_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Mix_inplace_add, /*inplace_add*/
(binaryfunc)Mix_inplace_sub, /*inplace_subtract*/
(binaryfunc)Mix_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Mix_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -247,15 +248,14 @@ static PyNumberMethods Mix_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Mix_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Mix_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject MixType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Mix_base", /*tp_name*/
sizeof(Mix), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -263,7 +263,7 @@ PyTypeObject MixType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Mix_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/engine/pvstreammodule.c b/src/engine/pvstreammodule.c
index 12cded6..e488af3 100644
--- a/src/engine/pvstreammodule.c
+++ b/src/engine/pvstreammodule.c
@@ -34,7 +34,7 @@ PVStream_dealloc(PVStream* self)
{
self->magn = NULL;
self->freq = NULL;
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
int
@@ -98,8 +98,7 @@ PVStream_setCount(PVStream *self, int *data)
}
PyTypeObject PVStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"pyo.PVStream", /*tp_name*/
sizeof(PVStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -107,7 +106,7 @@ PyTypeObject PVStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/engine/pyomodule.c b/src/engine/pyomodule.c
index 82db41b..cdb1f59 100644
--- a/src/engine/pyomodule.c
+++ b/src/engine/pyomodule.c
@@ -20,7 +20,7 @@
#include <Python.h>
#include <math.h>
-#include "portaudio.h"
+#include "py2to3.h"
#include "sndfile.h"
#include "pyomodule.h"
#include "servermodule.h"
@@ -30,21 +30,62 @@
#include "tablemodule.h"
#include "matrixmodule.h"
-/** TODO:
- ** Add an argument to pa_get_* and pm_get_* functions to allow printing to the console
- **/
+#ifdef USE_PORTAUDIO
+#include "ad_portaudio.h"
+PyObject * with_portaudio() { Py_INCREF(Py_True); return Py_True; };
+#else
+#define pa_warning "Pyo built without Portaudio support.\n"
+PyObject * portaudio_get_version() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_get_version_text() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_count_host_apis() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_list_host_apis() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_get_default_host_api() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_count_devices() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_list_devices() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_get_devices_infos() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_get_output_devices() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_get_output_max_channels(PyObject *self, PyObject *arg) { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_get_input_max_channels(PyObject *self, PyObject *arg) { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_get_input_devices() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_get_default_input() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * portaudio_get_default_output() { PySys_WriteStdout(pa_warning); Py_RETURN_NONE; };
+PyObject * with_portaudio() { Py_INCREF(Py_False); return Py_False; };
+#endif
-/****** Portaudio utilities ******/
-static void portaudio_assert(PaError ecode, const char* cmdName) {
- if (ecode != paNoError) {
- const char* eText = Pa_GetErrorText(ecode);
- if (!eText) {
- eText = "???";
- }
- fprintf(stderr, "portaudio error in %s: %s\n", cmdName, eText);
- Pa_Terminate();
- }
-}
+#ifdef USE_PORTMIDI
+#include "md_portmidi.h"
+PyObject * with_portmidi() { Py_INCREF(Py_True); return Py_True; };
+#else
+#define pm_warning "Pyo built without Portmidi sipport.\n"
+PyObject * portmidi_count_devices() { PySys_WriteStdout(pm_warning); Py_RETURN_NONE; };
+PyObject * portmidi_list_devices() { PySys_WriteStdout(pm_warning); Py_RETURN_NONE; };
+PyObject * portmidi_get_input_devices() { PySys_WriteStdout(pm_warning); Py_RETURN_NONE; };
+PyObject * portmidi_get_output_devices() { PySys_WriteStdout(pm_warning); Py_RETURN_NONE; };
+PyObject * portmidi_get_default_input() { PySys_WriteStdout(pm_warning); Py_RETURN_NONE; };
+PyObject * portmidi_get_default_output() { PySys_WriteStdout(pm_warning); Py_RETURN_NONE; };
+PyObject * with_portmidi() { Py_INCREF(Py_False); return Py_False; };
+#endif
+
+#ifdef USE_JACK
+PyObject * with_jack() { Py_INCREF(Py_True); return Py_True; };
+#else
+PyObject * with_jack() { Py_INCREF(Py_False); return Py_False; };
+#endif
+
+#ifdef USE_COREAUDIO
+PyObject * with_coreaudio() { Py_INCREF(Py_True); return Py_True; };
+#else
+PyObject * with_coreaudio() { Py_INCREF(Py_False); return Py_False; };
+#endif
+
+#ifdef USE_OSC
+PyObject * with_osc() { Py_INCREF(Py_True); return Py_True; };
+#else
+PyObject * with_osc() { Py_INCREF(Py_False); return Py_False; };
+#endif
+
+/** Portaudio utility functions __doc__ strings. **/
+/**************************************************/
#define portaudio_count_host_apis_info \
"\nReturns the number of host apis found by Portaudio.\n\n\
@@ -58,117 +99,29 @@ static void portaudio_assert(PaError ecode, const char* cmdName) {
>>> print v\n\
1899\n\n"
-static PyObject *
-portaudio_get_version() {
- return PyInt_FromLong(Pa_GetVersion());
-}
-
#define portaudio_get_version_text_info \
"\nReturns the textual description of the current portaudio installation.\n\n\
>>> desc = pa_get_version_text()\n\
>>> print desc\n\
PortAudio V19-devel (built Oct 8 2012 16:25:16)\n\n"
-static PyObject *
-portaudio_get_version_text() {
- return PyString_FromString(Pa_GetVersionText());
-}
-
-static PyObject *
-portaudio_count_host_apis(){
- PaError err;
- PaHostApiIndex numApis;
-
- err = Pa_Initialize();
- if (err != paNoError) {
- portaudio_assert(err, "Pa_Initialize");
- Py_RETURN_NONE;
- }
- else {
- numApis = Pa_GetHostApiCount();
- if( numApis < 0 )
- portaudio_assert(numApis, "Pa_GetHostApiCount");
- return PyInt_FromLong(numApis);
- }
-}
-
#define portaudio_list_host_apis_info \
"\nPrints a list of all host apis found by Portaudio.\n\n\
>>> pa_list_host_apis()\n\
index: 0, id: 5, name: Core Audio, num devices: 6, default in: 0, default out: 2\n\n"
-static PyObject*
-portaudio_list_host_apis(){
- PaError err;
- PaHostApiIndex n, i;
-
- err = Pa_Initialize();
- if (err != paNoError) {
- portaudio_assert(err, "Pa_Initialize");
- }
- else {
- n = Pa_GetHostApiCount();
- if (n < 0){
- portaudio_assert(n, "Pa_GetHostApiCount");
- }
- else {
- for (i=0; i < n; ++i){
- const PaHostApiInfo *info = Pa_GetHostApiInfo(i);
- 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;
-}
-
#define portaudio_get_default_host_api_info \
"\nReturns the index number of Portaudio's default host api.\n\n\
>>> h = pa_get_default_host_api()\n\
>>> print h\n\
0\n\n"
-static PyObject*
-portaudio_get_default_host_api(){
- PaError err;
- PaHostApiIndex i;
-
- err = Pa_Initialize();
- if (err != paNoError) {
- portaudio_assert(err, "Pa_Initialize");
- Py_RETURN_NONE;
- }
- else {
- i = Pa_GetDefaultHostApi();
- return PyInt_FromLong(i);
- }
-}
-
#define portaudio_count_devices_info \
"\nReturns the number of devices found by Portaudio.\n\n\
>>> c = pa_count_devices()\n\
>>> print c\n\
6\n\n"
-static PyObject*
-portaudio_count_devices(){
- PaError err;
- PaDeviceIndex numDevices;
-
- err = Pa_Initialize();
- if (err != paNoError) {
- portaudio_assert(err, "Pa_Initialize");
- Py_RETURN_NONE;
- }
- else {
- numDevices = Pa_GetDeviceCount();
- if( numDevices < 0 )
- portaudio_assert(numDevices, "Pa_GetDeviceCount");
- return PyInt_FromLong(numDevices);
- }
-
-}
-
#define portaudio_list_devices_info \
"\nPrints a list of all devices found by Portaudio.\n\n\
>>> pa_list_devices()\n\
@@ -183,39 +136,6 @@ AUDIO devices:\n\
5: IN, name: Soundflower (16ch), host api index: 0, default sr: 44100 Hz, latency: 0.010000 s\n\
5: OUT, name: Soundflower (16ch), host api index: 0, default sr: 44100 Hz, latency: 0.000000 s\n\n"
-static PyObject*
-portaudio_list_devices(){
- PaError err;
- PaDeviceIndex n, i;
-
- err = Pa_Initialize();
- if (err != paNoError) {
- portaudio_assert(err, "Pa_Initialize");
- Py_RETURN_NONE;
- }
- else {
- n = Pa_GetDeviceCount();
- if (n < 0){
- portaudio_assert(n, "Pa_GetDeviceCount");
- }
- else {
- printf("AUDIO devices:\n");
- 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;
-}
-
#define portaudio_get_devices_infos_info \
"\nReturns informations about all devices found by Portaudio.\n\n\
This function returns two dictionaries, one containing a dictionary for each input device and one containing a dictionary for each output device.\
@@ -232,90 +152,12 @@ Keys of outer dictionaries are the device index as returned by Portaudio. Keys o
... for key in ['name', 'host api index', 'default sr', 'latency']:\n\
... print ' %s:' % key, outputs[index][key]\n\n"
-static PyObject*
-portaudio_get_devices_infos(){
- PaError err;
- PaDeviceIndex n, i;
- PyObject *inDict, *outDict, *tmpDict;
- inDict = PyDict_New();
- outDict = PyDict_New();
-
- err = Pa_Initialize();
- if (err != paNoError) {
- portaudio_assert(err, "Pa_Initialize");
- Py_RETURN_NONE;
- }
- else {
- n = Pa_GetDeviceCount();
- if (n < 0){
- portaudio_assert(n, "Pa_GetDeviceCount");
- Py_RETURN_NONE;
- }
- else {
- for (i=0; i < n; ++i){
- const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
- assert(info);
- tmpDict = PyDict_New();
- if (info->maxInputChannels > 0) {
- PyDict_SetItemString(tmpDict, "name", PyString_FromString(info->name));
- PyDict_SetItemString(tmpDict, "host api index", PyInt_FromLong((int)info->hostApi));
- PyDict_SetItemString(tmpDict, "default sr", PyInt_FromLong((int)info->defaultSampleRate));
- PyDict_SetItemString(tmpDict, "latency", PyFloat_FromDouble((float)info->defaultLowInputLatency));
- PyDict_SetItem(inDict, PyInt_FromLong(i), PyDict_Copy(tmpDict));
- }
- if (info->maxOutputChannels > 0) {
- PyDict_SetItemString(tmpDict, "name", PyString_FromString(info->name));
- PyDict_SetItemString(tmpDict, "host api index", PyInt_FromLong((int)info->hostApi));
- PyDict_SetItemString(tmpDict, "default sr", PyInt_FromLong((int)info->defaultSampleRate));
- PyDict_SetItemString(tmpDict, "latency", PyFloat_FromDouble((float)info->defaultLowOutputLatency));
- PyDict_SetItem(outDict, PyInt_FromLong(i), PyDict_Copy(tmpDict));
- }
- }
- return Py_BuildValue("(OO)", inDict, outDict);
- }
- }
-}
-
#define portaudio_get_output_devices_info \
"\nReturns output devices (device names, device indexes) found by Portaudio.\n\n`device names` is a list of strings and `device indexes` is a list of the actual\nPortaudio index of each device.\n\n\
>>> outs = pa_get_output_devices()\n\
>>> print outs\n\
(['Built-in Output', 'UA-4FX', 'Soundflower (2ch)', 'Soundflower (16ch)'], [2, 3, 4, 5])\n\n"
-static PyObject*
-portaudio_get_output_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");
- Py_RETURN_NONE;
- }
- else {
- n = Pa_GetDeviceCount();
- if (n < 0){
- portaudio_assert(n, "Pa_GetDeviceCount");
- Py_RETURN_NONE;
- }
- else {
- for (i=0; i < n; ++i){
- const PaDeviceInfo *info=Pa_GetDeviceInfo(i);
- 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);
- }
- }
-}
-
#define portaudio_get_output_max_channels_info \
"\nRetrieve the maximum number of output channels for the specified device.\n\n:Args:\n\n \
x: int\n Device index as listed by Portaudio (see pa_get_output_devices).\n\n\
@@ -332,30 +174,6 @@ x: int\n Device index as listed by Portaudio (see pa_get_output_devices).
>>> else:\n\
... nchnls = 1\n\n"
-static PyObject*
-portaudio_get_output_max_channels(PyObject *self, PyObject *arg){
- PaError err;
- PaDeviceIndex n, i = PyInt_AsLong(arg);
-
- err = Pa_Initialize();
- if (err != paNoError) {
- portaudio_assert(err, "Pa_Initialize");
- Py_RETURN_NONE;
- }
- else {
- n = Pa_GetDeviceCount();
- if (n < 0){
- portaudio_assert(n, "Pa_GetDeviceCount");
- Py_RETURN_NONE;
- }
- else {
- const PaDeviceInfo *info=Pa_GetDeviceInfo(i);
- assert(info);
- return PyInt_FromLong(info->maxOutputChannels);
- }
- }
-}
-
#define portaudio_get_input_max_channels_info \
"\nRetrieve the maximum number of input channels for the specified device.\n\n:Args:\n\n \
x: int\n Device index as listed by Portaudio (see pa_get_input_devices).\n\n\
@@ -372,70 +190,12 @@ x: int\n Device index as listed by Portaudio (see pa_get_input_devices).\
>>> else:\n\
... nchnls = 1\n\n"
-static PyObject*
-portaudio_get_input_max_channels(PyObject *self, PyObject *arg){
- PaError err;
- PaDeviceIndex n, i = PyInt_AsLong(arg);
-
- err = Pa_Initialize();
- if (err != paNoError) {
- portaudio_assert(err, "Pa_Initialize");
- Py_RETURN_NONE;
- }
- else {
- n = Pa_GetDeviceCount();
- if (n < 0){
- portaudio_assert(n, "Pa_GetDeviceCount");
- Py_RETURN_NONE;
- }
- else {
- const PaDeviceInfo *info=Pa_GetDeviceInfo(i);
- assert(info);
- return PyInt_FromLong(info->maxInputChannels);
- }
- }
-}
-
#define portaudio_get_input_devices_info \
"\nReturns input devices (device names, device indexes) found by Portaudio.\n\n`device names` is a list of strings and `device indexes` is a list of the actual\nPortaudio index of each device.\n\n\
>>> ins = pa_get_input_devices()\n\
>>> print ins\n\
(['Built-in Microphone', 'Built-in Input', 'UA-4FX', 'Soundflower (2ch)', 'Soundflower (16ch)'], [0, 1, 3, 4, 5])\n\n"
-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");
- Py_RETURN_NONE;
- }
- else {
- n = Pa_GetDeviceCount();
- if (n < 0){
- portaudio_assert(n, "Pa_GetDeviceCount");
- Py_RETURN_NONE;
- }
- else {
- for (i=0; i < n; ++i){
- const PaDeviceInfo *info=Pa_GetDeviceInfo(i);
- 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);
- }
- }
-}
-
#define portaudio_get_default_input_info \
"\nReturns the index number of Portaudio's default input device.\n\n\
>>> names, indexes = pa_get_input_devices()\n\
@@ -443,23 +203,6 @@ portaudio_get_input_devices(){
>>> print name\n\
'Built-in Microphone'\n\n"
-static PyObject*
-portaudio_get_default_input(){
- PaError err;
- PaDeviceIndex i;
-
- err = Pa_Initialize();
- if (err != paNoError) {
- portaudio_assert(err, "Pa_Initialize");
- Py_RETURN_NONE;
- }
- else {
- i = Pa_GetDefaultInputDevice();
- return PyInt_FromLong(i);
- }
-
-}
-
#define portaudio_get_default_output_info \
"\nReturns the index number of Portaudio's default output device.\n\n\
>>> names, indexes = pa_get_output_devices()\n\
@@ -467,37 +210,15 @@ portaudio_get_default_input(){
>>> print name\n\
'UA-4FX'\n\n"
-static PyObject*
-portaudio_get_default_output(){
- PaError err;
- PaDeviceIndex i;
-
- err = Pa_Initialize();
- if (err != paNoError) {
- portaudio_assert(err, "Pa_Initialize");
- Py_RETURN_NONE;
- }
- else {
- i = Pa_GetDefaultOutputDevice();
- return PyInt_FromLong(i);
-
- }
-}
+/** Portmidi utility functions __doc__ strings. **/
+/*************************************************/
-/****** Portmidi utilities ******/
#define portmidi_count_devices_info \
"\nReturns the number of devices found by Portmidi.\n\n\
>>> c = pm_count_devices()\n\
>>> print c\n\
6\n\n"
-static PyObject *
-portmidi_count_devices(){
- int numDevices;
- numDevices = Pm_CountDevices();
- return PyInt_FromLong(numDevices);
-}
-
#define portmidi_list_devices_info \
"\nPrints a list of all devices found by Portmidi.\n\n\
>>> pm_list_devices()\n\
@@ -509,81 +230,18 @@ MIDI devices:\n\
4: OUT, name: to MaxMSP 1, interface: CoreMIDI\n\
5: OUT, name: to MaxMSP 2, interface: CoreMIDI\n\n"
-static PyObject *
-portmidi_list_devices(){
- int i;
- printf("MIDI devices:\n");
- for (i = 0; i < Pm_CountDevices(); i++) {
- const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
- if (info->input && info->output)
- printf("%d: IN/OUT, name: %s, interface: %s\n", i, info->name, info->interf);
- else if (info->input)
- printf("%d: IN, name: %s, interface: %s\n", i, info->name, info->interf);
- else if (info->output)
- printf("%d: OUT, name: %s, interface: %s\n", i, info->name, info->interf);
- }
- printf("\n");
- Py_RETURN_NONE;
-}
-
#define portmidi_get_input_devices_info \
"\nReturns midi input devices (device names, device indexes) found by Portmidi.\n\n`device names` is a list of strings and `device indexes` is a list of the actual\nPortmidi index of each device.\n\n\
>>> ins = pm_get_input_devices()\n\
>>> print ins\n\
(['IAC Driver Bus 1', 'from MaxMSP 1', 'from MaxMSP 2'], [0, 1, 2])\n\n"
-static PyObject*
-portmidi_get_input_devices(){
- int n, i;
- PyObject *list, *list_index;
- list = PyList_New(0);
- list_index = PyList_New(0);
- n = Pm_CountDevices();
- if (n < 0){
- printf("Portmidi warning: No Midi interface found\n\n");
- }
- else {
- for (i=0; i < n; i++){
- const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
- if (info->input){
- PyList_Append(list, PyString_FromString(info->name));
- PyList_Append(list_index, PyInt_FromLong(i));
- }
- }
- printf("\n");
- }
- return Py_BuildValue("OO", list, list_index);
-}
-
#define portmidi_get_output_devices_info \
"\nReturns midi output devices (device names, device indexes) found by Portmidi.\n\n`device names` is a list of strings and `device indexes` is a list of the actual\nPortmidi index of each device.\n\n\
>>> outs = pm_get_output_devices()\n\
>>> print outs\n\
(['IAC Driver Bus 1', 'to MaxMSP 1', 'to MaxMSP 2'], [3, 4, 5])\n\n"
-static PyObject*
-portmidi_get_output_devices(){
- int n, i;
- PyObject *list, *list_index;
- list = PyList_New(0);
- list_index = PyList_New(0);
- n = Pm_CountDevices();
- if (n < 0){
- printf("Portmidi warning: No Midi interface found\n\n");
- }
- else {
- for (i=0; i < n; i++){
- const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
- if (info->output){
- PyList_Append(list, PyString_FromString(info->name));
- PyList_Append(list_index, PyInt_FromLong(i));
- }
- }
- printf("\n");
- }
- return Py_BuildValue("OO", list, list_index);
-}
-
#define portmidi_get_default_input_info \
"\nReturns the index number of Portmidi's default input device.\n\n\
>>> names, indexes = pm_get_input_devices()\n\
@@ -591,16 +249,6 @@ portmidi_get_output_devices(){
>>> print name\n\
'IAC Driver Bus 1'\n\n"
-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");
- return PyInt_FromLong(i);
-}
-
#define portmidi_get_default_output_info \
"\nReturns the index number of Portmidi's default output device.\n\n\
>>> names, indexes = pm_get_output_devices()\n\
@@ -608,14 +256,6 @@ portmidi_get_default_input(){
>>> print name\n\
'IAC Driver Bus 1'\n\n"
-static PyObject *
-portmidi_get_default_output(){
- PmDeviceID i;
- i = Pm_GetDefaultOutputDeviceID();
- if (i < 0)
- printf("pm_get_default_output: no midi output device found.\n");
- return PyInt_FromLong(i);
-}
/****** Libsndfile utilities ******/
static int
@@ -689,27 +329,20 @@ 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;
char *path;
char fileformat[5];
- char *sampletype;
- int format;
- int subformat;
- int print = 0;
+ char sampletype[16];
+ int format, subformat, print = 0;
static char *kwlist[] = {"path", "print", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|i", kwlist, &pathtmp, &print)) {
- PySys_WriteStderr("sndinfo: failed to open the file.\n");
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "s|i", kwlist, &path, &print)) {
+ PySys_WriteStderr("sndinfo: called with wrong arguments.\n");
Py_RETURN_NONE;
}
- path = malloc(strlen(pathtmp)+1);
- strcpy(path, pathtmp);
-
/* Open the sound file. */
info.format = 0;
sf = sf_open(path, SFM_READ, &info);
@@ -717,114 +350,64 @@ sndinfo(PyObject *self, PyObject *args, PyObject *kwds) {
PySys_WriteStderr("sndinfo: failed to open the file.\n");
Py_RETURN_NONE;
}
- else {
- /* Retrieve file format */
- format = (int)info.format;
- if (format > SF_FORMAT_WAV && format < SF_FORMAT_AIFF) {
- strcpy(fileformat, "WAVE");
- subformat = format - SF_FORMAT_WAV;
- }
- else if (format > SF_FORMAT_AIFF && format < SF_FORMAT_AU) {
- strcpy(fileformat, "AIFF");
- subformat = format - SF_FORMAT_AIFF;
- }
- else if (format > SF_FORMAT_AU && format < SF_FORMAT_RAW) {
- strcpy(fileformat, "AU");
- subformat = format - SF_FORMAT_AU;
- }
- else if (format > SF_FORMAT_RAW && format < SF_FORMAT_PAF) {
- strcpy(fileformat, "RAW");
- subformat = format - SF_FORMAT_RAW;
- }
- else if (format > SF_FORMAT_SD2 && format < SF_FORMAT_FLAC) {
- strcpy(fileformat, "SD2");
- subformat = format - SF_FORMAT_SD2;
- }
- else if (format > SF_FORMAT_FLAC && format < SF_FORMAT_CAF) {
- strcpy(fileformat, "FLAC");
- subformat = format - SF_FORMAT_FLAC;
- }
- else if (format > SF_FORMAT_CAF && format < SF_FORMAT_WVE) {
- strcpy(fileformat, "CAF");
- subformat = format - SF_FORMAT_CAF;
- }
- else if (format > SF_FORMAT_OGG && format < SF_FORMAT_MPC2K) {
- strcpy(fileformat, "OGG");
- subformat = format - SF_FORMAT_OGG;
- }
- else if (format > SF_FORMAT_RF64 && format < 0x230000) {
- strcpy(fileformat, "RF64");
- subformat = format - SF_FORMAT_RF64;
- }
- else {
- strcpy(fileformat, "????");
- subformat = -1;
- }
- /* Retrieve sample type */
- if (subformat != -1) {
- switch (subformat) {
- case SF_FORMAT_PCM_S8:
- sampletype = malloc(strlen("s8 bit int") + 1);
- strcpy(sampletype, "s8 bit int");
- break;
- case SF_FORMAT_PCM_U8:
- sampletype = malloc(strlen("u8 bit int") + 1);
- strcpy(sampletype, "u8 bit int");
- break;
- case SF_FORMAT_PCM_16:
- sampletype = malloc(strlen("16 bit int") + 1);
- strcpy(sampletype, "16 bit int");
- break;
- case SF_FORMAT_PCM_24:
- sampletype = malloc(strlen("24 bit int") + 1);
- strcpy(sampletype, "24 bit int");
- break;
- case SF_FORMAT_PCM_32:
- sampletype = malloc(strlen("32 bit int") + 1);
- strcpy(sampletype, "32 bit int");
- break;
- case SF_FORMAT_FLOAT:
- sampletype = malloc(strlen("32 bit float") + 1);
- strcpy(sampletype, "32 bit float");
- break;
- case SF_FORMAT_DOUBLE:
- sampletype = malloc(strlen("64 bit float") + 1);
- strcpy(sampletype, "64 bit float");
- break;
- case SF_FORMAT_ULAW:
- sampletype = malloc(strlen("U-Law encoded") + 1);
- strcpy(sampletype, "U-Law encoded");
- break;
- case SF_FORMAT_ALAW:
- sampletype = malloc(strlen("A-Law encoded") + 1);
- strcpy(sampletype, "A-Law encoded");
- break;
- case SF_FORMAT_VORBIS:
- sampletype = malloc(strlen("vorbis encoding") + 1);
- strcpy(sampletype, "vorbis encoding");
- break;
- default:
- /* printf("%d\n", subformat); */
- sampletype = malloc(strlen("Unknown...") + 1);
- strcpy(sampletype, "Unknown...");
- break;
- }
- }
- else {
- 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",
- 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),
- PyFloat_FromDouble(info.samplerate), PyInt_FromLong(info.channels), PyString_FromString(fileformat), PyString_FromString(sampletype));
- sf_close(sf);
- free(path);
- free(sampletype);
- return sndinfo;
- }
+ /* Retrieve file format */
+ format = (int)info.format & SF_FORMAT_TYPEMASK;
+ subformat = (int)info.format & SF_FORMAT_SUBMASK;
+ if (format == SF_FORMAT_WAV)
+ strcpy(fileformat, "WAVE");
+ else if (format == SF_FORMAT_AIFF)
+ strcpy(fileformat, "AIFF");
+ else if (format == SF_FORMAT_AU)
+ strcpy(fileformat, "AU");
+ else if (format == SF_FORMAT_RAW)
+ strcpy(fileformat, "RAW");
+ else if (format == SF_FORMAT_SD2)
+ strcpy(fileformat, "SD2");
+ else if (format == SF_FORMAT_FLAC)
+ strcpy(fileformat, "FLAC");
+ else if (format == SF_FORMAT_CAF)
+ strcpy(fileformat, "CAF");
+ else if (format == SF_FORMAT_OGG)
+ strcpy(fileformat, "OGG");
+ else if (format == SF_FORMAT_RF64)
+ strcpy(fileformat, "RF64");
+ else
+ strcpy(fileformat, "????");
+
+ /* Retrieve sample type */
+ if (subformat == SF_FORMAT_PCM_S8)
+ strcpy(sampletype, "s8 bit int");
+ else if (subformat == SF_FORMAT_PCM_U8)
+ strcpy(sampletype, "u8 bit int");
+ else if (subformat == SF_FORMAT_PCM_16)
+ strcpy(sampletype, "16 bit int");
+ else if (subformat == SF_FORMAT_PCM_24)
+ strcpy(sampletype, "24 bit int");
+ else if (subformat == SF_FORMAT_PCM_32)
+ strcpy(sampletype, "32 bit int");
+ else if (subformat == SF_FORMAT_FLOAT)
+ strcpy(sampletype, "32 bit float");
+ else if (subformat == SF_FORMAT_DOUBLE)
+ strcpy(sampletype, "64 bit float");
+ else if (subformat == SF_FORMAT_ULAW)
+ strcpy(sampletype, "U-Law encoded");
+ else if (subformat == SF_FORMAT_ALAW)
+ strcpy(sampletype, "A-Law encoded");
+ else if (subformat == SF_FORMAT_VORBIS)
+ strcpy(sampletype, "vorbis encoding");
+ else
+ strcpy(sampletype, "Unknown...");
+
+ if (print)
+ PySys_WriteStdout("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),
+ PyFloat_FromDouble(info.samplerate), PyInt_FromLong(info.channels),
+ PyUnicode_FromString(fileformat), PyUnicode_FromString(sampletype));
+ sf_close(sf);
+ return sndinfo;
}
#define savefile_info \
@@ -850,7 +433,10 @@ SD2 and FLAC only support 16 or 24 bit int. Supported types are:\n \
3. 32 bit float\n \
4. 64 bit float\n \
5. U-Law encoded\n \
-6. A-Law encoded\n\n\
+6. A-Law encoded\n \
+quality : float, optional\n The encoding quality value, between 0.0 (lowest quality) and\n \
+1.0 (highest quality). This argument has an effect only with\n \
+FLAC and OGG compressed formats. Defaults to 0.4.\n\n\
>>> from random import uniform\n\
>>> import os\n\
>>> home = os.path.expanduser('~')\n\
@@ -868,11 +454,12 @@ savefile(PyObject *self, PyObject *args, PyObject *kwds) {
int channels = 1;
int fileformat = 0;
int sampletype = 0;
+ double quality = 0.4;
SNDFILE *recfile;
SF_INFO recinfo;
- static char *kwlist[] = {"samples", "path", "sr", "channels", "fileformat", "sampletype", NULL};
+ static char *kwlist[] = {"samples", "path", "sr", "channels", "fileformat", "sampletype", "quality", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "Os|iiii", kwlist, &samples, &recpath, &sr, &channels, &fileformat, &sampletype))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "Os|iiiid", kwlist, &samples, &recpath, &sr, &channels, &fileformat, &sampletype, &quality))
return PyInt_FromLong(-1);
recinfo.samplerate = sr;
@@ -888,7 +475,7 @@ savefile(PyObject *self, PyObject *args, PyObject *kwds) {
}
else {
if (PyList_Size(samples) != channels) {
- printf("savefile: samples list size and channels must be the same!\n");
+ PySys_WriteStdout("savefile: samples list size and channels must be the same!\n");
return PyInt_FromLong(-1);
}
size = PyList_Size(PyList_GET_ITEM(samples, 0)) * channels;
@@ -900,9 +487,15 @@ savefile(PyObject *self, PyObject *args, PyObject *kwds) {
}
}
if (! (recfile = sf_open(recpath, SFM_WRITE, &recinfo))) {
- printf ("savefile: failed to open output file %s.\n", recpath);
+ PySys_WriteStdout("savefile: failed to open output file %s.\n", recpath);
return PyInt_FromLong(-1);
}
+
+ // Sets the encoding quality for FLAC and OGG compressed formats
+ if (fileformat == 5 || fileformat == 7) {
+ sf_command(recfile, SFC_SET_VBR_ENCODING_QUALITY, &quality, sizeof(double));
+ }
+
SF_WRITE(recfile, sampsarray, size);
sf_close(recfile);
free(sampsarray);
@@ -931,7 +524,10 @@ SD2 and FLAC only support 16 or 24 bit int. Supported types are:\n \
3. 32 bit float\n \
4. 64 bit float\n \
5. U-Law encoded\n \
-6. A-Law encoded\n\n\
+6. A-Law encoded\n \
+quality : float, optional\n The encoding quality value, between 0.0 (lowest quality) and\n \
+1.0 (highest quality). This argument has an effect only with\n \
+FLAC and OGG compressed formats. Defaults to 0.4.\n\n\
>>> import os\n\
>>> home = os.path.expanduser('~')\n\
>>> path1 = SNDS_PATH + '/transparent.aif'\n\
@@ -951,13 +547,14 @@ savefileFromTable(PyObject *self, PyObject *args, PyObject *kwds) {
int channels = 1;
int fileformat = 0;
int sampletype = 0;
+ double quality = 0.4;
int count = 0;
int num_items = 0;
SNDFILE *recfile;
SF_INFO recinfo;
- static char *kwlist[] = {"table", "path", "fileformat", "sampletype", NULL};
+ static char *kwlist[] = {"table", "path", "fileformat", "sampletype", "quality", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "Os|ii", kwlist, &table, &recpath, &fileformat, &sampletype))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "Os|iid", kwlist, &table, &recpath, &fileformat, &sampletype, &quality))
return PyInt_FromLong(-1);
base_objs = PyObject_GetAttrString(table, "_base_objs");
@@ -974,12 +571,17 @@ savefileFromTable(PyObject *self, PyObject *args, PyObject *kwds) {
recinfo.format = libsndfile_get_format(fileformat, sampletype);
if (! (recfile = sf_open(recpath, SFM_WRITE, &recinfo))) {
- printf ("savefileFromTable: failed to open output file %s.\n", recpath);
+ PySys_WriteStdout("savefileFromTable: failed to open output file %s.\n", recpath);
Py_XDECREF(base_objs);
Py_XDECREF(tablestreamlist);
return PyInt_FromLong(-1);
}
+ // Sets the encoding quality for FLAC and OGG compressed formats
+ if (fileformat == 5 || fileformat == 7) {
+ sf_command(recfile, SFC_SET_VBR_ENCODING_QUALITY, &quality, sizeof(double));
+ }
+
if (channels == 1) {
MYFLT *data;
if (size < (sr * 60)) {
@@ -1153,7 +755,7 @@ void lp_conv(MYFLT *samples, MYFLT *impulse, int num_samps, int size, int gain)
static PyObject *
upsamp(PyObject *self, PyObject *args, PyObject *kwds)
{
- int i, j, k;
+ unsigned int i, j, k;
char *inpath;
char *outpath;
SNDFILE *sf;
@@ -1163,7 +765,7 @@ upsamp(PyObject *self, PyObject *args, PyObject *kwds)
MYFLT *tmp;
MYFLT **samples;
MYFLT **upsamples;
- int up = 4;
+ unsigned int up = 4;
int order = 128;
static char *kwlist[] = {"path", "outfile", "up", "order", NULL};
@@ -1174,7 +776,7 @@ upsamp(PyObject *self, PyObject *args, PyObject *kwds)
info.format = 0;
sf = sf_open(inpath, SFM_READ, &info);
if (sf == NULL) {
- printf("upsamp: failed to open the input file %s.\n", inpath);
+ PySys_WriteStdout("upsamp: failed to open the input file %s.\n", inpath);
return PyInt_FromLong(-1);
}
snd_size = info.frames;
@@ -1227,7 +829,7 @@ upsamp(PyObject *self, PyObject *args, PyObject *kwds)
}
if (! (sf = sf_open(outpath, SFM_WRITE, &info))) {
- printf ("upsamp: failed to open output file %s.\n", outpath);
+ PySys_WriteStdout("upsamp: failed to open output file %s.\n", outpath);
free(tmp);
for (i=0; i<snd_chnls; i++) {
free(samples[i]);
@@ -1256,7 +858,7 @@ upsamp(PyObject *self, PyObject *args, PyObject *kwds)
static PyObject *
downsamp(PyObject *self, PyObject *args, PyObject *kwds)
{
- int i, j;
+ unsigned int i, j;
char *inpath;
char *outpath;
SNDFILE *sf;
@@ -1277,7 +879,7 @@ downsamp(PyObject *self, PyObject *args, PyObject *kwds)
info.format = 0;
sf = sf_open(inpath, SFM_READ, &info);
if (sf == NULL) {
- printf("downsamp: failed to open the input file %s.\n", inpath);
+ PySys_WriteStdout("downsamp: failed to open the input file %s.\n", inpath);
return PyInt_FromLong(-1);
}
snd_size = info.frames;
@@ -1335,7 +937,7 @@ downsamp(PyObject *self, PyObject *args, PyObject *kwds)
}
if (! (sf = sf_open(outpath, SFM_WRITE, &info))) {
- printf("downsamp: failed to open the output file %s.\n", outpath);
+ PySys_WriteStdout("downsamp: failed to open the output file %s.\n", outpath);
free(tmp);
for (i=0; i<snd_chnls; i++) {
free(samples[i]);
@@ -2054,7 +1656,7 @@ static PyObject *
sampsToSec(PyObject *self, PyObject *arg) {
PyObject *server = PyServer_get_server();
if (server == NULL) {
- printf("Warning: A Server must be booted before calling `sampsToSec` function.\n");
+ PySys_WriteStdout("Warning: A Server must be booted before calling `sampsToSec` function.\n");
Py_RETURN_NONE;
}
double sr = PyFloat_AsDouble(PyObject_CallMethod(server, "getSamplingRate", NULL));
@@ -2106,7 +1708,7 @@ static PyObject *
secToSamps(PyObject *self, PyObject *arg) {
PyObject *server = PyServer_get_server();
if (server == NULL) {
- printf("Warning: A Server must be booted before calling `secToSamps` function.\n");
+ PySys_WriteStdout("Warning: A Server must be booted before calling `secToSamps` function.\n");
Py_RETURN_NONE;
}
double sr = PyFloat_AsDouble(PyObject_CallMethod(server, "getSamplingRate", NULL));
@@ -2185,7 +1787,7 @@ serverBooted(PyObject *self) {
}
}
else {
- printf("Warning: A Server must be created before calling `serverBooted` function.\n");
+ PySys_WriteStdout("Warning: A Server must be created before calling `serverBooted` function.\n");
Py_INCREF(Py_False);
return Py_False;
}
@@ -2229,9 +1831,30 @@ static PyMethodDef pyo_functions[] = {
{"secToSamps", (PyCFunction)secToSamps, METH_O, secToSamps_info},
{"serverCreated", (PyCFunction)serverCreated, METH_NOARGS, serverCreated_info},
{"serverBooted", (PyCFunction)serverBooted, METH_NOARGS, serverBooted_info},
+{"withPortaudio", (PyCFunction)with_portaudio, METH_NOARGS, "Returns True if pyo is built with portaudio support."},
+{"withPortmidi", (PyCFunction)with_portmidi, METH_NOARGS, "Returns True if pyo is built with portmidi support."},
+{"withJack", (PyCFunction)with_jack, METH_NOARGS, "Returns True if pyo is built with jack support."},
+{"withCoreaudio", (PyCFunction)with_coreaudio, METH_NOARGS, "Returns True if pyo is built with coreaudio support."},
+{"withOSC", (PyCFunction)with_osc, METH_NOARGS, "Returns True if pyo is built with OSC (Open Sound Control) support."},
{NULL, NULL, 0, NULL},
};
+#if PY_MAJOR_VERSION >= 3
+// TODO: Pyo likely has a bunch of state stored in global variables right now, they should ideally be stored
+// in an interpreter specific struct as described in https://docs.python.org/3/howto/cporting.html
+static struct PyModuleDef pyo_moduledef = {
+ PyModuleDef_HEAD_INIT,
+ LIB_BASE_NAME,/* m_name */
+ "Python digital signal processing module.",/* m_doc */
+ 0,/* m_size */
+ pyo_functions,/* m_methods */
+ NULL,/* m_reload */
+ NULL,/* m_traverse */
+ NULL,/* m_clear */
+ NULL,/* m_free */
+};
+#endif
+
static PyObject *
module_add_object(PyObject *module, const char *name, PyTypeObject *type) {
if (PyType_Ready(type) < 0)
@@ -2242,27 +1865,51 @@ module_add_object(PyObject *module, const char *name, PyTypeObject *type) {
}
PyMODINIT_FUNC
+#if PY_MAJOR_VERSION >= 3
+#ifndef USE_DOUBLE
+PyInit__pyo(void)
+#else
+PyInit__pyo64(void)
+#endif
+#else
#ifndef USE_DOUBLE
init_pyo(void)
#else
init_pyo64(void)
#endif
+#endif
+
{
PyObject *m;
+#if PY_MAJOR_VERSION >= 3
+ m = PyModule_Create(&pyo_moduledef);
+#else
m = Py_InitModule3(LIB_BASE_NAME, pyo_functions, "Python digital signal processing module.");
+#endif
#ifndef NO_MESSAGES
#ifndef USE_DOUBLE
- printf("pyo version %s (uses single precision)\n", PYO_VERSION);
+ PySys_WriteStdout("pyo version %s (uses single precision)\n", PYO_VERSION);
#else
- printf("pyo version %s (uses double precision)\n", PYO_VERSION);
+ PySys_WriteStdout("pyo version %s (uses double precision)\n", PYO_VERSION);
#endif
#endif
module_add_object(m, "Server_base", &ServerType);
+#ifdef USE_PORTMIDI
module_add_object(m, "MidiListener_base", &MidiListenerType);
+#endif
+#ifdef USE_OSC
module_add_object(m, "OscListener_base", &OscListenerType);
+ module_add_object(m, "OscSend_base", &OscSendType);
+ module_add_object(m, "OscDataSend_base", &OscDataSendType);
+ module_add_object(m, "OscReceive_base", &OscReceiveType);
+ module_add_object(m, "OscReceiver_base", &OscReceiverType);
+ module_add_object(m, "OscListReceive_base", &OscListReceiveType);
+ module_add_object(m, "OscListReceiver_base", &OscListReceiverType);
+ module_add_object(m, "OscDataReceive_base", &OscDataReceiveType);
+#endif
module_add_object(m, "Stream", &StreamType);
module_add_object(m, "TriggerStream", &TriggerStreamType);
module_add_object(m, "PVStream", &PVStreamType);
@@ -2349,6 +1996,7 @@ init_pyo64(void)
module_add_object(m, "TableRead_base", &TableReadType);
module_add_object(m, "Pulsar_base", &PulsarType);
module_add_object(m, "Sine_base", &SineType);
+ module_add_object(m, "FastSine_base", &FastSineType);
module_add_object(m, "SineLoop_base", &SineLoopType);
module_add_object(m, "Fm_base", &FmType);
module_add_object(m, "CrossFm_base", &CrossFmType);
@@ -2358,6 +2006,8 @@ init_pyo64(void)
module_add_object(m, "RosslerAlt_base", &RosslerAltType);
module_add_object(m, "Lorenz_base", &LorenzType);
module_add_object(m, "LorenzAlt_base", &LorenzAltType);
+ module_add_object(m, "ChenLee_base", &ChenLeeType);
+ module_add_object(m, "ChenLeeAlt_base", &ChenLeeAltType);
module_add_object(m, "Phasor_base", &PhasorType);
module_add_object(m, "SuperSaw_base", &SuperSawType);
module_add_object(m, "Pointer_base", &PointerType);
@@ -2403,13 +2053,6 @@ init_pyo64(void)
module_add_object(m, "Programin_base", &PrograminType);
module_add_object(m, "MidiAdsr_base", &MidiAdsrType);
module_add_object(m, "MidiDelAdsr_base", &MidiDelAdsrType);
- module_add_object(m, "OscSend_base", &OscSendType);
- module_add_object(m, "OscDataSend_base", &OscDataSendType);
- module_add_object(m, "OscReceive_base", &OscReceiveType);
- module_add_object(m, "OscReceiver_base", &OscReceiverType);
- module_add_object(m, "OscListReceive_base", &OscListReceiveType);
- module_add_object(m, "OscListReceiver_base", &OscListReceiverType);
- module_add_object(m, "OscDataReceive_base", &OscDataReceiveType);
module_add_object(m, "TrigRand_base", &TrigRandType);
module_add_object(m, "TrigRandInt_base", &TrigRandIntType);
module_add_object(m, "TrigVal_base", &TrigValType);
@@ -2460,6 +2103,7 @@ init_pyo64(void)
module_add_object(m, "IRFM_base", &IRFMType);
module_add_object(m, "Granulator_base", &GranulatorType);
module_add_object(m, "Looper_base", &LooperType);
+ module_add_object(m, "LooperTimeStream_base", &LooperTimeStreamType);
module_add_object(m, "Harmonizer_base", &HarmonizerType);
module_add_object(m, "Print_base", &PrintType);
module_add_object(m, "M_Sin_base", &M_SinType);
@@ -2476,6 +2120,7 @@ init_pyo64(void)
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, "M_Exp_base", &M_ExpType);
module_add_object(m, "Snap_base", &SnapType);
module_add_object(m, "Interp_base", &InterpType);
module_add_object(m, "SampHold_base", &SampHoldType);
@@ -2513,6 +2158,7 @@ init_pyo64(void)
module_add_object(m, "ButHP_base", &ButHPType);
module_add_object(m, "ButBP_base", &ButBPType);
module_add_object(m, "ButBR_base", &ButBRType);
+ module_add_object(m, "MoogLP_base", &MoogLPType);
module_add_object(m, "PVAnal_base", &PVAnalType);
module_add_object(m, "PVSynth_base", &PVSynthType);
module_add_object(m, "PVTranspose_base", &PVTransposeType);
@@ -2555,6 +2201,8 @@ init_pyo64(void)
module_add_object(m, "RawMidi_base", &RawMidiType);
module_add_object(m, "Resample_base", &ResampleType);
module_add_object(m, "Expr_base", &ExprType);
+ module_add_object(m, "PadSynthTable_base", &PadSynthTableType);
+ module_add_object(m, "LogiMap_base", &LogiMapType);
PyModule_AddStringConstant(m, "PYO_VERSION", PYO_VERSION);
#ifdef COMPILE_EXTERNALS
@@ -2568,4 +2216,8 @@ init_pyo64(void)
#else
PyModule_AddIntConstant(m, "USE_DOUBLE", 1);
#endif
+
+#if PY_MAJOR_VERSION >= 3
+ return m;
+#endif
}
\ No newline at end of file
diff --git a/src/engine/servermodule.c b/src/engine/servermodule.c
index b020ff1..3f8e329 100644
--- a/src/engine/servermodule.c
+++ b/src/engine/servermodule.c
@@ -26,49 +26,90 @@
#include <stdlib.h>
#include <pthread.h>
+#include "py2to3.h"
#include "structmember.h"
-#include "portaudio.h"
-#include "portmidi.h"
-#include "porttime.h"
#include "sndfile.h"
#include "streammodule.h"
#include "pyomodule.h"
#include "servermodule.h"
+#ifdef USE_PORTAUDIO
+#include "ad_portaudio.h"
+#else
+int Server_pa_init(Server *self) { return -10; };
+int Server_pa_deinit(Server *self) { return 0; };
+int Server_pa_start(Server *self) { return 0; };
+int Server_pa_stop(Server *self) { return 0; };
+#endif
+
+#ifdef USE_JACK
+#include "ad_jack.h"
+#else
+int Server_jack_init(Server *self) { return -10; };
+int Server_jack_deinit(Server *self) { return 0; };
+int Server_jack_start(Server *self) { return 0; };
+int Server_jack_stop(Server *self) { return 0; };
+#endif
+
+#ifdef USE_COREAUDIO
+#include "ad_coreaudio.h"
+#else
+int Server_coreaudio_init(Server *self) { return -10; };
+int Server_coreaudio_deinit(Server *self) { return 0; };
+int Server_coreaudio_start(Server *self) { return 0; };
+int Server_coreaudio_stop(Server *self) { return 0; };
+#endif
+
+#ifdef USE_PORTMIDI
+#include "md_portmidi.h"
+#else
+void portmidiGetEvents(Server *self) {};
+int Server_pm_init(Server *self) { return -10; };
+int Server_pm_deinit(Server *self) { return 0; };
+void pm_noteout(Server *self, int pit, int vel, int chan, long timestamp) {};
+void pm_afterout(Server *self, int pit, int vel, int chan, long timestamp) {};
+void pm_ctlout(Server *self, int ctlnum, int value, int chan, long timestamp) {};
+void pm_programout(Server *self, int value, int chan, long timestamp) {};
+void pm_pressout(Server *self, int value, int chan, long timestamp) {};
+void pm_bendout(Server *self, int value, int chan, long timestamp) {};
+void pm_sysexout(Server *self, unsigned char *msg, long timestamp) {};
+#endif
+
+/** Array of Server objects. **/
+/******************************/
#define MAX_NBR_SERVER 256
static Server *my_server[MAX_NBR_SERVER];
static int serverID = 0;
-static PyObject *Server_shut_down(Server *self);
-static PyObject *Server_stop(Server *self);
-static void Server_process_gui(Server *server);
-static void Server_process_time(Server *server);
-static inline void Server_process_buffers(Server *server);
-static int Server_start_rec_internal(Server *self, char *filename);
+/* Function called by any new pyo object to get a pointer to the current server. */
+PyObject * PyServer_get_server() { return (PyObject *)my_server[serverID]; };
+
+/** Random generator and object seeds. **/
+/****************************************/
-/* random objects count and multiplier to assign different seed to each instance. */
#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,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,2203,2207};
-static unsigned int PYO_RAND_SEED = 1;
+ 2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,
+ 2153,2161,2179,2203,2207};
+
/* Linear congruential pseudo-random generator. */
+static unsigned int PYO_RAND_SEED = 1u;
unsigned int pyorand() {
PYO_RAND_SEED = (PYO_RAND_SEED * 1664525 + 1013904223) % PYO_RAND_MAX;
return PYO_RAND_SEED;
}
-#ifdef USE_COREAUDIO
-static int coreaudio_stop_callback(Server *self);
-#endif
+/** Logging levels. **/
+/*********************/
+/* Errors should indicate failure to execute a request. */
void
Server_error(Server *self, char * format, ...)
{
- // Errors should indicate failure to execute a request
if (self->verbosity & 1) {
char buffer[256];
va_list args;
@@ -76,1111 +117,72 @@ Server_error(Server *self, char * format, ...)
vsprintf (buffer,format, args);
va_end (args);
- printf("%s",buffer);
+ PySys_WriteStdout("%s",buffer);
}
}
+/* Messages should print useful or relevant information, or
+ information requested by the user. */
void
Server_message(Server *self, char * format, ...)
{
- // Messages should print useful or relevant information, or information requested by the user
if (self->verbosity & 2) {
char buffer[256];
va_list args;
va_start (args, format);
vsprintf (buffer,format, args);
- va_end (args);
-
- printf("%s",buffer);
- }
-}
-
-void
-Server_warning(Server *self, char * format, ...)
-{
- // Warnings should be used when an unexpected or unusual choice was made by pyo
-#ifndef NO_MESSAGES
- if (self->verbosity & 4) {
- char buffer[256];
- va_list args;
- va_start (args, format);
- vsprintf (buffer,format, args);
- va_end (args);
- printf("%s",buffer);
- }
-#endif
-}
-
-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];
- va_list args;
- va_start (args, format);
- vsprintf (buffer,format, args);
- va_end (args);
-
- printf("%s",buffer);
- }
-}
-
-/* Portmidi get input events */
-static void portmidiGetEvents(Server *self)
-{
- int i;
- PmError result;
- PmEvent buffer;
-
- 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 */
-static void portaudio_assert(PaError ecode, const char* cmdName) {
- if (ecode != paNoError) {
- const char* eText = Pa_GetErrorText(ecode);
- if (!eText) {
- eText = "???";
- }
- printf("portaudio error in %s: %s\n", cmdName, eText);
- Pa_Terminate();
- }
-}
-
-/* Portaudio callback function */
-static int
-pa_callback_interleaved( const void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *arg )
-{
- float *out = (float *)outputBuffer;
- Server *server = (Server *) arg;
-
- assert(framesPerBuffer == server->bufferSize);
- int i, j, bufchnls, index1, index2;
-
- /* avoid unused variable warnings */
- (void) timeInfo;
- (void) statusFlags;
-
- if (server->withPortMidi == 1) {
- portmidiGetEvents(server);
- }
-
- if (server->duplex == 1) {
- float *in = (float *)inputBuffer;
- bufchnls = server->ichnls + server->input_offset;
- for (i=0; i<server->bufferSize; i++) {
- index1 = i * server->ichnls;
- index2 = i * bufchnls + server->input_offset;
- for (j=0; j<server->ichnls; j++) {
- server->input_buffer[index1+j] = (MYFLT)in[index2+j];
- }
- }
- }
-
- Server_process_buffers(server);
- bufchnls = server->nchnls + server->output_offset;
- for (i=0; i<server->bufferSize; i++) {
- index1 = i * server->nchnls;
- index2 = i * bufchnls + server->output_offset;
- for (j=0; j<server->nchnls; j++) {
- out[index2+j] = (float) server->output_buffer[index1+j];
- }
- }
- server->midi_count = 0;
-
-#ifdef _OSX_
- if (server->server_stopped == 1)
- return paComplete;
- else
-#endif
- return paContinue;
-}
-
-static int
-pa_callback_nonInterleaved( const void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *arg )
-{
- 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);
- }
-
- if (server->duplex == 1) {
- float **in = (float **)inputBuffer;
- for (i=0; i<server->bufferSize; i++) {
- for (j=0; j<server->ichnls; j++) {
- server->input_buffer[(i*server->ichnls)+j] = (MYFLT)in[j+server->input_offset][i];
- }
- }
- }
-
- Server_process_buffers(server);
- for (i=0; i<server->bufferSize; i++) {
- for (j=0; j<server->nchnls; j++) {
- out[j+server->output_offset][i] = (float) server->output_buffer[(i*server->nchnls)+j];
- }
- }
- server->midi_count = 0;
-
-#ifdef _OSX_
- if (server->server_stopped == 1)
- return paComplete;
- else
-#endif
- return paContinue;
-}
-
-#ifdef USE_JACK
-/* Jack callbacks */
-
-static int
-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->ichnls], *out_buffers[server->nchnls];
-
- if (server->withPortMidi == 1) {
- portmidiGetEvents(server);
- }
- PyoJackBackendData *be_data = (PyoJackBackendData *) server->audio_be_data;
- 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->ichnls; j++) {
- server->input_buffer[(i*server->ichnls)+j] = (MYFLT) in_buffers[j][i];
- }
- }
- }
- Server_process_buffers(server);
- for (i=0; i<server->bufferSize; i++) {
- for (j=0; j<server->nchnls; j++) {
- out_buffers[j][i] = (jack_default_audio_sample_t) server->output_buffer[(i*server->nchnls)+j];
- }
- }
- server->midi_count = 0;
- return 0;
-}
-
-static int
-jack_srate_cb (jack_nframes_t nframes, void *arg)
-{
- Server *s = (Server *) arg;
- s->samplingRate = (double) nframes;
- Server_debug(s, "The sample rate is now %lu.\n", (unsigned long) nframes);
- return 0;
-}
-
-static int
-jack_bufsize_cb (jack_nframes_t nframes, void *arg)
-{
- Server *s = (Server *) arg;
- s->bufferSize = (int) nframes;
- Server_debug(s, "The buffer size is now %lu.\n", (unsigned long) nframes);
- return 0;
-}
-
-static void
-jack_error_cb (const char *desc)
-{
- printf("JACK error: %s\n", desc);
-}
-
-static void
-jack_shutdown_cb (void *arg)
-{
- Server *s = (Server *) arg;
- Server_shut_down(s);
- Server_warning(s, "JACK server shutdown. Pyo Server shut down.\n");
-}
-
-#endif
-
-#ifdef USE_COREAUDIO
-/* Coreaudio callbacks */
-
-OSStatus coreaudio_input_callback(AudioDeviceID device, const AudioTimeStamp* inNow,
- const AudioBufferList* inInputData,
- const AudioTimeStamp* inInputTime,
- AudioBufferList* outOutputData,
- const AudioTimeStamp* inOutputTime,
- void* defptr)
-{
- int i, j, bufchnls, servchnls, off1chnls, off2chnls;
- Server *server = (Server *) defptr;
- (void) outOutputData;
- const AudioBuffer* inputBuf = inInputData->mBuffers;
- float *bufdata = (float*)inputBuf->mData;
- bufchnls = inputBuf->mNumberChannels;
- 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;
-}
-
-OSStatus coreaudio_output_callback(AudioDeviceID device, const AudioTimeStamp* inNow,
- const AudioBufferList* inInputData,
- const AudioTimeStamp* inInputTime,
- AudioBufferList* outOutputData,
- const AudioTimeStamp* inOutputTime,
- void* defptr)
-{
- int i, j, bufchnls, servchnls, off1chnls, off2chnls;
- Server *server = (Server *) defptr;
-
- (void) inInputData;
-
- if (server->withPortMidi == 1) {
- portmidiGetEvents(server);
- }
-
- Server_process_buffers(server);
- AudioBuffer* outputBuf = outOutputData->mBuffers;
- bufchnls = outputBuf->mNumberChannels;
- servchnls = server->nchnls < bufchnls ? server->nchnls : bufchnls;
- float *bufdata = (float*)outputBuf->mData;
- for (i=0; i<server->bufferSize; i++) {
- off1chnls = i*bufchnls+server->output_offset;
- off2chnls = i*servchnls;
- for(j=0; j<servchnls; j++) {
- bufdata[off1chnls+j] = server->output_buffer[off2chnls+j];
- }
- }
- server->midi_count = 0;
-
- return kAudioHardwareNoError;
-}
-
-int
-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);
- return -1;
- }
- self->server_started = 0;
- return 0;
-}
-
-#endif
-
-static int
-offline_process_block(Server *arg)
-{
- Server *server = (Server *) arg;
- Server_process_buffers(server);
- return 0;
-}
-
-/* Server audio backend init functions */
-
-int
-Server_pa_init(Server *self)
-{
- PaError err;
- PaStreamParameters outputParameters;
- PaStreamParameters inputParameters;
- PaDeviceIndex n, inDevice, outDevice;
- const PaDeviceInfo *deviceInfo;
- PaHostApiIndex hostIndex;
- const PaHostApiInfo *hostInfo;
- PaHostApiTypeId hostId;
- PaSampleFormat sampleFormat;
- PaStreamCallback *streamCallback;
-
- err = Pa_Initialize();
- portaudio_assert(err, "Pa_Initialize");
-
- n = Pa_GetDeviceCount();
- if (n < 0) {
- portaudio_assert(n, "Pa_GetDeviceCount");
- }
-
- PyoPaBackendData *be_data = (PyoPaBackendData *) malloc(sizeof(PyoPaBackendData *));
- self->audio_be_data = (void *) be_data;
-
- if (self->output == -1)
- outDevice = Pa_GetDefaultOutputDevice(); /* default output device */
- else
- outDevice = (PaDeviceIndex) self->output; /* selected output device */
- if (self->input == -1)
- inDevice = Pa_GetDefaultInputDevice(); /* default input device */
- else
- inDevice = (PaDeviceIndex) self->input; /* selected input device */
-
- /* Retrieve host api id and define sample and callback format*/
- deviceInfo = Pa_GetDeviceInfo(outDevice);
- hostIndex = deviceInfo->hostApi;
- hostInfo = Pa_GetHostApiInfo(hostIndex);
- hostId = hostInfo->type;
- if (hostId == paASIO) {
- Server_debug(self, "Portaudio uses non-interleaved callback.\n");
- sampleFormat = paFloat32 | paNonInterleaved;
- streamCallback = pa_callback_nonInterleaved;
- }
- else if (hostId == paALSA) {
- Server_debug(self, "Portaudio uses interleaved callback.\n");
- Server_debug(self, "Using ALSA, if no input/output devices are specified, force to devices 0.\n");
- if (self->input == -1 && self->output == -1) {
- self->input = self->output = 0;
- inDevice = outDevice = (PaDeviceIndex) 0;
- }
- sampleFormat = paFloat32;
- streamCallback = pa_callback_interleaved;
- }
- 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));
- outputParameters.device = outDevice;
- outputParameters.channelCount = self->nchnls + self->output_offset;
- outputParameters.sampleFormat = sampleFormat;
- outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultHighOutputLatency;
- outputParameters.hostApiSpecificStreamInfo = NULL;
-
- if (self->duplex == 1) {
- memset(&inputParameters, 0, sizeof(inputParameters));
- inputParameters.device = inDevice;
- inputParameters.channelCount = self->ichnls + self->input_offset;
- inputParameters.sampleFormat = sampleFormat;
- inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultHighInputLatency ;
- inputParameters.hostApiSpecificStreamInfo = NULL;
- }
-
- if (self->input == -1 && self->output == -1) {
- if (self->duplex == 1)
- 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);
- }
- else {
- if (self->duplex == 1)
- 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);
- }
- portaudio_assert(err, "Pa_OpenStream");
- if (err < 0) {
- Server_error(self, "Portaudio error: %s", Pa_GetErrorText(err));
- return -1;
- }
- return 0;
-}
-
-int
-Server_pa_deinit(Server *self)
-{
- PaError err;
- PyoPaBackendData *be_data = (PyoPaBackendData *) self->audio_be_data;
-
- if (Pa_IsStreamActive(be_data->stream) || ! Pa_IsStreamStopped(be_data->stream)) {
- self->server_started = 0;
- 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
-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_AbortStream(be_data->stream);
- portaudio_assert(err, "Pa_AbortStream");
- }
- err = Pa_StartStream(be_data->stream);
- portaudio_assert(err, "Pa_StartStream");
- return err;
-}
-
-int
-Server_pa_stop(Server *self)
-{
- 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, 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, "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 to 'system'\n");
- ret = -1;
- }
- i++;
- }
- free (ports);
- }
-
- if (self->jackautoout) {
- 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 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";
- jack_options_t options = JackNullOption;
- jack_status_t status;
- int sampleRate = 0;
- int bufferSize = 0;
- int nchnls = 0;
- int total_nchnls = 0;
- int index = 0;
- int ret = 0;
- 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->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);
- if (be_data->jack_client == NULL) {
- Server_error(self, "Jack error: Unable to create JACK client\n");
- if (status & JackServerFailed) {
- Server_debug(self, "Jack error: jack_client_open() failed, "
- "status = 0x%2.0x\n", status);
- }
- return -1;
- }
- if (status & JackServerStarted) {
- Server_warning(self, "JACK server started.\n");
- }
- if (strcmp(self->serverName, jack_get_client_name(be_data->jack_client)) ) {
- 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;
- Server_warning(self, "Sample rate set to Jack engine sample rate: %" PRIu32 "\n", sampleRate);
- }
- else {
- Server_debug(self, "Jack engine sample rate: %" PRIu32 "\n", sampleRate);
- }
- if (sampleRate <= 0) {
- Server_error(self, "Invalid Jack engine sample rate.");
- jack_client_close (be_data->jack_client);
- return -1;
- }
- bufferSize = jack_get_buffer_size(be_data->jack_client);
- if (bufferSize != self->bufferSize) {
- self->bufferSize = bufferSize;
- Server_warning(self, "Buffer size set to Jack engine buffer size: %" PRIu32 "\n", bufferSize);
- }
- else {
- Server_debug(self, "Jack engine buffer size: %" PRIu32 "\n", bufferSize);
- }
-
- 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_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
- }
-
- if ((be_data->jack_in_ports[index] == NULL)) {
- Server_error(self, "Jack: no more JACK input ports available\n");
- return -1;
- }
- }
-
- nchnls = total_nchnls = self->nchnls + self->output_offset;
- while (nchnls-- > 0) {
- 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,
- JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
- }
- if ((be_data->jack_out_ports[index] == NULL)) {
- Server_error(self, "Jack: no more JACK output ports available\n");
- return -1;
- }
- }
- jack_set_error_function (jack_error_cb);
- jack_set_sample_rate_callback(be_data->jack_client, jack_srate_cb, (void *) self);
- jack_on_shutdown (be_data->jack_client, jack_shutdown_cb, (void *) self);
- jack_set_buffer_size_callback (be_data->jack_client, jack_bufsize_cb, (void *) self);
- return 0;
-}
-
-int
-Server_jack_deinit (Server *self)
-{
- int ret = 0;
- PyoJackBackendData *be_data = (PyoJackBackendData *) self->audio_be_data;
- ret = jack_client_close(be_data->jack_client);
- free(be_data->jack_in_ports);
- free(be_data->jack_out_ports);
- free(self->audio_be_data);
- return ret;
-}
-
-int
-Server_jack_start (Server *self)
-{
- PyoJackBackendData *be_data = (PyoJackBackendData *) self->audio_be_data;
- jack_set_process_callback(be_data->jack_client, jack_callback, (void *) self);
- if (jack_activate (be_data->jack_client)) {
- Server_error(self, "Jack error: cannot activate jack client.\n");
- jack_client_close (be_data->jack_client);
- Server_shut_down(self);
- return -1;
- }
- Server_jack_autoconnect(self);
- return 0;
-}
-
-int
-Server_jack_stop (Server *self)
-{
- PyoJackBackendData *be_data = (PyoJackBackendData *) self->audio_be_data;
- int ret = jack_deactivate(be_data->jack_client);
- self->server_started = 0;
- return ret;
-}
-
-#endif
-
-#ifdef USE_COREAUDIO
-int
-Server_coreaudio_init(Server *self)
-{
- OSStatus err = kAudioHardwareNoError;
- UInt32 count, namelen, propertySize;
- int i, numdevices;
- char *name;
- AudioDeviceID mOutputDevice = kAudioDeviceUnknown;
- 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);
- err = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &count, devices);
- if (err != kAudioHardwareNoError) {
- Server_error(self, "Get kAudioHardwarePropertyDevices error %s\n", (char*)&err);
- free(devices);
- }
-
- numdevices = count / sizeof(AudioDeviceID);
- Server_debug(self, "Coreaudio : Number of devices: %i\n", numdevices);
-
- for (i=0; i<numdevices; ++i) {
- err = AudioDeviceGetPropertyInfo(devices[i], 0, false, kAudioDevicePropertyDeviceName, &count, 0);
- if (err != kAudioHardwareNoError) {
- 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) {
- Server_error(self, "Get kAudioDevicePropertyDeviceName error %s A %d %08X\n", (char*)&err, i, devices[i]);
- free(name);
- break;
- }
- Server_debug(self, " %d : \"%s\"\n", i, name);
- free(name);
- }
-
- /************************************/
- /* Acquire input and output devices */
- /************************************/
- /* 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);
- if (err != kAudioHardwareNoError) {
- 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) {
- Server_error(self, "Get kAudioDevicePropertyDeviceName error %s A %08X\n", (char*)&err, mInputDevice);
- }
- Server_debug(self, "Coreaudio : Uses input device : \"%s\"\n", name);
- self->input = mInputDevice;
- free(name);
- }
-
- /* Acquire output audio device */
- if (self->output != -1)
- mOutputDevice = devices[self->output];
-
- if (mOutputDevice==kAudioDeviceUnknown) {
- count = sizeof(mOutputDevice);
- err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice, &count, (void *) &mOutputDevice);
- if (err != kAudioHardwareNoError) {
- Server_error(self, "Get kAudioHardwarePropertyDefaultOutputDevice error %s\n", (char*)&err);
- return -1;
- }
- }
-
- 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) {
- Server_error(self, "Get kAudioDevicePropertyDeviceName error %s A %08X\n", (char*)&err, mOutputDevice);
- }
- Server_debug(self, "Coreaudio : Uses output device : \"%s\"\n", name);
- self->output = mOutputDevice;
- free(name);
-
- /*************************************************/
- /* Get in/out buffer frame and buffer frame size */
- /*************************************************/
- UInt32 bufferSize;
- AudioValueRange range;
- Float64 sampleRate;
-
- /* Get input device buffer frame size and buffer frame size range */
- if (self->duplex == 1) {
- count = sizeof(UInt32);
- err = AudioDeviceGetProperty(mInputDevice, 0, false, kAudioDevicePropertyBufferFrameSize, &count, &bufferSize);
- 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);
- if (err != kAudioHardwareNoError)
- 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);
- if (err != kAudioHardwareNoError)
- Server_error(self, "Get kAudioDevicePropertyBufferFrameSize error %s\n", (char*)&err);
- Server_debug(self, "Coreaudio : Coreaudio output device buffer size = %ld\n", bufferSize);
-
- count = sizeof(AudioValueRange);
- err = AudioDeviceGetProperty(mOutputDevice, 0, false, kAudioDevicePropertyBufferSizeRange, &count, &range);
- 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);
- if (err != kAudioHardwareNoError)
- 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 *********/
- /****************************************/
- /* set/get the buffersize for the devices */
- count = sizeof(UInt32);
- err = AudioDeviceSetProperty(mOutputDevice, &now, 0, false, kAudioDevicePropertyBufferFrameSize, count, &self->bufferSize);
- if (err != kAudioHardwareNoError) {
- Server_error(self, "set kAudioDevicePropertyBufferFrameSize error %4.4s\n", (char*)&err);
- self->bufferSize = bufferSize;
- err = AudioDeviceSetProperty(mOutputDevice, &now, 0, false, kAudioDevicePropertyBufferFrameSize, count, &self->bufferSize);
- if (err != kAudioHardwareNoError)
- 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);
-
- if (self->duplex == 1) {
- 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);
- double pyoSamplingRate = self->samplingRate;
- 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;
- err = AudioDeviceSetProperty(mOutputDevice, &now, 0, false, kAudioDevicePropertyNominalSampleRate, count, &sampleRate);
- if (err != kAudioHardwareNoError)
- Server_error(self, "set kAudioDevicePropertyNominalSampleRate error %s\n", (char*)&err);
- 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);
- }
- }
-
-
- /****************************************/
- /* Input and output stream descriptions */
- /****************************************/
- AudioStreamBasicDescription outputStreamDescription;
- AudioStreamBasicDescription inputStreamDescription;
-
- // Get input device stream configuration
- if (self->duplex == 1) {
- count = sizeof(AudioStreamBasicDescription);
- 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)
- Server_debug(self, "Get kAudioDevicePropertyNominalSampleRate error %s\n", (char*)&err);
- */
- Server_debug(self, "Coreaudio : Coreaudio driver input stream sampling rate = %.2f\n", inputStreamDescription.mSampleRate);
- 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);
- 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);
- 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);
- if (err != kAudioHardwareNoError)
- Server_debug(self, "Get kAudioDevicePropertyStreamFormat error %s\n", (char*)&err);
- */
- Server_debug(self, "Coreaudio : Coreaudio driver output stream sampling rate = %.2f\n", outputStreamDescription.mSampleRate);
- Server_debug(self, "Coreaudio : Coreaudio driver output stream bytes per frame = %i\n", outputStreamDescription.mBytesPerFrame);
- Server_debug(self, "Coreaudio : Coreaudio driver output stream number of channels = %i\n", outputStreamDescription.mChannelsPerFrame);
-
-
- /**************************************************/
- /********* 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
- 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;
- err = AudioDeviceGetProperty(self->input, 0, true, kAudioDevicePropertyIOProcStreamUsage, &propertySize, input_su);
- for (i=0; i<inputStreamDescription.mChannelsPerFrame; ++i) {
- input_su->mStreamIsOn[i] = 1;
- }
- 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
- if (err != kAudioHardwareNoError) {
- Server_error(self, "Output AudioDeviceAddIOProc failed %d\n", (int)err);
- return -1;
- }
- err = AudioDeviceGetPropertyInfo(self->output, 0, false, kAudioDevicePropertyIOProcStreamUsage, &propertySize, &writable);
- AudioHardwareIOProcStreamUsage *output_su = (AudioHardwareIOProcStreamUsage*)malloc(propertySize);
- output_su->mIOProc = (void*)coreaudio_output_callback;
- err = AudioDeviceGetProperty(self->output, 0, false, kAudioDevicePropertyIOProcStreamUsage, &propertySize, output_su);
- for (i=0; i<outputStreamDescription.mChannelsPerFrame; ++i) {
- output_su->mStreamIsOn[i] = 1;
- }
- err = AudioDeviceSetProperty(self->output, &now, 0, false, kAudioDevicePropertyIOProcStreamUsage, propertySize, output_su);
-
- return 0;
-}
-
-int
-Server_coreaudio_deinit(Server *self)
-{
- OSStatus err = kAudioHardwareNoError;
-
- if (self->duplex == 1) {
- err = AudioDeviceRemoveIOProc(self->input, coreaudio_input_callback);
- if (err != kAudioHardwareNoError) {
- Server_error(self, "Input AudioDeviceRemoveIOProc failed %d\n", (int)err);
- return -1;
- }
- }
+ va_end (args);
- err = AudioDeviceRemoveIOProc(self->output, coreaudio_output_callback);
- if (err != kAudioHardwareNoError) {
- Server_error(self, "Output AudioDeviceRemoveIOProc failed %d\n", (int)err);
- return -1;
+ PySys_WriteStdout("%s",buffer);
}
-
- return 0;
}
-int
-Server_coreaudio_start(Server *self)
+/* Warnings should be used when an unexpected or unusual
+ choice was made by pyo. */
+void
+Server_warning(Server *self, char * format, ...)
{
- OSStatus err = kAudioHardwareNoError;
-
- if (self->duplex == 1) {
- err = AudioDeviceStart(self->input, coreaudio_input_callback);
- 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;
+#ifndef NO_MESSAGES
+ if (self->verbosity & 4) {
+ char buffer[256];
+ va_list args;
+ va_start (args, format);
+ vsprintf (buffer,format, args);
+ va_end (args);
+ PySys_WriteStdout("%s",buffer);
}
- return 0;
+#endif
}
-int
-Server_coreaudio_stop(Server *self)
+/* Debug messages should print internal information which
+ might be necessary for debugging internal conditions. */
+void
+Server_debug(Server *self, char * format, ...)
{
- coreaudio_stop_callback(self);
- self->server_stopped = 1;
- return 0;
+ if (self->verbosity & 8) {
+ char buffer[256];
+ va_list args;
+ va_start (args, format);
+ vsprintf (buffer,format, args);
+ va_end (args);
+
+ PySys_WriteStdout("%s",buffer);
+ }
}
-#endif
+/** Offline server. **/
+/*********************/
-int
-Server_offline_init(Server *self)
+static int
+offline_process_block(Server *arg)
{
+ Server *server = (Server *) arg;
+ Server_process_buffers(server);
return 0;
}
-int
-Server_offline_deinit(Server *self)
-{
- return 0;
-}
+int Server_offline_init(Server *self) { return 0; };
+int Server_offline_deinit(Server *self) { return 0; };
void
*Server_offline_thread(void *arg)
@@ -1247,18 +249,11 @@ Server_offline_stop(Server *self)
return 0;
}
-/******* Embedded Server *******/
-int
-Server_embedded_init(Server *self)
-{
- return 0;
-}
+/** Embedded server. **/
+/**********************/
-int
-Server_embedded_deinit(Server *self)
-{
- return 0;
-}
+int Server_embedded_init(Server *self) { return 0; };
+int Server_embedded_deinit(Server *self) { return 0; };
/* interleaved embedded callback */
int
@@ -1269,7 +264,6 @@ Server_embedded_i_start(Server *self)
return 0;
}
-// To be easier to call without depending on the Server structure
int
Server_embedded_i_startIdx(int idx)
{
@@ -1282,22 +276,20 @@ int
Server_embedded_ni_start(Server *self)
{
int i, j;
+ float out[self->bufferSize * self->nchnls];
+
Server_process_buffers(self);
- float *out = (float *)calloc(self->bufferSize * self->nchnls, sizeof(float));
+
for (i=0; i<(self->bufferSize*self->nchnls); i++){
out[i] = self->output_buffer[i];
}
- /* Non-Interleaved */
for (i=0; i<self->bufferSize; i++) {
- for (j=0; j<=self->nchnls; j++) {
- /* TODO: This could probably be more efficient (ob) */
- self->output_buffer[i+(self->bufferSize*(j+1))-self->bufferSize] = out[(i*self->nchnls)+j];
+ for (j=0; j<self->nchnls; j++) {
+ self->output_buffer[(j*self->bufferSize)+i] = out[(i*self->nchnls)+j];
}
}
-
self->midi_count = 0;
-
return 0;
}
@@ -1328,8 +320,6 @@ Server_embedded_nb_start(Server *self)
return 0;
}
-/* 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)
{
@@ -1338,22 +328,31 @@ Server_embedded_stop(Server *self)
return 0;
}
-/***************************************************/
-/* Main Processing functions */
+/** Main Processing functions. **/
+/********************************/
-static inline void
+void
Server_process_buffers(Server *server)
{
+ //clock_t begin = clock();
+
float *out = server->output_buffer;
MYFLT buffer[server->nchnls][server->bufferSize];
- int i, j, chnl;
- int nchnls = server->nchnls;
+ int i, j, chnl, nchnls = server->nchnls;
MYFLT amp = server->amp;
Stream *stream_tmp;
MYFLT *data;
memset(&buffer, 0, sizeof(buffer));
+
+ /* This is the biggest bottle-neck of the callback. Don't know
+ how (or if possible) to improve GIL acquire/release.
+ */
PyGILState_STATE s = PyGILState_Ensure();
+
+ if (server->CALLBACK != NULL)
+ PyObject_Call((PyObject *)server->CALLBACK, PyTuple_New(0), NULL);
+
for (i=0; i<server->stream_count; i++) {
stream_tmp = (Stream *)PyList_GET_ITEM(server->streams, i);
if (Stream_getStreamActive(stream_tmp) == 1) {
@@ -1379,7 +378,9 @@ Server_process_buffers(Server *server)
Server_process_time(server);
}
server->elapsedSamples += server->bufferSize;
+
PyGILState_Release(s);
+
if (amp != server->lastAmp) {
server->timeCount = 0;
server->stepVal = (amp - server->currentAmp) / server->timeStep;
@@ -1395,12 +396,17 @@ Server_process_buffers(Server *server)
out[(i*server->nchnls)+j] = (float)buffer[j][i] * server->currentAmp;
}
}
+
+ /* Writing to disk is not real time safe. */
if (server->record == 1)
sf_write_float(server->recfile, out, server->bufferSize * server->nchnls);
+ //clock_t end = clock();
+ //double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
+ //printf("%f\n", time_spent);
}
-static void
+void
Server_process_gui(Server *server)
{
float rms[server->nchnls];
@@ -1456,7 +462,7 @@ Server_process_gui(Server *server)
}
}
-static void
+void
Server_process_time(Server *server)
{
int hours, minutes, seconds, milliseconds;
@@ -1479,25 +485,14 @@ Server_process_time(Server *server)
}
}
-/***************************************************/
-
-/* Global function called by any new audio object to
- get a pointer to the server */
PyObject *
-PyServer_get_server()
-{
- return (PyObject *)my_server[serverID];
-}
-
-static PyObject *
Server_shut_down(Server *self)
{
int i;
int ret = -1;
if (self->server_booted == 0) {
Server_error(self, "The Server must be booted!\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
if (self->server_started == 1) {
Server_stop((Server *)self);
@@ -1507,19 +502,24 @@ Server_shut_down(Server *self)
rnd_objs_count[i] = 0;
}
+ switch (self->midi_be_type) {
+ case PyoPortmidi:
+ if (self->withPortMidi == 1 || self->withPortMidiOut == 1)
+ ret = Server_pm_deinit(self);
+ break;
+ default:
+ break;
+ }
+
switch (self->audio_be_type) {
case PyoPortaudio:
ret = Server_pa_deinit(self);
break;
case PyoCoreaudio:
-#ifdef USE_COREAUDIO
ret = Server_coreaudio_deinit(self);
-#endif
break;
case PyoJack:
-#ifdef USE_JACK
ret = Server_jack_deinit(self);
-#endif
break;
case PyoOffline:
ret = Server_offline_deinit(self);
@@ -1536,15 +536,16 @@ Server_shut_down(Server *self)
Server_error(self, "Error closing audio backend.\n");
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
-/* handling of PyObjects */
static int
Server_traverse(Server *self, visitproc visit, void *arg)
{
- /* GUI and TIME ? */
+ Py_VISIT(self->GUI);
+ Py_VISIT(self->TIME);
+ if (self->CALLBACK != NULL)
+ Py_VISIT(self->CALLBACK);
Py_VISIT(self->streams);
Py_VISIT(self->jackAutoConnectInputPorts);
Py_VISIT(self->jackAutoConnectOutputPorts);
@@ -1554,6 +555,10 @@ Server_traverse(Server *self, visitproc visit, void *arg)
static int
Server_clear(Server *self)
{
+ Py_CLEAR(self->GUI);
+ Py_CLEAR(self->TIME);
+ if (self->CALLBACK != NULL)
+ Py_CLEAR(self->CALLBACK);
Py_CLEAR(self->streams);
Py_CLEAR(self->jackAutoConnectInputPorts);
Py_CLEAR(self->jackAutoConnectOutputPorts);
@@ -1569,14 +574,16 @@ Server_dealloc(Server* self)
free(self->input_buffer);
free(self->output_buffer);
free(self->serverName);
+ if (self->withGUI == 1)
+ free(self->lastRms);
my_server[self->thisServerID] = NULL;
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
Server_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- /* Unused variables to allow the safety check of the embeded audio backend. */
+ /* Unused variables to allow the safety check of the embedded audio backend. */
double samplingRate = 44100.0;
int nchnls = 2;
int ichnls = 2;
@@ -1592,20 +599,9 @@ Server_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return Py_False;
}
- /* TODO: Need some testing to validate that there is no conflict when more than one server are running at the same time. */
- /*
- if (strcmp(audioType, "embedded") != 0)
- {
- if (PyServer_get_server() != NULL) {
- PyErr_SetString(PyExc_RuntimeError, "Warning: Trying to create a new Server object while one is already created!\n");
- Py_RETURN_NONE;
- }
- }
- */
-
/* find the first free serverID */
for(serverID = 0; serverID < MAX_NBR_SERVER; serverID++){
- if(my_server[serverID] == NULL){
+ if (my_server[serverID] == NULL){
break;
}
}
@@ -1618,6 +614,7 @@ Server_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self = (Server *)type->tp_alloc(type, 0);
self->server_booted = 0;
self->audio_be_data = NULL;
+ self->midi_be_data = NULL;
self->serverName = (char *) calloc(32, sizeof(char));
self->jackautoin = 1;
self->jackautoout = 1;
@@ -1648,8 +645,10 @@ Server_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->recdur = -1;
self->recformat = 0;
self->rectype = 0;
+ self->recquality = 0.4;
self->startoffset = 0.0;
self->globalSeed = 0;
+ self->CALLBACK = NULL;
self->thisServerID = serverID;
Py_XDECREF(my_server[serverID]);
my_server[serverID] = (Server *)self;
@@ -1662,11 +661,13 @@ Server_init(Server *self, PyObject *args, PyObject *kwds)
static char *kwlist[] = {"sr", "nchnls", "buffersize", "duplex", "audio", "jackname", "ichnls", NULL};
char *audioType = "portaudio";
+ char *midiType = "portmidi";
char *serverName = "pyo";
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;
}
@@ -1689,6 +690,15 @@ Server_init(Server *self, PyObject *args, PyObject *kwds)
Server_warning(self, "Unknown audio type. Using Portaudio\n");
self->audio_be_type = PyoPortaudio;
}
+
+ if (strcmp(midiType, "portmidi") == 0 || strcmp(midiType, "pm") == 0 ) {
+ self->midi_be_type = PyoPortmidi;
+ }
+ else {
+ Server_warning(self, "Unknown midi type. Using Portmidi\n");
+ self->midi_be_type = PyoPortmidi;
+ }
+
strncpy(self->serverName, serverName, 32);
if (strlen(serverName) > 31) {
self->serverName[31] = '\0';
@@ -1697,6 +707,9 @@ Server_init(Server *self, PyObject *args, PyObject *kwds)
return 0;
}
+/** Server's setters. **/
+/***********************/
+
static PyObject *
Server_setDefaultRecPath(Server *self, PyObject *args, PyObject *kwds)
{
@@ -1705,8 +718,7 @@ Server_setDefaultRecPath(Server *self, PyObject *args, PyObject *kwds)
if (! PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &self->recpath))
return PyInt_FromLong(-1);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1714,15 +726,13 @@ Server_setInputOffset(Server *self, PyObject *arg)
{
if (self->server_booted) {
Server_warning(self, "Can't change input offset for booted server.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
if (arg != NULL) {
if (PyInt_Check(arg))
self->input_offset = PyInt_AsLong(arg);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1730,15 +740,13 @@ Server_setOutputOffset(Server *self, PyObject *arg)
{
if (self->server_booted) {
Server_warning(self, "Can't change output offset for booted server.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
if (arg != NULL) {
if (PyInt_Check(arg))
self->output_offset = PyInt_AsLong(arg);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1748,20 +756,19 @@ Server_setInputDevice(Server *self, PyObject *arg)
if (PyInt_Check(arg))
self->input = PyInt_AsLong(arg);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
Server_setInOutDevice(Server *self, PyObject *arg)
{
if (arg != NULL) {
- if (PyInt_Check(arg))
+ if (PyInt_Check(arg)) {
self->input = PyInt_AsLong(arg);
self->output = PyInt_AsLong(arg);
+ }
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1771,8 +778,7 @@ Server_setOutputDevice(Server *self, PyObject *arg)
if (PyInt_Check(arg))
self->output = PyInt_AsLong(arg);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1782,8 +788,7 @@ Server_setMidiInputDevice(Server *self, PyObject *arg)
if (PyInt_Check(arg))
self->midi_input = PyInt_AsLong(arg);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1793,16 +798,14 @@ Server_setMidiOutputDevice(Server *self, PyObject *arg)
if (PyInt_Check(arg))
self->midi_output = PyInt_AsLong(arg);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
Server_deactivateMidi(Server *self)
{
self->midiActive = 0;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1810,8 +813,7 @@ Server_setSamplingRate(Server *self, PyObject *arg)
{
if (self->server_booted) {
Server_warning(self, "Can't change sampling rate for booted server.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
if (arg != NULL && PyNumber_Check(arg)) {
self->samplingRate = PyFloat_AsDouble(arg);
@@ -1819,8 +821,7 @@ Server_setSamplingRate(Server *self, PyObject *arg)
else {
Server_error(self, "Sampling rate must be a number.\n");
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1828,8 +829,7 @@ Server_setNchnls(Server *self, PyObject *arg)
{
if (self->server_booted) {
Server_warning(self, "Can't change number of channels for booted server.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
if (arg != NULL && PyInt_Check(arg)) {
self->nchnls = PyInt_AsLong(arg);
@@ -1837,8 +837,7 @@ Server_setNchnls(Server *self, PyObject *arg)
else {
Server_error(self, "Number of channels must be an integer.\n");
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1846,8 +845,7 @@ 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;
+ Py_RETURN_NONE;
}
if (arg != NULL && PyInt_Check(arg)) {
self->ichnls = PyInt_AsLong(arg);
@@ -1855,8 +853,7 @@ Server_setIchnls(Server *self, PyObject *arg)
else {
Server_error(self, "Number of input channels must be an integer.\n");
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1864,8 +861,7 @@ Server_setBufferSize(Server *self, PyObject *arg)
{
if (self->server_booted) {
Server_warning(self, "Can't change buffer size for booted server.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
if (arg != NULL && PyInt_Check(arg)) {
self->bufferSize = PyInt_AsLong(arg);
@@ -1873,8 +869,7 @@ Server_setBufferSize(Server *self, PyObject *arg)
else {
Server_error(self, "Buffer size must be an integer.\n");
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1882,15 +877,13 @@ Server_setDuplex(Server *self, PyObject *arg)
{
if (self->server_booted) {
Server_warning(self,"Can't change duplex mode for booted server.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
if (arg != NULL) {
if (PyInt_Check(arg))
self->duplex = PyInt_AsLong(arg);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1899,15 +892,13 @@ 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;
+ Py_RETURN_NONE;
}
self->jackautoin = in;
self->jackautoout = out;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1924,8 +915,7 @@ Server_setJackAutoConnectInputPorts(Server *self, PyObject *arg)
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1942,31 +932,20 @@ Server_setJackAutoConnectOutputPorts(Server *self, PyObject *arg)
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
Server_setGlobalSeed(Server *self, PyObject *arg)
{
- unsigned int tmp;
+ self->globalSeed = 0;
- if (arg != NULL) {
- if (PyInt_Check(arg)) {
- tmp = PyInt_AsLong(arg);
- if (tmp < 0)
- self->globalSeed = 0;
- else
- self->globalSeed = tmp;
- }
- else
- self->globalSeed = 0;
+ if (arg != NULL && PyLong_Check(arg)) {
+ self->globalSeed = (int)PyInt_AsLong(arg);
+ self->globalSeed = self->globalSeed > 0 ? self->globalSeed : 0;
}
- else
- self->globalSeed = 0;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
int
@@ -2002,8 +981,7 @@ Server_setAmp(Server *self, PyObject *arg)
self->resetAmp = self->amp;
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2033,8 +1011,7 @@ Server_setAmpCallable(Server *self, PyObject *arg)
self->gcount = 0;
self->withGUI = 1;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2059,8 +1036,22 @@ Server_setTimeCallable(Server *self, PyObject *arg)
self->tcount = 0;
self->withTIME = 1;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+Server_setCallback(Server *self, PyObject *arg)
+{
+ PyObject *tmp;
+
+ ASSERT_ARG_NOT_NULL
+
+ tmp = arg;
+ Py_XDECREF(self->CALLBACK);
+ Py_INCREF(tmp);
+ self->CALLBACK = tmp;
+
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2074,8 +1065,7 @@ Server_setVerbosity(Server *self, PyObject *arg)
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2089,184 +1079,17 @@ Server_setStartOffset(Server *self, PyObject *arg)
}
}
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-int
-Server_pm_init(Server *self)
-{
- int i = 0;
- PmError pmerr;
-
- if (self->midiActive == 0) {
- self->withPortMidi = 0;
- self->withPortMidiOut = 0;
- return 0;
- }
-
- pmerr = Pm_Initialize();
- if (pmerr) {
- Server_warning(self, "Portmidi warning: could not initialize Portmidi: %s\n", Pm_GetErrorText(pmerr));
- 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 < 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",
- 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 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 < 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 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->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;
- for (i=0; i<self->midiin_count; i++) {
- Pm_SetFilter(self->midiin[i], PM_FILT_ACTIVE | PM_FILT_CLOCK);
- }
- }
- return 0;
+ Py_RETURN_NONE;
}
-
static PyObject *
Server_boot(Server *self, PyObject *arg)
{
- int audioerr = 0;
+ int audioerr = 0, midierr = 0;
int i;
if (self->server_booted == 1) {
Server_error(self, "Server already booted!\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
self->server_started = 0;
self->stream_count = 0;
@@ -2284,28 +1107,27 @@ Server_boot(Server *self, PyObject *arg)
switch (self->audio_be_type) {
case PyoPortaudio:
audioerr = Server_pa_init(self);
+ if (audioerr < 0) {
+ Server_pa_deinit(self);
+ if (audioerr == -10)
+ Server_error(self, "Pyo built without Portaudio support\n");
+ }
break;
case PyoJack:
-#ifdef USE_JACK
audioerr = Server_jack_init(self);
if (audioerr < 0) {
Server_jack_deinit(self);
+ if (audioerr == -10)
+ Server_error(self, "Pyo built without Jack support\n");
}
-#else
- audioerr = -1;
- Server_error(self, "Pyo built without Jack support\n");
-#endif
break;
case PyoCoreaudio:
-#ifdef USE_COREAUDIO
audioerr = Server_coreaudio_init(self);
if (audioerr < 0) {
Server_coreaudio_deinit(self);
+ if (audioerr == -10)
+ Server_error(self, "Pyo built without Coreaudio support\n");
}
-#else
- audioerr = -1;
- Server_error(self, "Pyo built without Coreaudio support\n");
-#endif
break;
case PyoOffline:
audioerr = Server_offline_init(self);
@@ -2351,40 +1173,47 @@ Server_boot(Server *self, PyObject *arg)
Server_error(self, "\nServer not booted.\n");
}
- Py_INCREF(Py_None);
- return Py_None;
+ if (self->audio_be_type != PyoOffline && self->audio_be_type != PyoOfflineNB && self->audio_be_type != PyoEmbedded) {
+ switch (self->midi_be_type) {
+ case PyoPortmidi:
+ midierr = Server_pm_init(self);
+ if (midierr < 0) {
+ Server_pm_deinit(self);
+ if (midierr == -10)
+ Server_error(self, "Pyo built without Portmidi support\n");
+ }
+ break;
+ }
+ }
+
+ Py_RETURN_NONE;
}
static PyObject *
Server_start(Server *self)
{
- int err = -1, midierr = 0;
+ int err = -1;
if (self->server_started == 1) {
Server_warning(self, "Server already started!\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
if (self->server_booted == 0) {
Server_warning(self, "The Server must be booted!\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
Server_debug(self, "Server_start: number of streams %d\n", self->stream_count);
/* Ensure Python is set up for threading */
- PyEval_InitThreads();
+ if (!PyEval_ThreadsInitialized()) {
+ PyEval_InitThreads();
+ }
self->server_stopped = 0;
self->server_started = 1;
self->timeStep = (int)(0.01 * self->samplingRate);
- if (self->audio_be_type != PyoOffline && self->audio_be_type != PyoOfflineNB && self->audio_be_type != PyoEmbedded) {
- midierr = Server_pm_init(self);
- Server_debug(self, "PortMidi initialization return code : %d.\n", midierr);
- }
-
if (self->startoffset > 0.0) {
Server_message(self,"Rendering %.2f seconds offline...\n", self->startoffset);
int numBlocks = ceil(self->startoffset * self->samplingRate/self->bufferSize);
@@ -2403,14 +1232,10 @@ Server_start(Server *self)
err = Server_pa_start(self);
break;
case PyoCoreaudio:
-#ifdef USE_COREAUDIO
err = Server_coreaudio_start(self);
-#endif
break;
case PyoJack:
-#ifdef USE_JACK
err = Server_jack_start(self);
-#endif
break;
case PyoOffline:
err = Server_offline_start(self);
@@ -2426,83 +1251,56 @@ Server_start(Server *self)
Server_error(self, "Error starting server.\n");
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
-static PyObject *
+PyObject *
Server_stop(Server *self)
{
- int i;
- int err = -1;
+ int err = 0;
if (self->server_started == 0) {
Server_warning(self, "The Server must be started!\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
switch (self->audio_be_type) {
case PyoPortaudio:
- err = Server_pa_stop(self);
- break;
+ err = Server_pa_stop(self); break;
case PyoCoreaudio:
-#ifdef USE_COREAUDIO
- err = Server_coreaudio_stop(self);
-#endif
- break;
+ err = Server_coreaudio_stop(self); break;
case PyoJack:
-#ifdef USE_JACK
- err = Server_jack_stop(self);
-#endif
- break;
+ err = Server_jack_stop(self); break;
case PyoOffline:
- err = Server_offline_stop(self);
- break;
+ err = Server_offline_stop(self); break;
case PyoOfflineNB:
- err = Server_offline_stop(self);
- break;
+ err = Server_offline_stop(self); break;
case PyoEmbedded:
- err = Server_embedded_stop(self);
- break;
+ err = Server_embedded_stop(self); break;
}
- if (err < 0) {
+ if (err != 0) {
Server_error(self, "Error stopping server.\n");
}
else {
self->server_stopped = 1;
- if (self->withPortMidi == 1) {
- for (i=0; i<self->midiin_count; i++) {
- Pm_Close(self->midiin[i]);
- }
- }
- if (self->withPortMidiOut == 1) {
- 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;
- self->withPortMidiOut = 0;
}
- Py_INCREF(Py_None);
- return Py_None;
+
+ /* This call is needed to recover from thread fork with python3/jack on debian.*/
+ /* TODO: Need to be tested with other OSes and audio driver. */
+ PyOS_AfterFork();
+
+ Py_RETURN_NONE;
}
static PyObject *
Server_recordOptions(Server *self, PyObject *args, PyObject *kwds)
{
- static char *kwlist[] = {"dur", "filename", "fileformat", "sampletype", NULL};
+ static char *kwlist[] = {"dur", "filename", "fileformat", "sampletype", "quality", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "d|sii", kwlist, &self->recdur, &self->recpath, &self->recformat, &self->rectype)) {
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "d|siid", kwlist, &self->recdur, &self->recpath, &self->recformat, &self->rectype, &self->recquality)) {
return PyInt_FromLong(-1);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2517,11 +1315,10 @@ Server_start_rec(Server *self, PyObject *args, PyObject *kwds)
}
Server_start_rec_internal(self, filename);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
-static int
+int
Server_start_rec_internal(Server *self, char *filename)
{
/* Prepare sfinfo */
@@ -2602,6 +1399,11 @@ Server_start_rec_internal(Server *self, char *filename)
}
}
+ /* Sets the encoding quality for FLAC and OGG compressed formats. */
+ if (self->recformat == 5 || self->recformat == 7) {
+ sf_command(self->recfile, SFC_SET_VBR_ENCODING_QUALITY, &self->recquality, sizeof(double));
+ }
+
self->record = 1;
return 0;
}
@@ -2612,8 +1414,7 @@ Server_stop_rec(Server *self, PyObject *args)
self->record = 0;
sf_close(self->recfile);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2633,8 +1434,7 @@ Server_addStream(Server *self, PyObject *args)
self->stream_count++;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject *
@@ -2660,8 +1460,7 @@ Server_removeStream(Server *self, int id)
}
PyGILState_Release(s);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject *
@@ -2698,160 +1497,165 @@ Server_changeStreamPosition(Server *self, PyObject *args)
PyList_Insert(self->streams, i, (PyObject *)cur_stream_tmp);
self->stream_count++;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
+}
+
+void pyoGetMidiEvents(Server *self) {
+ switch (self->midi_be_type) {
+ case PyoPortmidi:
+ portmidiGetEvents(self);
+ break;
+ default:
+ break;
+ }
}
PyObject *
Server_noteout(Server *self, PyObject *args)
{
- int i, pit, vel, chan, curtime;
- PmEvent buffer[1];
- PmTimestamp timestamp;
+ int pit, vel, chan;
+ PyoMidiTimestamp timestamp;
- if (! PyArg_ParseTuple(args, "iiii", &pit, &vel, &chan, ×tamp))
+ if (! PyArg_ParseTuple(args, "iiil", &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(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);
+ switch (self->midi_be_type) {
+ case PyoPortmidi:
+ pm_noteout(self, pit, vel, chan, timestamp);
+ break;
+ default:
+ break;
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject *
Server_afterout(Server *self, PyObject *args)
{
- int i, pit, vel, chan, curtime;
- PmEvent buffer[1];
- PmTimestamp timestamp;
+ int pit, vel, chan;
+ PyoMidiTimestamp timestamp;
- if (! PyArg_ParseTuple(args, "iiii", &pit, &vel, &chan, ×tamp))
+ if (! PyArg_ParseTuple(args, "iiil", &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);
+ switch (self->midi_be_type) {
+ case PyoPortmidi:
+ pm_afterout(self, pit, vel, chan, timestamp);
+ break;
+ default:
+ break;
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject *
Server_ctlout(Server *self, PyObject *args)
{
- int i, ctlnum, value, chan, curtime;
- PmEvent buffer[1];
- PmTimestamp timestamp;
+ int ctlnum, value, chan;
+ PyoMidiTimestamp timestamp;
- if (! PyArg_ParseTuple(args, "iiii", &ctlnum, &value, &chan, ×tamp))
+ if (! PyArg_ParseTuple(args, "iiil", &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);
+ switch (self->midi_be_type) {
+ case PyoPortmidi:
+ pm_ctlout(self, ctlnum, value, chan, timestamp);
+ break;
+ default:
+ break;
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject *
Server_programout(Server *self, PyObject *args)
{
- int i, value, chan, curtime;
- PmEvent buffer[1];
- PmTimestamp timestamp;
+ int value, chan;
+ PyoMidiTimestamp timestamp;
- if (! PyArg_ParseTuple(args, "iii", &value, &chan, ×tamp))
+ if (! PyArg_ParseTuple(args, "iil", &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);
+ switch (self->midi_be_type) {
+ case PyoPortmidi:
+ pm_programout(self, value, chan, timestamp);
+ break;
+ default:
+ break;
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject *
Server_pressout(Server *self, PyObject *args)
{
- int i, value, chan, curtime;
- PmEvent buffer[1];
- PmTimestamp timestamp;
+ int value, chan;
+ PyoMidiTimestamp timestamp;
- if (! PyArg_ParseTuple(args, "iii", &value, &chan, ×tamp))
+ if (! PyArg_ParseTuple(args, "iil", &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);
+ switch (self->midi_be_type) {
+ case PyoPortmidi:
+ pm_pressout(self, value, chan, timestamp);
+ break;
+ default:
+ break;
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject *
Server_bendout(Server *self, PyObject *args)
{
- int i, lsb, msb, value, chan, curtime;
- PmEvent buffer[1];
- PmTimestamp timestamp;
+ int value, chan;
+ PyoMidiTimestamp timestamp;
+
+ if (! PyArg_ParseTuple(args, "iil", &value, &chan, ×tamp))
+ return PyInt_FromLong(-1);
+
+ if (self->withPortMidiOut) {
+ switch (self->midi_be_type) {
+ case PyoPortmidi:
+ pm_bendout(self, value, chan, timestamp);
+ break;
+ default:
+ break;
+ }
+ }
+ Py_RETURN_NONE;
+}
+
+PyObject *
+Server_sysexout(Server *self, PyObject *args)
+{
+ unsigned char *msg;
+ int size;
+ PyoMidiTimestamp timestamp;
- if (! PyArg_ParseTuple(args, "iii", &value, &chan, ×tamp))
+ if (! PyArg_ParseTuple(args, "s#l", &msg, &size, ×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);
+ switch (self->midi_be_type) {
+ case PyoPortmidi:
+ pm_sysexout(self, msg, timestamp);
+ break;
+ default:
+ break;
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
MYFLT *
@@ -2859,9 +1663,9 @@ Server_getInputBuffer(Server *self) {
return (MYFLT *)self->input_buffer;
}
-PmEvent *
+PyoMidiEvent *
Server_getMidiEventBuffer(Server *self) {
- return (PmEvent *)self->midiEvents;
+ return (PyoMidiEvent *)self->midiEvents;
}
int
@@ -2873,16 +1677,15 @@ static PyObject *
Server_addMidiEvent(Server *self, PyObject *args)
{
int status, data1, data2;
- PmEvent buffer;
+ PyoMidiEvent buffer;
if (! PyArg_ParseTuple(args, "iii", &status, &data1, &data2))
return PyInt_FromLong(-1);
buffer.timestamp = 0;
- buffer.message = Pm_Message(status, data1, data2);
+ buffer.message = PyoMidi_Message(status, data1, data2);
self->midiEvents[self->midi_count++] = buffer;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
int
@@ -2938,8 +1741,7 @@ Server_beginResamplingBlock(Server *self, PyObject *arg)
self->lastResampling = self->currentResampling;
self->currentResampling = PyInt_AsLong(arg);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2947,8 +1749,7 @@ Server_endResamplingBlock(Server *self)
{
self->lastResampling = self->currentResampling;
self->currentResampling = 1;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2980,8 +1781,7 @@ static PyObject *
Server_setServer(Server *self)
{
serverID = self->thisServerID;
- /* TODO: Should return a more conventional signal, like True or False */
- return PyString_FromString("Server set");
+ return PyInt_FromLong(serverID);
}
@@ -2990,7 +1790,7 @@ Server_getInputAddr(Server *self)
{
char address[32];
sprintf(address, "%p", &self->input_buffer[0]);
- return PyString_FromString(address);
+ return PyUnicode_FromString(address);
}
@@ -2999,7 +1799,7 @@ Server_getOutputAddr(Server *self)
{
char address[32];
sprintf(address, "%p", &self->output_buffer[0]);
- return PyString_FromString(address);
+ return PyUnicode_FromString(address);
}
static PyObject *
@@ -3013,7 +1813,7 @@ Server_getServerAddr(Server *self)
{
char address[32];
sprintf(address, "%p", &my_server[self->thisServerID]);
- return PyString_FromString(address);
+ return PyUnicode_FromString(address);
}
void
@@ -3028,7 +1828,7 @@ Server_getThisServerFunc(Server *self)
{
char address[32];
sprintf(address, "%p", &Server_getThisServer);
- return PyString_FromString(address);
+ return PyUnicode_FromString(address);
}
*/
@@ -3037,7 +1837,50 @@ Server_getEmbedICallbackAddr(Server *self)
{
char address[32];
sprintf(address, "%p", &Server_embedded_i_startIdx);
- return PyString_FromString(address);
+ return PyUnicode_FromString(address);
+}
+
+static PyObject *
+Server_getCurrentTime(Server *self)
+{
+ int hours, minutes, seconds, milliseconds;
+ float sr = self->samplingRate;
+ double sampsToSecs;
+ char curtime[20];
+
+ sampsToSecs = (double)(self->elapsedSamples / sr);
+ seconds = (int)sampsToSecs;
+ milliseconds = (int)((sampsToSecs - seconds) * 1000);
+ minutes = seconds / 60;
+ hours = minutes / 60;
+ minutes = minutes % 60;
+ seconds = seconds % 60;
+ sprintf(curtime, "%02d : %02d : %02d : %03d", hours, minutes, seconds, milliseconds);
+ return PyUnicode_FromString(curtime);
+}
+
+static PyObject *
+Server_getCurrentAmp(Server *self)
+{
+ PyObject *amplist;
+ float rms[self->nchnls];
+ float *out = self->output_buffer;
+ float outAmp;
+ int i,j;
+ for (j=0; j<self->nchnls; j++) {
+ rms[j] = 0.0;
+ for (i=0; i<self->bufferSize; i++) {
+ outAmp = out[(i*self->nchnls)+j];
+ outAmp *= outAmp;
+ if (outAmp > rms[j])
+ rms[j] = outAmp;
+ }
+ }
+ amplist = PyTuple_New(self->nchnls);
+ for (i=0; i<self->nchnls; i++) {
+ PyTuple_SET_ITEM(amplist, i, PyFloat_FromDouble(rms[i]));
+ }
+ return amplist;
}
static PyMethodDef Server_methods[] = {
@@ -3063,6 +1906,7 @@ static PyMethodDef Server_methods[] = {
{"setAmp", (PyCFunction)Server_setAmp, METH_O, "Sets the overall amplitude."},
{"setAmpCallable", (PyCFunction)Server_setAmpCallable, METH_O, "Sets the Server's GUI callable object."},
{"setTimeCallable", (PyCFunction)Server_setTimeCallable, METH_O, "Sets the Server's TIME callable object."},
+ {"setCallback", (PyCFunction)Server_setCallback, METH_O, "Sets the Server's CALLBACK callable object."},
{"setVerbosity", (PyCFunction)Server_setVerbosity, METH_O, "Sets the verbosity."},
{"setStartOffset", (PyCFunction)Server_setStartOffset, METH_O, "Sets starting time offset."},
{"boot", (PyCFunction)Server_boot, METH_O, "Setup and boot the server."},
@@ -3084,6 +1928,7 @@ static PyMethodDef Server_methods[] = {
{"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."},
+ {"sysexout", (PyCFunction)Server_sysexout, METH_VARARGS, "Send a system exclusive message to midi output stream."},
{"addMidiEvent", (PyCFunction)Server_addMidiEvent, METH_VARARGS, "Add a midi event manually (without using portmidi callback)."},
{"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."},
@@ -3101,6 +1946,8 @@ static PyMethodDef Server_methods[] = {
{"getServerID", (PyCFunction)Server_getServerID, METH_NOARGS, "Get the embedded device server memory address"},
{"getServerAddr", (PyCFunction)Server_getServerAddr, METH_NOARGS, "Get the embedded device server memory address"},
{"getEmbedICallbackAddr", (PyCFunction)Server_getEmbedICallbackAddr, METH_NOARGS, "Get the embedded device interleaved callback method memory address"},
+ {"getCurrentTime", (PyCFunction)Server_getCurrentTime, METH_NOARGS, "Get the current time as a formatted string."},
+ {"getCurrentAmp", (PyCFunction)Server_getCurrentAmp, METH_NOARGS, "Get the current global amplitudes as a list of floats."},
{NULL} /* Sentinel */
};
@@ -3110,8 +1957,7 @@ static PyMemberDef Server_members[] = {
};
PyTypeObject ServerType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Server", /*tp_name*/
sizeof(Server), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3119,7 +1965,7 @@ PyTypeObject ServerType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3149,4 +1995,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 ccbe3b8..9e800be 100644
--- a/src/engine/streammodule.c
+++ b/src/engine/streammodule.c
@@ -53,7 +53,7 @@ Stream_dealloc(Stream* self)
{
self->data = NULL;
Stream_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
int
@@ -185,8 +185,7 @@ static PyMethodDef Stream_methods[] = {
};
PyTypeObject StreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"pyo.Stream", /*tp_name*/
sizeof(Stream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -194,7 +193,7 @@ PyTypeObject StreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -255,7 +254,7 @@ static void
TriggerStream_dealloc(TriggerStream* self)
{
self->data = NULL;
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
MYFLT *
@@ -271,8 +270,7 @@ TriggerStream_setData(TriggerStream *self, MYFLT *data)
}
PyTypeObject TriggerStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"pyo.TriggerStream", /*tp_name*/
sizeof(TriggerStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -280,7 +278,7 @@ PyTypeObject TriggerStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/analysismodule.c b/src/objects/analysismodule.c
index 5244129..461e2b1 100644
--- a/src/objects/analysismodule.c
+++ b/src/objects/analysismodule.c
@@ -18,6 +18,7 @@
* License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -179,7 +180,7 @@ Follower_dealloc(Follower* self)
{
pyo_DEALLOC
Follower_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -305,7 +306,7 @@ static PyNumberMethods Follower_as_number = {
(binaryfunc)Follower_add, /*nb_add*/
(binaryfunc)Follower_sub, /*nb_subtract*/
(binaryfunc)Follower_multiply, /*nb_multiply*/
-(binaryfunc)Follower_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -319,16 +320,16 @@ static PyNumberMethods Follower_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Follower_inplace_add, /*inplace_add*/
(binaryfunc)Follower_inplace_sub, /*inplace_subtract*/
(binaryfunc)Follower_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Follower_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -337,15 +338,14 @@ static PyNumberMethods Follower_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Follower_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Follower_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject FollowerType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Follower_base", /*tp_name*/
sizeof(Follower), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -353,7 +353,7 @@ sizeof(Follower), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Follower_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -640,7 +640,7 @@ Follower2_dealloc(Follower2* self)
{
pyo_DEALLOC
Follower2_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -806,7 +806,7 @@ static PyNumberMethods Follower2_as_number = {
(binaryfunc)Follower2_add, /*nb_add*/
(binaryfunc)Follower2_sub, /*nb_subtract*/
(binaryfunc)Follower2_multiply, /*nb_multiply*/
- (binaryfunc)Follower2_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -820,16 +820,16 @@ static PyNumberMethods Follower2_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Follower2_inplace_add, /*inplace_add*/
(binaryfunc)Follower2_inplace_sub, /*inplace_subtract*/
(binaryfunc)Follower2_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Follower2_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -838,15 +838,14 @@ static PyNumberMethods Follower2_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Follower2_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Follower2_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject Follower2Type = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Follower2_base", /*tp_name*/
sizeof(Follower2), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -854,7 +853,7 @@ PyTypeObject Follower2Type = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Follower2_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1001,7 +1000,7 @@ ZCross_dealloc(ZCross* self)
{
pyo_DEALLOC
ZCross_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1103,7 +1102,7 @@ static PyNumberMethods ZCross_as_number = {
(binaryfunc)ZCross_add, /*nb_add*/
(binaryfunc)ZCross_sub, /*nb_subtract*/
(binaryfunc)ZCross_multiply, /*nb_multiply*/
-(binaryfunc)ZCross_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1117,16 +1116,16 @@ static PyNumberMethods ZCross_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)ZCross_inplace_add, /*inplace_add*/
(binaryfunc)ZCross_inplace_sub, /*inplace_subtract*/
(binaryfunc)ZCross_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)ZCross_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1135,15 +1134,14 @@ static PyNumberMethods ZCross_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)ZCross_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)ZCross_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ZCrossType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.ZCross_base", /*tp_name*/
sizeof(ZCross), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1151,7 +1149,7 @@ sizeof(ZCross), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&ZCross_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1367,7 +1365,7 @@ Yin_dealloc(Yin* self)
free(self->input_buffer);
free(self->yin_buffer);
Yin_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1533,7 +1531,7 @@ static PyNumberMethods Yin_as_number = {
(binaryfunc)Yin_add, /*nb_add*/
(binaryfunc)Yin_sub, /*nb_subtract*/
(binaryfunc)Yin_multiply, /*nb_multiply*/
-(binaryfunc)Yin_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1547,16 +1545,16 @@ static PyNumberMethods Yin_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Yin_inplace_add, /*inplace_add*/
(binaryfunc)Yin_inplace_sub, /*inplace_subtract*/
(binaryfunc)Yin_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Yin_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1565,15 +1563,14 @@ static PyNumberMethods Yin_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Yin_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Yin_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject YinType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Yin_base", /*tp_name*/
sizeof(Yin), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1581,7 +1578,7 @@ sizeof(Yin), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Yin_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1778,7 +1775,7 @@ Centroid_dealloc(Centroid* self)
free(self->twiddle);
free(self->window);
Centroid_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1801,7 +1798,7 @@ Centroid_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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);
+ PySys_WriteStdout("Warning : Centroid size less than buffer size!\nCentroid size set to buffersize: %d\n", self->bufsize);
self->size = self->bufsize;
}
@@ -1876,7 +1873,7 @@ 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*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1890,16 +1887,16 @@ static PyNumberMethods Centroid_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*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*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1908,15 +1905,14 @@ static PyNumberMethods Centroid_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Centroid_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Centroid_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject CentroidType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Centroid_base", /*tp_name*/
sizeof(Centroid), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1924,7 +1920,7 @@ sizeof(Centroid), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Centroid_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2110,7 +2106,7 @@ AttackDetector_dealloc(AttackDetector* self)
pyo_DEALLOC
free(self->buffer);
AttackDetector_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2328,7 +2324,7 @@ 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*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2342,16 +2338,16 @@ static PyNumberMethods AttackDetector_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*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*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2360,15 +2356,14 @@ static PyNumberMethods AttackDetector_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)AttackDetector_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)AttackDetector_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject AttackDetectorType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.AttackDetector_base", /*tp_name*/
sizeof(AttackDetector), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2376,7 +2371,7 @@ sizeof(AttackDetector), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&AttackDetector_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2488,7 +2483,7 @@ Scope_dealloc(Scope* self)
pyo_DEALLOC
free(self->buffer);
Scope_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2600,8 +2595,7 @@ static PyMethodDef Scope_methods[] = {
};
PyTypeObject ScopeType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Scope_base", /*tp_name*/
sizeof(Scope), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2609,7 +2603,7 @@ sizeof(Scope), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2749,7 +2743,7 @@ PeakAmp_dealloc(PeakAmp* self)
{
pyo_DEALLOC
PeakAmp_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2841,7 +2835,7 @@ 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*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2855,16 +2849,16 @@ static PyNumberMethods PeakAmp_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*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*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2873,15 +2867,14 @@ static PyNumberMethods PeakAmp_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)PeakAmp_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)PeakAmp_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject PeakAmpType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PeakAmp_base", /*tp_name*/
sizeof(PeakAmp), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2889,7 +2882,7 @@ sizeof(PeakAmp), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&PeakAmp_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/arithmeticmodule.c b/src/objects/arithmeticmodule.c
index 443925a..b22ba3b 100644
--- a/src/objects/arithmeticmodule.c
+++ b/src/objects/arithmeticmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -125,7 +126,7 @@ M_Sin_dealloc(M_Sin* self)
{
pyo_DEALLOC
M_Sin_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -211,7 +212,7 @@ static PyNumberMethods M_Sin_as_number = {
(binaryfunc)M_Sin_add, /*nb_add*/
(binaryfunc)M_Sin_sub, /*nb_subtract*/
(binaryfunc)M_Sin_multiply, /*nb_multiply*/
-(binaryfunc)M_Sin_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -225,16 +226,16 @@ static PyNumberMethods M_Sin_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Sin_inplace_add, /*inplace_add*/
(binaryfunc)M_Sin_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Sin_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)M_Sin_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -243,15 +244,14 @@ static PyNumberMethods M_Sin_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)M_Sin_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)M_Sin_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_SinType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Sin_base", /*tp_name*/
sizeof(M_Sin), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -259,7 +259,7 @@ sizeof(M_Sin), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Sin_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -390,7 +390,7 @@ M_Cos_dealloc(M_Cos* self)
{
pyo_DEALLOC
M_Cos_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -476,7 +476,7 @@ static PyNumberMethods M_Cos_as_number = {
(binaryfunc)M_Cos_add, /*nb_add*/
(binaryfunc)M_Cos_sub, /*nb_subtract*/
(binaryfunc)M_Cos_multiply, /*nb_multiply*/
- (binaryfunc)M_Cos_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -490,16 +490,16 @@ static PyNumberMethods M_Cos_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Cos_inplace_add, /*inplace_add*/
(binaryfunc)M_Cos_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Cos_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Cos_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -508,15 +508,14 @@ static PyNumberMethods M_Cos_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Cos_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Cos_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_CosType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Cos_base", /*tp_name*/
sizeof(M_Cos), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -524,7 +523,7 @@ PyTypeObject M_CosType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Cos_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -655,7 +654,7 @@ M_Tan_dealloc(M_Tan* self)
{
pyo_DEALLOC
M_Tan_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -741,7 +740,7 @@ static PyNumberMethods M_Tan_as_number = {
(binaryfunc)M_Tan_add, /*nb_add*/
(binaryfunc)M_Tan_sub, /*nb_subtract*/
(binaryfunc)M_Tan_multiply, /*nb_multiply*/
- (binaryfunc)M_Tan_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -755,16 +754,16 @@ static PyNumberMethods M_Tan_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Tan_inplace_add, /*inplace_add*/
(binaryfunc)M_Tan_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Tan_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Tan_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -773,15 +772,14 @@ static PyNumberMethods M_Tan_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Tan_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Tan_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_TanType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Tan_base", /*tp_name*/
sizeof(M_Tan), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -789,7 +787,7 @@ PyTypeObject M_TanType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Tan_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -925,7 +923,7 @@ M_Abs_dealloc(M_Abs* self)
{
pyo_DEALLOC
M_Abs_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1011,7 +1009,7 @@ static PyNumberMethods M_Abs_as_number = {
(binaryfunc)M_Abs_add, /*nb_add*/
(binaryfunc)M_Abs_sub, /*nb_subtract*/
(binaryfunc)M_Abs_multiply, /*nb_multiply*/
- (binaryfunc)M_Abs_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1025,16 +1023,16 @@ static PyNumberMethods M_Abs_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Abs_inplace_add, /*inplace_add*/
(binaryfunc)M_Abs_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Abs_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Abs_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1043,15 +1041,14 @@ static PyNumberMethods M_Abs_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Abs_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Abs_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_AbsType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Abs_base", /*tp_name*/
sizeof(M_Abs), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1059,7 +1056,7 @@ PyTypeObject M_AbsType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Abs_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1195,7 +1192,7 @@ M_Sqrt_dealloc(M_Sqrt* self)
{
pyo_DEALLOC
M_Sqrt_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1281,7 +1278,7 @@ static PyNumberMethods M_Sqrt_as_number = {
(binaryfunc)M_Sqrt_add, /*nb_add*/
(binaryfunc)M_Sqrt_sub, /*nb_subtract*/
(binaryfunc)M_Sqrt_multiply, /*nb_multiply*/
- (binaryfunc)M_Sqrt_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1295,16 +1292,16 @@ static PyNumberMethods M_Sqrt_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Sqrt_inplace_add, /*inplace_add*/
(binaryfunc)M_Sqrt_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Sqrt_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Sqrt_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1313,15 +1310,14 @@ static PyNumberMethods M_Sqrt_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Sqrt_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Sqrt_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_SqrtType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Sqrt_base", /*tp_name*/
sizeof(M_Sqrt), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1329,7 +1325,7 @@ PyTypeObject M_SqrtType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Sqrt_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1465,7 +1461,7 @@ M_Log_dealloc(M_Log* self)
{
pyo_DEALLOC
M_Log_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1551,7 +1547,7 @@ static PyNumberMethods M_Log_as_number = {
(binaryfunc)M_Log_add, /*nb_add*/
(binaryfunc)M_Log_sub, /*nb_subtract*/
(binaryfunc)M_Log_multiply, /*nb_multiply*/
- (binaryfunc)M_Log_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1565,16 +1561,16 @@ static PyNumberMethods M_Log_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Log_inplace_add, /*inplace_add*/
(binaryfunc)M_Log_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Log_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Log_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1583,15 +1579,14 @@ static PyNumberMethods M_Log_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Log_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Log_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_LogType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Log_base", /*tp_name*/
sizeof(M_Log), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1599,7 +1594,7 @@ PyTypeObject M_LogType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Log_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1735,7 +1730,7 @@ M_Log10_dealloc(M_Log10* self)
{
pyo_DEALLOC
M_Log10_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1821,7 +1816,7 @@ static PyNumberMethods M_Log10_as_number = {
(binaryfunc)M_Log10_add, /*nb_add*/
(binaryfunc)M_Log10_sub, /*nb_subtract*/
(binaryfunc)M_Log10_multiply, /*nb_multiply*/
- (binaryfunc)M_Log10_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1835,16 +1830,16 @@ static PyNumberMethods M_Log10_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Log10_inplace_add, /*inplace_add*/
(binaryfunc)M_Log10_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Log10_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Log10_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1853,15 +1848,14 @@ static PyNumberMethods M_Log10_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Log10_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Log10_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_Log10Type = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Log10_base", /*tp_name*/
sizeof(M_Log10), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1869,7 +1863,7 @@ PyTypeObject M_Log10Type = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Log10_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2005,7 +1999,7 @@ M_Log2_dealloc(M_Log2* self)
{
pyo_DEALLOC
M_Log2_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2091,7 +2085,7 @@ static PyNumberMethods M_Log2_as_number = {
(binaryfunc)M_Log2_add, /*nb_add*/
(binaryfunc)M_Log2_sub, /*nb_subtract*/
(binaryfunc)M_Log2_multiply, /*nb_multiply*/
- (binaryfunc)M_Log2_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2105,16 +2099,16 @@ static PyNumberMethods M_Log2_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Log2_inplace_add, /*inplace_add*/
(binaryfunc)M_Log2_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Log2_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Log2_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2123,15 +2117,14 @@ static PyNumberMethods M_Log2_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Log2_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Log2_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_Log2Type = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Log2_base", /*tp_name*/
sizeof(M_Log2), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2139,7 +2132,7 @@ PyTypeObject M_Log2Type = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Log2_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2327,7 +2320,7 @@ M_Pow_dealloc(M_Pow* self)
{
pyo_DEALLOC
M_Pow_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2488,7 +2481,7 @@ static PyNumberMethods M_Pow_as_number = {
(binaryfunc)M_Pow_add, /*nb_add*/
(binaryfunc)M_Pow_sub, /*nb_subtract*/
(binaryfunc)M_Pow_multiply, /*nb_multiply*/
- (binaryfunc)M_Pow_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2502,16 +2495,16 @@ static PyNumberMethods M_Pow_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Pow_inplace_add, /*inplace_add*/
(binaryfunc)M_Pow_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Pow_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Pow_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2520,15 +2513,14 @@ static PyNumberMethods M_Pow_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Pow_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Pow_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_PowType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Pow_base", /*tp_name*/
sizeof(M_Pow), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2536,7 +2528,7 @@ PyTypeObject M_PowType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Pow_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2724,7 +2716,7 @@ M_Atan2_dealloc(M_Atan2* self)
{
pyo_DEALLOC
M_Atan2_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2885,7 +2877,7 @@ static PyNumberMethods M_Atan2_as_number = {
(binaryfunc)M_Atan2_add, /*nb_add*/
(binaryfunc)M_Atan2_sub, /*nb_subtract*/
(binaryfunc)M_Atan2_multiply, /*nb_multiply*/
- (binaryfunc)M_Atan2_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2899,16 +2891,16 @@ static PyNumberMethods M_Atan2_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Atan2_inplace_add, /*inplace_add*/
(binaryfunc)M_Atan2_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Atan2_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Atan2_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2917,15 +2909,14 @@ static PyNumberMethods M_Atan2_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Atan2_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Atan2_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_Atan2Type = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Atan2_base", /*tp_name*/
sizeof(M_Atan2), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2933,7 +2924,7 @@ PyTypeObject M_Atan2Type = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Atan2_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3064,7 +3055,7 @@ M_Floor_dealloc(M_Floor* self)
{
pyo_DEALLOC
M_Floor_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3150,7 +3141,7 @@ static PyNumberMethods M_Floor_as_number = {
(binaryfunc)M_Floor_add, /*nb_add*/
(binaryfunc)M_Floor_sub, /*nb_subtract*/
(binaryfunc)M_Floor_multiply, /*nb_multiply*/
- (binaryfunc)M_Floor_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3164,16 +3155,16 @@ static PyNumberMethods M_Floor_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Floor_inplace_add, /*inplace_add*/
(binaryfunc)M_Floor_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Floor_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Floor_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3182,15 +3173,14 @@ static PyNumberMethods M_Floor_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Floor_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Floor_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_FloorType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Floor_base", /*tp_name*/
sizeof(M_Floor), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3198,7 +3188,7 @@ PyTypeObject M_FloorType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Floor_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3329,7 +3319,7 @@ M_Ceil_dealloc(M_Ceil* self)
{
pyo_DEALLOC
M_Ceil_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3415,7 +3405,7 @@ static PyNumberMethods M_Ceil_as_number = {
(binaryfunc)M_Ceil_add, /*nb_add*/
(binaryfunc)M_Ceil_sub, /*nb_subtract*/
(binaryfunc)M_Ceil_multiply, /*nb_multiply*/
- (binaryfunc)M_Ceil_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3429,16 +3419,16 @@ static PyNumberMethods M_Ceil_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Ceil_inplace_add, /*inplace_add*/
(binaryfunc)M_Ceil_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Ceil_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Ceil_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3447,15 +3437,14 @@ static PyNumberMethods M_Ceil_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Ceil_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Ceil_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_CeilType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Ceil_base", /*tp_name*/
sizeof(M_Ceil), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3463,7 +3452,7 @@ PyTypeObject M_CeilType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Ceil_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3594,7 +3583,7 @@ M_Round_dealloc(M_Round* self)
{
pyo_DEALLOC
M_Round_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3680,7 +3669,7 @@ static PyNumberMethods M_Round_as_number = {
(binaryfunc)M_Round_add, /*nb_add*/
(binaryfunc)M_Round_sub, /*nb_subtract*/
(binaryfunc)M_Round_multiply, /*nb_multiply*/
- (binaryfunc)M_Round_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3694,16 +3683,16 @@ static PyNumberMethods M_Round_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)M_Round_inplace_add, /*inplace_add*/
(binaryfunc)M_Round_inplace_sub, /*inplace_subtract*/
(binaryfunc)M_Round_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)M_Round_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3712,15 +3701,14 @@ static PyNumberMethods M_Round_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)M_Round_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)M_Round_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_RoundType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Round_base", /*tp_name*/
sizeof(M_Round), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3728,7 +3716,7 @@ PyTypeObject M_RoundType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Round_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3859,7 +3847,7 @@ M_Tanh_dealloc(M_Tanh* self)
{
pyo_DEALLOC
M_Tanh_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3945,7 +3933,7 @@ 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*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3959,16 +3947,16 @@ static PyNumberMethods M_Tanh_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*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*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3977,15 +3965,14 @@ static PyNumberMethods M_Tanh_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)M_Tanh_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)M_Tanh_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject M_TanhType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.M_Tanh_base", /*tp_name*/
sizeof(M_Tanh), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3993,7 +3980,7 @@ sizeof(M_Tanh), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&M_Tanh_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4023,4 +4010,268 @@ M_Tanh_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
M_Tanh_new, /* tp_new */
-};
\ No newline at end of file
+};
+
+/************/
+/* M_Exp */
+/************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ int modebuffer[2]; // need at least 2 slots for mul & add
+} M_Exp;
+
+static void
+M_Exp_process(M_Exp *self) {
+ int i;
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = MYEXP(in[i]);
+ }
+}
+
+static void M_Exp_postprocessing_ii(M_Exp *self) { POST_PROCESSING_II };
+static void M_Exp_postprocessing_ai(M_Exp *self) { POST_PROCESSING_AI };
+static void M_Exp_postprocessing_ia(M_Exp *self) { POST_PROCESSING_IA };
+static void M_Exp_postprocessing_aa(M_Exp *self) { POST_PROCESSING_AA };
+static void M_Exp_postprocessing_ireva(M_Exp *self) { POST_PROCESSING_IREVA };
+static void M_Exp_postprocessing_areva(M_Exp *self) { POST_PROCESSING_AREVA };
+static void M_Exp_postprocessing_revai(M_Exp *self) { POST_PROCESSING_REVAI };
+static void M_Exp_postprocessing_revaa(M_Exp *self) { POST_PROCESSING_REVAA };
+static void M_Exp_postprocessing_revareva(M_Exp *self) { POST_PROCESSING_REVAREVA };
+
+static void
+M_Exp_setProcMode(M_Exp *self)
+{
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ self->proc_func_ptr = M_Exp_process;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = M_Exp_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = M_Exp_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = M_Exp_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = M_Exp_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = M_Exp_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = M_Exp_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = M_Exp_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = M_Exp_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = M_Exp_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+M_Exp_compute_next_data_frame(M_Exp *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+M_Exp_traverse(M_Exp *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->input);
+ Py_VISIT(self->input_stream);
+ return 0;
+}
+
+static int
+M_Exp_clear(M_Exp *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
+ return 0;
+}
+
+static void
+M_Exp_dealloc(M_Exp* self)
+{
+ pyo_DEALLOC
+ M_Exp_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+static PyObject *
+M_Exp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *inputtmp, *input_streamtmp, *multmp=NULL, *addtmp=NULL;
+ M_Exp *self;
+ self = (M_Exp *)type->tp_alloc(type, 0);
+
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, M_Exp_compute_next_data_frame);
+ self->mode_func_ptr = M_Exp_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_Exp_getServer(M_Exp* self) { GET_SERVER };
+static PyObject * M_Exp_getStream(M_Exp* self) { GET_STREAM };
+static PyObject * M_Exp_setMul(M_Exp *self, PyObject *arg) { SET_MUL };
+static PyObject * M_Exp_setAdd(M_Exp *self, PyObject *arg) { SET_ADD };
+static PyObject * M_Exp_setSub(M_Exp *self, PyObject *arg) { SET_SUB };
+static PyObject * M_Exp_setDiv(M_Exp *self, PyObject *arg) { SET_DIV };
+
+static PyObject * M_Exp_play(M_Exp *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * M_Exp_out(M_Exp *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * M_Exp_stop(M_Exp *self) { STOP };
+
+static PyObject * M_Exp_multiply(M_Exp *self, PyObject *arg) { MULTIPLY };
+static PyObject * M_Exp_inplace_multiply(M_Exp *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * M_Exp_add(M_Exp *self, PyObject *arg) { ADD };
+static PyObject * M_Exp_inplace_add(M_Exp *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * M_Exp_sub(M_Exp *self, PyObject *arg) { SUB };
+static PyObject * M_Exp_inplace_sub(M_Exp *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * M_Exp_div(M_Exp *self, PyObject *arg) { DIV };
+static PyObject * M_Exp_inplace_div(M_Exp *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef M_Exp_members[] = {
+{"server", T_OBJECT_EX, offsetof(M_Exp, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(M_Exp, stream), 0, "Stream object."},
+{"input", T_OBJECT_EX, offsetof(M_Exp, input), 0, "Input sound object."},
+{"mul", T_OBJECT_EX, offsetof(M_Exp, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(M_Exp, add), 0, "Add factor."},
+{NULL} /* Sentinel */
+};
+
+static PyMethodDef M_Exp_methods[] = {
+{"getServer", (PyCFunction)M_Exp_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)M_Exp_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)M_Exp_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"stop", (PyCFunction)M_Exp_stop, METH_NOARGS, "Stops computing."},
+{"out", (PyCFunction)M_Exp_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"setMul", (PyCFunction)M_Exp_setMul, METH_O, "Sets oscillator mul factor."},
+{"setAdd", (PyCFunction)M_Exp_setAdd, METH_O, "Sets oscillator add factor."},
+{"setSub", (PyCFunction)M_Exp_setSub, METH_O, "Sets inverse add factor."},
+{"setDiv", (PyCFunction)M_Exp_setDiv, METH_O, "Sets inverse mul factor."},
+{NULL} /* Sentinel */
+};
+
+static PyNumberMethods M_Exp_as_number = {
+(binaryfunc)M_Exp_add, /*nb_add*/
+(binaryfunc)M_Exp_sub, /*nb_subtract*/
+(binaryfunc)M_Exp_multiply, /*nb_multiply*/
+INITIALIZE_NB_DIVIDE_ZERO /*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*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+0, /*nb_int*/
+0, /*nb_long*/
+0, /*nb_float*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+(binaryfunc)M_Exp_inplace_add, /*inplace_add*/
+(binaryfunc)M_Exp_inplace_sub, /*inplace_subtract*/
+(binaryfunc)M_Exp_inplace_multiply, /*inplace_multiply*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+(binaryfunc)M_Exp_div, /*nb_true_divide*/
+0, /*nb_inplace_floor_divide*/
+(binaryfunc)M_Exp_inplace_div, /*nb_inplace_true_divide*/
+0, /* nb_index */
+};
+
+PyTypeObject M_ExpType = {
+PyVarObject_HEAD_INIT(NULL, 0)
+"_pyo.M_Exp_base", /*tp_name*/
+sizeof(M_Exp), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)M_Exp_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_as_async (tp_compare in Python 2)*/
+0, /*tp_repr*/
+&M_Exp_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_Exp objects. Performs exp function on audio samples.", /* tp_doc */
+(traverseproc)M_Exp_traverse, /* tp_traverse */
+(inquiry)M_Exp_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+M_Exp_methods, /* tp_methods */
+M_Exp_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_Exp_new, /* tp_new */
+};
diff --git a/src/objects/bandsplitmodule.c b/src/objects/bandsplitmodule.c
index 1703f89..b5bfebe 100644
--- a/src/objects/bandsplitmodule.c
+++ b/src/objects/bandsplitmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -54,7 +55,6 @@ typedef struct {
int modebuffer[1];
} BandSplitter;
-
static void
BandSplitter_compute_variables(BandSplitter *self, MYFLT q)
{
@@ -73,7 +73,7 @@ BandSplitter_compute_variables(BandSplitter *self, MYFLT q)
self->b0[i] = alpha;
self->b2[i] = -alpha;
- self->a0[i] = 1 + alpha;
+ self->a0[i] = 1.0 / (1 + alpha);
self->a1[i] = -2 * c;
self->a2[i] = 1 - alpha;
}
@@ -104,12 +104,11 @@ BandSplitter_filters_i(BandSplitter *self) {
for (j=0; j<self->bands; j++) {
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];
+ 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->buffer_streams[i + j * self->bufsize] = self->y1[j] = val;
self->x2[j] = self->x1[j];
self->x1[j] = in[i];
- self->buffer_streams[i + j * self->bufsize] = val;
}
}
}
@@ -132,12 +131,11 @@ BandSplitter_filters_a(BandSplitter *self) {
for (i=0; i<self->bufsize; i++) {
BandSplitter_compute_variables((BandSplitter *)self, q[i]);
for (j=0; j<self->bands; j++) {
- 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];
+ 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->buffer_streams[i + j * self->bufsize] = self->y1[j] = val;
self->x2[j] = self->x1[j];
self->x1[j] = in[i];
- self->buffer_streams[i + j * self->bufsize] = val;
}
}
}
@@ -208,7 +206,7 @@ BandSplitter_dealloc(BandSplitter* self)
free(self->a2);
free(self->buffer_streams);
BandSplitter_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -228,7 +226,7 @@ BandSplitter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Stream_setFunctionPtr(self->stream, BandSplitter_compute_next_data_frame);
self->mode_func_ptr = BandSplitter_setProcMode;
- self->halfSr = self->sr / 2.;
+ self->halfSr = self->sr / 2.01;
self->TwoPiOnSr = TWOPI / self->sr;
static char *kwlist[] = {"input", "bands", "min", "max", "q", NULL};
@@ -322,8 +320,7 @@ static PyMethodDef BandSplitter_methods[] = {
};
PyTypeObject BandSplitterType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.BandSplitter_base", /*tp_name*/
sizeof(BandSplitter), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -331,7 +328,7 @@ sizeof(BandSplitter), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -454,7 +451,7 @@ BandSplit_dealloc(BandSplit* self)
{
pyo_DEALLOC
BandSplit_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -542,7 +539,7 @@ static PyNumberMethods BandSplit_as_number = {
(binaryfunc)BandSplit_add, /*nb_add*/
(binaryfunc)BandSplit_sub, /*nb_subtract*/
(binaryfunc)BandSplit_multiply, /*nb_multiply*/
-(binaryfunc)BandSplit_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -556,16 +553,16 @@ static PyNumberMethods BandSplit_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)BandSplit_inplace_add, /*inplace_add*/
(binaryfunc)BandSplit_inplace_sub, /*inplace_subtract*/
(binaryfunc)BandSplit_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)BandSplit_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -574,15 +571,14 @@ static PyNumberMethods BandSplit_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)BandSplit_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)BandSplit_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BandSplitType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.BandSplit_base", /*tp_name*/
sizeof(BandSplit), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -590,7 +586,7 @@ sizeof(BandSplit), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&BandSplit_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -847,7 +843,7 @@ FourBandMain_dealloc(FourBandMain* self)
pyo_DEALLOC
free(self->buffer_streams);
FourBandMain_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1022,8 +1018,7 @@ static PyMethodDef FourBandMain_methods[] = {
};
PyTypeObject FourBandMainType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.FourBandMain_base", /*tp_name*/
sizeof(FourBandMain), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1031,7 +1026,7 @@ PyTypeObject FourBandMainType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1154,7 +1149,7 @@ FourBand_dealloc(FourBand* self)
{
pyo_DEALLOC
FourBand_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1242,7 +1237,7 @@ static PyNumberMethods FourBand_as_number = {
(binaryfunc)FourBand_add, /*nb_add*/
(binaryfunc)FourBand_sub, /*nb_subtract*/
(binaryfunc)FourBand_multiply, /*nb_multiply*/
- (binaryfunc)FourBand_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1256,16 +1251,16 @@ static PyNumberMethods FourBand_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)FourBand_inplace_add, /*inplace_add*/
(binaryfunc)FourBand_inplace_sub, /*inplace_subtract*/
(binaryfunc)FourBand_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)FourBand_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1274,15 +1269,14 @@ static PyNumberMethods FourBand_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)FourBand_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)FourBand_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject FourBandType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.FourBand_base", /*tp_name*/
sizeof(FourBand), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1290,7 +1284,7 @@ PyTypeObject FourBandType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&FourBand_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/chorusmodule.c b/src/objects/chorusmodule.c
index 662a00c..498548b 100644
--- a/src/objects/chorusmodule.c
+++ b/src/objects/chorusmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -418,7 +419,7 @@ Chorus_dealloc(Chorus* self)
free(self->buffer[i]);
}
Chorus_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -518,6 +519,18 @@ static PyObject * Chorus_div(Chorus *self, PyObject *arg) { DIV };
static PyObject * Chorus_inplace_div(Chorus *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
+Chorus_reset(Chorus *self)
+{
+ int i, j;
+ for (i=0; i<8; i++) {
+ for (j=0; j<(self->size[i]+1); j++) {
+ self->buffer[i][j] = 0.;
+ }
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *
Chorus_setDepth(Chorus *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -628,6 +641,7 @@ static PyMethodDef Chorus_methods[] = {
{"play", (PyCFunction)Chorus_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"out", (PyCFunction)Chorus_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
{"stop", (PyCFunction)Chorus_stop, METH_NOARGS, "Stops computing."},
+{"reset", (PyCFunction)Chorus_reset, METH_NOARGS, "Reset the delay line."},
{"setFeedback", (PyCFunction)Chorus_setFeedback, METH_O, "Sets feedback value between 0 -> 1."},
{"setDepth", (PyCFunction)Chorus_setDepth, METH_O, "Sets chorus depth."},
{"setMix", (PyCFunction)Chorus_setMix, METH_O, "Sets balance between dry and wet signals."},
@@ -642,7 +656,7 @@ static PyNumberMethods Chorus_as_number = {
(binaryfunc)Chorus_add, /*nb_add*/
(binaryfunc)Chorus_sub, /*nb_subtract*/
(binaryfunc)Chorus_multiply, /*nb_multiply*/
-(binaryfunc)Chorus_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -656,16 +670,16 @@ static PyNumberMethods Chorus_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Chorus_inplace_add, /*inplace_add*/
(binaryfunc)Chorus_inplace_sub, /*inplace_subtract*/
(binaryfunc)Chorus_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Chorus_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -674,15 +688,14 @@ static PyNumberMethods Chorus_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Chorus_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Chorus_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ChorusType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Chorus_base", /*tp_name*/
sizeof(Chorus), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -690,7 +703,7 @@ sizeof(Chorus), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Chorus_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/compressmodule.c b/src/objects/compressmodule.c
index 01e7f54..fe5ec25 100644
--- a/src/objects/compressmodule.c
+++ b/src/objects/compressmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -52,7 +53,7 @@ typedef struct {
static MYFLT
C_clip(MYFLT x)
{
- if (x <= 0.0)
+ if (x < 0.00000001)
return 0.00000001;
else if (x > 1.0)
return 1.0;
@@ -240,7 +241,7 @@ Compress_dealloc(Compress* self)
pyo_DEALLOC
free(self->lh_buffer);
Compress_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -470,7 +471,7 @@ Compress_setLookAhead(Compress *self, PyObject *arg)
if (tmp <= 25.0)
self->lh_delay = (long)(tmp * 0.001 * self->sr);
else
- printf("lookahead must be less than 25.0 ms.\n");
+ PySys_WriteStdout("Compress: lookahead argument must be less than 25.0 ms.\n");
}
Py_INCREF(Py_None);
@@ -489,7 +490,7 @@ Compress_setKnee(Compress *self, PyObject *arg)
if (tmp >= 0.0 && tmp <= 1.0)
self->knee = tmp;
else
- printf("knee must be in range 0 (hard) -> 1 (soft).\n");
+ PySys_WriteStdout("Compress: knee argument must be in range 0 (hard) -> 1 (soft).\n");
}
Py_INCREF(Py_None);
@@ -532,7 +533,7 @@ static PyNumberMethods Compress_as_number = {
(binaryfunc)Compress_add, /*nb_add*/
(binaryfunc)Compress_sub, /*nb_subtract*/
(binaryfunc)Compress_multiply, /*nb_multiply*/
-(binaryfunc)Compress_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -546,16 +547,16 @@ static PyNumberMethods Compress_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Compress_inplace_add, /*inplace_add*/
(binaryfunc)Compress_inplace_sub, /*inplace_subtract*/
(binaryfunc)Compress_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Compress_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -564,15 +565,14 @@ static PyNumberMethods Compress_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Compress_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Compress_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject CompressType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Compress_base", /*tp_name*/
sizeof(Compress), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -580,7 +580,7 @@ sizeof(Compress), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Compress_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1218,7 +1218,7 @@ Gate_dealloc(Gate* self)
pyo_DEALLOC
free(self->lh_buffer);
Gate_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1420,7 +1420,7 @@ Gate_setLookAhead(Gate *self, PyObject *arg)
if (tmp <= 25.0)
self->lh_delay = (long)(tmp * 0.001 * self->sr);
else
- printf("lookahead must be less than 25.0 ms.\n");
+ PySys_WriteStdout("Gate: lookahead argument must be less than 25.0 ms.\n");
}
Py_INCREF(Py_None);
@@ -1460,7 +1460,7 @@ static PyNumberMethods Gate_as_number = {
(binaryfunc)Gate_add, /*nb_add*/
(binaryfunc)Gate_sub, /*nb_subtract*/
(binaryfunc)Gate_multiply, /*nb_multiply*/
- (binaryfunc)Gate_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1474,16 +1474,16 @@ static PyNumberMethods Gate_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Gate_inplace_add, /*inplace_add*/
(binaryfunc)Gate_inplace_sub, /*inplace_subtract*/
(binaryfunc)Gate_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Gate_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1492,15 +1492,14 @@ static PyNumberMethods Gate_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Gate_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Gate_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject GateType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Gate_base", /*tp_name*/
sizeof(Gate), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1508,7 +1507,7 @@ PyTypeObject GateType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Gate_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1714,7 +1713,7 @@ Balance_dealloc(Balance* self)
{
pyo_DEALLOC
Balance_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1850,7 +1849,7 @@ static PyNumberMethods Balance_as_number = {
(binaryfunc)Balance_add, /*nb_add*/
(binaryfunc)Balance_sub, /*nb_subtract*/
(binaryfunc)Balance_multiply, /*nb_multiply*/
- (binaryfunc)Balance_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1864,16 +1863,16 @@ static PyNumberMethods Balance_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Balance_inplace_add, /*inplace_add*/
(binaryfunc)Balance_inplace_sub, /*inplace_subtract*/
(binaryfunc)Balance_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Balance_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1882,15 +1881,14 @@ static PyNumberMethods Balance_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Balance_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Balance_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BalanceType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Balance_base", /*tp_name*/
sizeof(Balance), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1898,7 +1896,7 @@ PyTypeObject BalanceType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Balance_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/convolvemodule.c b/src/objects/convolvemodule.c
index 424f8c0..841c277 100644
--- a/src/objects/convolvemodule.c
+++ b/src/objects/convolvemodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -147,7 +148,7 @@ Convolve_dealloc(Convolve* self)
pyo_DEALLOC
free(self->input_tmp);
Convolve_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -270,7 +271,7 @@ static PyNumberMethods Convolve_as_number = {
(binaryfunc)Convolve_add, /*nb_add*/
(binaryfunc)Convolve_sub, /*nb_subtract*/
(binaryfunc)Convolve_multiply, /*nb_multiply*/
-(binaryfunc)Convolve_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -284,16 +285,16 @@ static PyNumberMethods Convolve_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Convolve_inplace_add, /*inplace_add*/
(binaryfunc)Convolve_inplace_sub, /*inplace_subtract*/
(binaryfunc)Convolve_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Convolve_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -302,15 +303,14 @@ static PyNumberMethods Convolve_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Convolve_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Convolve_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ConvolveType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Convolve_base", /*tp_name*/
sizeof(Convolve), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -318,7 +318,7 @@ sizeof(Convolve), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Convolve_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -617,7 +617,7 @@ IRWinSinc_dealloc(IRWinSinc* self)
free(self->impulse);
free(self->impulse_tmp);
IRWinSinc_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -802,7 +802,7 @@ static PyNumberMethods IRWinSinc_as_number = {
(binaryfunc)IRWinSinc_add, /*nb_add*/
(binaryfunc)IRWinSinc_sub, /*nb_subtract*/
(binaryfunc)IRWinSinc_multiply, /*nb_multiply*/
- (binaryfunc)IRWinSinc_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -816,16 +816,16 @@ static PyNumberMethods IRWinSinc_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)IRWinSinc_inplace_add, /*inplace_add*/
(binaryfunc)IRWinSinc_inplace_sub, /*inplace_subtract*/
(binaryfunc)IRWinSinc_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)IRWinSinc_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -834,15 +834,14 @@ static PyNumberMethods IRWinSinc_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)IRWinSinc_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)IRWinSinc_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject IRWinSincType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.IRWinSinc_base", /*tp_name*/
sizeof(IRWinSinc), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -850,7 +849,7 @@ PyTypeObject IRWinSincType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&IRWinSinc_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1024,7 +1023,7 @@ IRAverage_dealloc(IRAverage* self)
free(self->input_tmp);
free(self->impulse);
IRAverage_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1114,7 +1113,7 @@ static PyNumberMethods IRAverage_as_number = {
(binaryfunc)IRAverage_add, /*nb_add*/
(binaryfunc)IRAverage_sub, /*nb_subtract*/
(binaryfunc)IRAverage_multiply, /*nb_multiply*/
- (binaryfunc)IRAverage_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1128,16 +1127,16 @@ static PyNumberMethods IRAverage_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)IRAverage_inplace_add, /*inplace_add*/
(binaryfunc)IRAverage_inplace_sub, /*inplace_subtract*/
(binaryfunc)IRAverage_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)IRAverage_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1146,15 +1145,14 @@ static PyNumberMethods IRAverage_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)IRAverage_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)IRAverage_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject IRAverageType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.IRAverage_base", /*tp_name*/
sizeof(IRAverage), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1162,7 +1160,7 @@ PyTypeObject IRAverageType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&IRAverage_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1480,7 +1478,7 @@ IRPulse_dealloc(IRPulse* self)
free(self->input_tmp);
free(self->impulse);
IRPulse_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1666,7 +1664,7 @@ static PyNumberMethods IRPulse_as_number = {
(binaryfunc)IRPulse_add, /*nb_add*/
(binaryfunc)IRPulse_sub, /*nb_subtract*/
(binaryfunc)IRPulse_multiply, /*nb_multiply*/
- (binaryfunc)IRPulse_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1680,16 +1678,16 @@ static PyNumberMethods IRPulse_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)IRPulse_inplace_add, /*inplace_add*/
(binaryfunc)IRPulse_inplace_sub, /*inplace_subtract*/
(binaryfunc)IRPulse_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)IRPulse_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1698,15 +1696,14 @@ static PyNumberMethods IRPulse_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)IRPulse_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)IRPulse_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject IRPulseType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.IRPulse_base", /*tp_name*/
sizeof(IRPulse), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1714,7 +1711,7 @@ PyTypeObject IRPulseType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&IRPulse_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1963,7 +1960,7 @@ IRFM_dealloc(IRFM* self)
free(self->input_tmp);
free(self->impulse);
IRFM_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2167,7 +2164,7 @@ static PyNumberMethods IRFM_as_number = {
(binaryfunc)IRFM_add, /*nb_add*/
(binaryfunc)IRFM_sub, /*nb_subtract*/
(binaryfunc)IRFM_multiply, /*nb_multiply*/
- (binaryfunc)IRFM_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2181,16 +2178,16 @@ static PyNumberMethods IRFM_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)IRFM_inplace_add, /*inplace_add*/
(binaryfunc)IRFM_inplace_sub, /*inplace_subtract*/
(binaryfunc)IRFM_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)IRFM_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2199,15 +2196,14 @@ static PyNumberMethods IRFM_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)IRFM_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)IRFM_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject IRFMType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.IRFM_base", /*tp_name*/
sizeof(IRFM), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2215,7 +2211,7 @@ PyTypeObject IRFMType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&IRFM_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/delaymodule.c b/src/objects/delaymodule.c
index 0566768..528d048 100644
--- a/src/objects/delaymodule.c
+++ b/src/objects/delaymodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -305,7 +306,7 @@ Delay_dealloc(Delay* self)
pyo_DEALLOC
free(self->buffer);
Delay_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -493,7 +494,7 @@ static PyNumberMethods Delay_as_number = {
(binaryfunc)Delay_add, /*nb_add*/
(binaryfunc)Delay_sub, /*nb_subtract*/
(binaryfunc)Delay_multiply, /*nb_multiply*/
- (binaryfunc)Delay_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -507,16 +508,16 @@ static PyNumberMethods Delay_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Delay_inplace_add, /*inplace_add*/
(binaryfunc)Delay_inplace_sub, /*inplace_subtract*/
(binaryfunc)Delay_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Delay_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -525,15 +526,14 @@ static PyNumberMethods Delay_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Delay_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Delay_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject DelayType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Delay_base", /*tp_name*/
sizeof(Delay), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -541,7 +541,7 @@ PyTypeObject DelayType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Delay_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -746,7 +746,7 @@ SDelay_dealloc(SDelay* self)
pyo_DEALLOC
free(self->buffer);
SDelay_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -892,7 +892,7 @@ static PyNumberMethods SDelay_as_number = {
(binaryfunc)SDelay_add, /*nb_add*/
(binaryfunc)SDelay_sub, /*nb_subtract*/
(binaryfunc)SDelay_multiply, /*nb_multiply*/
- (binaryfunc)SDelay_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -906,16 +906,16 @@ static PyNumberMethods SDelay_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)SDelay_inplace_add, /*inplace_add*/
(binaryfunc)SDelay_inplace_sub, /*inplace_subtract*/
(binaryfunc)SDelay_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)SDelay_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -924,15 +924,14 @@ static PyNumberMethods SDelay_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)SDelay_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)SDelay_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SDelayType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SDelay_base", /*tp_name*/
sizeof(SDelay), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -940,7 +939,7 @@ PyTypeObject SDelayType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&SDelay_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1430,7 +1429,7 @@ Waveguide_dealloc(Waveguide* self)
pyo_DEALLOC
free(self->buffer);
Waveguide_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1525,6 +1524,24 @@ static PyObject * Waveguide_div(Waveguide *self, PyObject *arg) { DIV };
static PyObject * Waveguide_inplace_div(Waveguide *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
+Waveguide_reset(Waveguide *self)
+{
+ int i;
+
+ for (i=0; i<(self->size+1); i++) {
+ self->buffer[i] = 0.;
+ }
+ for(i=0; i<4; i++) {
+ self->lagrange[i] = 0.0;
+ }
+ self->lpsamp = 0.0;
+ self->xn1 = 0.0;
+ self->yn1 = 0.0;
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
Waveguide_setFreq(Waveguide *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -1603,6 +1620,7 @@ static PyMethodDef Waveguide_methods[] = {
{"play", (PyCFunction)Waveguide_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"out", (PyCFunction)Waveguide_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
{"stop", (PyCFunction)Waveguide_stop, METH_NOARGS, "Stops computing."},
+{"reset", (PyCFunction)Waveguide_reset, METH_NOARGS, "Reset the delay line."},
{"setFreq", (PyCFunction)Waveguide_setFreq, METH_O, "Sets freq time in seconds."},
{"setDur", (PyCFunction)Waveguide_setDur, METH_O, "Sets dur value between 0 -> 1."},
{"setMul", (PyCFunction)Waveguide_setMul, METH_O, "Sets oscillator mul factor."},
@@ -1616,7 +1634,7 @@ static PyNumberMethods Waveguide_as_number = {
(binaryfunc)Waveguide_add, /*nb_add*/
(binaryfunc)Waveguide_sub, /*nb_subtract*/
(binaryfunc)Waveguide_multiply, /*nb_multiply*/
-(binaryfunc)Waveguide_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1630,16 +1648,16 @@ static PyNumberMethods Waveguide_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Waveguide_inplace_add, /*inplace_add*/
(binaryfunc)Waveguide_inplace_sub, /*inplace_subtract*/
(binaryfunc)Waveguide_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Waveguide_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1648,15 +1666,14 @@ static PyNumberMethods Waveguide_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Waveguide_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Waveguide_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject WaveguideType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Waveguide_base", /*tp_name*/
sizeof(Waveguide), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1664,7 +1681,7 @@ sizeof(Waveguide), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Waveguide_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2441,7 +2458,7 @@ AllpassWG_dealloc(AllpassWG* self)
free(self->alpbuffer[i]);
}
AllpassWG_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2540,6 +2557,24 @@ static PyObject * AllpassWG_div(AllpassWG *self, PyObject *arg) { DIV };
static PyObject * AllpassWG_inplace_div(AllpassWG *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
+AllpassWG_reset(AllpassWG *self)
+{
+ int i, j;
+ for (i=0; i<(self->size+1); i++) {
+ self->buffer[i] = 0.;
+ }
+ for (i=0; i<3; i++) {
+ for (j=0; j<(self->alpsize+1); j++) {
+ self->alpbuffer[i][j] = 0.;
+ }
+ }
+ self->in_count = self->alp_in_count[0] = self->alp_in_count[1] = self->alp_in_count[2] = 0;
+ self->xn1 = self->yn1 = 0.0;
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
AllpassWG_setFreq(AllpassWG *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -2650,6 +2685,7 @@ static PyMethodDef AllpassWG_methods[] = {
{"play", (PyCFunction)AllpassWG_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"out", (PyCFunction)AllpassWG_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
{"stop", (PyCFunction)AllpassWG_stop, METH_NOARGS, "Stops computing."},
+ {"reset", (PyCFunction)AllpassWG_reset, METH_NOARGS, "Reset the delay line."},
{"setFreq", (PyCFunction)AllpassWG_setFreq, METH_O, "Sets freq time in seconds."},
{"setFeed", (PyCFunction)AllpassWG_setFeed, METH_O, "Sets feed value between 0 -> 1."},
{"setDetune", (PyCFunction)AllpassWG_setDetune, METH_O, "Sets detune value between 0 -> 1."},
@@ -2664,7 +2700,7 @@ static PyNumberMethods AllpassWG_as_number = {
(binaryfunc)AllpassWG_add, /*nb_add*/
(binaryfunc)AllpassWG_sub, /*nb_subtract*/
(binaryfunc)AllpassWG_multiply, /*nb_multiply*/
- (binaryfunc)AllpassWG_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2678,16 +2714,16 @@ static PyNumberMethods AllpassWG_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)AllpassWG_inplace_add, /*inplace_add*/
(binaryfunc)AllpassWG_inplace_sub, /*inplace_subtract*/
(binaryfunc)AllpassWG_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)AllpassWG_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2696,15 +2732,14 @@ static PyNumberMethods AllpassWG_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)AllpassWG_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)AllpassWG_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject AllpassWGType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.AllpassWG_base", /*tp_name*/
sizeof(AllpassWG), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2712,7 +2747,7 @@ PyTypeObject AllpassWGType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&AllpassWG_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2845,7 +2880,7 @@ Delay1_dealloc(Delay1* self)
{
pyo_DEALLOC
Delay1_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2932,7 +2967,7 @@ static PyNumberMethods Delay1_as_number = {
(binaryfunc)Delay1_add, /*nb_add*/
(binaryfunc)Delay1_sub, /*nb_subtract*/
(binaryfunc)Delay1_multiply, /*nb_multiply*/
-(binaryfunc)Delay1_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2946,16 +2981,16 @@ static PyNumberMethods Delay1_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Delay1_inplace_add, /*inplace_add*/
(binaryfunc)Delay1_inplace_sub, /*inplace_subtract*/
(binaryfunc)Delay1_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Delay1_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2964,15 +2999,14 @@ static PyNumberMethods Delay1_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Delay1_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Delay1_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject Delay1Type = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Delay1_base", /*tp_name*/
sizeof(Delay1), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2980,7 +3014,7 @@ sizeof(Delay1), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Delay1_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3427,7 +3461,7 @@ SmoothDelay_dealloc(SmoothDelay* self)
pyo_DEALLOC
free(self->buffer);
SmoothDelay_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3600,8 +3634,7 @@ SmoothDelay_reset(SmoothDelay *self)
for (i=0; i<(self->size+1); i++) {
self->buffer[i] = 0.;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyMemberDef SmoothDelay_members[] = {
@@ -3636,7 +3669,7 @@ 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*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3650,16 +3683,16 @@ static PyNumberMethods SmoothDelay_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*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*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3668,15 +3701,14 @@ static PyNumberMethods SmoothDelay_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)SmoothDelay_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)SmoothDelay_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SmoothDelayType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SmoothDelay_base", /*tp_name*/
sizeof(SmoothDelay), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3684,7 +3716,7 @@ PyTypeObject SmoothDelayType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&SmoothDelay_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/distomodule.c b/src/objects/distomodule.c
index 4782382..1eb929b 100644
--- a/src/objects/distomodule.c
+++ b/src/objects/distomodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -39,9 +40,8 @@ typedef struct {
MYFLT y1; // sample memory
} Disto;
-static MYFLT
-_clip(MYFLT x)
-{
+/* old version (prior to 0.8.0) with atan2
+static MYFLT _clip(MYFLT x) {
if (x < 0)
return 0;
else if (x > 1)
@@ -70,72 +70,78 @@ Disto_transform_ii(Disto *self) {
self->data[i] = val;
}
}
-
+*/
static void
-Disto_transform_ai(Disto *self) {
- MYFLT val, drv, coeff;
+Disto_transform_ii(Disto *self) {
int i;
+ MYFLT val;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ MYFLT drv = PyFloat_AS_DOUBLE(self->drive);
+ MYFLT slp = PyFloat_AS_DOUBLE(self->slope);
- MYFLT *drive = Stream_getData((Stream *)self->drive_stream);
- MYFLT slp = _clip(PyFloat_AS_DOUBLE(self->slope));
+ drv = (drv < 0.0) ? 0.0 : (drv > 0.998) ? 0.998 : drv;
+ drv = (2.0 * drv) / (1 - drv);
+ slp = (slp < 0.0) ? 0.0 : (slp > 0.999) ? 0.999 : slp;
for (i=0; i<self->bufsize; i++) {
- drv = .4 - _clip(drive[i]) * .3999;
- val = MYATAN2(in[i], drv);
- self->data[i] = val;
+ val = (1 + drv) * in[i] / (1 + drv * MYFABS(in[i]));
+ self->data[i] = self->y1 = val + (self->y1 - val) * slp;
}
+}
+
+static void
+Disto_transform_ai(Disto *self) {
+ int i;
+ MYFLT val, drv;
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ MYFLT *drive = Stream_getData((Stream *)self->drive_stream);
+ MYFLT slp = PyFloat_AS_DOUBLE(self->slope);
+ slp = (slp < 0.0) ? 0.0 : (slp > 0.999) ? 0.999 : slp;
- coeff = 1.0 - slp;
for (i=0; i<self->bufsize; i++) {
- val = self->data[i] * coeff + self->y1 * slp;
- self->y1 = val;
- self->data[i] = val;
+ drv = drive[i];
+ drv = (drv < 0.0) ? 0.0 : (drv > 0.998) ? 0.998 : drv;
+ drv = (2.0 * drv) / (1 - drv);
+ val = (1 + drv) * in[i] / (1 + drv * MYFABS(in[i]));
+ self->data[i] = self->y1 = val + (self->y1 - val) * slp;
}
}
static void
Disto_transform_ia(Disto *self) {
- MYFLT val, coeff, slp;
int i;
+ MYFLT val, slp;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
-
- MYFLT drv = .4 - _clip(PyFloat_AS_DOUBLE(self->drive)) * .3999;
+ MYFLT drv = PyFloat_AS_DOUBLE(self->drive);
MYFLT *slope = Stream_getData((Stream *)self->slope_stream);
+ drv = (drv < 0.0) ? 0.0 : (drv > 0.998) ? 0.998 : drv;
+ drv = (2.0 * drv) / (1 - drv);
+
for (i=0; i<self->bufsize; i++) {
- val = MYATAN2(in[i], drv);
- self->data[i] = val;
- }
- for (i=0; i<self->bufsize; i++) {
- slp = _clip(slope[i]);
- coeff = 1.0 - slp;
- val = self->data[i] * coeff + self->y1 * slp;
- self->y1 = val;
- self->data[i] = val;
+ slp = slope[i];
+ slp = (slp < 0.0) ? 0.0 : (slp > 0.999) ? 0.999 : slp;
+ val = (1 + drv) * in[i] / (1 + drv * MYFABS(in[i]));
+ self->data[i] = self->y1 = val + (self->y1 - val) * slp;
}
}
static void
Disto_transform_aa(Disto *self) {
- MYFLT val, drv, coeff, slp;
int i;
+ MYFLT val, drv, slp;
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);
- self->data[i] = val;
- }
- for (i=0; i<self->bufsize; i++) {
- slp = _clip(slope[i]);
- coeff = 1.0 - slp;
- val = self->data[i] * coeff + self->y1 * slp;
- self->y1 = val;
- self->data[i] = val;
+ drv = drive[i];
+ drv = (drv < 0.0) ? 0.0 : (drv > 0.998) ? 0.998 : drv;
+ slp = slope[i];
+ slp = (slp < 0.0) ? 0.0 : (slp > 0.999) ? 0.999 : slp;
+ drv = (2.0 * drv) / (1 - drv);
+ val = (1 + drv) * in[i] / (1 + drv * MYFABS(in[i]));
+ self->data[i] = self->y1 = val + (self->y1 - val) * slp;
}
}
@@ -239,7 +245,7 @@ Disto_dealloc(Disto* self)
{
pyo_DEALLOC
Disto_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -404,7 +410,7 @@ static PyNumberMethods Disto_as_number = {
(binaryfunc)Disto_add, /*nb_add*/
(binaryfunc)Disto_sub, /*nb_subtract*/
(binaryfunc)Disto_multiply, /*nb_multiply*/
- (binaryfunc)Disto_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -418,16 +424,16 @@ static PyNumberMethods Disto_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Disto_inplace_add, /*inplace_add*/
(binaryfunc)Disto_inplace_sub, /*inplace_subtract*/
(binaryfunc)Disto_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Disto_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -436,15 +442,14 @@ static PyNumberMethods Disto_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Disto_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Disto_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject DistoType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Disto_base", /*tp_name*/
sizeof(Disto), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -452,7 +457,7 @@ PyTypeObject DistoType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Disto_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -679,7 +684,7 @@ Clip_dealloc(Clip* self)
{
pyo_DEALLOC
Clip_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -843,7 +848,7 @@ static PyNumberMethods Clip_as_number = {
(binaryfunc)Clip_add, /*nb_add*/
(binaryfunc)Clip_sub, /*nb_subtract*/
(binaryfunc)Clip_multiply, /*nb_multiply*/
-(binaryfunc)Clip_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -857,16 +862,16 @@ static PyNumberMethods Clip_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Clip_inplace_add, /*inplace_add*/
(binaryfunc)Clip_inplace_sub, /*inplace_subtract*/
(binaryfunc)Clip_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Clip_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -875,15 +880,14 @@ static PyNumberMethods Clip_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Clip_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Clip_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ClipType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Clip_base", /*tp_name*/
sizeof(Clip), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -891,7 +895,7 @@ sizeof(Clip), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Clip_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1148,7 +1152,7 @@ Mirror_dealloc(Mirror* self)
{
pyo_DEALLOC
Mirror_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1312,7 +1316,7 @@ static PyNumberMethods Mirror_as_number = {
(binaryfunc)Mirror_add, /*nb_add*/
(binaryfunc)Mirror_sub, /*nb_subtract*/
(binaryfunc)Mirror_multiply, /*nb_multiply*/
- (binaryfunc)Mirror_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1326,16 +1330,16 @@ static PyNumberMethods Mirror_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Mirror_inplace_add, /*inplace_add*/
(binaryfunc)Mirror_inplace_sub, /*inplace_subtract*/
(binaryfunc)Mirror_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Mirror_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1344,15 +1348,14 @@ static PyNumberMethods Mirror_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Mirror_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Mirror_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject MirrorType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Mirror_base", /*tp_name*/
sizeof(Mirror), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1360,7 +1363,7 @@ PyTypeObject MirrorType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Mirror_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1641,7 +1644,7 @@ Wrap_dealloc(Wrap* self)
{
pyo_DEALLOC
Wrap_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1805,7 +1808,7 @@ static PyNumberMethods Wrap_as_number = {
(binaryfunc)Wrap_add, /*nb_add*/
(binaryfunc)Wrap_sub, /*nb_subtract*/
(binaryfunc)Wrap_multiply, /*nb_multiply*/
- (binaryfunc)Wrap_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1819,16 +1822,16 @@ static PyNumberMethods Wrap_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Wrap_inplace_add, /*inplace_add*/
(binaryfunc)Wrap_inplace_sub, /*inplace_subtract*/
(binaryfunc)Wrap_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Wrap_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1837,15 +1840,14 @@ static PyNumberMethods Wrap_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Wrap_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Wrap_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject WrapType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Wrap_base", /*tp_name*/
sizeof(Wrap), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1853,7 +1855,7 @@ PyTypeObject WrapType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Wrap_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2123,7 +2125,7 @@ Degrade_dealloc(Degrade* self)
{
pyo_DEALLOC
Degrade_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2289,7 +2291,7 @@ static PyNumberMethods Degrade_as_number = {
(binaryfunc)Degrade_add, /*nb_add*/
(binaryfunc)Degrade_sub, /*nb_subtract*/
(binaryfunc)Degrade_multiply, /*nb_multiply*/
-(binaryfunc)Degrade_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2303,16 +2305,16 @@ static PyNumberMethods Degrade_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Degrade_inplace_add, /*inplace_add*/
(binaryfunc)Degrade_inplace_sub, /*inplace_subtract*/
(binaryfunc)Degrade_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Degrade_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2321,15 +2323,14 @@ static PyNumberMethods Degrade_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Degrade_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Degrade_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject DegradeType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Degrade_base", /*tp_name*/
sizeof(Degrade), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2337,7 +2338,7 @@ sizeof(Degrade), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Degrade_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2493,7 +2494,7 @@ Min_dealloc(Min* self)
{
pyo_DEALLOC
Min_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2619,7 +2620,7 @@ static PyNumberMethods Min_as_number = {
(binaryfunc)Min_add, /*nb_add*/
(binaryfunc)Min_sub, /*nb_subtract*/
(binaryfunc)Min_multiply, /*nb_multiply*/
-(binaryfunc)Min_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2633,16 +2634,16 @@ static PyNumberMethods Min_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Min_inplace_add, /*inplace_add*/
(binaryfunc)Min_inplace_sub, /*inplace_subtract*/
(binaryfunc)Min_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Min_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2651,15 +2652,14 @@ static PyNumberMethods Min_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Min_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Min_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject MinType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Min_base", /*tp_name*/
sizeof(Min), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2667,7 +2667,7 @@ sizeof(Min), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Min_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2823,7 +2823,7 @@ Max_dealloc(Max* self)
{
pyo_DEALLOC
Max_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2949,7 +2949,7 @@ static PyNumberMethods Max_as_number = {
(binaryfunc)Max_add, /*nb_add*/
(binaryfunc)Max_sub, /*nb_subtract*/
(binaryfunc)Max_multiply, /*nb_multiply*/
-(binaryfunc)Max_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2963,16 +2963,16 @@ static PyNumberMethods Max_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Max_inplace_add, /*inplace_add*/
(binaryfunc)Max_inplace_sub, /*inplace_subtract*/
(binaryfunc)Max_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Max_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2981,15 +2981,14 @@ static PyNumberMethods Max_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Max_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Max_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject MaxType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Max_base", /*tp_name*/
sizeof(Max), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2997,7 +2996,7 @@ sizeof(Max), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Max_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/exprmodule.c b/src/objects/exprmodule.c
index 0f5d70d..5d5a7ff 100644
--- a/src/objects/exprmodule.c
+++ b/src/objects/exprmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -201,18 +202,18 @@ void
print_expr(expr ex, int node)
{
int i;
- printf("=== Node # %d ===\n", node);
- printf("Operator: %d\nNodes: ", ex.type_op);
- for (i=0; i<ex.num; i++) { printf("%d, ", ex.nodes[i]); }
- printf("\nVars: ");
- for (i=0; i<ex.num; i++) { printf("%d, ", ex.vars[i]); }
- printf("\nInputs: ");
- for (i=0; i<ex.num; i++) { printf("%d, ", ex.input[i]); }
- printf("\nOutputs: ");
- for (i=0; i<ex.num; i++) { printf("%d, ", ex.output[i]); }
- printf("\nValues: ");
- for (i=0; i<ex.num; i++) { printf("%f, ", ex.values[i]); }
- printf("\n\n");
+ PySys_WriteStdout("=== Node # %d ===\n", node);
+ PySys_WriteStdout("Operator: %d\nNodes: ", ex.type_op);
+ for (i=0; i<ex.num; i++) { PySys_WriteStdout("%d, ", ex.nodes[i]); }
+ PySys_WriteStdout("\nVars: ");
+ for (i=0; i<ex.num; i++) { PySys_WriteStdout("%d, ", ex.vars[i]); }
+ PySys_WriteStdout("\nInputs: ");
+ for (i=0; i<ex.num; i++) { PySys_WriteStdout("%d, ", ex.input[i]); }
+ PySys_WriteStdout("\nOutputs: ");
+ for (i=0; i<ex.num; i++) { PySys_WriteStdout("%d, ", ex.output[i]); }
+ PySys_WriteStdout("\nValues: ");
+ for (i=0; i<ex.num; i++) { PySys_WriteStdout("%f, ", ex.values[i]); }
+ PySys_WriteStdout("\n\n");
}
static void
@@ -496,7 +497,7 @@ Expr_dealloc(Expr* self)
{
pyo_DEALLOC
Expr_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -577,51 +578,49 @@ Expr_setExpr(Expr *self, PyObject *arg)
PyObject *sentence = NULL, *exp = NULL, *explist = NULL, *tmpstr = NULL;
PyObject *varDict = NULL, *waitingDict = NULL, *waitingList = NULL;
Py_ssize_t len, start, end;
-
+
PyDict_Clear(self->variables);
varDict = PyDict_New();
waitingDict = PyDict_New();
- if (PyString_Check(arg)) {
+ if (PY_STRING_CHECK(arg)) {
Py_INCREF(arg);
Py_XDECREF(sentence);
sentence = arg;
- len = PyString_Size(sentence);
+ len = PyUnicode_GetSize(sentence);
if (len == 0) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- if (PyUnicode_Count(sentence, PyString_FromString(")"), 0, len) != PyUnicode_Count(sentence, PyString_FromString("("), 0, len)) {
- printf("Expr: mismatched brackets, expression bypassed.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ if (PyUnicode_Count(sentence, PyUnicode_FromString(")"), 0, len) != PyUnicode_Count(sentence, PyUnicode_FromString("("), 0, len)) {
+ PySys_WriteStdout("Expr: mismatched brackets, expression bypassed.\n");
+ Py_RETURN_NONE;
}
for (i=0; i<self->count; i++) {
clearexpr(self->lexp[i]);
}
self->count = 0;
- while (PyUnicode_Find(sentence, PyString_FromString(")"), 0, len, 1) != -1) {
- end = PyUnicode_Find(sentence, PyString_FromString(")"), 0, len, 1) + 1;
- start = PyUnicode_Find(sentence, PyString_FromString("("), 0, end, -1);
+ while (PyUnicode_Find(sentence, PyUnicode_FromString(")"), 0, len, 1) != -1) {
+ end = PyUnicode_Find(sentence, PyUnicode_FromString(")"), 0, len, 1) + 1;
+ start = PyUnicode_Find(sentence, PyUnicode_FromString("("), 0, end, -1);
exp = PySequence_GetSlice(sentence, start, end);
- if (PyUnicode_Contains(exp, PyString_FromString("let ")) || PyUnicode_Contains(exp, PyString_FromString("var "))) {
+ if (PyUnicode_Contains(exp, PyUnicode_FromString("let ")) || PyUnicode_Contains(exp, PyUnicode_FromString("var "))) {
sentence = PyUnicode_Concat(PySequence_GetSlice(sentence, 0, start), PySequence_GetSlice(sentence, end, len));
}
else {
- sentence = PyUnicode_Replace(sentence, exp, PyUnicode_Format(PyString_FromString("_%d"), PyInt_FromLong(self->count)), 1);
+ sentence = PyUnicode_Replace(sentence, exp, PyUnicode_Format(PyUnicode_FromString("_%d"), PyInt_FromLong(self->count)), 1);
}
- exp = PyUnicode_Replace(exp, PyString_FromString("("), PyString_FromString(""), -1);
- exp = PyUnicode_Replace(exp, PyString_FromString(")"), PyString_FromString(""), -1);
+ exp = PyUnicode_Replace(exp, PyUnicode_FromString("("), PyUnicode_FromString(""), -1);
+ exp = PyUnicode_Replace(exp, PyUnicode_FromString(")"), PyUnicode_FromString(""), -1);
explist = PyUnicode_Split(exp, NULL, -1);
// Prepare variable from "var" function
- if (PyUnicode_Compare(PyList_GetItem(explist, 0), PyString_FromString("var")) == 0) {
- PyList_SetItem(explist, 0, PyString_FromString("const"));
+ if (PyUnicode_Compare(PyList_GetItem(explist, 0), PyUnicode_FromString("var")) == 0) {
+ PyList_SetItem(explist, 0, PyUnicode_FromString("const"));
PyDict_SetItem(self->variables, PyList_GetItem(explist, 1), PyInt_FromLong(self->count));
PySequence_DelItem(explist, 1);
}
// Prepare variable from "let" function
- if (PyUnicode_Compare(PyList_GetItem(explist, 0), PyString_FromString("let")) == 0) {
- PyList_SetItem(explist, 0, PyString_FromString("const"));
+ if (PyUnicode_Compare(PyList_GetItem(explist, 0), PyUnicode_FromString("let")) == 0) {
+ PyList_SetItem(explist, 0, PyUnicode_FromString("const"));
if (PyDict_GetItem(waitingDict, PyList_GetItem(explist, 1)) != NULL) {
waitingList = PyDict_GetItem(waitingDict, PyList_GetItem(explist, 1));
for (j=0; j<PyList_Size(waitingList); j++) {
@@ -635,19 +634,19 @@ Expr_setExpr(Expr *self, PyObject *arg)
PySequence_DelItem(explist, 1);
}
// Initialize expression node
- self->lexp[self->count] = initexpr(PyString_AsString(PyList_GetItem(explist, 0)), PyList_Size(explist));
+ self->lexp[self->count] = initexpr(PY_STRING_AS_STRING(PyList_GetItem(explist, 0)), PyList_Size(explist));
if (PyList_Size(explist) == 1 && self->lexp[self->count].type_op == OP_CONST) {
- PyList_Insert(explist, 0, PyString_FromString("const"));
+ PyList_Insert(explist, 0, PyUnicode_FromString("const"));
}
while (PyList_Size(explist) < (self->lexp[self->count].num+1)) {
- PyList_Append(explist, PyString_FromString("0.0"));
+ PyList_Append(explist, PyUnicode_FromString("0.0"));
}
for (i=0; i<self->lexp[self->count].num; i++) {
- if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyString_FromString("_"))) {
- tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyString_FromString("_"), PyString_FromString(""), -1);
- self->lexp[self->count].nodes[i] = PyInt_AsLong(PyInt_FromString(PyString_AsString(tmpstr), NULL, 0));
+ if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyUnicode_FromString("_"))) {
+ tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyUnicode_FromString("_"), PyUnicode_FromString(""), -1);
+ self->lexp[self->count].nodes[i] = PyInt_AsLong(PyInt_FromString(PY_STRING_AS_STRING(tmpstr), NULL, 0));
}
- else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyString_FromString("#"))) {
+ else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyUnicode_FromString("#"))) {
if (PyDict_GetItem(self->variables, PyList_GetItem(explist, i+1)) != NULL) {
self->lexp[self->count].vars[i] = PyInt_AsLong(PyDict_GetItem(self->variables, PyList_GetItem(explist, i+1)));
}
@@ -663,50 +662,50 @@ Expr_setExpr(Expr *self, PyObject *arg)
PyDict_SetItem(waitingDict, PyList_GetItem(explist, i+1), waitingList);
}
}
- else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyString_FromString("$x"))) {
- tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyString_FromString("$x"), PyString_FromString(""), -1);
- tmpstr = PyUnicode_Replace(tmpstr, PyString_FromString("["), PyString_FromString(""), -1);
- tmpstr = PyUnicode_Replace(tmpstr, PyString_FromString("]"), PyString_FromString(""), -1);
- self->lexp[self->count].input[i] = PyInt_AsLong(PyInt_FromString(PyString_AsString(tmpstr), NULL, 0));
+ else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyUnicode_FromString("$x"))) {
+ tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyUnicode_FromString("$x"), PyUnicode_FromString(""), -1);
+ tmpstr = PyUnicode_Replace(tmpstr, PyUnicode_FromString("["), PyUnicode_FromString(""), -1);
+ tmpstr = PyUnicode_Replace(tmpstr, PyUnicode_FromString("]"), PyUnicode_FromString(""), -1);
+ self->lexp[self->count].input[i] = PyInt_AsLong(PyInt_FromString(PY_STRING_AS_STRING(tmpstr), NULL, 0));
}
- else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyString_FromString("$y"))) {
- tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyString_FromString("$y"), PyString_FromString(""), -1);
- tmpstr = PyUnicode_Replace(tmpstr, PyString_FromString("["), PyString_FromString(""), -1);
- tmpstr = PyUnicode_Replace(tmpstr, PyString_FromString("]"), PyString_FromString(""), -1);
- self->lexp[self->count].output[i] = PyInt_AsLong(PyInt_FromString(PyString_AsString(tmpstr), NULL, 0));
+ else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyUnicode_FromString("$y"))) {
+ tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyUnicode_FromString("$y"), PyUnicode_FromString(""), -1);
+ tmpstr = PyUnicode_Replace(tmpstr, PyUnicode_FromString("["), PyUnicode_FromString(""), -1);
+ tmpstr = PyUnicode_Replace(tmpstr, PyUnicode_FromString("]"), PyUnicode_FromString(""), -1);
+ self->lexp[self->count].output[i] = PyInt_AsLong(PyInt_FromString(PY_STRING_AS_STRING(tmpstr), NULL, 0));
}
else {
self->lexp[self->count].values[i] = PyFloat_AsDouble(PyFloat_FromString(PyList_GetItem(explist, i+1), NULL));
}
}
- len = PyString_Size(sentence);
+ len = PyUnicode_GetSize(sentence);
self->count++;
}
explist = PyUnicode_Split(sentence, NULL, -1);
if (PyList_Size(explist) == 1)
- PyList_Insert(explist, 0, PyString_FromString("const"));
+ PyList_Insert(explist, 0, PyUnicode_FromString("const"));
// Initialize last expression node
- self->lexp[self->count] = initexpr(PyString_AsString(PyList_GetItem(explist, 0)), PyList_Size(explist));
+ self->lexp[self->count] = initexpr(PY_STRING_AS_STRING(PyList_GetItem(explist, 0)), PyList_Size(explist));
for (i=0; i<self->lexp[self->count].num; i++) {
- if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyString_FromString("_"))) {
- tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyString_FromString("_"), PyString_FromString(""), -1);
- self->lexp[self->count].nodes[i] = PyInt_AsLong(PyInt_FromString(PyString_AsString(tmpstr), NULL, 0));
+ if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyUnicode_FromString("_"))) {
+ tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyUnicode_FromString("_"), PyUnicode_FromString(""), -1);
+ self->lexp[self->count].nodes[i] = PyInt_AsLong(PyInt_FromString(PY_STRING_AS_STRING(tmpstr), NULL, 0));
}
- else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyString_FromString("#"))) {
+ else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyUnicode_FromString("#"))) {
self->lexp[self->count].vars[i] = PyInt_AsLong(PyDict_GetItem(varDict, PyList_GetItem(explist, i+1)));
}
- else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyString_FromString("$x"))) {
- tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyString_FromString("$x"), PyString_FromString(""), -1);
- tmpstr = PyUnicode_Replace(tmpstr, PyString_FromString("["), PyString_FromString(""), -1);
- tmpstr = PyUnicode_Replace(tmpstr, PyString_FromString("]"), PyString_FromString(""), -1);
- self->lexp[self->count].input[i] = PyInt_AsLong(PyInt_FromString(PyString_AsString(tmpstr), NULL, 0));
+ else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyUnicode_FromString("$x"))) {
+ tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyUnicode_FromString("$x"), PyUnicode_FromString(""), -1);
+ tmpstr = PyUnicode_Replace(tmpstr, PyUnicode_FromString("["), PyUnicode_FromString(""), -1);
+ tmpstr = PyUnicode_Replace(tmpstr, PyUnicode_FromString("]"), PyUnicode_FromString(""), -1);
+ self->lexp[self->count].input[i] = PyInt_AsLong(PyInt_FromString(PY_STRING_AS_STRING(tmpstr), NULL, 0));
}
- else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyString_FromString("$y"))) {
- tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyString_FromString("$y"), PyString_FromString(""), -1);
- tmpstr = PyUnicode_Replace(tmpstr, PyString_FromString("["), PyString_FromString(""), -1);
- tmpstr = PyUnicode_Replace(tmpstr, PyString_FromString("]"), PyString_FromString(""), -1);
- self->lexp[self->count].output[i] = PyInt_AsLong(PyInt_FromString(PyString_AsString(tmpstr), NULL, 0));
+ else if (PyUnicode_Contains(PyList_GetItem(explist, i+1), PyUnicode_FromString("$y"))) {
+ tmpstr = PyUnicode_Replace(PyList_GetItem(explist, i+1), PyUnicode_FromString("$y"), PyUnicode_FromString(""), -1);
+ tmpstr = PyUnicode_Replace(tmpstr, PyUnicode_FromString("["), PyUnicode_FromString(""), -1);
+ tmpstr = PyUnicode_Replace(tmpstr, PyUnicode_FromString("]"), PyUnicode_FromString(""), -1);
+ self->lexp[self->count].output[i] = PyInt_AsLong(PyInt_FromString(PY_STRING_AS_STRING(tmpstr), NULL, 0));
}
else {
self->lexp[self->count].values[i] = PyFloat_AsDouble(PyFloat_FromString(PyList_GetItem(explist, i+1), NULL));
@@ -724,8 +723,7 @@ Expr_setExpr(Expr *self, PyObject *arg)
Py_XDECREF(waitingDict);
Py_XDECREF(waitingList);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -742,8 +740,7 @@ Expr_setVar(Expr *self, PyObject *args, PyObject *kwds)
index = PyInt_AsLong(PyDict_GetItem(self->variables, varname));
self->lexp[index].values[0] = PyFloat_AsDouble(value);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -752,8 +749,7 @@ Expr_printNodes(Expr *self) {
for (i=0; i<self->count; i++) {
print_expr(self->lexp[i], i);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
};
static PyMemberDef Expr_members[] = {
@@ -785,7 +781,7 @@ static PyNumberMethods Expr_as_number = {
(binaryfunc)Expr_add, /*nb_add*/
(binaryfunc)Expr_sub, /*nb_subtract*/
(binaryfunc)Expr_multiply, /*nb_multiply*/
- (binaryfunc)Expr_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -799,16 +795,16 @@ static PyNumberMethods Expr_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Expr_inplace_add, /*inplace_add*/
(binaryfunc)Expr_inplace_sub, /*inplace_subtract*/
(binaryfunc)Expr_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Expr_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -817,15 +813,14 @@ static PyNumberMethods Expr_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Expr_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Expr_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ExprType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Expr_base", /*tp_name*/
sizeof(Expr), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -833,7 +828,7 @@ PyTypeObject ExprType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Expr_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/fadermodule.c b/src/objects/fadermodule.c
index 4049c59..b48c754 100644
--- a/src/objects/fadermodule.c
+++ b/src/objects/fadermodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -34,6 +35,7 @@ typedef struct {
MYFLT attack;
MYFLT release;
MYFLT duration;
+ MYFLT exp;
double currentTime;
MYFLT sampleToSec;
} Fader;
@@ -50,8 +52,11 @@ static void Fader_internal_stop(Fader *self) {
static void
Fader_generate_auto(Fader *self) {
- MYFLT val;
+ MYFLT val, iatt, irel;
int i;
+
+ iatt = 1.0 / self->attack;
+ irel = 1.0 / self->release;
if (self->ended == 1) {
Fader_internal_stop((Fader *)self);
@@ -60,26 +65,35 @@ Fader_generate_auto(Fader *self) {
for (i=0; i<self->bufsize; i++) {
if (self->currentTime <= self->attack)
- val = self->currentTime / self->attack;
+ val = self->currentTime * iatt;
else if (self->currentTime > self->duration) {
val = 0.;
self->ended = 1;
}
else if (self->currentTime >= (self->duration - self->release))
- val = (self->duration - self->currentTime) / self->release;
+ val = (self->duration - self->currentTime) * irel;
else
val = 1.;
self->data[i] = val;
self->currentTime += self->sampleToSec;
}
+
+ if (self->exp != 1.0) {
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = MYPOW(self->data[i], self->exp);
+ }
+ }
}
static void
Fader_generate_wait(Fader *self) {
- MYFLT val;
+ MYFLT val, iatt, irel;
int i;
+ iatt = 1.0 / self->attack;
+ irel = 1.0 / self->release;
+
if (self->fademode == 1 && self->currentTime > self->release) {
Fader_internal_stop((Fader *)self);
return;
@@ -89,20 +103,26 @@ Fader_generate_wait(Fader *self) {
if (self->fademode == 0) {
if (self->currentTime <= self->attack)
- val = self->currentTime / self->attack;
+ val = self->currentTime * iatt;
else
val = 1.;
self->topValue = val;
}
else {
if (self->currentTime <= self->release)
- val = (1. - self->currentTime / self->release) * self->topValue;
+ val = (1. - self->currentTime * irel) * self->topValue;
else
val = 0.;
}
self->data[i] = val;
self->currentTime += self->sampleToSec;
}
+
+ if (self->exp != 1.0) {
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = MYPOW(self->data[i], self->exp);
+ }
+ }
}
static void Fader_postprocessing_ii(Fader *self) { POST_PROCESSING_II };
@@ -126,7 +146,7 @@ Fader_setProcMode(Fader *self)
else
self->proc_func_ptr = Fader_generate_auto;
- switch (muladdmode) {
+ switch (muladdmode) {
case 0:
self->muladd_func_ptr = Fader_postprocessing_ii;
break;
@@ -183,7 +203,7 @@ Fader_dealloc(Fader* self)
{
pyo_DEALLOC
Fader_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -202,6 +222,7 @@ Fader_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->attack = 0.01;
self->release = 0.1;
self->duration = 0.0;
+ self->exp = 1.0;
self->currentTime = 0.0;
INIT_OBJECT_COMMON
@@ -295,6 +316,16 @@ Fader_setDur(Fader *self, PyObject *arg)
return Py_None;
}
+static PyObject *
+Fader_setExp(Fader *self, PyObject *arg)
+{
+ MYFLT tmp = PyFloat_AsDouble(arg);
+ if (tmp > 0.0)
+ self->exp = tmp;
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyMemberDef Fader_members[] = {
{"server", T_OBJECT_EX, offsetof(Fader, server), 0, "Pyo server."},
{"stream", T_OBJECT_EX, offsetof(Fader, stream), 0, "Stream object."},
@@ -314,6 +345,7 @@ static PyMethodDef Fader_methods[] = {
{"setFadein", (PyCFunction)Fader_setFadein, METH_O, "Sets fadein time in seconds."},
{"setFadeout", (PyCFunction)Fader_setFadeout, METH_O, "Sets fadeout time in seconds."},
{"setDur", (PyCFunction)Fader_setDur, METH_O, "Sets duration in seconds (0 means wait for stop method to start fadeout)."},
+{"setExp", (PyCFunction)Fader_setExp, METH_O, "Sets the exponent factor for exponential envelope."},
{"setDiv", (PyCFunction)Fader_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
@@ -322,7 +354,7 @@ static PyNumberMethods Fader_as_number = {
(binaryfunc)Fader_add, /*nb_add*/
(binaryfunc)Fader_sub, /*nb_subtract*/
(binaryfunc)Fader_multiply, /*nb_multiply*/
-(binaryfunc)Fader_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -336,16 +368,16 @@ static PyNumberMethods Fader_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Fader_inplace_add, /*inplace_add*/
(binaryfunc)Fader_inplace_sub, /*inplace_subtract*/
(binaryfunc)Fader_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Fader_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -354,15 +386,14 @@ static PyNumberMethods Fader_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Fader_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Fader_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject FaderType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Fader_base", /*tp_name*/
sizeof(Fader), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -370,7 +401,7 @@ sizeof(Fader), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Fader_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -412,6 +443,7 @@ typedef struct {
MYFLT sustain;
MYFLT release;
MYFLT duration;
+ MYFLT exp;
double currentTime;
MYFLT sampleToSec;
} Adsr;
@@ -453,6 +485,12 @@ Adsr_generate_auto(Adsr *self) {
self->data[i] = val;
self->currentTime += self->sampleToSec;
}
+
+ if (self->exp != 1.0) {
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = MYPOW(self->data[i], self->exp);
+ }
+ }
}
static void
@@ -488,6 +526,12 @@ Adsr_generate_wait(Adsr *self) {
self->data[i] = val;
self->currentTime += self->sampleToSec;
}
+
+ if (self->exp != 1.0) {
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = MYPOW(self->data[i], self->exp);
+ }
+ }
}
static void Adsr_postprocessing_ii(Adsr *self) { POST_PROCESSING_II };
@@ -511,7 +555,7 @@ Adsr_setProcMode(Adsr *self)
else
self->proc_func_ptr = Adsr_generate_auto;
- switch (muladdmode) {
+ switch (muladdmode) {
case 0:
self->muladd_func_ptr = Adsr_postprocessing_ii;
break;
@@ -568,7 +612,7 @@ Adsr_dealloc(Adsr* self)
{
pyo_DEALLOC
Adsr_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -588,6 +632,7 @@ Adsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sustain = 0.707;
self->release = 0.1;
self->duration = 0.0;
+ self->exp = 1.0;
self->currentTime = 0.0;
INIT_OBJECT_COMMON
@@ -726,6 +771,18 @@ Adsr_setDur(Adsr *self, PyObject *arg)
return Py_None;
}
+static PyObject *
+Adsr_setExp(Adsr *self, PyObject *arg)
+{
+ if (PyNumber_Check(arg)) {
+ MYFLT tmp = PyFloat_AsDouble(arg);
+ if (tmp > 0.0)
+ self->exp = tmp;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyMemberDef Adsr_members[] = {
{"server", T_OBJECT_EX, offsetof(Adsr, server), 0, "Pyo server."},
{"stream", T_OBJECT_EX, offsetof(Adsr, stream), 0, "Stream object."},
@@ -747,6 +804,7 @@ static PyMethodDef Adsr_methods[] = {
{"setSustain", (PyCFunction)Adsr_setSustain, METH_O, "Sets attack time in seconds."},
{"setRelease", (PyCFunction)Adsr_setRelease, METH_O, "Sets release time in seconds."},
{"setDur", (PyCFunction)Adsr_setDur, METH_O, "Sets duration in seconds (0 means wait for stop method to start fadeout)."},
+{"setExp", (PyCFunction)Adsr_setExp, METH_O, "Sets the exponent factor for exponential envelope."},
{"setDiv", (PyCFunction)Adsr_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
@@ -755,7 +813,7 @@ static PyNumberMethods Adsr_as_number = {
(binaryfunc)Adsr_add, /*nb_add*/
(binaryfunc)Adsr_sub, /*nb_subtract*/
(binaryfunc)Adsr_multiply, /*nb_multiply*/
-(binaryfunc)Adsr_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -769,16 +827,16 @@ static PyNumberMethods Adsr_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Adsr_inplace_add, /*inplace_add*/
(binaryfunc)Adsr_inplace_sub, /*inplace_subtract*/
(binaryfunc)Adsr_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Adsr_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -787,15 +845,14 @@ static PyNumberMethods Adsr_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Adsr_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Adsr_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject AdsrType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Adsr_base", /*tp_name*/
sizeof(Adsr), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -803,7 +860,7 @@ sizeof(Adsr), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Adsr_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -994,7 +1051,7 @@ Linseg_dealloc(Linseg* self)
free(self->targets);
free(self->times);
Linseg_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1149,7 +1206,7 @@ static PyNumberMethods Linseg_as_number = {
(binaryfunc)Linseg_add, /*nb_add*/
(binaryfunc)Linseg_sub, /*nb_subtract*/
(binaryfunc)Linseg_multiply, /*nb_multiply*/
-(binaryfunc)Linseg_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1163,16 +1220,16 @@ static PyNumberMethods Linseg_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Linseg_inplace_add, /*inplace_add*/
(binaryfunc)Linseg_inplace_sub, /*inplace_subtract*/
(binaryfunc)Linseg_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Linseg_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1181,15 +1238,14 @@ static PyNumberMethods Linseg_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Linseg_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Linseg_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject LinsegType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Linseg_base", /*tp_name*/
sizeof(Linseg), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1197,7 +1253,7 @@ sizeof(Linseg), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Linseg_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1410,7 +1466,7 @@ Expseg_dealloc(Expseg* self)
free(self->targets);
free(self->times);
Expseg_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1593,7 +1649,7 @@ static PyNumberMethods Expseg_as_number = {
(binaryfunc)Expseg_add, /*nb_add*/
(binaryfunc)Expseg_sub, /*nb_subtract*/
(binaryfunc)Expseg_multiply, /*nb_multiply*/
- (binaryfunc)Expseg_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1607,16 +1663,16 @@ static PyNumberMethods Expseg_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Expseg_inplace_add, /*inplace_add*/
(binaryfunc)Expseg_inplace_sub, /*inplace_subtract*/
(binaryfunc)Expseg_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Expseg_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1625,15 +1681,14 @@ static PyNumberMethods Expseg_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Expseg_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Expseg_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ExpsegType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Expseg_base", /*tp_name*/
sizeof(Expseg), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1641,7 +1696,7 @@ PyTypeObject ExpsegType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Expseg_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1671,4 +1726,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 9b16b6e..14076b0 100644
--- a/src/objects/fftmodule.c
+++ b/src/objects/fftmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -177,7 +178,7 @@ FFTMain_dealloc(FFTMain* self)
free(self->twiddle);
free(self->twiddle2);
FFTMain_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -233,7 +234,7 @@ FFTMain_setSize(FFTMain *self, PyObject *args, PyObject *kwds)
FFTMain_realloc_memories(self);
}
else
- printf("FFT size must be a power of two!\n");
+ PySys_WriteStdout("FFT size must be a power of two!\n");
Py_INCREF(Py_None);
return Py_None;
@@ -269,8 +270,7 @@ static PyMethodDef FFTMain_methods[] = {
};
PyTypeObject FFTMainType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.FFTMain_base", /*tp_name*/
sizeof(FFTMain), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -278,7 +278,7 @@ sizeof(FFTMain), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -401,7 +401,7 @@ FFT_dealloc(FFT* self)
{
pyo_DEALLOC
FFT_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -486,7 +486,7 @@ static PyNumberMethods FFT_as_number = {
(binaryfunc)FFT_add, /*nb_add*/
(binaryfunc)FFT_sub, /*nb_subtract*/
(binaryfunc)FFT_multiply, /*nb_multiply*/
-(binaryfunc)FFT_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -500,16 +500,16 @@ static PyNumberMethods FFT_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)FFT_inplace_add, /*inplace_add*/
(binaryfunc)FFT_inplace_sub, /*inplace_subtract*/
(binaryfunc)FFT_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)FFT_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -518,15 +518,14 @@ static PyNumberMethods FFT_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)FFT_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)FFT_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject FFTType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.FFT_base", /*tp_name*/
sizeof(FFT), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -534,7 +533,7 @@ sizeof(FFT), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&FFT_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -742,7 +741,7 @@ IFFT_dealloc(IFFT* self)
free(self->twiddle);
free(self->twiddle2);
IFFT_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -835,7 +834,7 @@ IFFT_setSize(IFFT *self, PyObject *args, PyObject *kwds)
IFFT_realloc_memories(self);
}
else
- printf("IFFT size must be a power of two!\n");
+ PySys_WriteStdout("IFFT size must be a power of two!\n");
Py_INCREF(Py_None);
return Py_None;
@@ -882,7 +881,7 @@ static PyNumberMethods IFFT_as_number = {
(binaryfunc)IFFT_add, /*nb_add*/
(binaryfunc)IFFT_sub, /*nb_subtract*/
(binaryfunc)IFFT_multiply, /*nb_multiply*/
- (binaryfunc)IFFT_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -896,16 +895,16 @@ static PyNumberMethods IFFT_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)IFFT_inplace_add, /*inplace_add*/
(binaryfunc)IFFT_inplace_sub, /*inplace_subtract*/
(binaryfunc)IFFT_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)IFFT_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -914,15 +913,14 @@ static PyNumberMethods IFFT_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)IFFT_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)IFFT_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject IFFTType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.IFFT_base", /*tp_name*/
sizeof(IFFT), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -930,7 +928,7 @@ PyTypeObject IFFTType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&IFFT_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1073,7 +1071,7 @@ CarToPol_dealloc(CarToPol* self)
{
pyo_DEALLOC
CarToPol_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1165,7 +1163,7 @@ static PyNumberMethods CarToPol_as_number = {
(binaryfunc)CarToPol_add, /*nb_add*/
(binaryfunc)CarToPol_sub, /*nb_subtract*/
(binaryfunc)CarToPol_multiply, /*nb_multiply*/
- (binaryfunc)CarToPol_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1179,16 +1177,16 @@ static PyNumberMethods CarToPol_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)CarToPol_inplace_add, /*inplace_add*/
(binaryfunc)CarToPol_inplace_sub, /*inplace_subtract*/
(binaryfunc)CarToPol_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)CarToPol_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1197,15 +1195,14 @@ static PyNumberMethods CarToPol_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)CarToPol_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)CarToPol_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject CarToPolType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.CarToPol_base", /*tp_name*/
sizeof(CarToPol), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1213,7 +1210,7 @@ PyTypeObject CarToPolType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&CarToPol_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1356,7 +1353,7 @@ PolToCar_dealloc(PolToCar* self)
{
pyo_DEALLOC
PolToCar_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1448,7 +1445,7 @@ static PyNumberMethods PolToCar_as_number = {
(binaryfunc)PolToCar_add, /*nb_add*/
(binaryfunc)PolToCar_sub, /*nb_subtract*/
(binaryfunc)PolToCar_multiply, /*nb_multiply*/
- (binaryfunc)PolToCar_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1462,16 +1459,16 @@ static PyNumberMethods PolToCar_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)PolToCar_inplace_add, /*inplace_add*/
(binaryfunc)PolToCar_inplace_sub, /*inplace_subtract*/
(binaryfunc)PolToCar_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)PolToCar_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1480,15 +1477,14 @@ static PyNumberMethods PolToCar_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)PolToCar_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)PolToCar_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject PolToCarType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PolToCar_base", /*tp_name*/
sizeof(PolToCar), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1496,7 +1492,7 @@ PyTypeObject PolToCarType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&PolToCar_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1624,7 +1620,7 @@ FrameDeltaMain_dealloc(FrameDeltaMain* self)
free(self->frameBuffer);
free(self->buffer_streams);
FrameDeltaMain_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1720,7 +1716,7 @@ FrameDeltaMain_setFrameSize(FrameDeltaMain *self, PyObject *arg)
}
}
else
- printf("frameSize must be a power of two!\n");
+ PySys_WriteStdout("frameSize must be a power of two!\n");
Py_INCREF(Py_None);
return Py_None;
@@ -1744,8 +1740,7 @@ static PyMethodDef FrameDeltaMain_methods[] = {
};
PyTypeObject FrameDeltaMainType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.FrameDeltaMain_base", /*tp_name*/
sizeof(FrameDeltaMain), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1753,7 +1748,7 @@ PyTypeObject FrameDeltaMainType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1876,7 +1871,7 @@ FrameDelta_dealloc(FrameDelta* self)
{
pyo_DEALLOC
FrameDelta_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1963,7 +1958,7 @@ static PyNumberMethods FrameDelta_as_number = {
(binaryfunc)FrameDelta_add, /*nb_add*/
(binaryfunc)FrameDelta_sub, /*nb_subtract*/
(binaryfunc)FrameDelta_multiply, /*nb_multiply*/
- (binaryfunc)FrameDelta_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1977,16 +1972,16 @@ static PyNumberMethods FrameDelta_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)FrameDelta_inplace_add, /*inplace_add*/
(binaryfunc)FrameDelta_inplace_sub, /*inplace_subtract*/
(binaryfunc)FrameDelta_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)FrameDelta_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1995,15 +1990,14 @@ static PyNumberMethods FrameDelta_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)FrameDelta_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)FrameDelta_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject FrameDeltaType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.FrameDelta_base", /*tp_name*/
sizeof(FrameDelta), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2011,7 +2005,7 @@ PyTypeObject FrameDeltaType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&FrameDelta_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2133,7 +2127,7 @@ FrameAccumMain_dealloc(FrameAccumMain* self)
free(self->frameBuffer);
free(self->buffer_streams);
FrameAccumMain_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2229,7 +2223,7 @@ FrameAccumMain_setFrameSize(FrameAccumMain *self, PyObject *arg)
}
}
else
- printf("frameSize must be a power of two!\n");
+ PySys_WriteStdout("frameSize must be a power of two!\n");
Py_INCREF(Py_None);
return Py_None;
@@ -2253,8 +2247,7 @@ static PyMethodDef FrameAccumMain_methods[] = {
};
PyTypeObject FrameAccumMainType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.FrameAccumMain_base", /*tp_name*/
sizeof(FrameAccumMain), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2262,7 +2255,7 @@ PyTypeObject FrameAccumMainType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2385,7 +2378,7 @@ FrameAccum_dealloc(FrameAccum* self)
{
pyo_DEALLOC
FrameAccum_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2472,7 +2465,7 @@ static PyNumberMethods FrameAccum_as_number = {
(binaryfunc)FrameAccum_add, /*nb_add*/
(binaryfunc)FrameAccum_sub, /*nb_subtract*/
(binaryfunc)FrameAccum_multiply, /*nb_multiply*/
- (binaryfunc)FrameAccum_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2486,16 +2479,16 @@ static PyNumberMethods FrameAccum_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)FrameAccum_inplace_add, /*inplace_add*/
(binaryfunc)FrameAccum_inplace_sub, /*inplace_subtract*/
(binaryfunc)FrameAccum_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)FrameAccum_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2504,15 +2497,14 @@ static PyNumberMethods FrameAccum_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)FrameAccum_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)FrameAccum_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject FrameAccumType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.FrameAccum_base", /*tp_name*/
sizeof(FrameAccum), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2520,7 +2512,7 @@ PyTypeObject FrameAccumType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&FrameAccum_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2700,7 +2692,7 @@ VectralMain_dealloc(VectralMain* self)
free(self->frameBuffer);
free(self->buffer_streams);
VectralMain_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2816,7 +2808,7 @@ VectralMain_setFrameSize(VectralMain *self, PyObject *arg)
}
}
else
- printf("frameSize must be a power of two!\n");
+ PySys_WriteStdout("frameSize must be a power of two!\n");
Py_INCREF(Py_None);
return Py_None;
@@ -2930,8 +2922,7 @@ static PyMethodDef VectralMain_methods[] = {
};
PyTypeObject VectralMainType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.VectralMain_base", /*tp_name*/
sizeof(VectralMain), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2939,7 +2930,7 @@ PyTypeObject VectralMainType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3062,7 +3053,7 @@ Vectral_dealloc(Vectral* self)
{
pyo_DEALLOC
Vectral_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3149,7 +3140,7 @@ static PyNumberMethods Vectral_as_number = {
(binaryfunc)Vectral_add, /*nb_add*/
(binaryfunc)Vectral_sub, /*nb_subtract*/
(binaryfunc)Vectral_multiply, /*nb_multiply*/
- (binaryfunc)Vectral_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3163,16 +3154,16 @@ static PyNumberMethods Vectral_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Vectral_inplace_add, /*inplace_add*/
(binaryfunc)Vectral_inplace_sub, /*inplace_subtract*/
(binaryfunc)Vectral_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Vectral_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3181,15 +3172,14 @@ static PyNumberMethods Vectral_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Vectral_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Vectral_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject VectralType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Vectral_base", /*tp_name*/
sizeof(Vectral), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3197,7 +3187,7 @@ PyTypeObject VectralType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Vectral_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3292,7 +3282,7 @@ CvlVerb_analyse_impulse(CvlVerb *self) {
info.format = 0;
sf = sf_open(self->impulse_path, SFM_READ, &info);
if (sf == NULL) {
- printf("CvlVerb failed to open the impulse file %s.\n", self->impulse_path);
+ PySys_WriteStdout("CvlVerb failed to open the impulse file %s.\n", self->impulse_path);
return;
}
snd_size = info.frames;
@@ -3301,7 +3291,7 @@ CvlVerb_analyse_impulse(CvlVerb *self) {
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");
+ PySys_WriteStdout("CvlVerb warning: Impulse sampling rate does't match the sampling rate of the server.\n");
}
self->num_iter = (int)MYCEIL((MYFLT)snd_size / self->size);
@@ -3601,7 +3591,7 @@ CvlVerb_dealloc(CvlVerb* self)
free(self->real);
free(self->imag);
CvlVerb_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3627,7 +3617,7 @@ CvlVerb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
if (self->size < self->bufsize) {
- printf("Warning : CvlVerb size less than buffer size!\nCvlVerb size set to buffersize: %d\n", self->bufsize);
+ PySys_WriteStdout("Warning: CvlVerb size less than buffer size!\nCvlVerb size set to buffersize: %d\n", self->bufsize);
self->size = self->bufsize;
}
@@ -3740,7 +3730,7 @@ static PyNumberMethods CvlVerb_as_number = {
(binaryfunc)CvlVerb_add, /*nb_add*/
(binaryfunc)CvlVerb_sub, /*nb_subtract*/
(binaryfunc)CvlVerb_multiply, /*nb_multiply*/
- (binaryfunc)CvlVerb_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3754,16 +3744,16 @@ static PyNumberMethods CvlVerb_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)CvlVerb_inplace_add, /*inplace_add*/
(binaryfunc)CvlVerb_inplace_sub, /*inplace_subtract*/
(binaryfunc)CvlVerb_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)CvlVerb_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3772,15 +3762,14 @@ static PyNumberMethods CvlVerb_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)CvlVerb_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)CvlVerb_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject CvlVerbType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.CvlVerb_base", /*tp_name*/
sizeof(CvlVerb), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3788,7 +3777,7 @@ sizeof(CvlVerb), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&CvlVerb_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4042,7 +4031,7 @@ Spectrum_dealloc(Spectrum* self)
}
free(self->twiddle);
Spectrum_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4084,7 +4073,7 @@ Spectrum_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
while (k < self->size)
k *= 2;
self->size = k;
- printf("size must be a power-of-2, using the next power-of-2 greater than size : %d\n", self->size);
+ PySys_WriteStdout("Spectrum: size argument must be a power-of-2, using the next power-of-2 greater than size : %d\n", self->size);
}
Spectrum_realloc_memories(self);
@@ -4110,7 +4099,7 @@ Spectrum_setSize(Spectrum *self, PyObject *arg)
Spectrum_realloc_memories(self);
}
else
- printf("FFT size must be a power of two!\n");
+ PySys_WriteStdout("FFT size must be a power of two!\n");
}
Py_INCREF(Py_None);
@@ -4253,8 +4242,7 @@ static PyMethodDef Spectrum_methods[] = {
};
PyTypeObject SpectrumType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Spectrum_base", /*tp_name*/
sizeof(Spectrum), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4262,7 +4250,7 @@ sizeof(Spectrum), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/filtremodule.c b/src/objects/filtremodule.c
index 5795a0f..cece39e 100644
--- a/src/objects/filtremodule.c
+++ b/src/objects/filtremodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -41,6 +42,7 @@ typedef struct {
int modebuffer[4]; // need at least 2 slots for mul & add
int filtertype;
MYFLT nyquist;
+ MYFLT twoPiOverSr;
// sample memories
MYFLT x1;
MYFLT x2;
@@ -64,7 +66,7 @@ Biquad_compute_coeffs_lp(Biquad *self)
{
self->b0 = self->b2 = (1 - self->c) / 2;
self->b1 = 1 - self->c;
- self->a0 = 1 + self->alpha;
+ self->a0 = 1.0 / (1 + self->alpha);
self->a1 = -2 * self->c;
self->a2 = 1 - self->alpha;
}
@@ -75,7 +77,7 @@ Biquad_compute_coeffs_hp(Biquad *self)
self->b0 = (1 + self->c) / 2;
self->b1 = -(1 + self->c);
self->b2 = self->b0;
- self->a0 = 1 + self->alpha;
+ self->a0 = 1.0 / (1 + self->alpha);
self->a1 = -2 * self->c;
self->a2 = 1 - self->alpha;
}
@@ -86,7 +88,7 @@ Biquad_compute_coeffs_bp(Biquad *self)
self->b0 = self->alpha;
self->b1 = 0;
self->b2 = -self->alpha;
- self->a0 = 1 + self->alpha;
+ self->a0 = 1.0 / (1 + self->alpha);
self->a1 = -2 * self->c;
self->a2 = 1 - self->alpha;
}
@@ -97,7 +99,7 @@ Biquad_compute_coeffs_bs(Biquad *self)
self->b0 = 1;
self->b1 = self->a1 = -2 * self->c;
self->b2 = 1;
- self->a0 = 1 + self->alpha;
+ self->a0 = 1.0 / (1 + self->alpha);
self->a2 = 1 - self->alpha;
}
@@ -106,7 +108,8 @@ Biquad_compute_coeffs_ap(Biquad *self)
{
self->b0 = self->a2 = 1 - self->alpha;
self->b1 = self->a1 = -2 * self->c;
- self->b2 = self->a0 = 1 + self->alpha;
+ self->b2 = 1 + self->alpha;
+ self->a0 = 1.0 / (1 + self->alpha);
}
static void
@@ -119,7 +122,7 @@ Biquad_compute_variables(Biquad *self, MYFLT freq, MYFLT q)
if (q < 0.1)
q = 0.1;
- self->w0 = TWOPI * freq / self->sr;
+ self->w0 = freq * self->twoPiOverSr;
self->c = MYCOS(self->w0);
self->alpha = MYSIN(self->w0) / (2 * q);
(*self->coeffs_func_ptr)(self);
@@ -137,12 +140,11 @@ Biquad_filters_ii(Biquad *self) {
}
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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -162,12 +164,11 @@ Biquad_filters_ai(Biquad *self) {
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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -187,12 +188,11 @@ Biquad_filters_ia(Biquad *self) {
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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -212,12 +212,11 @@ Biquad_filters_aa(Biquad *self) {
for (i=0; i<self->bufsize; i++) {
Biquad_compute_variables(self, fr[i], 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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -340,7 +339,7 @@ Biquad_dealloc(Biquad* self)
{
pyo_DEALLOC
Biquad_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -363,6 +362,7 @@ Biquad_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
INIT_OBJECT_COMMON
self->nyquist = (MYFLT)self->sr * 0.49;
+ self->twoPiOverSr = TWOPI / (MYFLT)self->sr;
Stream_setFunctionPtr(self->stream, Biquad_compute_next_data_frame);
self->mode_func_ptr = Biquad_setProcMode;
@@ -527,7 +527,7 @@ static PyNumberMethods Biquad_as_number = {
(binaryfunc)Biquad_add, /*nb_add*/
(binaryfunc)Biquad_sub, /*nb_subtract*/
(binaryfunc)Biquad_multiply, /*nb_multiply*/
- (binaryfunc)Biquad_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -541,16 +541,16 @@ static PyNumberMethods Biquad_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Biquad_inplace_add, /*inplace_add*/
(binaryfunc)Biquad_inplace_sub, /*inplace_subtract*/
(binaryfunc)Biquad_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Biquad_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -559,15 +559,14 @@ static PyNumberMethods Biquad_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Biquad_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Biquad_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BiquadType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Biquad_base", /*tp_name*/
sizeof(Biquad), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -575,7 +574,7 @@ PyTypeObject BiquadType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Biquad_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -654,7 +653,7 @@ Biquadx_compute_coeffs_lp(Biquadx *self)
{
self->b0 = self->b2 = (1 - self->c) / 2;
self->b1 = 1 - self->c;
- self->a0 = 1 + self->alpha;
+ self->a0 = 1.0 / (1 + self->alpha);
self->a1 = -2 * self->c;
self->a2 = 1 - self->alpha;
}
@@ -665,7 +664,7 @@ Biquadx_compute_coeffs_hp(Biquadx *self)
self->b0 = (1 + self->c) / 2;
self->b1 = -(1 + self->c);
self->b2 = self->b0;
- self->a0 = 1 + self->alpha;
+ self->a0 = 1.0 / (1 + self->alpha);
self->a1 = -2 * self->c;
self->a2 = 1 - self->alpha;
}
@@ -676,7 +675,7 @@ Biquadx_compute_coeffs_bp(Biquadx *self)
self->b0 = self->alpha;
self->b1 = 0;
self->b2 = -self->alpha;
- self->a0 = 1 + self->alpha;
+ self->a0 = 1.0 / (1 + self->alpha);
self->a1 = -2 * self->c;
self->a2 = 1 - self->alpha;
}
@@ -687,7 +686,7 @@ Biquadx_compute_coeffs_bs(Biquadx *self)
self->b0 = 1;
self->b1 = self->a1 = -2 * self->c;
self->b2 = 1;
- self->a0 = 1 + self->alpha;
+ self->a0 = 1.0 / (1 + self->alpha);
self->a2 = 1 - self->alpha;
}
@@ -696,7 +695,8 @@ Biquadx_compute_coeffs_ap(Biquadx *self)
{
self->b0 = self->a2 = 1 - self->alpha;
self->b1 = self->a1 = -2 * self->c;
- self->b2 = self->a0 = 1 + self->alpha;
+ self->b2 = 1 + self->alpha;
+ self->a0 = 1.0 / (1 + self->alpha);
}
static void
@@ -732,7 +732,7 @@ Biquadx_filters_ii(Biquadx *self) {
for (i=0; i<self->bufsize; i++) {
vin = in[i];
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;
+ 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;
self->y2[j] = self->y1[j];
@@ -763,7 +763,7 @@ Biquadx_filters_ai(Biquadx *self) {
Biquadx_compute_variables(self, fr[i], q);
vin = in[i];
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;
+ 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;
self->y2[j] = self->y1[j];
@@ -794,7 +794,7 @@ Biquadx_filters_ia(Biquadx *self) {
Biquadx_compute_variables(self, fr, q[i]);
vin = in[i];
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;
+ 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;
self->y2[j] = self->y1[j];
@@ -825,7 +825,7 @@ Biquadx_filters_aa(Biquadx *self) {
Biquadx_compute_variables(self, fr[i], q[i]);
vin = in[i];
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;
+ 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;
self->y2[j] = self->y1[j];
@@ -958,7 +958,7 @@ Biquadx_dealloc(Biquadx* self)
free(self->y1);
free(self->y2);
Biquadx_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1165,7 +1165,7 @@ static PyNumberMethods Biquadx_as_number = {
(binaryfunc)Biquadx_add, /*nb_add*/
(binaryfunc)Biquadx_sub, /*nb_subtract*/
(binaryfunc)Biquadx_multiply, /*nb_multiply*/
- (binaryfunc)Biquadx_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1179,16 +1179,16 @@ static PyNumberMethods Biquadx_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Biquadx_inplace_add, /*inplace_add*/
(binaryfunc)Biquadx_inplace_sub, /*inplace_subtract*/
(binaryfunc)Biquadx_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Biquadx_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1197,15 +1197,14 @@ static PyNumberMethods Biquadx_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Biquadx_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Biquadx_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BiquadxType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Biquadx_base", /*tp_name*/
sizeof(Biquadx), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1213,7 +1212,7 @@ PyTypeObject BiquadxType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Biquadx_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1383,7 +1382,7 @@ Biquada_dealloc(Biquada* self)
{
pyo_DEALLOC
Biquada_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1576,7 +1575,7 @@ static PyNumberMethods Biquada_as_number = {
(binaryfunc)Biquada_add, /*nb_add*/
(binaryfunc)Biquada_sub, /*nb_subtract*/
(binaryfunc)Biquada_multiply, /*nb_multiply*/
- (binaryfunc)Biquada_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1590,16 +1589,16 @@ static PyNumberMethods Biquada_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Biquada_inplace_add, /*inplace_add*/
(binaryfunc)Biquada_inplace_sub, /*inplace_subtract*/
(binaryfunc)Biquada_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Biquada_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1608,15 +1607,14 @@ static PyNumberMethods Biquada_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Biquada_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Biquada_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BiquadaType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Biquada_base", /*tp_name*/
sizeof(Biquada), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1624,7 +1622,7 @@ PyTypeObject BiquadaType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Biquada_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1672,6 +1670,7 @@ typedef struct {
int modebuffer[5]; // need at least 2 slots for mul & add
int filtertype;
MYFLT nyquist;
+ MYFLT twoPiOverSr;
// sample memories
MYFLT x1;
MYFLT x2;
@@ -1700,7 +1699,7 @@ EQ_compute_coeffs_peak(EQ *self)
self->b0 = 1.0 + alphaMul;
self->b1 = self->a1 = -2.0 * self->c;
self->b2 = 1.0 - alphaMul;
- self->a0 = 1.0 + alphaDiv;
+ self->a0 = 1.0 / (1.0 + alphaDiv);
self->a2 = 1.0 - alphaDiv;
}
@@ -1714,7 +1713,7 @@ EQ_compute_coeffs_lowshelf(EQ *self)
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->a0 = 1.0 / ((self->A + 1.0) + AminOneC + twoSqrtAAlpha);
self->a1 = -2.0 * ((self->A - 1.0) + AAddOneC);
self->a2 = (self->A + 1.0) + AminOneC - twoSqrtAAlpha;
}
@@ -1729,7 +1728,7 @@ EQ_compute_coeffs_highshelf(EQ *self)
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->a0 = 1.0 / ((self->A + 1.0) - AminOneC + twoSqrtAAlpha);
self->a1 = 2.0 * ((self->A - 1.0) - AAddOneC);
self->a2 = (self->A + 1.0) - AminOneC - twoSqrtAAlpha;
}
@@ -1743,7 +1742,7 @@ EQ_compute_variables(EQ *self, MYFLT freq, MYFLT q, MYFLT boost)
freq = self->nyquist;
self->A = MYPOW(10.0, boost/40.0);
- self->w0 = TWOPI * freq / self->sr;
+ self->w0 = freq * self->twoPiOverSr;
self->c = MYCOS(self->w0);
self->alpha = MYSIN(self->w0) / (2 * q);
(*self->coeffs_func_ptr)(self);
@@ -1761,12 +1760,11 @@ EQ_filters_iii(EQ *self) {
}
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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -1787,12 +1785,11 @@ EQ_filters_aii(EQ *self) {
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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -1813,12 +1810,11 @@ EQ_filters_iai(EQ *self) {
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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -1839,12 +1835,11 @@ EQ_filters_aai(EQ *self) {
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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -1865,12 +1860,11 @@ EQ_filters_iia(EQ *self) {
for (i=0; i<self->bufsize; i++) {
EQ_compute_variables(self, fr, 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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -1891,12 +1885,11 @@ EQ_filters_aia(EQ *self) {
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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -1917,12 +1910,11 @@ EQ_filters_iaa(EQ *self) {
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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -1943,12 +1935,11 @@ EQ_filters_aaa(EQ *self) {
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;
+ 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;
- self->y1 = val;
+ self->data[i] = self->y1 = val;
self->x2 = self->x1;
self->x1 = in[i];
- self->data[i] = val;
}
}
@@ -2081,7 +2072,7 @@ EQ_dealloc(EQ* self)
{
pyo_DEALLOC
EQ_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2106,6 +2097,7 @@ EQ_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
INIT_OBJECT_COMMON
self->nyquist = (MYFLT)self->sr * 0.49;
+ self->twoPiOverSr = TWOPI / (MYFLT)self->sr;
Stream_setFunctionPtr(self->stream, EQ_compute_next_data_frame);
self->mode_func_ptr = EQ_setProcMode;
@@ -2307,7 +2299,7 @@ static PyNumberMethods EQ_as_number = {
(binaryfunc)EQ_add, /*nb_add*/
(binaryfunc)EQ_sub, /*nb_subtract*/
(binaryfunc)EQ_multiply, /*nb_multiply*/
-(binaryfunc)EQ_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2321,16 +2313,16 @@ static PyNumberMethods EQ_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)EQ_inplace_add, /*inplace_add*/
(binaryfunc)EQ_inplace_sub, /*inplace_subtract*/
(binaryfunc)EQ_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)EQ_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2339,15 +2331,14 @@ static PyNumberMethods EQ_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)EQ_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)EQ_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject EQType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.EQ_base", /*tp_name*/
sizeof(EQ), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2355,7 +2346,7 @@ sizeof(EQ), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&EQ_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2402,6 +2393,7 @@ typedef struct {
int dir;
} Port;
+// inline ?
static void
direction(Port *self, MYFLT val)
{
@@ -2416,83 +2408,94 @@ direction(Port *self, MYFLT val)
static void
Port_filters_ii(Port *self) {
- MYFLT val;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
MYFLT risetime = PyFloat_AS_DOUBLE(self->risetime);
MYFLT falltime = PyFloat_AS_DOUBLE(self->falltime);
- MYFLT risefactor = 1. / ((risetime + 0.001) * self->sr);
- MYFLT fallfactor = 1. / ((falltime + 0.001) * self->sr);
+ if (risetime < 0)
+ risetime = 0.0;
+ if (falltime < 0)
+ falltime = 0.0;
+ MYFLT risefactor = 1.0 / ((risetime + 0.00025) * self->sr);
+ MYFLT fallfactor = 1.0 / ((falltime + 0.00025) * self->sr);
MYFLT factors[2] = {fallfactor, risefactor};
for (i=0; i<self->bufsize; i++) {
direction(self, in[i]);
- val = self->y1 + (in[i] - self->y1) * factors[self->dir];
- self->y1 = val;
- self->data[i] = val;
+ self->data[i] = self->y1 = self->y1 + (in[i] - self->y1) * factors[self->dir];
}
}
static void
Port_filters_ai(Port *self) {
- MYFLT val, risefactor;
+ MYFLT risetime, risefactor;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
- MYFLT *risetime = Stream_getData((Stream *)self->risetime_stream);
+ MYFLT *rt = Stream_getData((Stream *)self->risetime_stream);
MYFLT falltime = PyFloat_AS_DOUBLE(self->falltime);
- MYFLT fallfactor = 1. / ((falltime + 0.001) * self->sr);
+ if (falltime < 0)
+ falltime = 0.0;
+ MYFLT fallfactor = 1.0 / ((falltime + 0.00025) * self->sr);
for (i=0; i<self->bufsize; i++) {
direction(self, in[i]);
- risefactor = (*risetime++ + 0.001) * self->sr;
+ risetime = rt[i];
+ if (risetime < 0)
+ risetime = 0.0;
+ risefactor = (risetime + 0.00025) * self->sr;
if (self->dir == 1)
- val = self->y1 + (*in++ - self->y1) / risefactor;
+ self->data[i] = self->y1 = self->y1 + (in[i] - self->y1) / risefactor;
else
- val = self->y1 + (*in++ - self->y1) * fallfactor;
- self->y1 = val;
- self->data[i] = val;
+ self->data[i] = self->y1 = self->y1 + (in[i] - self->y1) * fallfactor;
}
}
static void
Port_filters_ia(Port *self) {
- MYFLT val, fallfactor;
+ MYFLT falltime, fallfactor;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
- MYFLT *falltime = Stream_getData((Stream *)self->falltime_stream);
+ MYFLT *ft = Stream_getData((Stream *)self->falltime_stream);
MYFLT risetime = PyFloat_AS_DOUBLE(self->risetime);
- MYFLT risefactor = 1. / ((risetime + 0.001) * self->sr);
+ if (risetime < 0)
+ risetime = 0.0;
+ MYFLT risefactor = 1.0 / ((risetime + 0.00025) * self->sr);
for (i=0; i<self->bufsize; i++) {
direction(self, in[i]);
- fallfactor = (*falltime++ + 0.001) * self->sr;
+ falltime = ft[i];
+ if (falltime < 0)
+ falltime = 0.0;
+ fallfactor = (falltime + 0.00025) * self->sr;
if (self->dir == 1)
- val = self->y1 + (*in++ - self->y1) * risefactor;
+ self->data[i] = self->y1 = self->y1 + (in[i] - self->y1) * risefactor;
else
- val = self->y1 + (*in++ - self->y1) / fallfactor;
- self->y1 = val;
- self->data[i] = val;
+ self->data[i] = self->y1 = self->y1 + (in[i] - self->y1) / fallfactor;
}
}
static void
Port_filters_aa(Port *self) {
- MYFLT val, risefactor, fallfactor;
+ MYFLT risetime, falltime, risefactor, fallfactor;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
- MYFLT *risetime = Stream_getData((Stream *)self->risetime_stream);
- MYFLT *falltime = Stream_getData((Stream *)self->falltime_stream);
+ MYFLT *rt = Stream_getData((Stream *)self->risetime_stream);
+ MYFLT *ft = 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;
+ risetime = rt[i];
+ if (risetime < 0)
+ risetime = 0.0;
+ falltime = ft[i];
+ if (falltime < 0)
+ falltime = 0.0;
+ risefactor = (risetime + 0.00025) * self->sr;
+ fallfactor = (falltime + 0.00025) * self->sr;
if (self->dir == 1)
- val = self->y1 + (*in++ - self->y1) / risefactor;
+ self->data[i] = self->y1 = self->y1 + (in[i] - self->y1) / risefactor;
else
- val = self->y1 + (*in++ - self->y1) / fallfactor;
- self->y1 = val;
- self->data[i] = val;
+ self->data[i] = self->y1 = self->y1 + (in[i] - self->y1) / fallfactor;
}
}
@@ -2596,7 +2599,7 @@ Port_dealloc(Port* self)
{
pyo_DEALLOC
Port_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2767,7 +2770,7 @@ static PyNumberMethods Port_as_number = {
(binaryfunc)Port_add, /*nb_add*/
(binaryfunc)Port_sub, /*nb_subtract*/
(binaryfunc)Port_multiply, /*nb_multiply*/
-(binaryfunc)Port_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2781,16 +2784,16 @@ static PyNumberMethods Port_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Port_inplace_add, /*inplace_add*/
(binaryfunc)Port_inplace_sub, /*inplace_subtract*/
(binaryfunc)Port_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Port_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2799,15 +2802,14 @@ static PyNumberMethods Port_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Port_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Port_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject PortType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Port_base", /*tp_name*/
sizeof(Port), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2815,7 +2817,7 @@ sizeof(Port), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Port_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2859,60 +2861,51 @@ typedef struct {
int modebuffer[3]; // need at least 2 slots for mul & add
MYFLT lastFreq;
MYFLT nyquist;
+ MYFLT mTwoPiOverSr;
// sample memories
MYFLT y1;
// variables
- MYFLT c1;
- MYFLT c2;
+ MYFLT c;
} Tone;
static void
Tone_filters_i(Tone *self) {
- MYFLT val, b;
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;
+ if (fr <= 0.1)
+ fr = 0.1;
else if (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;
+ self->c = MYEXP(self->mTwoPiOverSr * fr);
}
for (i=0; i<self->bufsize; i++) {
- val = self->c1 * in[i] + self->c2 * self->y1;
- self->data[i] = val;
- self->y1 = val;
+ self->data[i] = self->y1 = in[i] + (self->y1 - in[i]) * self->c;
}
}
static void
Tone_filters_a(Tone *self) {
- MYFLT val, freq, b;
int i;
+ MYFLT freq;
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->lastFreq) {
- if (freq <= 1.0)
- freq = 1.0;
+ if (freq <= 0.1)
+ freq = 0.1;
else if (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));
- self->c1 = 1.0 - self->c2;
+ self->c = MYEXP(self->mTwoPiOverSr * freq);
}
- val = self->c1 * in[i] + self->c2 * self->y1;
- self->data[i] = val;
- self->y1 = val;
+ self->data[i] = self->y1 = in[i] + (self->y1 - in[i]) * self->c;
}
}
@@ -3006,7 +2999,7 @@ Tone_dealloc(Tone* self)
{
pyo_DEALLOC
Tone_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3019,7 +3012,7 @@ Tone_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->freq = PyFloat_FromDouble(1000);
self->lastFreq = -1.0;
- self->y1 = self->c1 = self->c2 = 0.0;
+ self->y1 = self->c = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
@@ -3027,6 +3020,7 @@ Tone_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
INIT_OBJECT_COMMON
self->nyquist = (MYFLT)self->sr * 0.49;
+ self->mTwoPiOverSr = -TWOPI / (MYFLT)self->sr;
Stream_setFunctionPtr(self->stream, Tone_compute_next_data_frame);
self->mode_func_ptr = Tone_setProcMode;
@@ -3136,7 +3130,7 @@ static PyNumberMethods Tone_as_number = {
(binaryfunc)Tone_add, /*nb_add*/
(binaryfunc)Tone_sub, /*nb_subtract*/
(binaryfunc)Tone_multiply, /*nb_multiply*/
-(binaryfunc)Tone_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3150,16 +3144,16 @@ static PyNumberMethods Tone_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Tone_inplace_add, /*inplace_add*/
(binaryfunc)Tone_inplace_sub, /*inplace_subtract*/
(binaryfunc)Tone_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Tone_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3168,15 +3162,14 @@ static PyNumberMethods Tone_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Tone_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Tone_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ToneType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Tone_base", /*tp_name*/
sizeof(Tone), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3184,7 +3177,7 @@ sizeof(Tone), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Tone_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3228,58 +3221,53 @@ typedef struct {
int modebuffer[3]; // need at least 2 slots for mul & add
MYFLT lastFreq;
MYFLT nyquist;
+ MYFLT mTwoPiOverSr;
// sample memories
MYFLT y1;
// variables
- MYFLT c1;
- MYFLT c2;
+ MYFLT c;
} Atone;
static void
Atone_filters_i(Atone *self) {
- MYFLT val, b;
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;
+ if (fr <= 0.1)
+ fr = 0.1;
else if (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;
+ self->c = MYEXP(self->mTwoPiOverSr * fr);
}
for (i=0; i<self->bufsize; i++) {
- self->y1 = val = self->c1 * in[i] + self->c2 * self->y1;
- self->data[i] = in[i] - val;
+ self->y1 = in[i] + (self->y1 - in[i]) * self->c;
+ self->data[i] = in[i] - self->y1;
}
}
static void
Atone_filters_a(Atone *self) {
- MYFLT val, freq, b;
int i;
+ MYFLT freq;
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->lastFreq) {
- if (freq <= 1.0)
- freq = 1.0;
+ if (freq <= 0.1)
+ freq = 0.1;
else if (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));
- self->c1 = 1.0 - self->c2;
+ self->c = MYEXP(self->mTwoPiOverSr * freq);
}
- self->y1 = val = self->c1 * in[i] + self->c2 * self->y1;
- self->data[i] = in[i] - val;
+ self->y1 = in[i] + (self->y1 - in[i]) * self->c;
+ self->data[i] = in[i] - self->y1;
}
}
@@ -3373,7 +3361,7 @@ Atone_dealloc(Atone* self)
{
pyo_DEALLOC
Atone_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3386,7 +3374,7 @@ Atone_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->freq = PyFloat_FromDouble(1000);
self->lastFreq = -1.0;
- self->y1 = self->c1 = self->c2 = 0.0;
+ self->y1 = self->c = 0.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
@@ -3394,6 +3382,7 @@ Atone_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
INIT_OBJECT_COMMON
self->nyquist = (MYFLT)self->sr * 0.49;
+ self->mTwoPiOverSr = -TWOPI / (MYFLT)self->sr;
Stream_setFunctionPtr(self->stream, Atone_compute_next_data_frame);
self->mode_func_ptr = Atone_setProcMode;
@@ -3503,7 +3492,7 @@ static PyNumberMethods Atone_as_number = {
(binaryfunc)Atone_add, /*nb_add*/
(binaryfunc)Atone_sub, /*nb_subtract*/
(binaryfunc)Atone_multiply, /*nb_multiply*/
-(binaryfunc)Atone_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3517,16 +3506,16 @@ static PyNumberMethods Atone_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Atone_inplace_add, /*inplace_add*/
(binaryfunc)Atone_inplace_sub, /*inplace_subtract*/
(binaryfunc)Atone_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Atone_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3535,15 +3524,14 @@ static PyNumberMethods Atone_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Atone_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Atone_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject AtoneType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Atone_base", /*tp_name*/
sizeof(Atone), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3551,7 +3539,7 @@ sizeof(Atone), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Atone_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3591,22 +3579,18 @@ typedef struct {
PyObject *input;
Stream *input_stream;
int modebuffer[2]; // need at least 2 slots for mul & add
- // sample memories
MYFLT x1;
MYFLT y1;
} DCBlock;
static void
DCBlock_filters(DCBlock *self) {
- MYFLT x, y;
int i;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
for (i=0; i<self->bufsize; i++) {
- x = in[i];
- y = x - self->x1 + 0.995 * self->y1;
- self->x1 = x;
- self->data[i] = self->y1 = y;
+ self->data[i] = self->y1 = in[i] - self->x1 + 0.995 * self->y1;
+ self->x1 = in[i];
}
}
@@ -3689,7 +3673,7 @@ DCBlock_dealloc(DCBlock* self)
{
pyo_DEALLOC
DCBlock_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3776,7 +3760,7 @@ static PyNumberMethods DCBlock_as_number = {
(binaryfunc)DCBlock_add, /*nb_add*/
(binaryfunc)DCBlock_sub, /*nb_subtract*/
(binaryfunc)DCBlock_multiply, /*nb_multiply*/
-(binaryfunc)DCBlock_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3790,16 +3774,16 @@ static PyNumberMethods DCBlock_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)DCBlock_inplace_add, /*inplace_add*/
(binaryfunc)DCBlock_inplace_sub, /*inplace_subtract*/
(binaryfunc)DCBlock_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)DCBlock_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3808,15 +3792,14 @@ static PyNumberMethods DCBlock_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)DCBlock_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)DCBlock_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject DCBlockType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.DCBlock_base", /*tp_name*/
sizeof(DCBlock), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3824,7 +3807,7 @@ sizeof(DCBlock), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&DCBlock_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3873,7 +3856,7 @@ typedef struct {
static void
Allpass_process_ii(Allpass *self) {
- MYFLT val, xind, frac;
+ MYFLT val, xind, frac, omsqrf;
int i, ind;
MYFLT del = PyFloat_AS_DOUBLE(self->delay);
@@ -3889,6 +3872,7 @@ Allpass_process_ii(Allpass *self) {
feed = 0;
else if (feed > 1)
feed = 1;
+ omsqrf = 1.0 - (feed * feed);
MYFLT *in = Stream_getData((Stream *)self->input_stream);
@@ -3898,8 +3882,8 @@ Allpass_process_ii(Allpass *self) {
xind += self->size;
ind = (int)xind;
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;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
+ self->data[i] = val * omsqrf + in[i] * -feed;
self->buffer[self->in_count] = in[i] + (val * feed);
if (self->in_count == 0)
@@ -3912,7 +3896,7 @@ Allpass_process_ii(Allpass *self) {
static void
Allpass_process_ai(Allpass *self) {
- MYFLT val, xind, frac, sampdel, del;
+ MYFLT val, xind, frac, sampdel, del, omsqrf;
int i, ind;
MYFLT *delobj = Stream_getData((Stream *)self->delay_stream);
@@ -3922,6 +3906,7 @@ Allpass_process_ai(Allpass *self) {
feed = 0;
else if (feed > 1)
feed = 1;
+ omsqrf = 1.0 - (feed * feed);
MYFLT *in = Stream_getData((Stream *)self->input_stream);
@@ -3937,8 +3922,8 @@ Allpass_process_ai(Allpass *self) {
xind += self->size;
ind = (int)xind;
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;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
+ self->data[i] = val * omsqrf + in[i] * -feed;
self->buffer[self->in_count] = in[i] + (val * feed);
if (self->in_count == 0)
@@ -3976,7 +3961,7 @@ Allpass_process_ia(Allpass *self) {
xind += self->size;
ind = (int)xind;
frac = xind - ind;
- val = self->buffer[ind] * (1.0 - frac) + self->buffer[ind+1] * frac;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
self->data[i] = val * (1.0 - (feed * feed)) + in[i] * -feed;
self->buffer[self->in_count] = in[i] + (val * feed);
@@ -4015,7 +4000,7 @@ Allpass_process_aa(Allpass *self) {
xind += self->size;
ind = (int)xind;
frac = xind - ind;
- val = self->buffer[ind] * (1.0 - frac) + self->buffer[ind+1] * frac;
+ val = self->buffer[ind] + (self->buffer[ind+1] - self->buffer[ind]) * frac;
self->data[i] = val * (1.0 - (feed * feed)) + in[i] * -feed;
self->buffer[self->in_count] = in[i] + (val * feed);
@@ -4128,7 +4113,7 @@ Allpass_dealloc(Allpass* self)
pyo_DEALLOC
free(self->buffer);
Allpass_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4301,7 +4286,7 @@ static PyNumberMethods Allpass_as_number = {
(binaryfunc)Allpass_add, /*nb_add*/
(binaryfunc)Allpass_sub, /*nb_subtract*/
(binaryfunc)Allpass_multiply, /*nb_multiply*/
- (binaryfunc)Allpass_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4315,16 +4300,16 @@ static PyNumberMethods Allpass_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Allpass_inplace_add, /*inplace_add*/
(binaryfunc)Allpass_inplace_sub, /*inplace_subtract*/
(binaryfunc)Allpass_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Allpass_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4333,15 +4318,14 @@ static PyNumberMethods Allpass_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Allpass_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Allpass_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject AllpassType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Allpass_base", /*tp_name*/
sizeof(Allpass), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4349,7 +4333,7 @@ PyTypeObject AllpassType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Allpass_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4391,7 +4375,8 @@ typedef struct {
Stream *bw_stream;
int init;
int modebuffer[4]; // need at least 2 slots for mul & add
- MYFLT oneOnSr;
+ MYFLT minusPiOverSr;
+ MYFLT twoPiOverSr;
MYFLT nyquist;
// sample memories
MYFLT y1;
@@ -4410,8 +4395,8 @@ Allpass2_compute_variables(Allpass2 *self, MYFLT freq, MYFLT bw)
else if (freq >= self->nyquist)
freq = self->nyquist;
- radius = MYPOW(E, -PI * bw * self->oneOnSr);
- angle = TWOPI * freq * self->oneOnSr;
+ radius = MYEXP(bw * self->minusPiOverSr);
+ angle = freq * self->twoPiOverSr;
self->alpha = radius * radius;
self->beta = -2.0 * radius * MYCOS(angle);
@@ -4606,7 +4591,7 @@ Allpass2_dealloc(Allpass2* self)
{
pyo_DEALLOC
Allpass2_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4627,7 +4612,8 @@ Allpass2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
INIT_OBJECT_COMMON
- self->oneOnSr = 1.0 / self->sr;
+ self->minusPiOverSr = -PI / self->sr;
+ self->twoPiOverSr = TWOPI / self->sr;
self->nyquist = (MYFLT)self->sr * 0.49;
Stream_setFunctionPtr(self->stream, Allpass2_compute_next_data_frame);
@@ -4775,7 +4761,7 @@ static PyNumberMethods Allpass2_as_number = {
(binaryfunc)Allpass2_add, /*nb_add*/
(binaryfunc)Allpass2_sub, /*nb_subtract*/
(binaryfunc)Allpass2_multiply, /*nb_multiply*/
-(binaryfunc)Allpass2_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4789,16 +4775,16 @@ static PyNumberMethods Allpass2_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Allpass2_inplace_add, /*inplace_add*/
(binaryfunc)Allpass2_inplace_sub, /*inplace_subtract*/
(binaryfunc)Allpass2_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Allpass2_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4807,15 +4793,14 @@ static PyNumberMethods Allpass2_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Allpass2_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Allpass2_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject Allpass2Type = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Allpass2_base", /*tp_name*/
sizeof(Allpass2), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4823,7 +4808,7 @@ sizeof(Allpass2), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Allpass2_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4909,7 +4894,7 @@ Phaser_compute_variables(Phaser *self, MYFLT freq, MYFLT spread, MYFLT q)
else if (fr >= self->halfSr)
fr = self->halfSr;
- radius = MYPOW(E, fr * qfactor);
+ radius = MYEXP(fr * qfactor);
angle = fr * self->twoPiOnSr;
self->alpha[i] = radius * radius;
@@ -4917,7 +4902,7 @@ Phaser_compute_variables(Phaser *self, MYFLT freq, MYFLT spread, MYFLT q)
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);
+ self->beta[i] = -2.0 * radius * (HALF_COS_ARRAY[i] + (HALF_COS_ARRAY[i+1] - HALF_COS_ARRAY[i]) * fpart);
fr *= spread;
}
}
@@ -5354,7 +5339,7 @@ Phaser_dealloc(Phaser* self)
free(self->alpha);
free(self->beta);
Phaser_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5612,7 +5597,7 @@ static PyNumberMethods Phaser_as_number = {
(binaryfunc)Phaser_add, /*nb_add*/
(binaryfunc)Phaser_sub, /*nb_subtract*/
(binaryfunc)Phaser_multiply, /*nb_multiply*/
- (binaryfunc)Phaser_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5626,16 +5611,16 @@ static PyNumberMethods Phaser_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Phaser_inplace_add, /*inplace_add*/
(binaryfunc)Phaser_inplace_sub, /*inplace_subtract*/
(binaryfunc)Phaser_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Phaser_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5644,15 +5629,14 @@ static PyNumberMethods Phaser_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Phaser_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Phaser_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject PhaserType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Phaser_base", /*tp_name*/
sizeof(Phaser), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5660,7 +5644,7 @@ PyTypeObject PhaserType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Phaser_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -6585,7 +6569,7 @@ Vocoder_dealloc(Vocoder* self)
free(self->a2);
free(self->follow);
Vocoder_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -6867,7 +6851,7 @@ static PyNumberMethods Vocoder_as_number = {
(binaryfunc)Vocoder_add, /*nb_add*/
(binaryfunc)Vocoder_sub, /*nb_subtract*/
(binaryfunc)Vocoder_multiply, /*nb_multiply*/
- (binaryfunc)Vocoder_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -6881,16 +6865,16 @@ static PyNumberMethods Vocoder_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Vocoder_inplace_add, /*inplace_add*/
(binaryfunc)Vocoder_inplace_sub, /*inplace_subtract*/
(binaryfunc)Vocoder_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Vocoder_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -6899,15 +6883,14 @@ static PyNumberMethods Vocoder_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Vocoder_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Vocoder_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject VocoderType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Vocoder_base", /*tp_name*/
sizeof(Vocoder), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -6915,7 +6898,7 @@ PyTypeObject VocoderType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Vocoder_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -7462,7 +7445,7 @@ SVF_dealloc(SVF* self)
{
pyo_DEALLOC
SVF_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -7671,7 +7654,7 @@ static PyNumberMethods SVF_as_number = {
(binaryfunc)SVF_add, /*nb_add*/
(binaryfunc)SVF_sub, /*nb_subtract*/
(binaryfunc)SVF_multiply, /*nb_multiply*/
- (binaryfunc)SVF_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -7685,16 +7668,16 @@ static PyNumberMethods SVF_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)SVF_inplace_add, /*inplace_add*/
(binaryfunc)SVF_inplace_sub, /*inplace_subtract*/
(binaryfunc)SVF_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)SVF_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -7703,15 +7686,14 @@ static PyNumberMethods SVF_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)SVF_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)SVF_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SVFType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SVF_base", /*tp_name*/
sizeof(SVF), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -7719,7 +7701,7 @@ PyTypeObject SVFType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&SVF_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -7890,7 +7872,7 @@ Average_dealloc(Average* self)
pyo_DEALLOC
free(self->buffer);
Average_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -8015,7 +7997,7 @@ static PyNumberMethods Average_as_number = {
(binaryfunc)Average_add, /*nb_add*/
(binaryfunc)Average_sub, /*nb_subtract*/
(binaryfunc)Average_multiply, /*nb_multiply*/
- (binaryfunc)Average_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -8029,16 +8011,16 @@ static PyNumberMethods Average_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Average_inplace_add, /*inplace_add*/
(binaryfunc)Average_inplace_sub, /*inplace_subtract*/
(binaryfunc)Average_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Average_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -8047,15 +8029,14 @@ static PyNumberMethods Average_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Average_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Average_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject AverageType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Average_base", /*tp_name*/
sizeof(Average), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -8063,7 +8044,7 @@ PyTypeObject AverageType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Average_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -8331,7 +8312,7 @@ Reson_dealloc(Reson* self)
{
pyo_DEALLOC
Reson_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -8502,7 +8483,7 @@ static PyNumberMethods Reson_as_number = {
(binaryfunc)Reson_add, /*nb_add*/
(binaryfunc)Reson_sub, /*nb_subtract*/
(binaryfunc)Reson_multiply, /*nb_multiply*/
- (binaryfunc)Reson_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -8516,16 +8497,16 @@ static PyNumberMethods Reson_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Reson_inplace_add, /*inplace_add*/
(binaryfunc)Reson_inplace_sub, /*inplace_subtract*/
(binaryfunc)Reson_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Reson_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -8534,15 +8515,14 @@ static PyNumberMethods Reson_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Reson_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Reson_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ResonType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Reson_base", /*tp_name*/
sizeof(Reson), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -8550,7 +8530,7 @@ PyTypeObject ResonType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Reson_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -8856,7 +8836,7 @@ Resonx_dealloc(Resonx* self)
free(self->y1);
free(self->y2);
Resonx_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -9046,7 +9026,7 @@ static PyNumberMethods Resonx_as_number = {
(binaryfunc)Resonx_add, /*nb_add*/
(binaryfunc)Resonx_sub, /*nb_subtract*/
(binaryfunc)Resonx_multiply, /*nb_multiply*/
- (binaryfunc)Resonx_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -9060,16 +9040,16 @@ static PyNumberMethods Resonx_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Resonx_inplace_add, /*inplace_add*/
(binaryfunc)Resonx_inplace_sub, /*inplace_subtract*/
(binaryfunc)Resonx_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Resonx_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -9078,15 +9058,14 @@ static PyNumberMethods Resonx_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Resonx_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Resonx_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ResonxType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Resonx_base", /*tp_name*/
sizeof(Resonx), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -9094,7 +9073,7 @@ PyTypeObject ResonxType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Resonx_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -9161,8 +9140,8 @@ ButLP_filters_i(ButLP *self) {
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
if (fr != self->lastFreq) {
- if (fr <= 1.0)
- fr = 1.0;
+ if (fr < 0.1)
+ fr = 0.1;
else if (fr >= self->nyquist)
fr = self->nyquist;
self->lastFreq = fr;
@@ -9193,8 +9172,8 @@ ButLP_filters_a(ButLP *self) {
for (i=0; i<self->bufsize; i++) {
fr = freq[i];
if (fr != self->lastFreq) {
- if (fr <= 1.0)
- fr = 1.0;
+ if (fr < 0.1)
+ fr = 0.1;
else if (fr >= self->nyquist)
fr = self->nyquist;
self->lastFreq = fr;
@@ -9303,7 +9282,7 @@ ButLP_dealloc(ButLP* self)
{
pyo_DEALLOC
ButLP_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -9435,7 +9414,7 @@ static PyNumberMethods ButLP_as_number = {
(binaryfunc)ButLP_add, /*nb_add*/
(binaryfunc)ButLP_sub, /*nb_subtract*/
(binaryfunc)ButLP_multiply, /*nb_multiply*/
-(binaryfunc)ButLP_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -9449,16 +9428,16 @@ static PyNumberMethods ButLP_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)ButLP_inplace_add, /*inplace_add*/
(binaryfunc)ButLP_inplace_sub, /*inplace_subtract*/
(binaryfunc)ButLP_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)ButLP_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -9467,15 +9446,14 @@ static PyNumberMethods ButLP_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)ButLP_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)ButLP_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ButLPType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.ButLP_base", /*tp_name*/
sizeof(ButLP), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -9483,7 +9461,7 @@ sizeof(ButLP), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&ButLP_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -9550,8 +9528,8 @@ ButHP_filters_i(ButHP *self) {
MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
if (fr != self->lastFreq) {
- if (fr <= 1.0)
- fr = 1.0;
+ if (fr < 0.1)
+ fr = 0.1;
else if (fr >= self->nyquist)
fr = self->nyquist;
self->lastFreq = fr;
@@ -9582,8 +9560,8 @@ ButHP_filters_a(ButHP *self) {
for (i=0; i<self->bufsize; i++) {
fr = freq[i];
if (fr != self->lastFreq) {
- if (fr <= 1.0)
- fr = 1.0;
+ if (fr < 0.1)
+ fr = 0.1;
else if (fr >= self->nyquist)
fr = self->nyquist;
self->lastFreq = fr;
@@ -9692,7 +9670,7 @@ ButHP_dealloc(ButHP* self)
{
pyo_DEALLOC
ButHP_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -9824,7 +9802,7 @@ static PyNumberMethods ButHP_as_number = {
(binaryfunc)ButHP_add, /*nb_add*/
(binaryfunc)ButHP_sub, /*nb_subtract*/
(binaryfunc)ButHP_multiply, /*nb_multiply*/
-(binaryfunc)ButHP_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -9838,16 +9816,16 @@ static PyNumberMethods ButHP_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)ButHP_inplace_add, /*inplace_add*/
(binaryfunc)ButHP_inplace_sub, /*inplace_subtract*/
(binaryfunc)ButHP_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)ButHP_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -9856,15 +9834,14 @@ static PyNumberMethods ButHP_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)ButHP_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)ButHP_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ButHPType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.ButHP_base", /*tp_name*/
sizeof(ButHP), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -9872,7 +9849,7 @@ sizeof(ButHP), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&ButHP_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -10147,7 +10124,7 @@ ButBP_dealloc(ButBP* self)
{
pyo_DEALLOC
ButBP_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -10318,7 +10295,7 @@ static PyNumberMethods ButBP_as_number = {
(binaryfunc)ButBP_add, /*nb_add*/
(binaryfunc)ButBP_sub, /*nb_subtract*/
(binaryfunc)ButBP_multiply, /*nb_multiply*/
- (binaryfunc)ButBP_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -10332,16 +10309,16 @@ static PyNumberMethods ButBP_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)ButBP_inplace_add, /*inplace_add*/
(binaryfunc)ButBP_inplace_sub, /*inplace_subtract*/
(binaryfunc)ButBP_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)ButBP_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -10350,15 +10327,14 @@ static PyNumberMethods ButBP_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)ButBP_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)ButBP_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ButBPType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.ButBP_base", /*tp_name*/
sizeof(ButBP), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -10366,7 +10342,7 @@ PyTypeObject ButBPType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&ButBP_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -10641,7 +10617,7 @@ ButBR_dealloc(ButBR* self)
{
pyo_DEALLOC
ButBR_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -10812,7 +10788,7 @@ static PyNumberMethods ButBR_as_number = {
(binaryfunc)ButBR_add, /*nb_add*/
(binaryfunc)ButBR_sub, /*nb_subtract*/
(binaryfunc)ButBR_multiply, /*nb_multiply*/
- (binaryfunc)ButBR_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -10826,16 +10802,16 @@ static PyNumberMethods ButBR_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)ButBR_inplace_add, /*inplace_add*/
(binaryfunc)ButBR_inplace_sub, /*inplace_subtract*/
(binaryfunc)ButBR_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)ButBR_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -10844,15 +10820,14 @@ static PyNumberMethods ButBR_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)ButBR_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)ButBR_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ButBRType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.ButBR_base", /*tp_name*/
sizeof(ButBR), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -10860,7 +10835,7 @@ PyTypeObject ButBRType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&ButBR_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -11141,7 +11116,7 @@ ComplexRes_dealloc(ComplexRes* self)
{
pyo_DEALLOC
ComplexRes_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -11313,7 +11288,7 @@ static PyNumberMethods ComplexRes_as_number = {
(binaryfunc)ComplexRes_add, /*nb_add*/
(binaryfunc)ComplexRes_sub, /*nb_subtract*/
(binaryfunc)ComplexRes_multiply, /*nb_multiply*/
-(binaryfunc)ComplexRes_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -11327,16 +11302,16 @@ static PyNumberMethods ComplexRes_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)ComplexRes_inplace_add, /*inplace_add*/
(binaryfunc)ComplexRes_inplace_sub, /*inplace_subtract*/
(binaryfunc)ComplexRes_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)ComplexRes_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -11345,15 +11320,14 @@ static PyNumberMethods ComplexRes_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)ComplexRes_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)ComplexRes_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ComplexResType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.ComplexRes_base", /*tp_name*/
sizeof(ComplexRes), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -11361,7 +11335,7 @@ sizeof(ComplexRes), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&ComplexRes_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -11391,4 +11365,511 @@ ComplexRes_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
ComplexRes_new, /* tp_new */
-};
\ No newline at end of file
+};
+
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *input;
+ Stream *input_stream;
+ PyObject *freq;
+ Stream *freq_stream;
+ PyObject *res;
+ Stream *res_stream;
+ int modebuffer[4]; // need at least 2 slots for mul & add
+ MYFLT nyquist;
+ MYFLT last_freq;
+ MYFLT last_res;
+ // sample memories
+ MYFLT y1;
+ MYFLT y2;
+ MYFLT y3;
+ MYFLT y4;
+ MYFLT oldX;
+ MYFLT oldY1;
+ MYFLT oldY2;
+ MYFLT oldY3;
+ MYFLT oneOverSr;
+ // coefficients
+ MYFLT r;
+ MYFLT p;
+ MYFLT k;
+} MoogLP;
+
+static void
+MoogLP_compute_coeffs(MoogLP *self, MYFLT freq, MYFLT res)
+{
+ MYFLT f, fi, t, t2;
+
+ if (freq < 0.1)
+ freq = 0.1;
+ else if (freq > self->nyquist)
+ freq = self->nyquist;
+ if (res < 0.0)
+ res = 0.0;
+ else if (res > 10.0)
+ res = 10.0;
+
+ f = (freq + freq) * self->oneOverSr;
+ fi = 1.0 - f;
+ self->p = f * (1.8 - 0.8 * f);
+ self->k = 2.0 * MYSIN(f * PI * 0.5) - 1.0;
+ t = (1.0 - self->p) * 1.386249;
+ t2 = 12.0 + t * t;
+ self->r = res * 0.5 * (t2 + 6.0 * t) / (t2 - 6.0 * t);
+ /* Resonance compensation according to normalized frequency. */
+ self->r *= fi * fi * fi * 0.9 + 0.1;
+}
+
+static void
+MoogLP_filters_ii(MoogLP *self) {
+ MYFLT x, fr, res;
+ int i;
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ fr = PyFloat_AS_DOUBLE(self->freq);
+ res = PyFloat_AS_DOUBLE(self->res);
+
+ if (fr != self->last_freq || res != self->last_res) {
+ self->last_freq = fr;
+ self->last_res = res;
+ MoogLP_compute_coeffs(self, fr, res);
+ }
+
+ for (i=0; i<self->bufsize; i++) {
+ x = in[i] - self->r * self->y4;
+ self->y1 = (x + self->oldX) * self->p - self->k * self->y1;
+ self->y2 = (self->y1 + self->oldY1) * self->p - self->k * self->y2;
+ self->y3 = (self->y2 + self->oldY2) * self->p - self->k * self->y3;
+ self->y4 = (self->y3 + self->oldY3) * self->p - self->k * self->y4;
+ self->y4 -= (self->y4*self->y4*self->y4) * 0.16666666666666666;
+ self->oldX = x; self->oldY1 = self->y1; self->oldY2 = self->y2; self->oldY3 = self->y3;
+ self->data[i] = self->y4;
+ }
+}
+
+static void
+MoogLP_filters_ai(MoogLP *self) {
+ MYFLT x, fr, res;
+ int i;
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
+ res = PyFloat_AS_DOUBLE(self->res);
+
+ for (i=0; i<self->bufsize; i++) {
+ fr = freq[i];
+ if (fr != self->last_freq || res != self->last_res) {
+ self->last_freq = fr;
+ self->last_res = res;
+ MoogLP_compute_coeffs(self, fr, res);
+ }
+ x = in[i] - self->r * self->y4;
+ self->y1 = (x + self->oldX) * self->p - self->k * self->y1;
+ self->y2 = (self->y1 + self->oldY1) * self->p - self->k * self->y2;
+ self->y3 = (self->y2 + self->oldY2) * self->p - self->k * self->y3;
+ self->y4 = (self->y3 + self->oldY3) * self->p - self->k * self->y4;
+ self->y4 -= (self->y4*self->y4*self->y4) * 0.16666666666666666;
+ self->oldX = x; self->oldY1 = self->y1; self->oldY2 = self->y2; self->oldY3 = self->y3;
+ self->data[i] = self->y4;
+ }
+}
+
+static void
+MoogLP_filters_ia(MoogLP *self) {
+ MYFLT x, fr, res;
+ int i;
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ fr = PyFloat_AS_DOUBLE(self->freq);
+ MYFLT *rz = Stream_getData((Stream *)self->res_stream);
+
+ for (i=0; i<self->bufsize; i++) {
+ res = rz[i];
+ if (fr != self->last_freq || res != self->last_res) {
+ self->last_freq = fr;
+ self->last_res = res;
+ MoogLP_compute_coeffs(self, fr, res);
+ }
+ x = in[i] - self->r * self->y4;
+ self->y1 = (x + self->oldX) * self->p - self->k * self->y1;
+ self->y2 = (self->y1 + self->oldY1) * self->p - self->k * self->y2;
+ self->y3 = (self->y2 + self->oldY2) * self->p - self->k * self->y3;
+ self->y4 = (self->y3 + self->oldY3) * self->p - self->k * self->y4;
+ self->y4 -= (self->y4*self->y4*self->y4) * 0.16666666666666666;
+ self->oldX = x; self->oldY1 = self->y1; self->oldY2 = self->y2; self->oldY3 = self->y3;
+ self->data[i] = self->y4;
+ }
+}
+
+static void
+MoogLP_filters_aa(MoogLP *self) {
+ MYFLT x, fr, res;
+ int i;
+ MYFLT *in = Stream_getData((Stream *)self->input_stream);
+ MYFLT *freq = Stream_getData((Stream *)self->freq_stream);
+ MYFLT *rz = Stream_getData((Stream *)self->res_stream);
+
+ for (i=0; i<self->bufsize; i++) {
+ fr = freq[i];
+ res = rz[i];
+ if (fr != self->last_freq || res != self->last_res) {
+ self->last_freq = fr;
+ self->last_res = res;
+ MoogLP_compute_coeffs(self, fr, res);
+ }
+ x = in[i] - self->r * self->y4;
+ self->y1 = (x + self->oldX) * self->p - self->k * self->y1;
+ self->y2 = (self->y1 + self->oldY1) * self->p - self->k * self->y2;
+ self->y3 = (self->y2 + self->oldY2) * self->p - self->k * self->y3;
+ self->y4 = (self->y3 + self->oldY3) * self->p - self->k * self->y4;
+ self->y4 -= (self->y4*self->y4*self->y4) * 0.16666666666666666;
+ self->oldX = x; self->oldY1 = self->y1; self->oldY2 = self->y2; self->oldY3 = self->y3;
+ self->data[i] = self->y4;
+ }
+}
+
+static void MoogLP_postprocessing_ii(MoogLP *self) { POST_PROCESSING_II };
+static void MoogLP_postprocessing_ai(MoogLP *self) { POST_PROCESSING_AI };
+static void MoogLP_postprocessing_ia(MoogLP *self) { POST_PROCESSING_IA };
+static void MoogLP_postprocessing_aa(MoogLP *self) { POST_PROCESSING_AA };
+static void MoogLP_postprocessing_ireva(MoogLP *self) { POST_PROCESSING_IREVA };
+static void MoogLP_postprocessing_areva(MoogLP *self) { POST_PROCESSING_AREVA };
+static void MoogLP_postprocessing_revai(MoogLP *self) { POST_PROCESSING_REVAI };
+static void MoogLP_postprocessing_revaa(MoogLP *self) { POST_PROCESSING_REVAA };
+static void MoogLP_postprocessing_revareva(MoogLP *self) { POST_PROCESSING_REVAREVA };
+
+static void
+MoogLP_setProcMode(MoogLP *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 = MoogLP_filters_ii;
+ break;
+ case 1:
+ self->proc_func_ptr = MoogLP_filters_ai;
+ break;
+ case 10:
+ self->proc_func_ptr = MoogLP_filters_ia;
+ break;
+ case 11:
+ self->proc_func_ptr = MoogLP_filters_aa;
+ break;
+ }
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = MoogLP_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = MoogLP_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = MoogLP_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = MoogLP_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = MoogLP_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = MoogLP_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = MoogLP_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = MoogLP_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = MoogLP_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+MoogLP_compute_next_data_frame(MoogLP *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+MoogLP_traverse(MoogLP *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->res);
+ Py_VISIT(self->res_stream);
+ return 0;
+}
+
+static int
+MoogLP_clear(MoogLP *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->input);
+ Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->res);
+ Py_CLEAR(self->res_stream);
+ return 0;
+}
+
+static void
+MoogLP_dealloc(MoogLP* self)
+{
+ pyo_DEALLOC
+ MoogLP_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+static PyObject *
+MoogLP_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *inputtmp, *input_streamtmp, *freqtmp=NULL, *restmp=NULL, *multmp=NULL, *addtmp=NULL;
+ MoogLP *self;
+ self = (MoogLP *)type->tp_alloc(type, 0);
+
+ self->freq = PyFloat_FromDouble(1000);
+ self->res = PyFloat_FromDouble(1);
+ self->last_freq = self->last_res = -1.0;
+ self->y1 = self->y2 = self->y3 = self->y4 = self->oldX = self->oldY1 = self->oldY2 = self->oldY3 - 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.49;
+ self->oneOverSr = 1.0 / (MYFLT)self->sr;
+
+ Stream_setFunctionPtr(self->stream, MoogLP_compute_next_data_frame);
+ self->mode_func_ptr = MoogLP_setProcMode;
+
+ static char *kwlist[] = {"input", "freq", "res", "mul", "add", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &inputtmp, &freqtmp, &restmp, &multmp, &addtmp))
+ Py_RETURN_NONE;
+
+ INIT_INPUT_STREAM
+
+ if (freqtmp) {
+ PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
+ }
+
+ if (restmp) {
+ PyObject_CallMethod((PyObject *)self, "setRes", "O", restmp);
+ }
+
+ 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 * MoogLP_getServer(MoogLP* self) { GET_SERVER };
+static PyObject * MoogLP_getStream(MoogLP* self) { GET_STREAM };
+static PyObject * MoogLP_setMul(MoogLP *self, PyObject *arg) { SET_MUL };
+static PyObject * MoogLP_setAdd(MoogLP *self, PyObject *arg) { SET_ADD };
+static PyObject * MoogLP_setSub(MoogLP *self, PyObject *arg) { SET_SUB };
+static PyObject * MoogLP_setDiv(MoogLP *self, PyObject *arg) { SET_DIV };
+
+static PyObject * MoogLP_play(MoogLP *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * MoogLP_out(MoogLP *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * MoogLP_stop(MoogLP *self) { STOP };
+
+static PyObject * MoogLP_multiply(MoogLP *self, PyObject *arg) { MULTIPLY };
+static PyObject * MoogLP_inplace_multiply(MoogLP *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * MoogLP_add(MoogLP *self, PyObject *arg) { ADD };
+static PyObject * MoogLP_inplace_add(MoogLP *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * MoogLP_sub(MoogLP *self, PyObject *arg) { SUB };
+static PyObject * MoogLP_inplace_sub(MoogLP *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * MoogLP_div(MoogLP *self, PyObject *arg) { DIV };
+static PyObject * MoogLP_inplace_div(MoogLP *self, PyObject *arg) { INPLACE_DIV };
+
+static PyObject *
+MoogLP_setFreq(MoogLP *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->freq);
+ if (isNumber == 1) {
+ self->freq = PyNumber_Float(tmp);
+ self->modebuffer[2] = 0;
+ }
+ else {
+ self->freq = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->freq, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->freq_stream);
+ self->freq_stream = (Stream *)streamtmp;
+ self->modebuffer[2] = 1;
+ }
+
+ (*self->mode_func_ptr)(self);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+MoogLP_setRes(MoogLP *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->res);
+ if (isNumber == 1) {
+ self->res = PyNumber_Float(tmp);
+ self->modebuffer[3] = 0;
+ }
+ else {
+ self->res = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->res, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->res_stream);
+ self->res_stream = (Stream *)streamtmp;
+ self->modebuffer[3] = 1;
+ }
+
+ (*self->mode_func_ptr)(self);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef MoogLP_members[] = {
+ {"server", T_OBJECT_EX, offsetof(MoogLP, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(MoogLP, stream), 0, "Stream object."},
+ {"input", T_OBJECT_EX, offsetof(MoogLP, input), 0, "Input sound object."},
+ {"freq", T_OBJECT_EX, offsetof(MoogLP, freq), 0, "Cutoff frequency in cycle per second."},
+ {"res", T_OBJECT_EX, offsetof(MoogLP, res), 0, "Resonance factor."},
+ {"mul", T_OBJECT_EX, offsetof(MoogLP, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(MoogLP, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef MoogLP_methods[] = {
+ {"getServer", (PyCFunction)MoogLP_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)MoogLP_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)MoogLP_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)MoogLP_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)MoogLP_stop, METH_NOARGS, "Stops computing."},
+ {"setFreq", (PyCFunction)MoogLP_setFreq, METH_O, "Sets filter cutoff frequency in cycle per second."},
+ {"setRes", (PyCFunction)MoogLP_setRes, METH_O, "Sets filter's resonance."},
+ {"setMul", (PyCFunction)MoogLP_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)MoogLP_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)MoogLP_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)MoogLP_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods MoogLP_as_number = {
+ (binaryfunc)MoogLP_add, /*nb_add*/
+ (binaryfunc)MoogLP_sub, /*nb_subtract*/
+ (binaryfunc)MoogLP_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*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*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)MoogLP_inplace_add, /*inplace_add*/
+ (binaryfunc)MoogLP_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)MoogLP_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+ (binaryfunc)MoogLP_div, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ (binaryfunc)MoogLP_inplace_div, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
+};
+
+PyTypeObject MoogLPType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.MoogLP_base", /*tp_name*/
+ sizeof(MoogLP), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)MoogLP_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
+ 0, /*tp_repr*/
+ &MoogLP_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*/
+ "MoogLP objects. Second-order resonant bandpass filter.", /* tp_doc */
+ (traverseproc)MoogLP_traverse, /* tp_traverse */
+ (inquiry)MoogLP_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ MoogLP_methods, /* tp_methods */
+ MoogLP_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 */
+ MoogLP_new, /* tp_new */
+};
diff --git a/src/objects/freeverbmodule.c b/src/objects/freeverbmodule.c
index a0c6b0a..895efee 100644
--- a/src/objects/freeverbmodule.c
+++ b/src/objects/freeverbmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -613,7 +614,7 @@ Freeverb_dealloc(Freeverb* self)
free(self->allpass_buf[i]);
}
Freeverb_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -684,14 +685,14 @@ Freeverb_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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));
- self->allpass_nSamples[i] = nsamps;
- self->allpass_bufPos[i] = 0;
- for(j=0; j<nsamps; j++) {
- self->allpass_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));
+ self->allpass_nSamples[i] = nsamps;
+ self->allpass_bufPos[i] = 0;
+ for(j=0; j<nsamps; j++) {
+ self->allpass_buf[i][j] = 0.0;
+ }
}
return (PyObject *)self;
@@ -718,6 +719,26 @@ static PyObject * Freeverb_div(Freeverb *self, PyObject *arg) { DIV };
static PyObject * Freeverb_inplace_div(Freeverb *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
+Freeverb_reset(Freeverb *self)
+{
+ int i, j;
+ for(i=0; i<NUM_COMB; i++) {
+ self->comb_bufPos[i] = 0;
+ self->comb_filterState[i] = 0.0;
+ for(j=0; j<self->comb_nSamples[i]; j++) {
+ self->comb_buf[i][j] = 0.0;
+ }
+ }
+ for(i=0; i<NUM_ALLPASS; i++) {
+ self->allpass_bufPos[i] = 0;
+ for(j=0; j<self->allpass_nSamples[i]; j++) {
+ self->allpass_buf[i][j] = 0.0;
+ }
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *
Freeverb_setSize(Freeverb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -827,6 +848,7 @@ static PyMethodDef Freeverb_methods[] = {
{"play", (PyCFunction)Freeverb_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"out", (PyCFunction)Freeverb_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
{"stop", (PyCFunction)Freeverb_stop, METH_NOARGS, "Stops computing."},
+ {"reset", (PyCFunction)Freeverb_reset, METH_NOARGS, "Reset the delay lines."},
{"setSize", (PyCFunction)Freeverb_setSize, METH_O, "Sets distortion size factor (0 -> 1)."},
{"setDamp", (PyCFunction)Freeverb_setDamp, METH_O, "Sets lowpass filter damp factor."},
{"setMix", (PyCFunction)Freeverb_setMix, METH_O, "Sets the mix factor."},
@@ -841,7 +863,7 @@ static PyNumberMethods Freeverb_as_number = {
(binaryfunc)Freeverb_add, /*nb_add*/
(binaryfunc)Freeverb_sub, /*nb_subtract*/
(binaryfunc)Freeverb_multiply, /*nb_multiply*/
- (binaryfunc)Freeverb_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -855,16 +877,16 @@ static PyNumberMethods Freeverb_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Freeverb_inplace_add, /*inplace_add*/
(binaryfunc)Freeverb_inplace_sub, /*inplace_subtract*/
(binaryfunc)Freeverb_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Freeverb_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -873,15 +895,14 @@ static PyNumberMethods Freeverb_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Freeverb_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Freeverb_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject FreeverbType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Freeverb_base", /*tp_name*/
sizeof(Freeverb), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -889,7 +910,7 @@ PyTypeObject FreeverbType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Freeverb_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/granulatormodule.c b/src/objects/granulatormodule.c
index f07b6cb..f459b22 100644
--- a/src/objects/granulatormodule.c
+++ b/src/objects/granulatormodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -677,7 +678,7 @@ Granulator_dealloc(Granulator* self)
free(self->gsize);
free(self->lastppos);
Granulator_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1003,7 +1004,7 @@ static PyNumberMethods Granulator_as_number = {
(binaryfunc)Granulator_add, /*nb_add*/
(binaryfunc)Granulator_sub, /*nb_subtract*/
(binaryfunc)Granulator_multiply, /*nb_multiply*/
- (binaryfunc)Granulator_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1017,16 +1018,16 @@ static PyNumberMethods Granulator_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Granulator_inplace_add, /*inplace_add*/
(binaryfunc)Granulator_inplace_sub, /*inplace_subtract*/
(binaryfunc)Granulator_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Granulator_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1035,15 +1036,14 @@ static PyNumberMethods Granulator_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Granulator_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Granulator_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject GranulatorType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_pitch*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Granulator_base", /*tp_name*/
sizeof(Granulator), /*tp_basicpitch*/
0, /*tp_itempitch*/
@@ -1051,7 +1051,7 @@ PyTypeObject GranulatorType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Granulator_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1096,6 +1096,7 @@ typedef struct {
Stream *xfade_stream;
MYFLT *trigsBuffer;
TriggerStream *trig_stream;
+ MYFLT *time_buffer;
int xfadeshape;
int startfromloop;
int init;
@@ -1103,6 +1104,8 @@ typedef struct {
int tmpmode;
int direction[2];
double pointerPos[2];
+ double loopDuration;
+ int current;
int active[2];
long loopstart[2];
long loopend[2];
@@ -1115,16 +1118,45 @@ typedef struct {
MYFLT (*interp_func_ptr)(MYFLT *, int, MYFLT, int);
int modebuffer[6];
int autosmooth;
+ int appendfade;
+ int fadeinseconds;
MYFLT lastpitch;
// sample memories
MYFLT y1;
MYFLT y2;
// variables
MYFLT c1;
-
} Looper;
static void
+Looper_endloop(Looper *self) {
+ int which = self->current;
+ switch (self->mode[which]) {
+ case 0:
+ self->maxfadepoint[which] = self->pointerPos[which];
+ self->loopend[which] = self->maxfadepoint[which] + self->crossfadedur[which];
+ break;
+ case 1:
+ self->maxfadepoint[which] = self->pointerPos[which];
+ self->loopend[which] = self->maxfadepoint[which] + self->crossfadedur[which];
+ break;
+ case 2:
+ self->maxfadepoint[which] = self->pointerPos[which];
+ self->loopend[which] = self->maxfadepoint[which] - self->crossfadedur[which];
+ break;
+ case 3:
+ if (self->direction[which] == 0) {
+ self->maxfadepoint[which] = self->pointerPos[which];
+ self->loopend[which] = self->maxfadepoint[which] + self->crossfadedur[which];
+ } else {
+ self->maxfadepoint[which] = self->pointerPos[which];
+ self->loopend[which] = self->maxfadepoint[which] - self->crossfadedur[which];
+ }
+ break;
+ }
+}
+
+static void
Looper_reset(Looper *self, int x, int which, int init) {
MYFLT start, dur, xfade;
@@ -1150,6 +1182,10 @@ Looper_reset(Looper *self, int x, int which, int init) {
start = (MYFLT)(size/tableSr);
if (dur < 0.001)
dur = 0.001;
+
+ if (self->fadeinseconds == 1)
+ xfade = xfade / dur * 100.0;
+
if (xfade < 0.0)
xfade = 0.0;
else if (xfade > 50.0)
@@ -1164,6 +1200,8 @@ Looper_reset(Looper *self, int x, int which, int init) {
else
self->fader = LOOPER_LINEAR_FADE;
+ self->current = which;
+
if (self->tmpmode != self->mode[which])
self->mode[which] = self->tmpmode;
@@ -1174,9 +1212,12 @@ Looper_reset(Looper *self, int x, int which, int init) {
case 0:
self->loopstart[which] = 0;
self->loopend[which] = (long)size;
+ self->crossfadedur[which] = (long)((self->loopend[which] - self->loopstart[which]) * xfade * 0.01);
if (self->crossfadedur[which] < 1)
self->crossfadedur[which] = 1;
self->crossfadescaling[which] = 1.0 / self->crossfadedur[which] * 512.0;
+ if (self->appendfade == 1)
+ self->loopend[which] += self->crossfadedur[which];
if (init == 1 && self->startfromloop == 0) {
self->minfadepoint[which] = self->crossfadedur[which];
self->maxfadepoint[which] = self->loopend[which] - self->crossfadedur[which];
@@ -1187,6 +1228,7 @@ Looper_reset(Looper *self, int x, int which, int init) {
self->maxfadepoint[which] = self->loopend[which] - self->crossfadedur[which];
self->pointerPos[which] = self->loopstart[which];
}
+ self->loopDuration = self->maxfadepoint[which] - self->loopstart[which];
break;
case 1:
self->loopstart[which] = (long)(start * tableSr);
@@ -1195,6 +1237,8 @@ Looper_reset(Looper *self, int x, int which, int init) {
if (self->crossfadedur[which] < 1)
self->crossfadedur[which] = 1;
self->crossfadescaling[which] = 1.0 / self->crossfadedur[which] * 512.0;
+ if (self->appendfade == 1)
+ self->loopend[which] += self->crossfadedur[which];
if (init == 1 && self->startfromloop == 0) {
self->minfadepoint[which] = self->crossfadedur[which];
self->maxfadepoint[which] = self->loopend[which] - self->crossfadedur[which];
@@ -1205,6 +1249,7 @@ Looper_reset(Looper *self, int x, int which, int init) {
self->maxfadepoint[which] = self->loopend[which] - self->crossfadedur[which];
self->pointerPos[which] = self->loopstart[which];
}
+ self->loopDuration = self->maxfadepoint[which] - self->loopstart[which];
break;
case 2:
self->loopstart[which] = (long)((start + dur) * tableSr);
@@ -1213,6 +1258,8 @@ Looper_reset(Looper *self, int x, int which, int init) {
if (self->crossfadedur[which] < 1)
self->crossfadedur[which] = 1;
self->crossfadescaling[which] = 1.0 / self->crossfadedur[which] * 512.0;
+ if (self->appendfade == 1)
+ self->loopend[which] -= self->crossfadedur[which];
if (init == 1 && self->startfromloop == 0) {
self->minfadepoint[which] = size - self->crossfadedur[which];
self->maxfadepoint[which] = self->loopend[which] + self->crossfadedur[which];
@@ -1223,9 +1270,10 @@ Looper_reset(Looper *self, int x, int which, int init) {
self->maxfadepoint[which] = self->loopend[which] + self->crossfadedur[which];
self->pointerPos[which] = self->loopstart[which];
}
+ self->loopDuration = self->loopstart[which] - self->maxfadepoint[which];
break;
case 3:
- if (self->direction[1-which] == 0) {
+ if (self->direction[1-which] == 0 && init == 0) {
self->direction[which] = 1;
self->loopstart[which] = (long)((start + dur) * tableSr);
self->loopend[which] = (long)(start * tableSr);
@@ -1233,9 +1281,12 @@ Looper_reset(Looper *self, int x, int which, int init) {
if (self->crossfadedur[which] < 1)
self->crossfadedur[which] = 1;
self->crossfadescaling[which] = 1.0 / self->crossfadedur[which] * 512.0;
+ if (self->appendfade == 1)
+ self->loopend[which] -= self->crossfadedur[which];
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->loopDuration = self->loopstart[which] - self->maxfadepoint[which];
}
else {
self->direction[which] = 0;
@@ -1245,6 +1296,8 @@ Looper_reset(Looper *self, int x, int which, int init) {
if (self->crossfadedur[which] < 1)
self->crossfadedur[which] = 1;
self->crossfadescaling[which] = 1.0 / self->crossfadedur[which] * 512.0;
+ if (self->appendfade == 1)
+ self->loopend[which] += self->crossfadedur[which];
if (init == 1 && self->startfromloop == 0) {
self->minfadepoint[which] = self->crossfadedur[which];
self->maxfadepoint[which] = self->loopend[which] - self->crossfadedur[which];
@@ -1255,6 +1308,7 @@ Looper_reset(Looper *self, int x, int which, int init) {
self->maxfadepoint[which] = self->loopend[which] - self->crossfadedur[which];
self->pointerPos[which] = self->loopstart[which];
}
+ self->loopDuration = self->maxfadepoint[which] - self->loopstart[which];
}
break;
}
@@ -1271,7 +1325,7 @@ static void
Looper_transform_i(Looper *self) {
MYFLT fpart, amp, fr;
double pit;
- int i, j, ipart;
+ int i, j, k, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
@@ -1313,12 +1367,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.0)
- self->pointerPos[j] = 0.0;
+ if (self->pointerPos[j] < 0.0) {
+ self->pointerPos[j] = self->time_buffer[i] = 0.0;
+ }
+ else if (self->pointerPos[j] <= self->maxfadepoint[j]) {
+ self->time_buffer[i] = (self->pointerPos[j] - self->loopstart[j]) / self->loopDuration;
+ }
else if (self->pointerPos[j] >= self->loopend[j]) {
self->active[j] = 0;
+ for (k=0; k < self->bufsize; k++) {
+ self->time_buffer[k] = 0.0;
+ }
PyObject_CallMethod((PyObject *)self, "stop", NULL);
}
+ else {
+ self->time_buffer[i] = 1.0;
+ }
break;
case 1:
if (self->pointerPos[j] >= 0 && self->pointerPos[j] < size) {
@@ -1337,8 +1401,12 @@ 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.0)
- self->pointerPos[j] = 0.0;
+ if (self->pointerPos[j] < 0.0) {
+ self->pointerPos[j] = self->time_buffer[i] = 0.0;
+ }
+ else if (self->pointerPos[j] <= self->maxfadepoint[j]) {
+ self->time_buffer[i] = (self->pointerPos[j] - self->loopstart[j]) / self->loopDuration;
+ }
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])
@@ -1361,8 +1429,13 @@ 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] >= size)
+ if (self->pointerPos[j] >= size) {
self->pointerPos[j] = size-1;
+ self->time_buffer[i] = 0.0;
+ }
+ else if (self->pointerPos[j] >= self->maxfadepoint[j]) {
+ self->time_buffer[i] = (self->loopstart[j] - self->pointerPos[j]) / self->loopDuration;
+ }
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])
@@ -1386,8 +1459,12 @@ 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.0)
- self->pointerPos[j] = 0.0;
+ if (self->pointerPos[j] < 0.0) {
+ self->pointerPos[j] = self->time_buffer[i] = 0.0;
+ }
+ else if (self->pointerPos[j] <= self->maxfadepoint[j]) {
+ self->time_buffer[i] = (self->pointerPos[j] - self->loopstart[j]) / self->loopDuration;
+ }
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])
@@ -1410,8 +1487,13 @@ 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] >= size)
+ if (self->pointerPos[j] >= size) {
self->pointerPos[j] = size-1;
+ self->time_buffer[i] = 0.0;
+ }
+ else if (self->pointerPos[j] >= self->maxfadepoint[j]) {
+ self->time_buffer[i] = (self->loopstart[j] - self->pointerPos[j]) / self->loopDuration;
+ }
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])
@@ -1444,7 +1526,7 @@ static void
Looper_transform_a(Looper *self) {
MYFLT fpart, amp, fr, pitval;
double pit, srFactor;
- int i, j, ipart;
+ int i, j, k, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
@@ -1488,10 +1570,17 @@ 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.0)
- self->pointerPos[j] = 0.0;
+ if (self->pointerPos[j] < 0.0) {
+ self->pointerPos[j] = self->time_buffer[i] = 0.0;
+ }
+ else if (self->pointerPos[j] <= self->maxfadepoint[j]) {
+ self->time_buffer[i] = (self->pointerPos[j] - self->loopstart[j]) / self->loopDuration;
+ }
else if (self->pointerPos[j] >= self->loopend[j]) {
self->active[j] = 0;
+ for (k=0; k < self->bufsize; k++) {
+ self->time_buffer[k] = 0.0;
+ }
PyObject_CallMethod((PyObject *)self, "stop", NULL);
}
break;
@@ -1512,8 +1601,12 @@ 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.0)
- self->pointerPos[j] = 0.0;
+ if (self->pointerPos[j] < 0.0) {
+ self->pointerPos[j] = self->time_buffer[i] = 0.0;
+ }
+ else if (self->pointerPos[j] <= self->maxfadepoint[j]) {
+ self->time_buffer[i] = (self->pointerPos[j] - self->loopstart[j]) / self->loopDuration;
+ }
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])
@@ -1536,8 +1629,13 @@ 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] >= size)
+ if (self->pointerPos[j] >= size) {
self->pointerPos[j] = size-1;
+ self->time_buffer[i] = 0.0;
+ }
+ else if (self->pointerPos[j] >= self->maxfadepoint[j]) {
+ self->time_buffer[i] = (self->loopstart[j] - self->pointerPos[j]) / self->loopDuration;
+ }
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])
@@ -1561,8 +1659,12 @@ 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.0)
- self->pointerPos[j] = 0.0;
+ if (self->pointerPos[j] < 0.0) {
+ self->pointerPos[j] = self->time_buffer[i] = 0.0;
+ }
+ else if (self->pointerPos[j] <= self->maxfadepoint[j]) {
+ self->time_buffer[i] = (self->pointerPos[j] - self->loopstart[j]) / self->loopDuration;
+ }
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])
@@ -1585,8 +1687,13 @@ 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] >= size)
+ if (self->pointerPos[j] >= size) {
self->pointerPos[j] = size-1;
+ self->time_buffer[i] = 0.0;
+ }
+ else if (self->pointerPos[j] >= self->maxfadepoint[j]) {
+ self->time_buffer[i] = (self->loopstart[j] - self->pointerPos[j]) / self->loopDuration;
+ }
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])
@@ -1681,6 +1788,11 @@ Looper_compute_next_data_frame(Looper *self)
(*self->muladd_func_ptr)(self);
}
+static MYFLT *
+Looper_getTimeBuffer(Looper *self) {
+ return self->time_buffer;
+}
+
static int
Looper_traverse(Looper *self, visitproc visit, void *arg)
{
@@ -1720,8 +1832,9 @@ Looper_dealloc(Looper* self)
{
pyo_DEALLOC
free(self->trigsBuffer);
+ free(self->time_buffer);
Looper_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1743,10 +1856,12 @@ Looper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->startfromloop = 0;
self->interp = 2;
self->init = 1;
+ self->appendfade = self->fadeinseconds = 0;
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->loopDuration = 0.0;
+ self->active[0] = self->active[1] = self->current = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
@@ -1798,9 +1913,10 @@ Looper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
(*self->mode_func_ptr)(self);
self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
+ self->time_buffer = (MYFLT *)realloc(self->time_buffer, self->bufsize * sizeof(MYFLT));
for (i=0; i<self->bufsize; i++) {
- self->trigsBuffer[i] = 0.0;
+ self->trigsBuffer[i] = self->time_buffer[i] = 0.0;
}
MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
@@ -2066,6 +2182,43 @@ Looper_on_reset(Looper *self) {
return Py_None;
};
+static PyObject *
+Looper_loopnow(Looper *self) {
+ Looper_endloop(self);
+ Py_INCREF(Py_None);
+ return Py_None;
+};
+
+static PyObject *
+Looper_appendFadeTime(Looper *self, PyObject *arg)
+{
+ ASSERT_ARG_NOT_NULL
+
+ int isInt = PyInt_Check(arg);
+
+ if (isInt == 1) {
+ self->appendfade = PyInt_AsLong(arg) == 0 ? 0 : 1;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+Looper_fadeInSeconds(Looper *self, PyObject *arg)
+{
+ ASSERT_ARG_NOT_NULL
+
+ int isInt = PyInt_Check(arg);
+
+ if (isInt == 1) {
+ self->fadeinseconds = PyInt_AsLong(arg) == 0 ? 0 : 1;
+ }
+
+ 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."},
@@ -2098,7 +2251,10 @@ 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."},
+ {"appendFadeTime", (PyCFunction)Looper_appendFadeTime, METH_O, "If positive, fade time is added to loop duration."},
+ {"fadeInSeconds", (PyCFunction)Looper_fadeInSeconds, METH_O, "If positive, fade time is set in seconds instead of percentage."},
{"reset", (PyCFunction)Looper_on_reset, METH_NOARGS, "Resets internal counters."},
+ {"loopnow", (PyCFunction)Looper_loopnow, METH_NOARGS, "Satrts a new loop immediately."},
{"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."},
@@ -2110,7 +2266,7 @@ static PyNumberMethods Looper_as_number = {
(binaryfunc)Looper_add, /*nb_add*/
(binaryfunc)Looper_sub, /*nb_subtract*/
(binaryfunc)Looper_multiply, /*nb_multiply*/
- (binaryfunc)Looper_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2124,16 +2280,16 @@ static PyNumberMethods Looper_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Looper_inplace_add, /*inplace_add*/
(binaryfunc)Looper_inplace_sub, /*inplace_subtract*/
(binaryfunc)Looper_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Looper_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2142,15 +2298,14 @@ static PyNumberMethods Looper_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Looper_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Looper_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject LooperType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_pitch*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Looper_base", /*tp_name*/
sizeof(Looper), /*tp_basicpitch*/
0, /*tp_itempitch*/
@@ -2158,7 +2313,7 @@ PyTypeObject LooperType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Looper_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2190,6 +2345,249 @@ PyTypeObject LooperType = {
Looper_new, /* tp_new */
};
+typedef struct {
+ pyo_audio_HEAD
+ Looper *mainPlayer;
+ int modebuffer[2];
+} LooperTimeStream;
+
+static void LooperTimeStream_postprocessing_ii(LooperTimeStream *self) { POST_PROCESSING_II };
+static void LooperTimeStream_postprocessing_ai(LooperTimeStream *self) { POST_PROCESSING_AI };
+static void LooperTimeStream_postprocessing_ia(LooperTimeStream *self) { POST_PROCESSING_IA };
+static void LooperTimeStream_postprocessing_aa(LooperTimeStream *self) { POST_PROCESSING_AA };
+static void LooperTimeStream_postprocessing_ireva(LooperTimeStream *self) { POST_PROCESSING_IREVA };
+static void LooperTimeStream_postprocessing_areva(LooperTimeStream *self) { POST_PROCESSING_AREVA };
+static void LooperTimeStream_postprocessing_revai(LooperTimeStream *self) { POST_PROCESSING_REVAI };
+static void LooperTimeStream_postprocessing_revaa(LooperTimeStream *self) { POST_PROCESSING_REVAA };
+static void LooperTimeStream_postprocessing_revareva(LooperTimeStream *self) { POST_PROCESSING_REVAREVA };
+
+static void
+LooperTimeStream_setProcMode(LooperTimeStream *self) {
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = LooperTimeStream_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = LooperTimeStream_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = LooperTimeStream_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = LooperTimeStream_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = LooperTimeStream_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = LooperTimeStream_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = LooperTimeStream_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = LooperTimeStream_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = LooperTimeStream_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+LooperTimeStream_compute_next_data_frame(LooperTimeStream *self)
+{
+ int i;
+ MYFLT *tmp;
+ tmp = Looper_getTimeBuffer((Looper *)self->mainPlayer);
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = tmp[i];
+ }
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+LooperTimeStream_traverse(LooperTimeStream *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->mainPlayer);
+ return 0;
+}
+
+static int
+LooperTimeStream_clear(LooperTimeStream *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->mainPlayer);
+ return 0;
+}
+
+static void
+LooperTimeStream_dealloc(LooperTimeStream* self)
+{
+ pyo_DEALLOC
+ LooperTimeStream_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+static PyObject *
+LooperTimeStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *maintmp=NULL;
+ LooperTimeStream *self;
+ self = (LooperTimeStream *)type->tp_alloc(type, 0);
+
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, LooperTimeStream_compute_next_data_frame);
+ self->mode_func_ptr = LooperTimeStream_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 = (Looper *)maintmp;
+
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * LooperTimeStream_getServer(LooperTimeStream* self) { GET_SERVER };
+static PyObject * LooperTimeStream_getStream(LooperTimeStream* self) { GET_STREAM };
+static PyObject * LooperTimeStream_setMul(LooperTimeStream *self, PyObject *arg) { SET_MUL };
+static PyObject * LooperTimeStream_setAdd(LooperTimeStream *self, PyObject *arg) { SET_ADD };
+static PyObject * LooperTimeStream_setSub(LooperTimeStream *self, PyObject *arg) { SET_SUB };
+static PyObject * LooperTimeStream_setDiv(LooperTimeStream *self, PyObject *arg) { SET_DIV };
+
+static PyObject * LooperTimeStream_play(LooperTimeStream *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * LooperTimeStream_out(LooperTimeStream *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * LooperTimeStream_stop(LooperTimeStream *self) { STOP };
+
+static PyObject * LooperTimeStream_multiply(LooperTimeStream *self, PyObject *arg) { MULTIPLY };
+static PyObject * LooperTimeStream_inplace_multiply(LooperTimeStream *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * LooperTimeStream_add(LooperTimeStream *self, PyObject *arg) { ADD };
+static PyObject * LooperTimeStream_inplace_add(LooperTimeStream *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * LooperTimeStream_sub(LooperTimeStream *self, PyObject *arg) { SUB };
+static PyObject * LooperTimeStream_inplace_sub(LooperTimeStream *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * LooperTimeStream_div(LooperTimeStream *self, PyObject *arg) { DIV };
+static PyObject * LooperTimeStream_inplace_div(LooperTimeStream *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef LooperTimeStream_members[] = {
+ {"server", T_OBJECT_EX, offsetof(LooperTimeStream, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(LooperTimeStream, stream), 0, "Stream object."},
+ {"mul", T_OBJECT_EX, offsetof(LooperTimeStream, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(LooperTimeStream, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef LooperTimeStream_methods[] = {
+ {"getServer", (PyCFunction)LooperTimeStream_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)LooperTimeStream_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)LooperTimeStream_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)LooperTimeStream_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)LooperTimeStream_stop, METH_NOARGS, "Stops computing."},
+ {"setMul", (PyCFunction)LooperTimeStream_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)LooperTimeStream_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)LooperTimeStream_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)LooperTimeStream_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods LooperTimeStream_as_number = {
+ (binaryfunc)LooperTimeStream_add, /*nb_add*/
+ (binaryfunc)LooperTimeStream_sub, /*nb_subtract*/
+ (binaryfunc)LooperTimeStream_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*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*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)LooperTimeStream_inplace_add, /*inplace_add*/
+ (binaryfunc)LooperTimeStream_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)LooperTimeStream_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+ (binaryfunc)LooperTimeStream_div, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ (binaryfunc)LooperTimeStream_inplace_div, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
+};
+
+PyTypeObject LooperTimeStreamType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.LooperTimeStream_base", /*tp_name*/
+ sizeof(LooperTimeStream), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)LooperTimeStream_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
+ 0, /*tp_repr*/
+ &LooperTimeStream_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*/
+ "LooperTimeStream objects. Returns the current recording time, in samples, of a Looper object.", /* tp_doc */
+ (traverseproc)LooperTimeStream_traverse, /* tp_traverse */
+ (inquiry)LooperTimeStream_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ LooperTimeStream_methods, /* tp_methods */
+ LooperTimeStream_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 */
+ LooperTimeStream_new, /* tp_new */
+};
+
static const MYFLT Granule_MAX_GRAINS = 4096;
typedef struct {
pyo_audio_HEAD
@@ -2509,7 +2907,7 @@ Granule_dealloc(Granule* self)
free(self->flags);
free(self->phase);
Granule_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2842,7 +3240,7 @@ static PyNumberMethods Granule_as_number = {
(binaryfunc)Granule_add, /*nb_add*/
(binaryfunc)Granule_sub, /*nb_subtract*/
(binaryfunc)Granule_multiply, /*nb_multiply*/
- (binaryfunc)Granule_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2856,16 +3254,16 @@ static PyNumberMethods Granule_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Granule_inplace_add, /*inplace_add*/
(binaryfunc)Granule_inplace_sub, /*inplace_subtract*/
(binaryfunc)Granule_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Granule_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2874,15 +3272,14 @@ static PyNumberMethods Granule_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Granule_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Granule_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject GranuleType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_pitch*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Granule_base", /*tp_name*/
sizeof(Granule), /*tp_basicpitch*/
0, /*tp_itempitch*/
@@ -2890,7 +3287,7 @@ PyTypeObject GranuleType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Granule_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3511,7 +3908,7 @@ MainParticle_dealloc(MainParticle* self)
free(self->amp2);
free(self->buffer_streams);
MainParticle_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
MYFLT *
@@ -3889,8 +4286,7 @@ static PyMethodDef MainParticle_methods[] = {
};
PyTypeObject MainParticleType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_pitch*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MainParticle_base", /*tp_name*/
sizeof(MainParticle), /*tp_basicpitch*/
0, /*tp_itempitch*/
@@ -3898,7 +4294,7 @@ PyTypeObject MainParticleType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4018,7 +4414,7 @@ Particle_dealloc(Particle* self)
{
pyo_DEALLOC
Particle_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4105,7 +4501,7 @@ 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*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4119,16 +4515,16 @@ static PyNumberMethods Particle_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*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*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4137,15 +4533,14 @@ static PyNumberMethods Particle_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Particle_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Particle_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ParticleType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Particle_base", /*tp_name*/
sizeof(Particle), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4153,7 +4548,7 @@ sizeof(Particle), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Particle_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/harmonizermodule.c b/src/objects/harmonizermodule.c
index ca4214d..a9653d8 100644
--- a/src/objects/harmonizermodule.c
+++ b/src/objects/harmonizermodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -422,7 +423,7 @@ Harmonizer_dealloc(Harmonizer* self)
pyo_DEALLOC
free(self->buffer);
Harmonizer_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -481,7 +482,7 @@ Harmonizer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (wintmp > 0.0 && wintmp <= 1.0)
self->winsize = wintmp;
else
- printf("Harmonizer : winsize lower than 0.0 or larger than 1.0 second, keeping default value.\n");
+ PySys_WriteStdout("Harmonizer : winsize lower than 0.0 or larger than 1.0 second, keeping default value.\n");
(*self->mode_func_ptr)(self);
@@ -509,6 +510,16 @@ static PyObject * Harmonizer_div(Harmonizer *self, PyObject *arg) { DIV };
static PyObject * Harmonizer_inplace_div(Harmonizer *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
+Harmonizer_reset(Harmonizer *self)
+{
+ int i;
+ for (i=0; i<(self->sr+1); i++) {
+ self->buffer[i] = 0.;
+ }
+ Py_RETURN_NONE;
+}
+
+static PyObject *
Harmonizer_setTranspo(Harmonizer *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -584,7 +595,7 @@ Harmonizer_setWinsize(Harmonizer *self, PyObject *arg)
if (wintmp > 0.0 && wintmp <= 1.0)
self->winsize = wintmp;
else
- printf("winsize lower than 0.0 or larger than 1.0 second!\n");
+ PySys_WriteStdout("Harmonizer: winsize lower than 0.0 or larger than 1.0 second!\n");
}
Py_INCREF(Py_None);
@@ -608,6 +619,7 @@ static PyMethodDef Harmonizer_methods[] = {
{"play", (PyCFunction)Harmonizer_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"out", (PyCFunction)Harmonizer_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
{"stop", (PyCFunction)Harmonizer_stop, METH_NOARGS, "Stops computing."},
+ {"reset", (PyCFunction)Harmonizer_reset, METH_NOARGS, "Reset the delay line."},
{"setTranspo", (PyCFunction)Harmonizer_setTranspo, METH_O, "Sets global transpo factor."},
{"setFeedback", (PyCFunction)Harmonizer_setFeedback, METH_O, "Sets feedback factor."},
{"setWinsize", (PyCFunction)Harmonizer_setWinsize, METH_O, "Sets the window size."},
@@ -622,7 +634,7 @@ static PyNumberMethods Harmonizer_as_number = {
(binaryfunc)Harmonizer_add, /*nb_add*/
(binaryfunc)Harmonizer_sub, /*nb_subtract*/
(binaryfunc)Harmonizer_multiply, /*nb_multiply*/
- (binaryfunc)Harmonizer_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -636,16 +648,16 @@ static PyNumberMethods Harmonizer_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Harmonizer_inplace_add, /*inplace_add*/
(binaryfunc)Harmonizer_inplace_sub, /*inplace_subtract*/
(binaryfunc)Harmonizer_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Harmonizer_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -654,15 +666,14 @@ static PyNumberMethods Harmonizer_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Harmonizer_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Harmonizer_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject HarmonizerType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_transpo*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Harmonizer_base", /*tp_name*/
sizeof(Harmonizer), /*tp_basictranspo*/
0, /*tp_itemtranspo*/
@@ -670,7 +681,7 @@ PyTypeObject HarmonizerType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Harmonizer_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/hilbertmodule.c b/src/objects/hilbertmodule.c
index 639bff1..1aae321 100644
--- a/src/objects/hilbertmodule.c
+++ b/src/objects/hilbertmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -127,7 +128,7 @@ HilbertMain_dealloc(HilbertMain* self)
pyo_DEALLOC
free(self->buffer_streams);
HilbertMain_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -187,8 +188,7 @@ static PyMethodDef HilbertMain_methods[] = {
};
PyTypeObject HilbertMainType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.HilbertMain_base", /*tp_name*/
sizeof(HilbertMain), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -196,7 +196,7 @@ sizeof(HilbertMain), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -319,7 +319,7 @@ Hilbert_dealloc(Hilbert* self)
{
pyo_DEALLOC
Hilbert_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -406,7 +406,7 @@ static PyNumberMethods Hilbert_as_number = {
(binaryfunc)Hilbert_add, /*nb_add*/
(binaryfunc)Hilbert_sub, /*nb_subtract*/
(binaryfunc)Hilbert_multiply, /*nb_multiply*/
-(binaryfunc)Hilbert_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -420,16 +420,16 @@ static PyNumberMethods Hilbert_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Hilbert_inplace_add, /*inplace_add*/
(binaryfunc)Hilbert_inplace_sub, /*inplace_subtract*/
(binaryfunc)Hilbert_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Hilbert_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -438,15 +438,14 @@ static PyNumberMethods Hilbert_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Hilbert_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Hilbert_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject HilbertType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Hilbert_base", /*tp_name*/
sizeof(Hilbert), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -454,7 +453,7 @@ sizeof(Hilbert), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Hilbert_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/inputmodule.c b/src/objects/inputmodule.c
index cd3df62..e9025a2 100644
--- a/src/objects/inputmodule.c
+++ b/src/objects/inputmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -110,7 +111,7 @@ Input_dealloc(Input* self)
{
pyo_DEALLOC
Input_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -194,7 +195,7 @@ static PyNumberMethods Input_as_number = {
(binaryfunc)Input_add, /*nb_add*/
(binaryfunc)Input_sub, /*nb_subtract*/
(binaryfunc)Input_multiply, /*nb_multiply*/
- (binaryfunc)Input_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -208,16 +209,16 @@ static PyNumberMethods Input_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Input_inplace_add, /*inplace_add*/
(binaryfunc)Input_inplace_sub, /*inplace_subtract*/
(binaryfunc)Input_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Input_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -226,15 +227,14 @@ static PyNumberMethods Input_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Input_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Input_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject InputType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Input_base", /*tp_name*/
sizeof(Input), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -242,7 +242,7 @@ PyTypeObject InputType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Input_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/lfomodule.c b/src/objects/lfomodule.c
index 1017756..c67d81c 100644
--- a/src/objects/lfomodule.c
+++ b/src/objects/lfomodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -34,6 +35,7 @@ typedef struct {
Stream *sharp_stream;
int modebuffer[4]; // need at least 2 slots for mul & add
int wavetype;
+ MYFLT oneOverSr;
MYFLT oneOverPiOverTwo;
MYFLT srOverFour;
MYFLT srOverEight;
@@ -48,18 +50,22 @@ static void
LFO_generates_ii(LFO *self) {
MYFLT val, inc, freq, sharp, pointer, numh;
MYFLT v1, v2, inc2, fade;
+ MYFLT sharp2 = 0.0;
int i, maxHarms;
freq = PyFloat_AS_DOUBLE(self->freq);
- if (freq <= 0) {
- return;
- }
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+
sharp = PyFloat_AS_DOUBLE(self->sharp);
if (sharp < 0.0)
sharp = 0.0;
else if (sharp > 1.0)
sharp = 1.0;
- inc = freq / self->sr;
+
+ inc = freq * self->oneOverSr;
switch (self->wavetype) {
case 0: /* Saw up */
@@ -189,14 +195,15 @@ LFO_generates_ii(LFO *self) {
}
break;
case 7: /* Sine-mod */
- inc2 = inc * sharp;
+ inc2 = inc * sharp * 0.99;
+ sharp2 = sharp * 0.5;
for (i=0; i<self->bufsize; i++) {
self->modPointerPos += inc2;
if (self->modPointerPos < 0)
self->modPointerPos += 1.0;
else if (self->modPointerPos >= 1)
self->modPointerPos -= 1.0;
- val = (0.5 * MYCOS(TWOPI*self->modPointerPos) + 0.5) * MYSIN(TWOPI*self->pointerPos);
+ val = ((sharp2 * MYCOS(TWOPI*self->modPointerPos) + sharp2) + (1.0 - sharp)) * MYSIN(TWOPI*self->pointerPos);
self->data[i] = val;
self->pointerPos += inc;
if (self->pointerPos < 0)
@@ -214,12 +221,10 @@ static void
LFO_generates_ai(LFO *self) {
MYFLT val, inc, freq, sharp, pointer, numh;
MYFLT v1, v2, inc2, fade;
+ MYFLT sharp2 = 0.0;
int i, maxHarms;
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
- if (fr[0] <= 0) {
- return;
- }
sharp = PyFloat_AS_DOUBLE(self->sharp);
if (sharp < 0.0)
sharp = 0.0;
@@ -230,7 +235,11 @@ LFO_generates_ai(LFO *self) {
case 0: /* Saw up */
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverFour/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
@@ -248,7 +257,11 @@ LFO_generates_ai(LFO *self) {
case 1: /* Saw down */
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverFour/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
@@ -266,7 +279,11 @@ LFO_generates_ai(LFO *self) {
case 2: /* Square */
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverEight/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
@@ -283,13 +300,17 @@ LFO_generates_ai(LFO *self) {
case 3: /* Triangle */
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverFour/freq);
if ((sharp * 36.0) > maxHarms)
numh = (MYFLT)(maxHarms / 36.0);
else
numh = sharp;
- v1 = MYTAN(MYSIN(TWOPI*self->pointerPos));
+ v1 = MYTAN(MYSIN(TWOPI*self->pointerPos)) * self->oneOverPiOverTwo;
pointer = self->pointerPos + 0.25;
if (pointer > 1.0)
pointer -= 1.0;
@@ -306,7 +327,11 @@ LFO_generates_ai(LFO *self) {
case 4: /* Pulse */
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverEight/freq);
numh = MYFLOOR(sharp * 46.0 + 4.0);
if (numh > maxHarms)
@@ -325,7 +350,11 @@ LFO_generates_ai(LFO *self) {
case 5: /* Bi-Pulse */
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverEight/freq);
numh = MYFLOOR(sharp * 46.0 + 4.0);
if (numh > maxHarms)
@@ -345,7 +374,11 @@ LFO_generates_ai(LFO *self) {
numh = 1.0 - sharp;
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
inc2 = 1.0 / (int)(1.0 / inc * numh);
self->pointerPos += inc;
if (self->pointerPos < 0)
@@ -368,16 +401,21 @@ LFO_generates_ai(LFO *self) {
}
break;
case 7: /* Sine-mod */
+ sharp2 = sharp * 0.5;
for (i=0; i<self->bufsize; i++) {
freq = fr[i];
- inc = freq / self->sr;
- inc2 = inc * sharp;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
+ inc2 = inc * sharp * 0.99;
self->modPointerPos += inc2;
if (self->modPointerPos < 0)
self->modPointerPos += 1.0;
else if (self->modPointerPos >= 1)
self->modPointerPos -= 1.0;
- val = (0.5 * MYCOS(TWOPI*self->modPointerPos) + 0.5) * MYSIN(TWOPI*self->pointerPos);
+ val = ((sharp2 * MYCOS(TWOPI*self->modPointerPos) + sharp2) + (1.0 - sharp)) * MYSIN(TWOPI*self->pointerPos);
self->data[i] = val;
self->pointerPos += inc;
if (self->pointerPos < 0)
@@ -395,14 +433,17 @@ static void
LFO_generates_ia(LFO *self) {
MYFLT val, inc, freq, sharp, pointer, numh;
MYFLT v1, v2, inc2, fade;
+ MYFLT sharp2 = 0.0;
int i, maxHarms;
freq = PyFloat_AS_DOUBLE(self->freq);
- if (freq <= 0) {
- return;
- }
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
+
MYFLT *sh = Stream_getData((Stream *)self->sharp_stream);
- inc = freq / self->sr;
switch (self->wavetype) {
case 0: /* Saw up */
@@ -479,7 +520,7 @@ LFO_generates_ia(LFO *self) {
numh = (MYFLT)(maxHarms / 36.0);
else
numh = sharp;
- v1 = MYTAN(MYSIN(TWOPI*self->pointerPos));
+ v1 = MYTAN(MYSIN(TWOPI*self->pointerPos)) * self->oneOverPiOverTwo;
pointer = self->pointerPos + 0.25;
if (pointer > 1.0)
pointer -= 1.0;
@@ -573,13 +614,14 @@ LFO_generates_ia(LFO *self) {
sharp = 0.0;
else if (sharp > 1.0)
sharp = 1.0;
- inc2 = inc * sharp;
+ inc2 = inc * sharp * 0.99;
+ sharp2 = sharp * 0.5;
self->modPointerPos += inc2;
if (self->modPointerPos < 0)
self->modPointerPos += 1.0;
else if (self->modPointerPos >= 1)
self->modPointerPos -= 1.0;
- val = (0.5 * MYCOS(TWOPI*self->modPointerPos) + 0.5) * MYSIN(TWOPI*self->pointerPos);
+ val = ((sharp2 * MYCOS(TWOPI*self->modPointerPos) + sharp2) + (1.0 - sharp)) * MYSIN(TWOPI*self->pointerPos);
self->data[i] = val;
self->pointerPos += inc;
if (self->pointerPos < 0)
@@ -597,12 +639,10 @@ static void
LFO_generates_aa(LFO *self) {
MYFLT val, inc, freq, sharp, pointer, numh;
MYFLT v1, v2, inc2, fade;
+ MYFLT sharp2 = 0.0;
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) {
@@ -614,7 +654,11 @@ LFO_generates_aa(LFO *self) {
else if (sharp > 1.0)
sharp = 1.0;
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverFour/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
@@ -637,7 +681,11 @@ LFO_generates_aa(LFO *self) {
else if (sharp > 1.0)
sharp = 1.0;
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverFour/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
@@ -660,7 +708,11 @@ LFO_generates_aa(LFO *self) {
else if (sharp > 1.0)
sharp = 1.0;
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverEight/freq);
numh = sharp * 46.0 + 4.0;
if (numh > maxHarms)
@@ -682,13 +734,17 @@ LFO_generates_aa(LFO *self) {
else if (sharp > 1.0)
sharp = 1.0;
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverFour/freq);
if ((sharp * 36.0) > maxHarms)
numh = (MYFLT)(maxHarms / 36.0);
else
numh = sharp;
- v1 = MYTAN(MYSIN(TWOPI*self->pointerPos));
+ v1 = MYTAN(MYSIN(TWOPI*self->pointerPos)) * self->oneOverPiOverTwo;
pointer = self->pointerPos + 0.25;
if (pointer > 1.0)
pointer -= 1.0;
@@ -710,7 +766,11 @@ LFO_generates_aa(LFO *self) {
else if (sharp > 1.0)
sharp = 1.0;
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverEight/freq);
numh = MYFLOOR(sharp * 46.0 + 4.0);
if (numh > maxHarms)
@@ -734,7 +794,11 @@ LFO_generates_aa(LFO *self) {
else if (sharp > 1.0)
sharp = 1.0;
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
maxHarms = (int)(self->srOverEight/freq);
numh = MYFLOOR(sharp * 46.0 + 4.0);
if (numh > maxHarms)
@@ -759,7 +823,11 @@ LFO_generates_aa(LFO *self) {
sharp = 1.0;
numh = 1.0 - sharp;
freq = fr[i];
- inc = freq / self->sr;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
inc2 = 1.0 / (int)(1.0 / inc * numh);
self->pointerPos += inc;
if (self->pointerPos < 0)
@@ -789,14 +857,19 @@ LFO_generates_aa(LFO *self) {
else if (sharp > 1.0)
sharp = 1.0;
freq = fr[i];
- inc = freq / self->sr;
- inc2 = inc * sharp;
+ if (freq < 0.00001)
+ freq = 0.00001;
+ else if (freq > self->srOverFour)
+ freq = self->srOverFour;
+ inc = freq * self->oneOverSr;
+ inc2 = inc * sharp * 0.99;
+ sharp2 = sharp * 0.5;
self->modPointerPos += inc2;
if (self->modPointerPos < 0)
self->modPointerPos += 1.0;
else if (self->modPointerPos >= 1)
self->modPointerPos -= 1.0;
- val = (0.5 * MYCOS(TWOPI*self->modPointerPos) + 0.5) * MYSIN(TWOPI*self->pointerPos);
+ val = ((sharp2 * MYCOS(TWOPI*self->modPointerPos) + sharp2) + (1.0 - sharp)) * MYSIN(TWOPI*self->pointerPos);
self->data[i] = val;
self->pointerPos += inc;
if (self->pointerPos < 0)
@@ -906,7 +979,7 @@ LFO_dealloc(LFO* self)
{
pyo_DEALLOC
LFO_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -931,6 +1004,7 @@ LFO_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
INIT_OBJECT_COMMON
+ self->oneOverSr = 1.0 / (MYFLT)self->sr;
self->srOverFour = (MYFLT)self->sr * 0.25;
self->srOverEight = (MYFLT)self->sr * 0.125;
Stream_setFunctionPtr(self->stream, LFO_compute_next_data_frame);
@@ -1112,7 +1186,7 @@ static PyNumberMethods LFO_as_number = {
(binaryfunc)LFO_add, /*nb_add*/
(binaryfunc)LFO_sub, /*nb_subtract*/
(binaryfunc)LFO_multiply, /*nb_multiply*/
- (binaryfunc)LFO_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1126,16 +1200,16 @@ static PyNumberMethods LFO_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)LFO_inplace_add, /*inplace_add*/
(binaryfunc)LFO_inplace_sub, /*inplace_subtract*/
(binaryfunc)LFO_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)LFO_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1144,15 +1218,14 @@ static PyNumberMethods LFO_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)LFO_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)LFO_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject LFOType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.LFO_base", /*tp_name*/
sizeof(LFO), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1160,7 +1233,7 @@ PyTypeObject LFOType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&LFO_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/matrixmodule.c b/src/objects/matrixmodule.c
index 851e002..a5d375b 100644
--- a/src/objects/matrixmodule.c
+++ b/src/objects/matrixmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "servermodule.h"
@@ -35,7 +36,7 @@
static void
MatrixStream_dealloc(MatrixStream* self)
{
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -122,8 +123,7 @@ MatrixStream_setHeight(MatrixStream *self, int size)
}
PyTypeObject MatrixStreamType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MatrixStream", /*tp_name*/
sizeof(MatrixStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -131,7 +131,7 @@ sizeof(MatrixStream), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -220,7 +220,7 @@ NewMatrix_dealloc(NewMatrix* self)
}
free(self->data);
NewMatrix_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -336,6 +336,25 @@ NewMatrix_getViewData(NewMatrix *self)
};
static PyObject *
+NewMatrix_getImageData(NewMatrix *self)
+{
+ int i, j, w3, index;
+ char value;
+ char matrix[self->width*self->height*3];
+
+ w3 = self->width * 3;
+ for(i=0; i<self->height; i++) {
+ for (j=0; j<self->width; j++) {
+ value = (char)(self->data[i][j]*128+128);
+ index = i * w3 + j * 3;
+ matrix[index] = matrix[index+1] = matrix[index+2] = value;
+ }
+ }
+
+ return PyByteArray_FromStringAndSize(matrix, self->width*self->height*3);
+};
+
+static PyObject *
NewMatrix_setMatrix(NewMatrix *self, PyObject *value)
{
int i, j;
@@ -403,6 +422,7 @@ static PyMethodDef NewMatrix_methods[] = {
{"getServer", (PyCFunction)NewMatrix_getServer, METH_NOARGS, "Returns server object."},
{"getData", (PyCFunction)NewMatrix_getData, METH_NOARGS, "Returns a list of matrix samples."},
{"getViewData", (PyCFunction)NewMatrix_getViewData, METH_NOARGS, "Returns a list of matrix samples normalized between 0 and 256 ."},
+{"getImageData", (PyCFunction)NewMatrix_getImageData, METH_NOARGS, "Returns a list of matrix samples in tuple of 3 ints normalized between 0 and 256 ."},
{"getMatrixStream", (PyCFunction)NewMatrix_getMatrixStream, METH_NOARGS, "Returns matrixstream object created by this matrix."},
{"setMatrix", (PyCFunction)NewMatrix_setMatrix, METH_O, "Sets the matrix from a list of list of floats (must be the same size as the object size)."},
{"setData", (PyCFunction)NewMatrix_setData, METH_O, "Sets the matrix from a list of list of floats (resizes the matrix)."},
@@ -418,8 +438,7 @@ static PyMethodDef NewMatrix_methods[] = {
};
PyTypeObject NewMatrixType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.NewMatrix_base", /*tp_name*/
sizeof(NewMatrix), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -427,7 +446,7 @@ sizeof(NewMatrix), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -566,7 +585,7 @@ MatrixRec_dealloc(MatrixRec* self)
pyo_DEALLOC
free(self->trigsBuffer);
MatrixRec_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -669,8 +688,7 @@ static PyMethodDef MatrixRec_methods[] = {
};
PyTypeObject MatrixRecType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MatrixRec_base", /*tp_name*/
sizeof(MatrixRec), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -678,7 +696,7 @@ PyTypeObject MatrixRecType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -774,7 +792,7 @@ MatrixRecLoop_dealloc(MatrixRecLoop* self)
pyo_DEALLOC
free(self->trigsBuffer);
MatrixRecLoop_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -859,8 +877,7 @@ static PyMethodDef MatrixRecLoop_methods[] = {
};
PyTypeObject MatrixRecLoopType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MatrixRecLoop_base", /*tp_name*/
sizeof(MatrixRecLoop), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -868,7 +885,7 @@ PyTypeObject MatrixRecLoopType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -985,7 +1002,7 @@ MatrixMorph_dealloc(MatrixMorph* self)
pyo_DEALLOC
free(self->buffer);
MatrixMorph_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1086,8 +1103,7 @@ static PyMethodDef MatrixMorph_methods[] = {
};
PyTypeObject MatrixMorphType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MatrixMorph_base", /*tp_name*/
sizeof(MatrixMorph), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1095,7 +1111,7 @@ PyTypeObject MatrixMorphType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/matrixprocessmodule.c b/src/objects/matrixprocessmodule.c
index e00446a..058d48b 100644
--- a/src/objects/matrixprocessmodule.c
+++ b/src/objects/matrixprocessmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -136,7 +137,7 @@ MatrixPointer_dealloc(MatrixPointer* self)
{
pyo_DEALLOC
MatrixPointer_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -320,7 +321,7 @@ static PyNumberMethods MatrixPointer_as_number = {
(binaryfunc)MatrixPointer_add, /*nb_add*/
(binaryfunc)MatrixPointer_sub, /*nb_subtract*/
(binaryfunc)MatrixPointer_multiply, /*nb_multiply*/
-(binaryfunc)MatrixPointer_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -334,16 +335,16 @@ static PyNumberMethods MatrixPointer_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)MatrixPointer_inplace_add, /*inplace_add*/
(binaryfunc)MatrixPointer_inplace_sub, /*inplace_subtract*/
(binaryfunc)MatrixPointer_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)MatrixPointer_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -352,15 +353,14 @@ static PyNumberMethods MatrixPointer_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)MatrixPointer_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)MatrixPointer_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_x */
};
PyTypeObject MatrixPointerType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MatrixPointer_base", /*tp_name*/
sizeof(MatrixPointer), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -368,7 +368,7 @@ sizeof(MatrixPointer), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&MatrixPointer_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/metromodule.c b/src/objects/metromodule.c
index 57dec3f..1262243 100644
--- a/src/objects/metromodule.c
+++ b/src/objects/metromodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -180,7 +181,7 @@ Metro_dealloc(Metro* self)
{
pyo_DEALLOC
Metro_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -298,7 +299,7 @@ static PyNumberMethods Metro_as_number = {
(binaryfunc)Metro_add, /*nb_add*/
(binaryfunc)Metro_sub, /*nb_subtract*/
(binaryfunc)Metro_multiply, /*nb_multiply*/
- (binaryfunc)Metro_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -312,16 +313,16 @@ static PyNumberMethods Metro_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Metro_inplace_add, /*inplace_add*/
(binaryfunc)Metro_inplace_sub, /*inplace_subtract*/
(binaryfunc)Metro_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Metro_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -330,15 +331,14 @@ static PyNumberMethods Metro_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Metro_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Metro_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject MetroType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Metro_base", /*tp_name*/
sizeof(Metro), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -346,7 +346,7 @@ sizeof(Metro), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Metro_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -541,7 +541,7 @@ Seqer_dealloc(Seqer* self)
pyo_DEALLOC
free(self->buffer_streams);
Seqer_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -672,8 +672,7 @@ static PyMethodDef Seqer_methods[] = {
};
PyTypeObject SeqerType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Seqer_base", /*tp_name*/
sizeof(Seqer), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -681,7 +680,7 @@ PyTypeObject SeqerType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -803,7 +802,7 @@ Seq_dealloc(Seq* self)
{
pyo_DEALLOC
Seq_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -883,7 +882,7 @@ static PyNumberMethods Seq_as_number = {
(binaryfunc)Seq_add, /*nb_add*/
(binaryfunc)Seq_sub, /*nb_subtract*/
(binaryfunc)Seq_multiply, /*nb_multiply*/
- (binaryfunc)Seq_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -897,16 +896,16 @@ static PyNumberMethods Seq_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Seq_inplace_add, /*inplace_add*/
(binaryfunc)Seq_inplace_sub, /*inplace_subtract*/
(binaryfunc)Seq_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Seq_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -915,15 +914,14 @@ static PyNumberMethods Seq_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Seq_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Seq_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SeqType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Seq_base", /*tp_name*/
sizeof(Seq), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -931,7 +929,7 @@ PyTypeObject SeqType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Seq_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -978,7 +976,8 @@ typedef struct {
static void
Clouder_generate_i(Clouder *self) {
- int i, rnd;
+ int i;
+ MYFLT rnd;
MYFLT dens = PyFloat_AS_DOUBLE(self->density);
if (dens <= 0.0)
@@ -992,7 +991,7 @@ Clouder_generate_i(Clouder *self) {
dens *= 0.5;
for (i=0; i<self->bufsize; i++) {
- rnd = (int)(RANDOM_UNIFORM * self->sr);
+ rnd = RANDOM_UNIFORM * self->sr;
if (rnd < dens) {
self->buffer_streams[i + self->voiceCount++ * self->bufsize] = 1.0;
if (self->voiceCount == self->poly)
@@ -1004,7 +1003,8 @@ Clouder_generate_i(Clouder *self) {
static void
Clouder_generate_a(Clouder *self) {
MYFLT dens;
- int i, rnd;
+ int i;
+ MYFLT rnd;
MYFLT *density = Stream_getData((Stream *)self->density_stream);
@@ -1020,7 +1020,7 @@ Clouder_generate_a(Clouder *self) {
dens = self->sr;
dens *= 0.5;
- rnd = (int)(RANDOM_UNIFORM * self->sr);
+ rnd = RANDOM_UNIFORM * self->sr;
if (rnd < dens) {
self->buffer_streams[i + self->voiceCount++ * self->bufsize] = 1.0;
if (self->voiceCount == self->poly)
@@ -1079,7 +1079,7 @@ Clouder_dealloc(Clouder* self)
pyo_DEALLOC
free(self->buffer_streams);
Clouder_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1175,8 +1175,7 @@ static PyMethodDef Clouder_methods[] = {
};
PyTypeObject ClouderType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Clouder_base", /*tp_name*/
sizeof(Clouder), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1184,7 +1183,7 @@ sizeof(Clouder), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1306,7 +1305,7 @@ Cloud_dealloc(Cloud* self)
{
pyo_DEALLOC
Cloud_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1386,7 +1385,7 @@ static PyNumberMethods Cloud_as_number = {
(binaryfunc)Cloud_add, /*nb_add*/
(binaryfunc)Cloud_sub, /*nb_subtract*/
(binaryfunc)Cloud_multiply, /*nb_multiply*/
- (binaryfunc)Cloud_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1400,16 +1399,16 @@ static PyNumberMethods Cloud_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Cloud_inplace_add, /*inplace_add*/
(binaryfunc)Cloud_inplace_sub, /*inplace_subtract*/
(binaryfunc)Cloud_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Cloud_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1418,15 +1417,14 @@ static PyNumberMethods Cloud_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Cloud_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Cloud_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject CloudType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Cloud_base", /*tp_name*/
sizeof(Cloud), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1434,7 +1432,7 @@ sizeof(Cloud), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Cloud_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1553,7 +1551,7 @@ Trig_dealloc(Trig* self)
{
pyo_DEALLOC
Trig_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1631,7 +1629,7 @@ static PyNumberMethods Trig_as_number = {
(binaryfunc)Trig_add, /*nb_add*/
(binaryfunc)Trig_sub, /*nb_subtract*/
(binaryfunc)Trig_multiply, /*nb_multiply*/
- (binaryfunc)Trig_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1645,16 +1643,16 @@ static PyNumberMethods Trig_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Trig_inplace_add, /*inplace_add*/
(binaryfunc)Trig_inplace_sub, /*inplace_subtract*/
(binaryfunc)Trig_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Trig_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1663,15 +1661,14 @@ static PyNumberMethods Trig_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Trig_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Trig_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Trig_base", /*tp_name*/
sizeof(Trig), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1679,7 +1676,7 @@ sizeof(Trig), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Trig_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1906,7 +1903,7 @@ Beater_makeSequence(Beater *self) {
j = 0;
for (i=0; i < self->taps; i++) {
- if ((pyorand() % 100) < self->tapProb[i]) {
+ if ((int)(pyorand() % 100) < self->tapProb[i]) {
self->sequence[i] = 1;
self->tapList[j++] = i;
}
@@ -2168,7 +2165,7 @@ Beater_dealloc(Beater* self)
free(self->end_buffer_streams);
free(self->amplitudes);
Beater_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2450,8 +2447,7 @@ static PyMethodDef Beater_methods[] = {
};
PyTypeObject BeaterType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Beater_base", /*tp_name*/
sizeof(Beater), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2459,7 +2455,7 @@ PyTypeObject BeaterType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2581,7 +2577,7 @@ Beat_dealloc(Beat* self)
{
pyo_DEALLOC
Beat_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2661,7 +2657,7 @@ static PyNumberMethods Beat_as_number = {
(binaryfunc)Beat_add, /*nb_add*/
(binaryfunc)Beat_sub, /*nb_subtract*/
(binaryfunc)Beat_multiply, /*nb_multiply*/
- (binaryfunc)Beat_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2675,16 +2671,16 @@ static PyNumberMethods Beat_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Beat_inplace_add, /*inplace_add*/
(binaryfunc)Beat_inplace_sub, /*inplace_subtract*/
(binaryfunc)Beat_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Beat_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2693,15 +2689,14 @@ static PyNumberMethods Beat_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Beat_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Beat_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BeatType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Beat_base", /*tp_name*/
sizeof(Beat), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2709,7 +2704,7 @@ PyTypeObject BeatType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Beat_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2831,7 +2826,7 @@ BeatTapStream_dealloc(BeatTapStream* self)
{
pyo_DEALLOC
BeatTapStream_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2911,7 +2906,7 @@ static PyNumberMethods BeatTapStream_as_number = {
(binaryfunc)BeatTapStream_add, /*nb_add*/
(binaryfunc)BeatTapStream_sub, /*nb_subtract*/
(binaryfunc)BeatTapStream_multiply, /*nb_multiply*/
- (binaryfunc)BeatTapStream_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2925,16 +2920,16 @@ static PyNumberMethods BeatTapStream_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)BeatTapStream_inplace_add, /*inplace_add*/
(binaryfunc)BeatTapStream_inplace_sub, /*inplace_subtract*/
(binaryfunc)BeatTapStream_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)BeatTapStream_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2943,15 +2938,14 @@ static PyNumberMethods BeatTapStream_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)BeatTapStream_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)BeatTapStream_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BeatTapStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.BeatTapStream_base", /*tp_name*/
sizeof(BeatTapStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2959,7 +2953,7 @@ PyTypeObject BeatTapStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&BeatTapStream_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3081,7 +3075,7 @@ BeatAmpStream_dealloc(BeatAmpStream* self)
{
pyo_DEALLOC
BeatAmpStream_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3161,7 +3155,7 @@ static PyNumberMethods BeatAmpStream_as_number = {
(binaryfunc)BeatAmpStream_add, /*nb_add*/
(binaryfunc)BeatAmpStream_sub, /*nb_subtract*/
(binaryfunc)BeatAmpStream_multiply, /*nb_multiply*/
- (binaryfunc)BeatAmpStream_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3175,16 +3169,16 @@ static PyNumberMethods BeatAmpStream_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)BeatAmpStream_inplace_add, /*inplace_add*/
(binaryfunc)BeatAmpStream_inplace_sub, /*inplace_subtract*/
(binaryfunc)BeatAmpStream_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)BeatAmpStream_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3193,15 +3187,14 @@ static PyNumberMethods BeatAmpStream_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)BeatAmpStream_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)BeatAmpStream_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BeatAmpStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.BeatAmpStream_base", /*tp_name*/
sizeof(BeatAmpStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3209,7 +3202,7 @@ PyTypeObject BeatAmpStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&BeatAmpStream_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3331,7 +3324,7 @@ BeatDurStream_dealloc(BeatDurStream* self)
{
pyo_DEALLOC
BeatDurStream_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3411,7 +3404,7 @@ static PyNumberMethods BeatDurStream_as_number = {
(binaryfunc)BeatDurStream_add, /*nb_add*/
(binaryfunc)BeatDurStream_sub, /*nb_subtract*/
(binaryfunc)BeatDurStream_multiply, /*nb_multiply*/
- (binaryfunc)BeatDurStream_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3425,16 +3418,16 @@ static PyNumberMethods BeatDurStream_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)BeatDurStream_inplace_add, /*inplace_add*/
(binaryfunc)BeatDurStream_inplace_sub, /*inplace_subtract*/
(binaryfunc)BeatDurStream_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)BeatDurStream_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3443,15 +3436,14 @@ static PyNumberMethods BeatDurStream_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)BeatDurStream_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)BeatDurStream_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BeatDurStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.BeatDurStream_base", /*tp_name*/
sizeof(BeatDurStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3459,7 +3451,7 @@ PyTypeObject BeatDurStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&BeatDurStream_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3581,7 +3573,7 @@ BeatEndStream_dealloc(BeatEndStream* self)
{
pyo_DEALLOC
BeatEndStream_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3661,7 +3653,7 @@ static PyNumberMethods BeatEndStream_as_number = {
(binaryfunc)BeatEndStream_add, /*nb_add*/
(binaryfunc)BeatEndStream_sub, /*nb_subtract*/
(binaryfunc)BeatEndStream_multiply, /*nb_multiply*/
- (binaryfunc)BeatEndStream_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3675,16 +3667,16 @@ static PyNumberMethods BeatEndStream_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)BeatEndStream_inplace_add, /*inplace_add*/
(binaryfunc)BeatEndStream_inplace_sub, /*inplace_subtract*/
(binaryfunc)BeatEndStream_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)BeatEndStream_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3693,15 +3685,14 @@ static PyNumberMethods BeatEndStream_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)BeatEndStream_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)BeatEndStream_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BeatEndStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.BeatEndStream_base", /*tp_name*/
sizeof(BeatEndStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3709,7 +3700,7 @@ PyTypeObject BeatEndStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&BeatEndStream_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3893,7 +3884,7 @@ TrigBurster_dealloc(TrigBurster* self)
free(self->currentAmp);
free(self->currentDur);
TrigBurster_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4029,8 +4020,7 @@ static PyMethodDef TrigBurster_methods[] = {
};
PyTypeObject TrigBursterType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigBurster_base", /*tp_name*/
sizeof(TrigBurster), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4038,7 +4028,7 @@ PyTypeObject TrigBursterType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4160,7 +4150,7 @@ TrigBurst_dealloc(TrigBurst* self)
{
pyo_DEALLOC
TrigBurst_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4240,7 +4230,7 @@ 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*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4254,16 +4244,16 @@ static PyNumberMethods TrigBurst_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*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*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4272,15 +4262,14 @@ static PyNumberMethods TrigBurst_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TrigBurst_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TrigBurst_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigBurstType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigBurst_base", /*tp_name*/
sizeof(TrigBurst), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4288,7 +4277,7 @@ PyTypeObject TrigBurstType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigBurst_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4410,7 +4399,7 @@ TrigBurstTapStream_dealloc(TrigBurstTapStream* self)
{
pyo_DEALLOC
TrigBurstTapStream_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4490,7 +4479,7 @@ 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*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4504,16 +4493,16 @@ static PyNumberMethods TrigBurstTapStream_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*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*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4522,15 +4511,14 @@ static PyNumberMethods TrigBurstTapStream_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TrigBurstTapStream_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TrigBurstTapStream_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigBurstTapStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigBurstTapStream_base", /*tp_name*/
sizeof(TrigBurstTapStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4538,7 +4526,7 @@ PyTypeObject TrigBurstTapStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigBurstTapStream_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4660,7 +4648,7 @@ TrigBurstAmpStream_dealloc(TrigBurstAmpStream* self)
{
pyo_DEALLOC
TrigBurstAmpStream_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4740,7 +4728,7 @@ 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*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4754,16 +4742,16 @@ static PyNumberMethods TrigBurstAmpStream_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*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*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4772,15 +4760,14 @@ static PyNumberMethods TrigBurstAmpStream_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TrigBurstAmpStream_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TrigBurstAmpStream_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigBurstAmpStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigBurstAmpStream_base", /*tp_name*/
sizeof(TrigBurstAmpStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4788,7 +4775,7 @@ PyTypeObject TrigBurstAmpStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigBurstAmpStream_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4910,7 +4897,7 @@ TrigBurstDurStream_dealloc(TrigBurstDurStream* self)
{
pyo_DEALLOC
TrigBurstDurStream_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4990,7 +4977,7 @@ 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*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5004,16 +4991,16 @@ static PyNumberMethods TrigBurstDurStream_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*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*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5022,15 +5009,14 @@ static PyNumberMethods TrigBurstDurStream_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TrigBurstDurStream_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TrigBurstDurStream_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigBurstDurStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigBurstDurStream_base", /*tp_name*/
sizeof(TrigBurstDurStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5038,7 +5024,7 @@ PyTypeObject TrigBurstDurStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigBurstDurStream_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5160,7 +5146,7 @@ TrigBurstEndStream_dealloc(TrigBurstEndStream* self)
{
pyo_DEALLOC
TrigBurstEndStream_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5240,7 +5226,7 @@ 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*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5254,16 +5240,16 @@ static PyNumberMethods TrigBurstEndStream_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*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*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5272,15 +5258,14 @@ static PyNumberMethods TrigBurstEndStream_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TrigBurstEndStream_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TrigBurstEndStream_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigBurstEndStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigBurstEndStream_base", /*tp_name*/
sizeof(TrigBurstEndStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5288,7 +5273,7 @@ PyTypeObject TrigBurstEndStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigBurstEndStream_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/midimodule.c b/src/objects/midimodule.c
index 480c982..a07b7c6 100644
--- a/src/objects/midimodule.c
+++ b/src/objects/midimodule.c
@@ -19,13 +19,13 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
#include "streammodule.h"
#include "servermodule.h"
#include "dummymodule.h"
-#include "portmidi.h"
typedef struct {
pyo_audio_HEAD
@@ -40,7 +40,7 @@ CtlScan_setProcMode(CtlScan *self) {}
static void
CtlScan_compute_next_data_frame(CtlScan *self)
{
- PmEvent *buffer;
+ PyoMidiEvent *buffer;
int i, count;
buffer = Server_getMidiEventBuffer((Server *)self->server);
@@ -49,9 +49,9 @@ CtlScan_compute_next_data_frame(CtlScan *self)
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);
+ int status = PyoMidi_MessageStatus(buffer[i].message); // Temp note event holders
+ int number = PyoMidi_MessageData1(buffer[i].message);
+ int value = PyoMidi_MessageData2(buffer[i].message);
if ((status & 0xF0) == 0xB0) {
if (number != self->ctlnumber) {
@@ -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);
+ PySys_WriteStdout("ctl number : %i, ctl value : %i, midi channel : %i\n", self->ctlnumber, value, status - 0xB0 + 1);
}
}
}
@@ -88,7 +88,7 @@ CtlScan_dealloc(CtlScan* self)
{
pyo_DEALLOC
CtlScan_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -183,8 +183,7 @@ static PyMethodDef CtlScan_methods[] = {
};
PyTypeObject CtlScanType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.CtlScan_base", /*tp_name*/
sizeof(CtlScan), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -192,7 +191,7 @@ PyTypeObject CtlScanType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -238,7 +237,7 @@ CtlScan2_setProcMode(CtlScan2 *self) {}
static void
CtlScan2_compute_next_data_frame(CtlScan2 *self)
{
- PmEvent *buffer;
+ PyoMidiEvent *buffer;
int i, count, midichnl;
buffer = Server_getMidiEventBuffer((Server *)self->server);
@@ -247,9 +246,9 @@ CtlScan2_compute_next_data_frame(CtlScan2 *self)
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);
+ int status = PyoMidi_MessageStatus(buffer[i].message); // Temp note event holders
+ int number = PyoMidi_MessageData1(buffer[i].message);
+ int value = PyoMidi_MessageData2(buffer[i].message);
if ((status & 0xF0) == 0xB0) {
midichnl = status - 0xB0 + 1;
@@ -262,7 +261,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);
+ PySys_WriteStdout("ctl number : %i, ctl value : %i, midi channel : %i\n", self->ctlnumber, value, midichnl);
}
}
}
@@ -289,7 +288,7 @@ CtlScan2_dealloc(CtlScan2* self)
{
pyo_DEALLOC
CtlScan2_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -384,8 +383,7 @@ static PyMethodDef CtlScan2_methods[] = {
};
PyTypeObject CtlScan2Type = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.CtlScan2_base", /*tp_name*/
sizeof(CtlScan2), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -393,7 +391,7 @@ PyTypeObject CtlScan2Type = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -487,13 +485,13 @@ Midictl_setProcMode(Midictl *self)
}
// Take MIDI events and translate them...
-void translateMidi(Midictl *self, PmEvent *buffer, int count)
+void translateMidi(Midictl *self, PyoMidiEvent *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);
- int value = Pm_MessageData2(buffer[i].message);
+ int status = PyoMidi_MessageStatus(buffer[i].message); // Temp note event holders
+ int number = PyoMidi_MessageData1(buffer[i].message);
+ int value = PyoMidi_MessageData2(buffer[i].message);
if (self->channel == 0) {
if ((status & 0xF0) == 0xB0)
@@ -519,7 +517,7 @@ void translateMidi(Midictl *self, PmEvent *buffer, int count)
static void
Midictl_compute_next_data_frame(Midictl *self)
{
- PmEvent *tmp;
+ PyoMidiEvent *tmp;
int i, count;
MYFLT step;
@@ -562,7 +560,7 @@ Midictl_dealloc(Midictl* self)
{
pyo_DEALLOC
Midictl_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -770,7 +768,7 @@ static PyNumberMethods Midictl_as_number = {
(binaryfunc)Midictl_add, /*nb_add*/
(binaryfunc)Midictl_sub, /*nb_subtract*/
(binaryfunc)Midictl_multiply, /*nb_multiply*/
- (binaryfunc)Midictl_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -784,16 +782,16 @@ static PyNumberMethods Midictl_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Midictl_inplace_add, /*inplace_add*/
(binaryfunc)Midictl_inplace_sub, /*inplace_subtract*/
(binaryfunc)Midictl_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Midictl_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -802,15 +800,14 @@ static PyNumberMethods Midictl_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Midictl_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Midictl_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject MidictlType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Midictl_base", /*tp_name*/
sizeof(Midictl), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -818,7 +815,7 @@ PyTypeObject MidictlType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Midictl_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -909,14 +906,14 @@ Bendin_setProcMode(Bendin *self)
}
// Take MIDI events and translate them...
-void Bendin_translateMidi(Bendin *self, PmEvent *buffer, int count)
+void Bendin_translateMidi(Bendin *self, PyoMidiEvent *buffer, int count)
{
int i, ok;
MYFLT val;
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);
+ int status = PyoMidi_MessageStatus(buffer[i].message); // Temp note event holders
+ int number = PyoMidi_MessageData1(buffer[i].message);
+ int value = PyoMidi_MessageData2(buffer[i].message);
if (self->channel == 0) {
if ((status & 0xF0) == 0xe0)
@@ -946,7 +943,7 @@ void Bendin_translateMidi(Bendin *self, PmEvent *buffer, int count)
static void
Bendin_compute_next_data_frame(Bendin *self)
{
- PmEvent *tmp;
+ PyoMidiEvent *tmp;
int i, count;
tmp = Server_getMidiEventBuffer((Server *)self->server);
@@ -982,7 +979,7 @@ Bendin_dealloc(Bendin* self)
{
pyo_DEALLOC
Bendin_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1136,7 +1133,7 @@ static PyNumberMethods Bendin_as_number = {
(binaryfunc)Bendin_add, /*nb_add*/
(binaryfunc)Bendin_sub, /*nb_subtract*/
(binaryfunc)Bendin_multiply, /*nb_multiply*/
- (binaryfunc)Bendin_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1150,16 +1147,16 @@ static PyNumberMethods Bendin_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Bendin_inplace_add, /*inplace_add*/
(binaryfunc)Bendin_inplace_sub, /*inplace_subtract*/
(binaryfunc)Bendin_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Bendin_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1168,15 +1165,14 @@ static PyNumberMethods Bendin_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Bendin_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Bendin_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BendinType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Bendin_base", /*tp_name*/
sizeof(Bendin), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1184,7 +1180,7 @@ PyTypeObject BendinType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Bendin_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1275,13 +1271,13 @@ Touchin_setProcMode(Touchin *self)
}
// Take MIDI events and translate them...
-void Touchin_translateMidi(Touchin *self, PmEvent *buffer, int count)
+void Touchin_translateMidi(Touchin *self, PyoMidiEvent *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);
- /* int value = Pm_MessageData2(buffer[i].message); */
+ int status = PyoMidi_MessageStatus(buffer[i].message); // Temp note event holders
+ int number = PyoMidi_MessageData1(buffer[i].message);
+ /* int value = PyoMidi_MessageData2(buffer[i].message); */
if (self->channel == 0) {
if ((status & 0xF0) == 0xd0)
@@ -1307,7 +1303,7 @@ void Touchin_translateMidi(Touchin *self, PmEvent *buffer, int count)
static void
Touchin_compute_next_data_frame(Touchin *self)
{
- PmEvent *tmp;
+ PyoMidiEvent *tmp;
int i, count;
tmp = Server_getMidiEventBuffer((Server *)self->server);
@@ -1343,7 +1339,7 @@ Touchin_dealloc(Touchin* self)
{
pyo_DEALLOC
Touchin_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1489,7 +1485,7 @@ static PyNumberMethods Touchin_as_number = {
(binaryfunc)Touchin_add, /*nb_add*/
(binaryfunc)Touchin_sub, /*nb_subtract*/
(binaryfunc)Touchin_multiply, /*nb_multiply*/
- (binaryfunc)Touchin_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1503,16 +1499,16 @@ static PyNumberMethods Touchin_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Touchin_inplace_add, /*inplace_add*/
(binaryfunc)Touchin_inplace_sub, /*inplace_subtract*/
(binaryfunc)Touchin_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Touchin_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1521,15 +1517,14 @@ static PyNumberMethods Touchin_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Touchin_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Touchin_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TouchinType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Touchin_base", /*tp_name*/
sizeof(Touchin), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1537,7 +1532,7 @@ PyTypeObject TouchinType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Touchin_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1624,13 +1619,13 @@ Programin_setProcMode(Programin *self)
}
// Take MIDI events and translate them...
-void Programin_translateMidi(Programin *self, PmEvent *buffer, int count)
+void Programin_translateMidi(Programin *self, PyoMidiEvent *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);
+ int status = PyoMidi_MessageStatus(buffer[i].message); // Temp note event holders
+ int number = PyoMidi_MessageData1(buffer[i].message);
if (self->channel == 0) {
if ((status & 0xF0) == 0xc0)
@@ -1655,7 +1650,7 @@ void Programin_translateMidi(Programin *self, PmEvent *buffer, int count)
static void
Programin_compute_next_data_frame(Programin *self)
{
- PmEvent *tmp;
+ PyoMidiEvent *tmp;
int i, count;
tmp = Server_getMidiEventBuffer((Server *)self->server);
@@ -1690,7 +1685,7 @@ Programin_dealloc(Programin* self)
{
pyo_DEALLOC
Programin_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1793,7 +1788,7 @@ static PyNumberMethods Programin_as_number = {
(binaryfunc)Programin_add, /*nb_add*/
(binaryfunc)Programin_sub, /*nb_subtract*/
(binaryfunc)Programin_multiply, /*nb_multiply*/
- (binaryfunc)Programin_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1807,16 +1802,16 @@ static PyNumberMethods Programin_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Programin_inplace_add, /*inplace_add*/
(binaryfunc)Programin_inplace_sub, /*inplace_subtract*/
(binaryfunc)Programin_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Programin_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1825,15 +1820,14 @@ static PyNumberMethods Programin_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Programin_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Programin_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject PrograminType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Programin_base", /*tp_name*/
sizeof(Programin), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1841,7 +1835,7 @@ PyTypeObject PrograminType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Programin_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1942,14 +1936,14 @@ int whichVoice(int *buf, int pitch, int len) {
}
// Take MIDI events and keep track of notes
-void grabMidiNotes(MidiNote *self, PmEvent *buffer, int count)
+void grabMidiNotes(MidiNote *self, PyoMidiEvent *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);
- int velocity = Pm_MessageData2(buffer[i].message);
+ int status = PyoMidi_MessageStatus(buffer[i].message); // Temp note event holders
+ int pitch = PyoMidi_MessageData1(buffer[i].message);
+ int velocity = PyoMidi_MessageData2(buffer[i].message);
if (self->channel == 0) {
if ((status & 0xF0) == 0x90 || (status & 0xF0) == 0x80)
@@ -1973,7 +1967,7 @@ void grabMidiNotes(MidiNote *self, PmEvent *buffer, int count)
kind = 1;
if (pitchIsIn(self->notebuf, pitch, self->voices) == 0 && kind == 1 && pitch >= self->first && pitch <= self->last) {
- //printf("%i, %i, %i\n", status, pitch, velocity);
+ //PySys_WriteStdout("%i, %i, %i\n", status, pitch, velocity);
if (!self->stealing) {
voice = nextEmptyVoice(self->notebuf, self->vcount, self->voices);
if (voice != -1) {
@@ -1991,7 +1985,7 @@ void grabMidiNotes(MidiNote *self, PmEvent *buffer, int count)
}
}
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);
+ //PySys_WriteStdout("%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.;
@@ -2004,7 +1998,7 @@ void grabMidiNotes(MidiNote *self, PmEvent *buffer, int count)
static void
MidiNote_compute_next_data_frame(MidiNote *self)
{
- PmEvent *tmp;
+ PyoMidiEvent *tmp;
int i, count;
for (i=0; i<self->bufsize*self->voices*2; i++) {
@@ -2038,7 +2032,7 @@ MidiNote_dealloc(MidiNote* self)
free(self->notebuf);
free(self->trigger_streams);
MidiNote_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static MYFLT *
@@ -2119,22 +2113,55 @@ static PyObject * MidiNote_play(MidiNote *self, PyObject *args, PyObject *kwds)
static PyObject * MidiNote_stop(MidiNote *self) { STOP };
static PyObject *
-MidiNote_setChannel(MidiNote *self, PyObject *arg)
+MidiNote_setScale(MidiNote *self, PyObject *arg)
{
- int tmp;
+ ASSERT_ARG_NOT_NULL
+
+ if (PyInt_Check(arg) == 1) {
+ int tmp = PyInt_AsLong(arg);
+ if (tmp >= 0 && tmp < 3)
+ self->scale = tmp;
+ }
+ Py_RETURN_NONE;
+}
+static PyObject *
+MidiNote_setFirst(MidiNote *self, PyObject *arg)
+{
ASSERT_ARG_NOT_NULL
- int isInt = PyInt_Check(arg);
+ if (PyInt_Check(arg) == 1) {
+ int tmp = PyInt_AsLong(arg);
+ if (tmp >= 0 && tmp < 128)
+ self->first = tmp;
+ }
+ Py_RETURN_NONE;
+}
- if (isInt == 1) {
- tmp = PyInt_AsLong(arg);
+static PyObject *
+MidiNote_setLast(MidiNote *self, PyObject *arg)
+{
+ ASSERT_ARG_NOT_NULL
+
+ if (PyInt_Check(arg) == 1) {
+ int tmp = PyInt_AsLong(arg);
if (tmp >= 0 && tmp < 128)
- self->channel = tmp;
+ self->last = tmp;
}
+ Py_RETURN_NONE;
+}
- Py_INCREF(Py_None);
- return Py_None;
+static PyObject *
+MidiNote_setChannel(MidiNote *self, PyObject *arg)
+{
+ ASSERT_ARG_NOT_NULL
+
+ if (PyInt_Check(arg) == 1) {
+ int tmp = PyInt_AsLong(arg);
+ if (tmp >= 0 && tmp < 128)
+ self->channel = tmp;
+ }
+ Py_RETURN_NONE;
}
static PyObject *
@@ -2181,6 +2208,9 @@ static PyMethodDef MidiNote_methods[] = {
{"_getStream", (PyCFunction)MidiNote_getStream, METH_NOARGS, "Returns stream object."},
{"play", (PyCFunction)MidiNote_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"stop", (PyCFunction)MidiNote_stop, METH_NOARGS, "Stops computing."},
+{"setScale", (PyCFunction)MidiNote_setScale, METH_O, "Sets the scale factor."},
+{"setFirst", (PyCFunction)MidiNote_setFirst, METH_O, "Sets the lowest midi note."},
+{"setLast", (PyCFunction)MidiNote_setLast, METH_O, "Sets the highest midi note."},
{"setChannel", (PyCFunction)MidiNote_setChannel, METH_O, "Sets the midi channel."},
{"setCentralKey", (PyCFunction)MidiNote_setCentralKey, METH_O, "Sets the midi key where there is no transposition."},
{"setStealing", (PyCFunction)MidiNote_setStealing, METH_O, "Sets the stealing mode."},
@@ -2188,8 +2218,7 @@ static PyMethodDef MidiNote_methods[] = {
};
PyTypeObject MidiNoteType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MidiNote_base", /*tp_name*/
sizeof(MidiNote), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2197,7 +2226,7 @@ sizeof(MidiNote), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2326,7 +2355,7 @@ Notein_dealloc(Notein* self)
{
pyo_DEALLOC
Notein_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2413,7 +2442,7 @@ static PyNumberMethods Notein_as_number = {
(binaryfunc)Notein_add, /*nb_add*/
(binaryfunc)Notein_sub, /*nb_subtract*/
(binaryfunc)Notein_multiply, /*nb_multiply*/
-(binaryfunc)Notein_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2427,16 +2456,16 @@ static PyNumberMethods Notein_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Notein_inplace_add, /*inplace_add*/
(binaryfunc)Notein_inplace_sub, /*inplace_subtract*/
(binaryfunc)Notein_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Notein_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2445,15 +2474,14 @@ static PyNumberMethods Notein_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Notein_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Notein_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject NoteinType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Notein_base", /*tp_name*/
sizeof(Notein), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2461,7 +2489,7 @@ sizeof(Notein), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Notein_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2582,7 +2610,7 @@ NoteinTrig_dealloc(NoteinTrig* self)
{
pyo_DEALLOC
NoteinTrig_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2669,7 +2697,7 @@ 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*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2683,16 +2711,16 @@ static PyNumberMethods NoteinTrig_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*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*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2701,15 +2729,14 @@ static PyNumberMethods NoteinTrig_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)NoteinTrig_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)NoteinTrig_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject NoteinTrigType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.NoteinTrig_base", /*tp_name*/
sizeof(NoteinTrig), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2717,7 +2744,7 @@ sizeof(NoteinTrig), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&NoteinTrig_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2764,6 +2791,8 @@ typedef struct {
MYFLT decay;
MYFLT sustain;
MYFLT release;
+ MYFLT exp;
+ MYFLT expscl;
MYFLT invAttack;
MYFLT initAmpMinusOffsetAmp;
MYFLT attackPlusDecay;
@@ -2772,6 +2801,7 @@ typedef struct {
MYFLT invRelease;
double currentTime;
MYFLT sampleToSec;
+ MYFLT *buf;
} MidiAdsr;
static void
@@ -2785,7 +2815,8 @@ MidiAdsr_generates(MidiAdsr *self) {
if (self->fademode == 0 && in[i] > 0.0) {
self->fademode = 1;
self->initAmp = in[i];
- self->offsetAmp = self->data[i];
+ self->expscl = MYPOW(self->initAmp, 1.0 / self->exp) / self->initAmp;
+ self->offsetAmp = self->buf[i];
self->sustainAmp = self->initAmp * self->sustain;
self->currentTime = 0.0;
self->invAttack = 1.0 / self->attack;
@@ -2815,9 +2846,19 @@ MidiAdsr_generates(MidiAdsr *self) {
else
val = 0.;
}
- self->data[i] = val;
+ self->buf[i] = val;
self->currentTime += self->sampleToSec;
}
+
+ if (self->exp != 1.0) {
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = MYPOW(self->buf[i] * self->expscl, self->exp);
+ }
+ } else {
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = self->buf[i];
+ }
+ }
}
static void MidiAdsr_postprocessing_ii(MidiAdsr *self) { POST_PROCESSING_II };
@@ -2898,8 +2939,9 @@ static void
MidiAdsr_dealloc(MidiAdsr* self)
{
pyo_DEALLOC
+ free(self->buf);
MidiAdsr_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2920,6 +2962,7 @@ MidiAdsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sustain = 0.707;
self->release = 0.1;
self->currentTime = 0.0;
+ self->exp = self->expscl = 1.0;
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, MidiAdsr_compute_next_data_frame);
@@ -2944,6 +2987,11 @@ MidiAdsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+ self->buf = (MYFLT *)realloc(self->buf, self->bufsize * sizeof(MYFLT));
+ for (i=0; i<self->bufsize; i++) {
+ self->buf[i] = 0.0;
+ }
+
if (self->attack < 0.000001)
self->attack = 0.000001;
if (self->decay < 0.000001)
@@ -3034,6 +3082,18 @@ MidiAdsr_setRelease(MidiAdsr *self, PyObject *arg)
return Py_None;
}
+static PyObject *
+MidiAdsr_setExp(MidiAdsr *self, PyObject *arg)
+{
+ if (PyNumber_Check(arg)) {
+ MYFLT tmp = PyFloat_AsDouble(arg);
+ if (tmp > 0.0)
+ self->exp = tmp;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyMemberDef MidiAdsr_members[] = {
{"server", T_OBJECT_EX, offsetof(MidiAdsr, server), 0, "Pyo server."},
{"stream", T_OBJECT_EX, offsetof(MidiAdsr, stream), 0, "Stream object."},
@@ -3055,6 +3115,7 @@ static PyMethodDef MidiAdsr_methods[] = {
{"setDecay", (PyCFunction)MidiAdsr_setDecay, METH_O, "Sets decay time in seconds."},
{"setSustain", (PyCFunction)MidiAdsr_setSustain, METH_O, "Sets sustain level in percent of note amplitude."},
{"setRelease", (PyCFunction)MidiAdsr_setRelease, METH_O, "Sets release time in seconds."},
+ {"setExp", (PyCFunction)MidiAdsr_setExp, METH_O, "Sets the exponent factor for exponential envelope."},
{"setDiv", (PyCFunction)MidiAdsr_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
@@ -3063,7 +3124,7 @@ static PyNumberMethods MidiAdsr_as_number = {
(binaryfunc)MidiAdsr_add, /*nb_add*/
(binaryfunc)MidiAdsr_sub, /*nb_subtract*/
(binaryfunc)MidiAdsr_multiply, /*nb_multiply*/
- (binaryfunc)MidiAdsr_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3077,16 +3138,16 @@ static PyNumberMethods MidiAdsr_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)MidiAdsr_inplace_add, /*inplace_add*/
(binaryfunc)MidiAdsr_inplace_sub, /*inplace_subtract*/
(binaryfunc)MidiAdsr_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)MidiAdsr_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3095,15 +3156,14 @@ static PyNumberMethods MidiAdsr_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)MidiAdsr_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)MidiAdsr_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject MidiAdsrType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MidiAdsr_base", /*tp_name*/
sizeof(MidiAdsr), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3111,7 +3171,7 @@ PyTypeObject MidiAdsrType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&MidiAdsr_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3159,6 +3219,8 @@ typedef struct {
MYFLT decay;
MYFLT sustain;
MYFLT release;
+ MYFLT exp;
+ MYFLT expscl;
MYFLT invAttack;
MYFLT initAmpMinusOffsetAmp;
MYFLT invDecay;
@@ -3168,6 +3230,7 @@ typedef struct {
MYFLT invRelease;
double currentTime;
MYFLT sampleToSec;
+ MYFLT *buf;
} MidiDelAdsr;
static void
@@ -3181,7 +3244,8 @@ MidiDelAdsr_generates(MidiDelAdsr *self) {
if (self->fademode == 0 && in[i] > 0.0) {
self->fademode = 1;
self->initAmp = in[i];
- self->offsetAmp = self->data[i];
+ self->expscl = MYPOW(self->initAmp, 1.0 / self->exp) / self->initAmp;
+ self->offsetAmp = self->buf[i];
self->sustainAmp = self->initAmp * self->sustain;
self->currentTime = 0.0;
self->invAttack = 1.0 / self->attack;
@@ -3214,9 +3278,19 @@ MidiDelAdsr_generates(MidiDelAdsr *self) {
else
val = 0.;
}
- self->data[i] = val;
+ self->buf[i] = val;
self->currentTime += self->sampleToSec;
}
+
+ if (self->exp != 1.0) {
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = MYPOW(self->buf[i] * self->expscl, self->exp);
+ }
+ } else {
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = self->buf[i];
+ }
+ }
}
static void MidiDelAdsr_postprocessing_ii(MidiDelAdsr *self) { POST_PROCESSING_II };
@@ -3297,8 +3371,9 @@ static void
MidiDelAdsr_dealloc(MidiDelAdsr* self)
{
pyo_DEALLOC
+ free(self->buf);
MidiDelAdsr_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3320,6 +3395,7 @@ MidiDelAdsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sustain = 0.707;
self->release = 0.1;
self->currentTime = 0.0;
+ self->exp = self->expscl = 1.0;
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, MidiDelAdsr_compute_next_data_frame);
@@ -3344,6 +3420,11 @@ MidiDelAdsr_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
+ self->buf = (MYFLT *)realloc(self->buf, self->bufsize * sizeof(MYFLT));
+ for (i=0; i<self->bufsize; i++) {
+ self->buf[i] = 0.0;
+ }
+
if (self->attack < 0.000001)
self->attack = 0.000001;
if (self->decay < 0.000001)
@@ -3447,6 +3528,18 @@ MidiDelAdsr_setRelease(MidiDelAdsr *self, PyObject *arg)
return Py_None;
}
+static PyObject *
+MidiDelAdsr_setExp(MidiDelAdsr *self, PyObject *arg)
+{
+ if (PyNumber_Check(arg)) {
+ MYFLT tmp = PyFloat_AsDouble(arg);
+ if (tmp > 0.0)
+ self->exp = tmp;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyMemberDef MidiDelAdsr_members[] = {
{"server", T_OBJECT_EX, offsetof(MidiDelAdsr, server), 0, "Pyo server."},
{"stream", T_OBJECT_EX, offsetof(MidiDelAdsr, stream), 0, "Stream object."},
@@ -3469,6 +3562,7 @@ static PyMethodDef MidiDelAdsr_methods[] = {
{"setDecay", (PyCFunction)MidiDelAdsr_setDecay, METH_O, "Sets decay time in seconds."},
{"setSustain", (PyCFunction)MidiDelAdsr_setSustain, METH_O, "Sets sustain level in percent of note amplitude."},
{"setRelease", (PyCFunction)MidiDelAdsr_setRelease, METH_O, "Sets release time in seconds."},
+ {"setExp", (PyCFunction)MidiDelAdsr_setExp, METH_O, "Sets the exponent factor for exponential envelope."},
{"setDiv", (PyCFunction)MidiDelAdsr_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
@@ -3477,7 +3571,7 @@ static PyNumberMethods MidiDelAdsr_as_number = {
(binaryfunc)MidiDelAdsr_add, /*nb_add*/
(binaryfunc)MidiDelAdsr_sub, /*nb_subtract*/
(binaryfunc)MidiDelAdsr_multiply, /*nb_multiply*/
- (binaryfunc)MidiDelAdsr_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3491,16 +3585,16 @@ static PyNumberMethods MidiDelAdsr_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)MidiDelAdsr_inplace_add, /*inplace_add*/
(binaryfunc)MidiDelAdsr_inplace_sub, /*inplace_subtract*/
(binaryfunc)MidiDelAdsr_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)MidiDelAdsr_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3509,15 +3603,14 @@ static PyNumberMethods MidiDelAdsr_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)MidiDelAdsr_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)MidiDelAdsr_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject MidiDelAdsrType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MidiDelAdsr_base", /*tp_name*/
sizeof(MidiDelAdsr), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3525,7 +3618,7 @@ PyTypeObject MidiDelAdsrType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&MidiDelAdsr_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3568,7 +3661,7 @@ RawMidi_setProcMode(RawMidi *self) {}
static void
RawMidi_compute_next_data_frame(RawMidi *self)
{
- PmEvent *buffer;
+ PyoMidiEvent *buffer;
int i, count, status, data1, data2;
buffer = Server_getMidiEventBuffer((Server *)self->server);
@@ -3577,9 +3670,9 @@ RawMidi_compute_next_data_frame(RawMidi *self)
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);
+ status = PyoMidi_MessageStatus(buffer[i].message); // Temp note event holders
+ data1 = PyoMidi_MessageData1(buffer[i].message);
+ data2 = PyoMidi_MessageData2(buffer[i].message);
tup = PyTuple_New(3);
PyTuple_SetItem(tup, 0, PyInt_FromLong(status));
PyTuple_SetItem(tup, 1, PyInt_FromLong(data1));
@@ -3610,7 +3703,7 @@ RawMidi_dealloc(RawMidi* self)
{
pyo_DEALLOC
RawMidi_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3681,8 +3774,7 @@ static PyMethodDef RawMidi_methods[] = {
};
PyTypeObject RawMidiType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.RawMidi_base", /*tp_name*/
sizeof(RawMidi), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3690,7 +3782,7 @@ PyTypeObject RawMidiType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/noisemodule.c b/src/objects/noisemodule.c
index 9cfad4d..e3226d7 100644
--- a/src/objects/noisemodule.c
+++ b/src/objects/noisemodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -132,7 +133,7 @@ Noise_dealloc(Noise* self)
{
pyo_DEALLOC
Noise_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -237,7 +238,7 @@ static PyNumberMethods Noise_as_number = {
(binaryfunc)Noise_add, /*nb_add*/
(binaryfunc)Noise_sub, /*nb_subtract*/
(binaryfunc)Noise_multiply, /*nb_multiply*/
-(binaryfunc)Noise_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -251,16 +252,16 @@ static PyNumberMethods Noise_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Noise_inplace_add, /*inplace_add*/
(binaryfunc)Noise_inplace_sub, /*inplace_subtract*/
(binaryfunc)Noise_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Noise_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -269,15 +270,14 @@ static PyNumberMethods Noise_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Noise_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Noise_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject NoiseType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Noise_base", /*tp_name*/
sizeof(Noise), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -285,7 +285,7 @@ sizeof(Noise), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Noise_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -421,7 +421,7 @@ PinkNoise_dealloc(PinkNoise* self)
{
pyo_DEALLOC
PinkNoise_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -507,7 +507,7 @@ static PyNumberMethods PinkNoise_as_number = {
(binaryfunc)PinkNoise_add, /*nb_add*/
(binaryfunc)PinkNoise_sub, /*nb_subtract*/
(binaryfunc)PinkNoise_multiply, /*nb_multiply*/
- (binaryfunc)PinkNoise_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -521,16 +521,16 @@ static PyNumberMethods PinkNoise_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)PinkNoise_inplace_add, /*inplace_add*/
(binaryfunc)PinkNoise_inplace_sub, /*inplace_subtract*/
(binaryfunc)PinkNoise_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)PinkNoise_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -539,15 +539,14 @@ static PyNumberMethods PinkNoise_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)PinkNoise_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)PinkNoise_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject PinkNoiseType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PinkNoise_base", /*tp_name*/
sizeof(PinkNoise), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -555,7 +554,7 @@ PyTypeObject PinkNoiseType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&PinkNoise_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -681,7 +680,7 @@ BrownNoise_dealloc(BrownNoise* self)
{
pyo_DEALLOC
BrownNoise_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -772,7 +771,7 @@ static PyNumberMethods BrownNoise_as_number = {
(binaryfunc)BrownNoise_add, /*nb_add*/
(binaryfunc)BrownNoise_sub, /*nb_subtract*/
(binaryfunc)BrownNoise_multiply, /*nb_multiply*/
- (binaryfunc)BrownNoise_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -786,16 +785,16 @@ static PyNumberMethods BrownNoise_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)BrownNoise_inplace_add, /*inplace_add*/
(binaryfunc)BrownNoise_inplace_sub, /*inplace_subtract*/
(binaryfunc)BrownNoise_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)BrownNoise_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -804,15 +803,14 @@ static PyNumberMethods BrownNoise_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)BrownNoise_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)BrownNoise_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BrownNoiseType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.BrownNoise_base", /*tp_name*/
sizeof(BrownNoise), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -820,7 +818,7 @@ PyTypeObject BrownNoiseType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&BrownNoise_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/oscbankmodule.c b/src/objects/oscbankmodule.c
index ccf5f91..86f90e9 100644
--- a/src/objects/oscbankmodule.c
+++ b/src/objects/oscbankmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -94,13 +95,13 @@ OscBank_setFrequencies(OscBank *self, MYFLT freq, MYFLT spread) {
seed = (seed * 15625 + 1) & 0xFFFF;
rnd = seed * 1.52587890625e-07 - 0.005 + 1.0;
self->frequencies[i] = (freq + scl * i) * rnd;
- /* printf("harm %d : %f Hz\n", i, self->frequencies[i]); */
+ /* PySys_WriteStdout("harm %d : %f Hz\n", i, self->frequencies[i]); */
}
}
else {
for (i=0; i<self->stages; i++) {
self->frequencies[i] = freq + scl * i;
- /* printf("harm %d : %f Hz\n", i, self->frequencies[i]); */
+ /* PySys_WriteStdout("harm %d : %f Hz\n", i, self->frequencies[i]); */
}
}
}
@@ -405,7 +406,7 @@ OscBank_dealloc(OscBank* self)
free(self->aValues);
free(self->aDiffs);
OscBank_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -815,7 +816,7 @@ static PyNumberMethods OscBank_as_number = {
(binaryfunc)OscBank_add, /*nb_add*/
(binaryfunc)OscBank_sub, /*nb_subtract*/
(binaryfunc)OscBank_multiply, /*nb_multiply*/
- (binaryfunc)OscBank_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -829,16 +830,16 @@ static PyNumberMethods OscBank_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)OscBank_inplace_add, /*inplace_add*/
(binaryfunc)OscBank_inplace_sub, /*inplace_subtract*/
(binaryfunc)OscBank_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)OscBank_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -847,15 +848,14 @@ static PyNumberMethods OscBank_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)OscBank_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)OscBank_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject OscBankType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.OscBank_base", /*tp_name*/
sizeof(OscBank), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -863,7 +863,7 @@ PyTypeObject OscBankType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&OscBank_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/oscilmodule.c b/src/objects/oscilmodule.c
index 6753138..4380f24 100644
--- a/src/objects/oscilmodule.c
+++ b/src/objects/oscilmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -33,10 +34,12 @@ static MYFLT COSINE_ARRAY[513] = {1.0, 0.9999247018391445, 0.9996988186962042, 0
-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;
-static const MYFLT ROSSLER_ALT_SCALE = 0.06028;
-static const MYFLT LORENZ_SCALE = 0.05107;
-static const MYFLT LORENZ_ALT_SCALE = 0.03679;
+static const MYFLT ROSSLER_SCALE = 0.054;
+static const MYFLT ROSSLER_ALT_SCALE = 0.0569;
+static const MYFLT LORENZ_SCALE = 0.044;
+static const MYFLT LORENZ_ALT_SCALE = 0.0328;
+static const MYFLT CHENLEE_SCALE = 0.02;
+static const MYFLT CHENLEE_ALT_SCALE = 0.02;
static MYFLT
_clip(MYFLT x) {
@@ -253,7 +256,7 @@ Sine_dealloc(Sine* self)
{
pyo_DEALLOC
Sine_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -425,7 +428,7 @@ static PyNumberMethods Sine_as_number = {
(binaryfunc)Sine_add, /*nb_add*/
(binaryfunc)Sine_sub, /*nb_subtract*/
(binaryfunc)Sine_multiply, /*nb_multiply*/
-(binaryfunc)Sine_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -439,16 +442,16 @@ static PyNumberMethods Sine_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Sine_inplace_add, /*inplace_add*/
(binaryfunc)Sine_inplace_sub, /*inplace_subtract*/
(binaryfunc)Sine_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Sine_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -457,15 +460,14 @@ static PyNumberMethods Sine_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Sine_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Sine_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SineType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Sine_base", /*tp_name*/
sizeof(Sine), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -473,7 +475,7 @@ sizeof(Sine), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Sine_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -505,233 +507,343 @@ Sine_members, /* tp_members */
Sine_new, /* tp_new */
};
-/*******************/
-/* SineLoop object */
-/*******************/
+
+/* FastSine object */
typedef struct {
pyo_audio_HEAD
PyObject *freq;
Stream *freq_stream;
- PyObject *feedback;
- Stream *feedback_stream;
- int modebuffer[4];
+ int modebuffer[3];
+ MYFLT initphase;
+ int quality;
MYFLT pointerPos;
- MYFLT lastValue;
-} SineLoop;
+ MYFLT twoPiOnSr;
+ MYFLT B;
+ MYFLT C;
+} FastSine;
static void
-SineLoop_readframes_ii(SineLoop *self) {
- MYFLT inc, fr, feed, pos, fpart;
- int i, ipart;
+FastSine_readframes_low_i(FastSine *self) {
+ int i;
+ MYFLT inc, fr, pos, b, c;
fr = PyFloat_AS_DOUBLE(self->freq);
- feed = _clip(PyFloat_AS_DOUBLE(self->feedback)) * 512;
- inc = fr * 512 / self->sr;
+ inc = fr * self->twoPiOnSr;
+ pos = self->pointerPos;
+ b = self->B;
+ c = self->C;
for (i=0; i<self->bufsize; i++) {
- self->pointerPos = Sine_clip(self->pointerPos);
- pos = Sine_clip(self->pointerPos + self->lastValue * feed);
- ipart = (int)pos;
- fpart = pos - ipart;
- self->data[i] = self->lastValue = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos += inc;
+ if (pos > PI)
+ pos -= TWOPI;
+ self->data[i] = b * pos + c * pos * MYFABS(pos);
+ pos += inc;
}
+ self->pointerPos = pos;
}
static void
-SineLoop_readframes_ai(SineLoop *self) {
- MYFLT inc, feed, pos, fpart, fac;
- int i, ipart;
+FastSine_readframes_low_a(FastSine *self) {
+ int i;
+ MYFLT pos, b, c;
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
- feed = _clip(PyFloat_AS_DOUBLE(self->feedback)) * 512;
- fac = 512 / self->sr;
+ pos = self->pointerPos;
+ b = self->B;
+ c = self->C;
for (i=0; i<self->bufsize; i++) {
- inc = fr[i] * fac;
- self->pointerPos = Sine_clip(self->pointerPos);
- pos = Sine_clip(self->pointerPos + self->lastValue * feed);
- ipart = (int)pos;
- fpart = pos - ipart;
- self->data[i] = self->lastValue = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos += inc;
+ if (pos > PI)
+ pos -= TWOPI;
+ self->data[i] = b * pos + c * pos * MYFABS(pos);
+ pos += fr[i] * self->twoPiOnSr;
}
+ self->pointerPos = pos;
}
static void
-SineLoop_readframes_ia(SineLoop *self) {
- MYFLT inc, fr, feed, pos, fpart;
- int i, ipart;
+FastSine_readframes_high_i(FastSine *self) {
+ int i;
+ MYFLT inc, fr, pos, b, c, y;
fr = PyFloat_AS_DOUBLE(self->freq);
- MYFLT *fd = Stream_getData((Stream *)self->feedback_stream);
- inc = fr * 512 / self->sr;
+ inc = fr * self->twoPiOnSr;
+ pos = self->pointerPos;
+ b = self->B;
+ c = self->C;
for (i=0; i<self->bufsize; i++) {
- feed = _clip(fd[i]) * 512;
- self->pointerPos = Sine_clip(self->pointerPos);
- pos = Sine_clip(self->pointerPos + self->lastValue * feed);
- ipart = (int)pos;
- fpart = pos - ipart;
- self->data[i] = self->lastValue = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos += inc;
+ if (pos > PI)
+ pos -= TWOPI;
+ y = b * pos + c * pos * MYFABS(pos);
+ self->data[i] = y + (y * MYFABS(y) - y) * 0.218;
+ pos += inc;
}
+ self->pointerPos = pos;
}
static void
-SineLoop_readframes_aa(SineLoop *self) {
- MYFLT inc, feed, pos, fpart, fac;
- int i, ipart;
+FastSine_readframes_high_a(FastSine *self) {
+ int i;
+ MYFLT pos, b, c, y;
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
- MYFLT *fd = Stream_getData((Stream *)self->feedback_stream);
- fac = 512 / self->sr;
+ pos = self->pointerPos;
+ b = self->B;
+ c = self->C;
for (i=0; i<self->bufsize; i++) {
- inc = fr[i] * fac;
- feed = _clip(fd[i]) * 512;
- self->pointerPos = Sine_clip(self->pointerPos);
- pos = Sine_clip(self->pointerPos + self->lastValue * feed);
- ipart = (int)pos;
- fpart = pos - ipart;
- self->data[i] = self->lastValue = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos += inc;
+ if (pos > PI)
+ pos -= TWOPI;
+ y = b * pos + c * pos * MYFABS(pos);
+ self->data[i] = y + (y * MYFABS(y) - y) * 0.218;
+ pos += fr[i] * self->twoPiOnSr;
}
+ self->pointerPos = pos;
}
-static void SineLoop_postprocessing_ii(SineLoop *self) { POST_PROCESSING_II };
-static void SineLoop_postprocessing_ai(SineLoop *self) { POST_PROCESSING_AI };
-static void SineLoop_postprocessing_ia(SineLoop *self) { POST_PROCESSING_IA };
-static void SineLoop_postprocessing_aa(SineLoop *self) { POST_PROCESSING_AA };
-static void SineLoop_postprocessing_ireva(SineLoop *self) { POST_PROCESSING_IREVA };
-static void SineLoop_postprocessing_areva(SineLoop *self) { POST_PROCESSING_AREVA };
-static void SineLoop_postprocessing_revai(SineLoop *self) { POST_PROCESSING_REVAI };
-static void SineLoop_postprocessing_revaa(SineLoop *self) { POST_PROCESSING_REVAA };
-static void SineLoop_postprocessing_revareva(SineLoop *self) { POST_PROCESSING_REVAREVA };
+/*
+static void
+FastSine_readframes_low_i(FastSine *self) {
+ MYFLT inc, fr, pos;
+ int i;
+
+ fr = PyFloat_AS_DOUBLE(self->freq);
+ inc = fr * self->fourOnSr;
+
+ pos = self->pointerPos;
+ for (i=0; i<self->bufsize; i++) {
+ if (pos > 2.0)
+ pos -= 4.0;
+
+ if (pos < 0) {
+ self->data[i] = pos * (pos + 2.0);
+ }
+ else {
+ self->data[i] = pos * (2.0 - pos);
+ }
+ pos += inc;
+ }
+ self->pointerPos = pos;
+}
static void
-SineLoop_setProcMode(SineLoop *self)
+FastSine_readframes_low_a(FastSine *self) {
+ MYFLT inc, pos;
+ int i;
+
+ MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
+
+ pos = self->pointerPos;
+ for (i=0; i<self->bufsize; i++) {
+ inc = fr[i] * self->fourOnSr;
+ if (pos > 2.0)
+ pos -= 4.0;
+
+ if (pos < 0) {
+ self->data[i] = pos * (pos + 2.0);
+ }
+ else {
+ self->data[i] = pos * (2.0 - pos);
+ }
+ pos += inc;
+ }
+ self->pointerPos = pos;
+}
+
+static void
+FastSine_readframes_high_i(FastSine *self) {
+ MYFLT inc, fr, pos, sine;
+ int i;
+
+ fr = PyFloat_AS_DOUBLE(self->freq);
+ inc = fr * self->fourOnSr;
+
+ pos = self->pointerPos;
+ for (i=0; i<self->bufsize; i++) {
+ if (pos > 2.0)
+ pos -= 4.0;
+
+ if (pos < 0) {
+ sine = -pos * (pos + 2.0);
+ self->data[i] = -sine * (0.225 * (sine - 1) + 1);
+ }
+ else {
+ sine = pos * (2.0 - pos);
+ self->data[i] = sine * (0.225 * (sine - 1) + 1);
+ }
+ pos += inc;
+ }
+ self->pointerPos = pos;
+}
+
+static void
+FastSine_readframes_high_a(FastSine *self) {
+ MYFLT inc, pos, sine;
+ int i;
+
+ MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
+
+ pos = self->pointerPos;
+ for (i=0; i<self->bufsize; i++) {
+ inc = fr[i] * self->fourOnSr;
+ if (pos > 2.0)
+ pos -= 4.0;
+
+ if (pos < 0) {
+ sine = -pos * (pos + 2.0);
+ self->data[i] = -sine * (0.225 * (sine - 1) + 1);
+ }
+ else {
+ sine = pos * (2.0 - pos);
+ self->data[i] = sine * (0.225 * (sine - 1) + 1);
+ }
+ pos += inc;
+ }
+ self->pointerPos = pos;
+}
+*/
+
+static void FastSine_postprocessing_ii(FastSine *self) { POST_PROCESSING_II };
+static void FastSine_postprocessing_ai(FastSine *self) { POST_PROCESSING_AI };
+static void FastSine_postprocessing_ia(FastSine *self) { POST_PROCESSING_IA };
+static void FastSine_postprocessing_aa(FastSine *self) { POST_PROCESSING_AA };
+static void FastSine_postprocessing_ireva(FastSine *self) { POST_PROCESSING_IREVA };
+static void FastSine_postprocessing_areva(FastSine *self) { POST_PROCESSING_AREVA };
+static void FastSine_postprocessing_revai(FastSine *self) { POST_PROCESSING_REVAI };
+static void FastSine_postprocessing_revaa(FastSine *self) { POST_PROCESSING_REVAA };
+static void FastSine_postprocessing_revareva(FastSine *self) { POST_PROCESSING_REVAREVA };
+
+static void
+FastSine_setProcMode(FastSine *self)
{
int procmode, muladdmode;
- procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
+ procmode = self->modebuffer[2];
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (procmode) {
case 0:
- self->proc_func_ptr = SineLoop_readframes_ii;
+ if (self->quality == 0)
+ self->proc_func_ptr = FastSine_readframes_low_i;
+ else if (self->quality == 1)
+ self->proc_func_ptr = FastSine_readframes_high_i;
break;
case 1:
- self->proc_func_ptr = SineLoop_readframes_ai;
- break;
- case 10:
- self->proc_func_ptr = SineLoop_readframes_ia;
- break;
- case 11:
- self->proc_func_ptr = SineLoop_readframes_aa;
+ if (self->quality == 0)
+ self->proc_func_ptr = FastSine_readframes_low_a;
+ else if (self->quality == 1)
+ self->proc_func_ptr = FastSine_readframes_high_a;
break;
}
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = SineLoop_postprocessing_ii;
+ self->muladd_func_ptr = FastSine_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = SineLoop_postprocessing_ai;
+ self->muladd_func_ptr = FastSine_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = SineLoop_postprocessing_revai;
+ self->muladd_func_ptr = FastSine_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = SineLoop_postprocessing_ia;
+ self->muladd_func_ptr = FastSine_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = SineLoop_postprocessing_aa;
+ self->muladd_func_ptr = FastSine_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = SineLoop_postprocessing_revaa;
+ self->muladd_func_ptr = FastSine_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = SineLoop_postprocessing_ireva;
+ self->muladd_func_ptr = FastSine_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = SineLoop_postprocessing_areva;
+ self->muladd_func_ptr = FastSine_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = SineLoop_postprocessing_revareva;
+ self->muladd_func_ptr = FastSine_postprocessing_revareva;
break;
}
}
static void
-SineLoop_compute_next_data_frame(SineLoop *self)
+FastSine_compute_next_data_frame(FastSine *self)
{
(*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
static int
-SineLoop_traverse(SineLoop *self, visitproc visit, void *arg)
+FastSine_traverse(FastSine *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);
return 0;
}
static int
-SineLoop_clear(SineLoop *self)
+FastSine_clear(FastSine *self)
{
pyo_CLEAR
Py_CLEAR(self->freq);
Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->feedback);
- Py_CLEAR(self->feedback_stream);
return 0;
}
static void
-SineLoop_dealloc(SineLoop* self)
+FastSine_dealloc(FastSine* self)
{
pyo_DEALLOC
- SineLoop_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ FastSine_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-SineLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+FastSine_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *freqtmp=NULL, *feedbacktmp=NULL, *multmp=NULL, *addtmp=NULL;
- SineLoop *self;
- self = (SineLoop *)type->tp_alloc(type, 0);
+ PyObject *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
+
+ FastSine *self;
+ self = (FastSine *)type->tp_alloc(type, 0);
self->freq = PyFloat_FromDouble(1000);
- self->feedback = PyFloat_FromDouble(0.0);
+ self->initphase = 0.0;
+ self->quality = 1;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
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;
+ Stream_setFunctionPtr(self->stream, FastSine_compute_next_data_frame);
+ self->mode_func_ptr = FastSine_setProcMode;
- static char *kwlist[] = {"freq", "feedback", "mul", "add", NULL};
+ self->twoPiOnSr = TWOPI / self->sr;
+ self->B = 4.0 / PI;
+ self->C = -4.0 / (PI * PI);
+
+ static char *kwlist[] = {"freq", "initphase", "quality", "mul", "add", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &freqtmp, &feedbacktmp, &multmp, &addtmp))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__OFIOO, kwlist, &freqtmp, &self->initphase, &self->quality, &multmp, &addtmp))
Py_RETURN_NONE;
+ if (self->initphase < 0.0)
+ self->initphase = 0.0;
+ else if (self->initphase > 1.0)
+ self->initphase = 1.0;
+ self->pointerPos = self->initphase * TWOPI;
+
+ if (self->quality < 0)
+ self->quality = 0;
+ else if (self->quality > 1)
+ self->quality = 1;
+
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);
}
@@ -742,33 +854,34 @@ SineLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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 * FastSine_getServer(FastSine* self) { GET_SERVER };
+static PyObject * FastSine_getStream(FastSine* self) { GET_STREAM };
+static PyObject * FastSine_setMul(FastSine *self, PyObject *arg) { SET_MUL };
+static PyObject * FastSine_setAdd(FastSine *self, PyObject *arg) { SET_ADD };
+static PyObject * FastSine_setSub(FastSine *self, PyObject *arg) { SET_SUB };
+static PyObject * FastSine_setDiv(FastSine *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 };
-static PyObject * SineLoop_stop(SineLoop *self) { STOP };
+static PyObject * FastSine_play(FastSine *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * FastSine_out(FastSine *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * FastSine_stop(FastSine *self) { STOP };
-static PyObject * SineLoop_multiply(SineLoop *self, PyObject *arg) { MULTIPLY };
-static PyObject * SineLoop_inplace_multiply(SineLoop *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * SineLoop_add(SineLoop *self, PyObject *arg) { ADD };
-static PyObject * SineLoop_inplace_add(SineLoop *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * SineLoop_sub(SineLoop *self, PyObject *arg) { SUB };
-static PyObject * SineLoop_inplace_sub(SineLoop *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * SineLoop_div(SineLoop *self, PyObject *arg) { DIV };
-static PyObject * SineLoop_inplace_div(SineLoop *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * FastSine_multiply(FastSine *self, PyObject *arg) { MULTIPLY };
+static PyObject * FastSine_inplace_multiply(FastSine *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * FastSine_add(FastSine *self, PyObject *arg) { ADD };
+static PyObject * FastSine_inplace_add(FastSine *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * FastSine_sub(FastSine *self, PyObject *arg) { SUB };
+static PyObject * FastSine_inplace_sub(FastSine *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * FastSine_div(FastSine *self, PyObject *arg) { DIV };
+static PyObject * FastSine_inplace_div(FastSine *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-SineLoop_setFreq(SineLoop *self, PyObject *arg)
+FastSine_setFreq(FastSine *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -799,28 +912,15 @@ SineLoop_setFreq(SineLoop *self, PyObject *arg)
}
static PyObject *
-SineLoop_setFeedback(SineLoop *self, PyObject *arg)
+FastSine_setQuality(FastSine *self, PyObject *arg)
{
- PyObject *tmp, *streamtmp;
-
+ int tmp;
ASSERT_ARG_NOT_NULL
- 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;
+ if (PyInt_Check(arg)) {
+ tmp = PyInt_AsLong(arg);
+ if (tmp >= 0 && tmp < 2)
+ self->quality = tmp;
}
(*self->mode_func_ptr)(self);
@@ -829,256 +929,228 @@ SineLoop_setFeedback(SineLoop *self, PyObject *arg)
return Py_None;
}
-static PyMemberDef SineLoop_members[] = {
- {"server", T_OBJECT_EX, offsetof(SineLoop, server), 0, "Pyo server."},
- {"stream", T_OBJECT_EX, offsetof(SineLoop, stream), 0, "Stream object."},
- {"freq", T_OBJECT_EX, offsetof(SineLoop, freq), 0, "Frequency in cycle per second."},
- {"feedback", T_OBJECT_EX, offsetof(SineLoop, feedback), 0, "Phase of signal (0 -> 1)"},
- {"mul", T_OBJECT_EX, offsetof(SineLoop, mul), 0, "Mul factor."},
- {"add", T_OBJECT_EX, offsetof(SineLoop, add), 0, "Add factor."},
- {NULL} /* Sentinel */
+static PyObject *
+FastSine_reset(FastSine *self)
+{
+ self->pointerPos = self->initphase * TWOPI;
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef FastSine_members[] = {
+{"server", T_OBJECT_EX, offsetof(FastSine, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(FastSine, stream), 0, "Stream object."},
+{"freq", T_OBJECT_EX, offsetof(FastSine, freq), 0, "Frequency in cycle per second."},
+{"mul", T_OBJECT_EX, offsetof(FastSine, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(FastSine, add), 0, "Add factor."},
+{NULL} /* Sentinel */
};
-static PyMethodDef SineLoop_methods[] = {
- {"getServer", (PyCFunction)SineLoop_getServer, METH_NOARGS, "Returns server object."},
- {"_getStream", (PyCFunction)SineLoop_getStream, METH_NOARGS, "Returns stream object."},
- {"play", (PyCFunction)SineLoop_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
- {"out", (PyCFunction)SineLoop_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
- {"stop", (PyCFunction)SineLoop_stop, METH_NOARGS, "Stops computing."},
- {"setFreq", (PyCFunction)SineLoop_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
- {"setFeedback", (PyCFunction)SineLoop_setFeedback, METH_O, "Sets oscillator feedback between 0 and 1."},
- {"setMul", (PyCFunction)SineLoop_setMul, METH_O, "Sets SineLoop mul factor."},
- {"setAdd", (PyCFunction)SineLoop_setAdd, METH_O, "Sets SineLoop add factor."},
- {"setSub", (PyCFunction)SineLoop_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)SineLoop_setDiv, METH_O, "Sets inverse mul factor."},
- {NULL} /* Sentinel */
+static PyMethodDef FastSine_methods[] = {
+{"getServer", (PyCFunction)FastSine_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)FastSine_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)FastSine_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"out", (PyCFunction)FastSine_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"stop", (PyCFunction)FastSine_stop, METH_NOARGS, "Stops computing."},
+{"setFreq", (PyCFunction)FastSine_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
+{"setQuality", (PyCFunction)FastSine_setQuality, METH_O, "Sets approximation quality."},
+{"reset", (PyCFunction)FastSine_reset, METH_NOARGS, "Resets pointer position to 0."},
+{"setMul", (PyCFunction)FastSine_setMul, METH_O, "Sets FastSine mul factor."},
+{"setAdd", (PyCFunction)FastSine_setAdd, METH_O, "Sets FastSine add factor."},
+{"setSub", (PyCFunction)FastSine_setSub, METH_O, "Sets inverse add factor."},
+{"setDiv", (PyCFunction)FastSine_setDiv, METH_O, "Sets inverse mul factor."},
+{NULL} /* Sentinel */
};
-static PyNumberMethods SineLoop_as_number = {
- (binaryfunc)SineLoop_add, /*nb_add*/
- (binaryfunc)SineLoop_sub, /*nb_subtract*/
- (binaryfunc)SineLoop_multiply, /*nb_multiply*/
- (binaryfunc)SineLoop_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)SineLoop_inplace_add, /*inplace_add*/
- (binaryfunc)SineLoop_inplace_sub, /*inplace_subtract*/
- (binaryfunc)SineLoop_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)SineLoop_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 */
+static PyNumberMethods FastSine_as_number = {
+(binaryfunc)FastSine_add, /*nb_add*/
+(binaryfunc)FastSine_sub, /*nb_subtract*/
+(binaryfunc)FastSine_multiply, /*nb_multiply*/
+INITIALIZE_NB_DIVIDE_ZERO /*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*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+0, /*nb_int*/
+0, /*nb_long*/
+0, /*nb_float*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+(binaryfunc)FastSine_inplace_add, /*inplace_add*/
+(binaryfunc)FastSine_inplace_sub, /*inplace_subtract*/
+(binaryfunc)FastSine_inplace_multiply, /*inplace_multiply*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+(binaryfunc)FastSine_div, /*nb_true_divide*/
+0, /*nb_inplace_floor_divide*/
+(binaryfunc)FastSine_inplace_div, /*nb_inplace_true_divide*/
+0, /* nb_index */
};
-PyTypeObject SineLoopType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.SineLoop_base", /*tp_name*/
- sizeof(SineLoop), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)SineLoop_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- &SineLoop_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*/
- "SineLoop objects. Generates a looped sinewave.", /* tp_doc */
- (traverseproc)SineLoop_traverse, /* tp_traverse */
- (inquiry)SineLoop_clear, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- SineLoop_methods, /* tp_methods */
- SineLoop_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 */
- SineLoop_new, /* tp_new */
+PyTypeObject FastSineType = {
+PyVarObject_HEAD_INIT(NULL, 0)
+"_pyo.FastSine_base", /*tp_name*/
+sizeof(FastSine), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)FastSine_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_as_async (tp_compare in Python 2)*/
+0, /*tp_repr*/
+&FastSine_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*/
+"FastSine objects. Generates a sinewave.", /* tp_doc */
+(traverseproc)FastSine_traverse, /* tp_traverse */
+(inquiry)FastSine_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+FastSine_methods, /* tp_methods */
+FastSine_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 */
+FastSine_new, /* tp_new */
};
-/***************/
-/* Osc objects */
-/***************/
-static double
-Osc_clip(double x, int size) {
- if (x < 0) {
- x += ((int)(-x / size) + 1) * size;
- }
- else if (x >= size) {
- x -= (int)(x / size) * size;
- }
- return x;
-}
-
+/*******************/
+/* SineLoop object */
+/*******************/
typedef struct {
pyo_audio_HEAD
- PyObject *table;
PyObject *freq;
Stream *freq_stream;
- PyObject *phase;
- Stream *phase_stream;
+ PyObject *feedback;
+ Stream *feedback_stream;
int modebuffer[4];
- double pointerPos;
- int interp; /* 0 = default to 2, 1 = nointerp, 2 = linear, 3 = cos, 4 = cubic */
- MYFLT (*interp_func_ptr)(MYFLT *, int, MYFLT, int);
-} Osc;
+ MYFLT pointerPos;
+ MYFLT lastValue;
+} SineLoop;
static void
-Osc_readframes_ii(Osc *self) {
- MYFLT fr, ph, fpart;
- double inc, pos;
+SineLoop_readframes_ii(SineLoop *self) {
+ MYFLT inc, fr, feed, pos, fpart;
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);
- inc = fr * size / self->sr;
+ feed = _clip(PyFloat_AS_DOUBLE(self->feedback)) * 512;
+ inc = fr * 512 / self->sr;
- ph *= size;
for (i=0; i<self->bufsize; i++) {
- self->pointerPos += inc;
- self->pointerPos = Osc_clip(self->pointerPos, size);
- pos = self->pointerPos + ph;
- if (pos >= size)
- pos -= size;
+ self->pointerPos = Sine_clip(self->pointerPos);
+ pos = Sine_clip(self->pointerPos + self->lastValue * feed);
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ self->data[i] = self->lastValue = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos += inc;
}
}
static void
-Osc_readframes_ai(Osc *self) {
- MYFLT ph, fpart, sizeOnSr;
- double inc, pos;
+SineLoop_readframes_ai(SineLoop *self) {
+ MYFLT inc, feed, pos, fpart, fac;
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;
+ feed = _clip(PyFloat_AS_DOUBLE(self->feedback)) * 512;
- sizeOnSr = size / self->sr;
+ fac = 512 / self->sr;
for (i=0; i<self->bufsize; i++) {
- inc = fr[i] * sizeOnSr;
- self->pointerPos += inc;
- self->pointerPos = Osc_clip(self->pointerPos, size);
- pos = self->pointerPos + ph;
- if (pos >= size)
- pos -= size;
+ inc = fr[i] * fac;
+ self->pointerPos = Sine_clip(self->pointerPos);
+ pos = Sine_clip(self->pointerPos + self->lastValue * feed);
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ self->data[i] = self->lastValue = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos += inc;
}
}
static void
-Osc_readframes_ia(Osc *self) {
- MYFLT fr, pha, fpart;
- double inc, pos;
+SineLoop_readframes_ia(SineLoop *self) {
+ MYFLT inc, fr, feed, pos, fpart;
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;
+ MYFLT *fd = Stream_getData((Stream *)self->feedback_stream);
+ inc = fr * 512 / self->sr;
for (i=0; i<self->bufsize; i++) {
- pha = ph[i] * size;
- self->pointerPos += inc;
- self->pointerPos = Osc_clip(self->pointerPos, size);
- pos = self->pointerPos + pha;
- if (pos >= size)
- pos -= size;
+ feed = _clip(fd[i]) * 512;
+ self->pointerPos = Sine_clip(self->pointerPos);
+ pos = Sine_clip(self->pointerPos + self->lastValue * feed);
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ self->data[i] = self->lastValue = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos += inc;
}
}
static void
-Osc_readframes_aa(Osc *self) {
- MYFLT pha, fpart, sizeOnSr;
- double inc, pos;
+SineLoop_readframes_aa(SineLoop *self) {
+ MYFLT inc, feed, pos, fpart, fac;
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 *fd = Stream_getData((Stream *)self->feedback_stream);
- sizeOnSr = size / self->sr;
+ fac = 512 / self->sr;
for (i=0; i<self->bufsize; i++) {
- inc = fr[i] * sizeOnSr;
- pha = ph[i] * size;
- self->pointerPos += inc;
- self->pointerPos = Osc_clip(self->pointerPos, size);
- pos = self->pointerPos + pha;
- if (pos >= size)
- pos -= size;
+ inc = fr[i] * fac;
+ feed = _clip(fd[i]) * 512;
+ self->pointerPos = Sine_clip(self->pointerPos);
+ pos = Sine_clip(self->pointerPos + self->lastValue * feed);
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ self->data[i] = self->lastValue = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos += inc;
}
}
-static void Osc_postprocessing_ii(Osc *self) { POST_PROCESSING_II };
-static void Osc_postprocessing_ai(Osc *self) { POST_PROCESSING_AI };
-static void Osc_postprocessing_ia(Osc *self) { POST_PROCESSING_IA };
-static void Osc_postprocessing_aa(Osc *self) { POST_PROCESSING_AA };
-static void Osc_postprocessing_ireva(Osc *self) { POST_PROCESSING_IREVA };
-static void Osc_postprocessing_areva(Osc *self) { POST_PROCESSING_AREVA };
-static void Osc_postprocessing_revai(Osc *self) { POST_PROCESSING_REVAI };
-static void Osc_postprocessing_revaa(Osc *self) { POST_PROCESSING_REVAA };
-static void Osc_postprocessing_revareva(Osc *self) { POST_PROCESSING_REVAREVA };
+static void SineLoop_postprocessing_ii(SineLoop *self) { POST_PROCESSING_II };
+static void SineLoop_postprocessing_ai(SineLoop *self) { POST_PROCESSING_AI };
+static void SineLoop_postprocessing_ia(SineLoop *self) { POST_PROCESSING_IA };
+static void SineLoop_postprocessing_aa(SineLoop *self) { POST_PROCESSING_AA };
+static void SineLoop_postprocessing_ireva(SineLoop *self) { POST_PROCESSING_IREVA };
+static void SineLoop_postprocessing_areva(SineLoop *self) { POST_PROCESSING_AREVA };
+static void SineLoop_postprocessing_revai(SineLoop *self) { POST_PROCESSING_REVAI };
+static void SineLoop_postprocessing_revaa(SineLoop *self) { POST_PROCESSING_REVAA };
+static void SineLoop_postprocessing_revareva(SineLoop *self) { POST_PROCESSING_REVAREVA };
static void
-Osc_setProcMode(Osc *self)
+SineLoop_setProcMode(SineLoop *self)
{
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
@@ -1086,129 +1158,120 @@ Osc_setProcMode(Osc *self)
switch (procmode) {
case 0:
- self->proc_func_ptr = Osc_readframes_ii;
+ self->proc_func_ptr = SineLoop_readframes_ii;
break;
case 1:
- self->proc_func_ptr = Osc_readframes_ai;
+ self->proc_func_ptr = SineLoop_readframes_ai;
break;
case 10:
- self->proc_func_ptr = Osc_readframes_ia;
+ self->proc_func_ptr = SineLoop_readframes_ia;
break;
case 11:
- self->proc_func_ptr = Osc_readframes_aa;
+ self->proc_func_ptr = SineLoop_readframes_aa;
break;
}
+
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = Osc_postprocessing_ii;
+ self->muladd_func_ptr = SineLoop_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = Osc_postprocessing_ai;
+ self->muladd_func_ptr = SineLoop_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = Osc_postprocessing_revai;
+ self->muladd_func_ptr = SineLoop_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = Osc_postprocessing_ia;
+ self->muladd_func_ptr = SineLoop_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = Osc_postprocessing_aa;
+ self->muladd_func_ptr = SineLoop_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = Osc_postprocessing_revaa;
+ self->muladd_func_ptr = SineLoop_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = Osc_postprocessing_ireva;
+ self->muladd_func_ptr = SineLoop_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = Osc_postprocessing_areva;
+ self->muladd_func_ptr = SineLoop_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = Osc_postprocessing_revareva;
+ self->muladd_func_ptr = SineLoop_postprocessing_revareva;
break;
}
}
static void
-Osc_compute_next_data_frame(Osc *self)
+SineLoop_compute_next_data_frame(SineLoop *self)
{
(*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
static int
-Osc_traverse(Osc *self, visitproc visit, void *arg)
+SineLoop_traverse(SineLoop *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->feedback);
+ Py_VISIT(self->feedback_stream);
return 0;
}
static int
-Osc_clear(Osc *self)
+SineLoop_clear(SineLoop *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->feedback);
+ Py_CLEAR(self->feedback_stream);
return 0;
}
static void
-Osc_dealloc(Osc* self)
+SineLoop_dealloc(SineLoop* self)
{
pyo_DEALLOC
- Osc_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ SineLoop_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-Osc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+SineLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *tabletmp, *freqtmp=NULL, *phasetmp=NULL, *multmp=NULL, *addtmp=NULL;
- Osc *self;
- self = (Osc *)type->tp_alloc(type, 0);
+ PyObject *freqtmp=NULL, *feedbacktmp=NULL, *multmp=NULL, *addtmp=NULL;
+ SineLoop *self;
+ self = (SineLoop *)type->tp_alloc(type, 0);
self->freq = PyFloat_FromDouble(1000);
- self->phase = PyFloat_FromDouble(0);
+ self->feedback = PyFloat_FromDouble(0.0);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
- self->pointerPos = 0.;
- self->interp = 2;
+ self->pointerPos = self->lastValue = 0.;
INIT_OBJECT_COMMON
- Stream_setFunctionPtr(self->stream, Osc_compute_next_data_frame);
- self->mode_func_ptr = Osc_setProcMode;
-
- static char *kwlist[] = {"table", "freq", "phase", "interp", "mul", "add", NULL};
+ Stream_setFunctionPtr(self->stream, SineLoop_compute_next_data_frame);
+ self->mode_func_ptr = SineLoop_setProcMode;
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOiOO", kwlist, &tabletmp, &freqtmp, &phasetmp, &self->interp, &multmp, &addtmp))
- Py_RETURN_NONE;
+ static char *kwlist[] = {"freq", "feedback", "mul", "add", NULL};
- if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PyErr_SetString(PyExc_TypeError, "\"table\" argument of Osc must be a PyoTableObject.\n");
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &freqtmp, &feedbacktmp, &multmp, &addtmp))
Py_RETURN_NONE;
- }
- Py_XDECREF(self->table);
- self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
-
- if (phasetmp) {
- PyObject_CallMethod((PyObject *)self, "setPhase", "O", phasetmp);
- }
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);
}
@@ -1221,55 +1284,31 @@ Osc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
(*self->mode_func_ptr)(self);
- SET_INTERP_POINTER
-
return (PyObject *)self;
}
-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_play(Osc *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * Osc_out(Osc *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * Osc_stop(Osc *self) { STOP };
-
-static PyObject * Osc_multiply(Osc *self, PyObject *arg) { MULTIPLY };
-static PyObject * Osc_inplace_multiply(Osc *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * Osc_add(Osc *self, PyObject *arg) { ADD };
-static PyObject * Osc_inplace_add(Osc *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * Osc_sub(Osc *self, PyObject *arg) { SUB };
-static PyObject * Osc_inplace_sub(Osc *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * Osc_div(Osc *self, PyObject *arg) { DIV };
-static PyObject * Osc_inplace_div(Osc *self, PyObject *arg) { INPLACE_DIV };
-
-static PyObject *
-Osc_getTable(Osc* self)
-{
- Py_INCREF(self->table);
- return self->table;
-};
-
-static PyObject *
-Osc_setTable(Osc *self, PyObject *arg)
-{
- PyObject *tmp;
-
- ASSERT_ARG_NOT_NULL
+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 };
- tmp = arg;
- Py_DECREF(self->table);
- self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
+static PyObject * SineLoop_play(SineLoop *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * SineLoop_out(SineLoop *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * SineLoop_stop(SineLoop *self) { STOP };
- Py_INCREF(Py_None);
- return Py_None;
-}
+static PyObject * SineLoop_multiply(SineLoop *self, PyObject *arg) { MULTIPLY };
+static PyObject * SineLoop_inplace_multiply(SineLoop *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * SineLoop_add(SineLoop *self, PyObject *arg) { ADD };
+static PyObject * SineLoop_inplace_add(SineLoop *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * SineLoop_sub(SineLoop *self, PyObject *arg) { SUB };
+static PyObject * SineLoop_inplace_sub(SineLoop *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * SineLoop_div(SineLoop *self, PyObject *arg) { DIV };
+static PyObject * SineLoop_inplace_div(SineLoop *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-Osc_setFreq(Osc *self, PyObject *arg)
+SineLoop_setFreq(SineLoop *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -1300,7 +1339,7 @@ Osc_setFreq(Osc *self, PyObject *arg)
}
static PyObject *
-Osc_setPhase(Osc *self, PyObject *arg)
+SineLoop_setFeedback(SineLoop *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -1310,17 +1349,17 @@ Osc_setPhase(Osc *self, PyObject *arg)
tmp = arg;
Py_INCREF(tmp);
- Py_DECREF(self->phase);
+ Py_DECREF(self->feedback);
if (isNumber == 1) {
- self->phase = PyNumber_Float(tmp);
+ self->feedback = PyNumber_Float(tmp);
self->modebuffer[3] = 0;
}
else {
- self->phase = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->phase, "_getStream", NULL);
+ self->feedback = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->feedback, "_getStream", NULL);
Py_INCREF(streamtmp);
- Py_XDECREF(self->phase_stream);
- self->phase_stream = (Stream *)streamtmp;
+ Py_XDECREF(self->feedback_stream);
+ self->feedback_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
@@ -1330,276 +1369,255 @@ Osc_setPhase(Osc *self, PyObject *arg)
return Py_None;
}
-static PyObject *
-Osc_setInterp(Osc *self, PyObject *arg)
-{
- ASSERT_ARG_NOT_NULL
-
- 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)
-{
- self->pointerPos = 0.0;
- Py_INCREF(Py_None);
- return Py_None;
-}
+static PyMemberDef SineLoop_members[] = {
+ {"server", T_OBJECT_EX, offsetof(SineLoop, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(SineLoop, stream), 0, "Stream object."},
+ {"freq", T_OBJECT_EX, offsetof(SineLoop, freq), 0, "Frequency in cycle per second."},
+ {"feedback", T_OBJECT_EX, offsetof(SineLoop, feedback), 0, "Phase of signal (0 -> 1)"},
+ {"mul", T_OBJECT_EX, offsetof(SineLoop, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(SineLoop, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
-static PyMemberDef Osc_members[] = {
- {"server", T_OBJECT_EX, offsetof(Osc, server), 0, "Pyo server."},
- {"stream", T_OBJECT_EX, offsetof(Osc, stream), 0, "Stream object."},
- {"table", T_OBJECT_EX, offsetof(Osc, table), 0, "Waveform table."},
- {"freq", T_OBJECT_EX, offsetof(Osc, freq), 0, "Frequency in cycle per second."},
- {"phase", T_OBJECT_EX, offsetof(Osc, phase), 0, "Oscillator phase."},
- {"mul", T_OBJECT_EX, offsetof(Osc, mul), 0, "Mul factor."},
- {"add", T_OBJECT_EX, offsetof(Osc, add), 0, "Add factor."},
- {NULL} /* Sentinel */
+static PyMethodDef SineLoop_methods[] = {
+ {"getServer", (PyCFunction)SineLoop_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)SineLoop_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)SineLoop_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)SineLoop_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)SineLoop_stop, METH_NOARGS, "Stops computing."},
+ {"setFreq", (PyCFunction)SineLoop_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
+ {"setFeedback", (PyCFunction)SineLoop_setFeedback, METH_O, "Sets oscillator feedback between 0 and 1."},
+ {"setMul", (PyCFunction)SineLoop_setMul, METH_O, "Sets SineLoop mul factor."},
+ {"setAdd", (PyCFunction)SineLoop_setAdd, METH_O, "Sets SineLoop add factor."},
+ {"setSub", (PyCFunction)SineLoop_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)SineLoop_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
};
-static PyMethodDef Osc_methods[] = {
- {"getTable", (PyCFunction)Osc_getTable, METH_NOARGS, "Returns waveform table object."},
- {"getServer", (PyCFunction)Osc_getServer, METH_NOARGS, "Returns server object."},
- {"_getStream", (PyCFunction)Osc_getStream, METH_NOARGS, "Returns stream object."},
- {"play", (PyCFunction)Osc_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
- {"out", (PyCFunction)Osc_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
- {"stop", (PyCFunction)Osc_stop, METH_NOARGS, "Stops computing."},
- {"setTable", (PyCFunction)Osc_setTable, METH_O, "Sets oscillator table."},
- {"setFreq", (PyCFunction)Osc_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
- {"setPhase", (PyCFunction)Osc_setPhase, METH_O, "Sets oscillator phase."},
- {"setInterp", (PyCFunction)Osc_setInterp, METH_O, "Sets oscillator interpolation mode."},
- {"reset", (PyCFunction)Osc_reset, METH_NOARGS, "Resets pointer position to 0."},
- {"setMul", (PyCFunction)Osc_setMul, METH_O, "Sets oscillator mul factor."},
- {"setAdd", (PyCFunction)Osc_setAdd, METH_O, "Sets oscillator add factor."},
- {"setSub", (PyCFunction)Osc_setSub, METH_O, "Sets oscillator inverse add factor."},
- {"setDiv", (PyCFunction)Osc_setDiv, METH_O, "Sets inverse mul factor."},
- {NULL} /* Sentinel */
+static PyNumberMethods SineLoop_as_number = {
+ (binaryfunc)SineLoop_add, /*nb_add*/
+ (binaryfunc)SineLoop_sub, /*nb_subtract*/
+ (binaryfunc)SineLoop_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*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*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)SineLoop_inplace_add, /*inplace_add*/
+ (binaryfunc)SineLoop_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)SineLoop_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+ (binaryfunc)SineLoop_div, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ (binaryfunc)SineLoop_inplace_div, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
};
-static PyNumberMethods Osc_as_number = {
- (binaryfunc)Osc_add, /*nb_add*/
- (binaryfunc)Osc_sub, /*nb_subtract*/
- (binaryfunc)Osc_multiply, /*nb_multiply*/
- (binaryfunc)Osc_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)Osc_inplace_add, /*inplace_add*/
- (binaryfunc)Osc_inplace_sub, /*inplace_subtract*/
- (binaryfunc)Osc_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Osc_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 SineLoopType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.SineLoop_base", /*tp_name*/
+ sizeof(SineLoop), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)SineLoop_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
+ 0, /*tp_repr*/
+ &SineLoop_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*/
+ "SineLoop objects. Generates a looped sinewave.", /* tp_doc */
+ (traverseproc)SineLoop_traverse, /* tp_traverse */
+ (inquiry)SineLoop_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ SineLoop_methods, /* tp_methods */
+ SineLoop_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 */
+ SineLoop_new, /* tp_new */
};
-PyTypeObject OscType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.Osc_base", /*tp_name*/
- sizeof(Osc), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)Osc_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- &Osc_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*/
- "Osc objects. Generates an oscillatory waveform.", /* tp_doc */
- (traverseproc)Osc_traverse, /* tp_traverse */
- (inquiry)Osc_clear, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- Osc_methods, /* tp_methods */
- Osc_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 */
- Osc_new, /* tp_new */
-};
+/***************/
+/* Osc objects */
+/***************/
+static double
+Osc_clip(double x, int size) {
+ if (x < 0) {
+ x += ((int)(-x / size) + 1) * size;
+ }
+ else if (x >= size) {
+ x -= (int)(x / size) * size;
+ }
+ return x;
+}
-/**************/
-/* OscLoop object */
-/**************/
typedef struct {
pyo_audio_HEAD
PyObject *table;
PyObject *freq;
Stream *freq_stream;
- PyObject *feedback;
- Stream *feedback_stream;
+ PyObject *phase;
+ Stream *phase_stream;
int modebuffer[4];
double pointerPos;
- MYFLT lastValue;
-} OscLoop;
+ int interp; /* 0 = default to 2, 1 = nointerp, 2 = linear, 3 = cos, 4 = cubic */
+ MYFLT (*interp_func_ptr)(MYFLT *, int, MYFLT, int);
+} Osc;
static void
-OscLoop_readframes_ii(OscLoop *self) {
- MYFLT fr, feed, pos, inc, fpart;
+Osc_readframes_ii(Osc *self) {
+ MYFLT fr, ph, fpart;
+ double inc, pos;
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;
+ ph = PyFloat_AS_DOUBLE(self->phase);
inc = fr * size / self->sr;
+ ph *= size;
for (i=0; i<self->bufsize; i++) {
self->pointerPos += inc;
self->pointerPos = Osc_clip(self->pointerPos, size);
- pos = self->pointerPos + (self->lastValue * feed);
+ pos = self->pointerPos + ph;
if (pos >= size)
pos -= size;
- else if (pos < 0)
- pos += size;
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = self->lastValue = tablelist[ipart] * (1.0 - fpart) + tablelist[ipart+1] * fpart;
+ self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
}
}
static void
-OscLoop_readframes_ai(OscLoop *self) {
- MYFLT inc, feed, pos, fpart, sizeOnSr;
+Osc_readframes_ai(Osc *self) {
+ MYFLT ph, fpart, sizeOnSr;
+ double inc, pos;
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;
+ ph = PyFloat_AS_DOUBLE(self->phase);
+ ph *= size;
sizeOnSr = size / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * sizeOnSr;
self->pointerPos += inc;
self->pointerPos = Osc_clip(self->pointerPos, size);
- pos = self->pointerPos + (self->lastValue * feed);
+ pos = self->pointerPos + ph;
if (pos >= size)
pos -= size;
- else if (pos < 0)
- pos += size;
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = self->lastValue = tablelist[ipart] * (1.0 - fpart) + tablelist[ipart+1] * fpart;
+ self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
}
}
static void
-OscLoop_readframes_ia(OscLoop *self) {
- MYFLT fr, feed, pos, inc, fpart;
+Osc_readframes_ia(Osc *self) {
+ MYFLT fr, pha, fpart;
+ double inc, pos;
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);
+ MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
inc = fr * size / self->sr;
for (i=0; i<self->bufsize; i++) {
- feed = _clip(fd[i]) * size;
+ pha = ph[i] * size;
self->pointerPos += inc;
self->pointerPos = Osc_clip(self->pointerPos, size);
- pos = self->pointerPos + (self->lastValue * feed);
+ pos = self->pointerPos + pha;
if (pos >= size)
pos -= size;
- else if (pos < 0)
- pos += size;
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = self->lastValue = tablelist[ipart] * (1.0 - fpart) + tablelist[ipart+1] * fpart;
+ self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
}
}
static void
-OscLoop_readframes_aa(OscLoop *self) {
- MYFLT inc, feed, pos, fpart, sizeOnSr;
+Osc_readframes_aa(Osc *self) {
+ MYFLT pha, fpart, sizeOnSr;
+ double inc, pos;
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);
+ MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
sizeOnSr = size / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * sizeOnSr;
- feed = _clip(fd[i]) * size;
+ pha = ph[i] * size;
self->pointerPos += inc;
self->pointerPos = Osc_clip(self->pointerPos, size);
- pos = self->pointerPos + (self->lastValue * feed);
+ pos = self->pointerPos + pha;
if (pos >= size)
pos -= size;
- else if (pos < 0)
- pos += size;
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = self->lastValue = tablelist[ipart] * (1.0 - fpart) + tablelist[ipart+1] * fpart;
+ self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
}
}
-static void OscLoop_postprocessing_ii(OscLoop *self) { POST_PROCESSING_II };
-static void OscLoop_postprocessing_ai(OscLoop *self) { POST_PROCESSING_AI };
-static void OscLoop_postprocessing_ia(OscLoop *self) { POST_PROCESSING_IA };
-static void OscLoop_postprocessing_aa(OscLoop *self) { POST_PROCESSING_AA };
-static void OscLoop_postprocessing_ireva(OscLoop *self) { POST_PROCESSING_IREVA };
-static void OscLoop_postprocessing_areva(OscLoop *self) { POST_PROCESSING_AREVA };
-static void OscLoop_postprocessing_revai(OscLoop *self) { POST_PROCESSING_REVAI };
-static void OscLoop_postprocessing_revaa(OscLoop *self) { POST_PROCESSING_REVAA };
-static void OscLoop_postprocessing_revareva(OscLoop *self) { POST_PROCESSING_REVAREVA };
+static void Osc_postprocessing_ii(Osc *self) { POST_PROCESSING_II };
+static void Osc_postprocessing_ai(Osc *self) { POST_PROCESSING_AI };
+static void Osc_postprocessing_ia(Osc *self) { POST_PROCESSING_IA };
+static void Osc_postprocessing_aa(Osc *self) { POST_PROCESSING_AA };
+static void Osc_postprocessing_ireva(Osc *self) { POST_PROCESSING_IREVA };
+static void Osc_postprocessing_areva(Osc *self) { POST_PROCESSING_AREVA };
+static void Osc_postprocessing_revai(Osc *self) { POST_PROCESSING_REVAI };
+static void Osc_postprocessing_revaa(Osc *self) { POST_PROCESSING_REVAA };
+static void Osc_postprocessing_revareva(Osc *self) { POST_PROCESSING_REVAREVA };
static void
-OscLoop_setProcMode(OscLoop *self)
+Osc_setProcMode(Osc *self)
{
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
@@ -1607,122 +1625,123 @@ OscLoop_setProcMode(OscLoop *self)
switch (procmode) {
case 0:
- self->proc_func_ptr = OscLoop_readframes_ii;
+ self->proc_func_ptr = Osc_readframes_ii;
break;
case 1:
- self->proc_func_ptr = OscLoop_readframes_ai;
+ self->proc_func_ptr = Osc_readframes_ai;
break;
case 10:
- self->proc_func_ptr = OscLoop_readframes_ia;
+ self->proc_func_ptr = Osc_readframes_ia;
break;
case 11:
- self->proc_func_ptr = OscLoop_readframes_aa;
+ self->proc_func_ptr = Osc_readframes_aa;
break;
}
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = OscLoop_postprocessing_ii;
+ self->muladd_func_ptr = Osc_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = OscLoop_postprocessing_ai;
+ self->muladd_func_ptr = Osc_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = OscLoop_postprocessing_revai;
+ self->muladd_func_ptr = Osc_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = OscLoop_postprocessing_ia;
+ self->muladd_func_ptr = Osc_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = OscLoop_postprocessing_aa;
+ self->muladd_func_ptr = Osc_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = OscLoop_postprocessing_revaa;
+ self->muladd_func_ptr = Osc_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = OscLoop_postprocessing_ireva;
+ self->muladd_func_ptr = Osc_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = OscLoop_postprocessing_areva;
+ self->muladd_func_ptr = Osc_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = OscLoop_postprocessing_revareva;
+ self->muladd_func_ptr = Osc_postprocessing_revareva;
break;
}
}
static void
-OscLoop_compute_next_data_frame(OscLoop *self)
+Osc_compute_next_data_frame(Osc *self)
{
(*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
static int
-OscLoop_traverse(OscLoop *self, visitproc visit, void *arg)
+Osc_traverse(Osc *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->feedback);
- Py_VISIT(self->feedback_stream);
+ Py_VISIT(self->phase);
+ Py_VISIT(self->phase_stream);
Py_VISIT(self->freq);
Py_VISIT(self->freq_stream);
return 0;
}
static int
-OscLoop_clear(OscLoop *self)
+Osc_clear(Osc *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->feedback);
- Py_CLEAR(self->feedback_stream);
+ Py_CLEAR(self->phase);
+ Py_CLEAR(self->phase_stream);
Py_CLEAR(self->freq);
Py_CLEAR(self->freq_stream);
return 0;
}
static void
-OscLoop_dealloc(OscLoop* self)
+Osc_dealloc(Osc* self)
{
pyo_DEALLOC
- OscLoop_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Osc_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-OscLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+Osc_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *tabletmp, *freqtmp=NULL, *feedbacktmp=NULL, *multmp=NULL, *addtmp=NULL;
- OscLoop *self;
- self = (OscLoop *)type->tp_alloc(type, 0);
+ PyObject *tabletmp, *freqtmp=NULL, *phasetmp=NULL, *multmp=NULL, *addtmp=NULL;
+ Osc *self;
+ self = (Osc *)type->tp_alloc(type, 0);
self->freq = PyFloat_FromDouble(1000);
- self->feedback = PyFloat_FromDouble(0);
+ self->phase = PyFloat_FromDouble(0);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
- self->pointerPos = self->lastValue = 0.;
+ self->pointerPos = 0.;
+ self->interp = 2;
INIT_OBJECT_COMMON
- Stream_setFunctionPtr(self->stream, OscLoop_compute_next_data_frame);
- self->mode_func_ptr = OscLoop_setProcMode;
+ Stream_setFunctionPtr(self->stream, Osc_compute_next_data_frame);
+ self->mode_func_ptr = Osc_setProcMode;
- static char *kwlist[] = {"table", "freq", "feedback", "mul", "add", NULL};
+ static char *kwlist[] = {"table", "freq", "phase", "interp", "mul", "add", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &tabletmp, &freqtmp, &feedbacktmp, &multmp, &addtmp))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOiOO", kwlist, &tabletmp, &freqtmp, &phasetmp, &self->interp, &multmp, &addtmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PyErr_SetString(PyExc_TypeError, "\"table\" argument of OscLoop must be a PyoTableObject.\n");
+ 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 (feedbacktmp) {
- PyObject_CallMethod((PyObject *)self, "setFeedback", "O", feedbacktmp);
+ if (phasetmp) {
+ PyObject_CallMethod((PyObject *)self, "setPhase", "O", phasetmp);
}
if (freqtmp) {
@@ -1741,38 +1760,40 @@ OscLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
(*self->mode_func_ptr)(self);
+ SET_INTERP_POINTER
+
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 * 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 * OscLoop_play(OscLoop *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * OscLoop_out(OscLoop *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * OscLoop_stop(OscLoop *self) { STOP };
+static PyObject * Osc_play(Osc *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Osc_out(Osc *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * Osc_stop(Osc *self) { STOP };
-static PyObject * OscLoop_multiply(OscLoop *self, PyObject *arg) { MULTIPLY };
-static PyObject * OscLoop_inplace_multiply(OscLoop *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * OscLoop_add(OscLoop *self, PyObject *arg) { ADD };
-static PyObject * OscLoop_inplace_add(OscLoop *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * OscLoop_sub(OscLoop *self, PyObject *arg) { SUB };
-static PyObject * OscLoop_inplace_sub(OscLoop *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * OscLoop_div(OscLoop *self, PyObject *arg) { DIV };
-static PyObject * OscLoop_inplace_div(OscLoop *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * Osc_multiply(Osc *self, PyObject *arg) { MULTIPLY };
+static PyObject * Osc_inplace_multiply(Osc *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Osc_add(Osc *self, PyObject *arg) { ADD };
+static PyObject * Osc_inplace_add(Osc *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Osc_sub(Osc *self, PyObject *arg) { SUB };
+static PyObject * Osc_inplace_sub(Osc *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Osc_div(Osc *self, PyObject *arg) { DIV };
+static PyObject * Osc_inplace_div(Osc *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-OscLoop_getTable(OscLoop* self)
+Osc_getTable(Osc* self)
{
Py_INCREF(self->table);
return self->table;
};
static PyObject *
-OscLoop_setTable(OscLoop *self, PyObject *arg)
+Osc_setTable(Osc *self, PyObject *arg)
{
PyObject *tmp;
@@ -1787,7 +1808,7 @@ OscLoop_setTable(OscLoop *self, PyObject *arg)
}
static PyObject *
-OscLoop_setFreq(OscLoop *self, PyObject *arg)
+Osc_setFreq(Osc *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -1818,7 +1839,7 @@ OscLoop_setFreq(OscLoop *self, PyObject *arg)
}
static PyObject *
-OscLoop_setFeedback(OscLoop *self, PyObject *arg)
+Osc_setPhase(Osc *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -1828,17 +1849,17 @@ OscLoop_setFeedback(OscLoop *self, PyObject *arg)
tmp = arg;
Py_INCREF(tmp);
- Py_DECREF(self->feedback);
+ Py_DECREF(self->phase);
if (isNumber == 1) {
- self->feedback = PyNumber_Float(tmp);
+ self->phase = PyNumber_Float(tmp);
self->modebuffer[3] = 0;
}
else {
- self->feedback = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->feedback, "_getStream", NULL);
+ self->phase = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->phase, "_getStream", NULL);
Py_INCREF(streamtmp);
- Py_XDECREF(self->feedback_stream);
- self->feedback_stream = (Stream *)streamtmp;
+ Py_XDECREF(self->phase_stream);
+ self->phase_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
@@ -1848,39 +1869,66 @@ OscLoop_setFeedback(OscLoop *self, PyObject *arg)
return Py_None;
}
-static PyMemberDef OscLoop_members[] = {
- {"server", T_OBJECT_EX, offsetof(OscLoop, server), 0, "Pyo server."},
- {"stream", T_OBJECT_EX, offsetof(OscLoop, stream), 0, "Stream object."},
- {"table", T_OBJECT_EX, offsetof(OscLoop, table), 0, "Waveform table."},
- {"freq", T_OBJECT_EX, offsetof(OscLoop, freq), 0, "Frequency in cycle per second."},
- {"feedback", T_OBJECT_EX, offsetof(OscLoop, feedback), 0, "Oscillator feedback."},
- {"mul", T_OBJECT_EX, offsetof(OscLoop, mul), 0, "Mul factor."},
- {"add", T_OBJECT_EX, offsetof(OscLoop, add), 0, "Add factor."},
+static PyObject *
+Osc_setInterp(Osc *self, PyObject *arg)
+{
+ ASSERT_ARG_NOT_NULL
+
+ 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)
+{
+ self->pointerPos = 0.0;
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef Osc_members[] = {
+ {"server", T_OBJECT_EX, offsetof(Osc, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(Osc, stream), 0, "Stream object."},
+ {"table", T_OBJECT_EX, offsetof(Osc, table), 0, "Waveform table."},
+ {"freq", T_OBJECT_EX, offsetof(Osc, freq), 0, "Frequency in cycle per second."},
+ {"phase", T_OBJECT_EX, offsetof(Osc, phase), 0, "Oscillator phase."},
+ {"mul", T_OBJECT_EX, offsetof(Osc, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(Osc, add), 0, "Add factor."},
{NULL} /* Sentinel */
};
-static PyMethodDef OscLoop_methods[] = {
- {"getTable", (PyCFunction)OscLoop_getTable, METH_NOARGS, "Returns waveform table object."},
- {"getServer", (PyCFunction)OscLoop_getServer, METH_NOARGS, "Returns server object."},
- {"_getStream", (PyCFunction)OscLoop_getStream, METH_NOARGS, "Returns stream object."},
- {"play", (PyCFunction)OscLoop_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
- {"out", (PyCFunction)OscLoop_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
- {"stop", (PyCFunction)OscLoop_stop, METH_NOARGS, "Stops computing."},
- {"setTable", (PyCFunction)OscLoop_setTable, METH_O, "Sets oscillator table."},
- {"setFreq", (PyCFunction)OscLoop_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
- {"setFeedback", (PyCFunction)OscLoop_setFeedback, METH_O, "Sets oscillator feedback."},
- {"setMul", (PyCFunction)OscLoop_setMul, METH_O, "Sets oscillator mul factor."},
- {"setAdd", (PyCFunction)OscLoop_setAdd, METH_O, "Sets oscillator add factor."},
- {"setSub", (PyCFunction)OscLoop_setSub, METH_O, "Sets oscillator inverse add factor."},
- {"setDiv", (PyCFunction)OscLoop_setDiv, METH_O, "Sets inverse mul factor."},
+static PyMethodDef Osc_methods[] = {
+ {"getTable", (PyCFunction)Osc_getTable, METH_NOARGS, "Returns waveform table object."},
+ {"getServer", (PyCFunction)Osc_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)Osc_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)Osc_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)Osc_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)Osc_stop, METH_NOARGS, "Stops computing."},
+ {"setTable", (PyCFunction)Osc_setTable, METH_O, "Sets oscillator table."},
+ {"setFreq", (PyCFunction)Osc_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
+ {"setPhase", (PyCFunction)Osc_setPhase, METH_O, "Sets oscillator phase."},
+ {"setInterp", (PyCFunction)Osc_setInterp, METH_O, "Sets oscillator interpolation mode."},
+ {"reset", (PyCFunction)Osc_reset, METH_NOARGS, "Resets pointer position to 0."},
+ {"setMul", (PyCFunction)Osc_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)Osc_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)Osc_setSub, METH_O, "Sets oscillator inverse add factor."},
+ {"setDiv", (PyCFunction)Osc_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
-static PyNumberMethods OscLoop_as_number = {
- (binaryfunc)OscLoop_add, /*nb_add*/
- (binaryfunc)OscLoop_sub, /*nb_subtract*/
- (binaryfunc)OscLoop_multiply, /*nb_multiply*/
- (binaryfunc)OscLoop_div, /*nb_divide*/
+static PyNumberMethods Osc_as_number = {
+ (binaryfunc)Osc_add, /*nb_add*/
+ (binaryfunc)Osc_sub, /*nb_subtract*/
+ (binaryfunc)Osc_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1894,16 +1942,16 @@ static PyNumberMethods OscLoop_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
- (binaryfunc)OscLoop_inplace_add, /*inplace_add*/
- (binaryfunc)OscLoop_inplace_sub, /*inplace_subtract*/
- (binaryfunc)OscLoop_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)OscLoop_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)Osc_inplace_add, /*inplace_add*/
+ (binaryfunc)Osc_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)Osc_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1912,25 +1960,24 @@ static PyNumberMethods OscLoop_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Osc_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Osc_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
-PyTypeObject OscLoopType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.OscLoop_base", /*tp_name*/
- sizeof(OscLoop), /*tp_basicsize*/
+PyTypeObject OscType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.Osc_base", /*tp_name*/
+ sizeof(Osc), /*tp_basicsize*/
0, /*tp_itemsize*/
- (destructor)OscLoop_dealloc, /*tp_dealloc*/
+ (destructor)Osc_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
- &OscLoop_as_number, /*tp_as_number*/
+ &Osc_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -1940,15 +1987,15 @@ PyTypeObject OscLoopType = {
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
- "OscLoop objects. Generates an oscillatory waveform.", /* tp_doc */
- (traverseproc)OscLoop_traverse, /* tp_traverse */
- (inquiry)OscLoop_clear, /* tp_clear */
+ "Osc objects. Generates an oscillatory waveform.", /* tp_doc */
+ (traverseproc)Osc_traverse, /* tp_traverse */
+ (inquiry)Osc_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- OscLoop_methods, /* tp_methods */
- OscLoop_members, /* tp_members */
+ Osc_methods, /* tp_methods */
+ Osc_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -1957,158 +2004,140 @@ PyTypeObject OscLoopType = {
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- OscLoop_new, /* tp_new */
+ Osc_new, /* tp_new */
};
+/**************/
+/* OscLoop object */
+/**************/
typedef struct {
pyo_audio_HEAD
PyObject *table;
PyObject *freq;
Stream *freq_stream;
- PyObject *phase;
- Stream *phase_stream;
- PyObject *trig;
- Stream *trig_stream;
+ PyObject *feedback;
+ Stream *feedback_stream;
int modebuffer[4];
double pointerPos;
- int interp; /* 0 = default to 2, 1 = nointerp, 2 = linear, 3 = cos, 4 = cubic */
- MYFLT (*interp_func_ptr)(MYFLT *, int, MYFLT, int);
-} OscTrig;
+ MYFLT lastValue;
+} OscLoop;
static void
-OscTrig_readframes_ii(OscTrig *self) {
- MYFLT fr, ph, fpart;
- double inc, pos;
+OscLoop_readframes_ii(OscLoop *self) {
+ MYFLT fr, feed, pos, inc, fpart;
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);
+ feed = _clip(PyFloat_AS_DOUBLE(self->feedback)) * size;
inc = fr * size / self->sr;
- ph *= size;
for (i=0; i<self->bufsize; i++) {
- if (tr[i] == 1)
- self->pointerPos = 0.0;
- else {
- self->pointerPos += inc;
- self->pointerPos = Osc_clip(self->pointerPos, size);
- }
- pos = self->pointerPos + ph;
+ self->pointerPos += inc;
+ self->pointerPos = Osc_clip(self->pointerPos, size);
+ pos = self->pointerPos + (self->lastValue * feed);
if (pos >= size)
pos -= size;
+ else if (pos < 0)
+ pos += size;
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ self->data[i] = self->lastValue = tablelist[ipart] * (1.0 - fpart) + tablelist[ipart+1] * fpart;
}
}
static void
-OscTrig_readframes_ai(OscTrig *self) {
- MYFLT ph, fpart, sizeOnSr;
- double inc, pos;
+OscLoop_readframes_ai(OscLoop *self) {
+ MYFLT inc, feed, pos, fpart, sizeOnSr;
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;
+ feed = _clip(PyFloat_AS_DOUBLE(self->feedback)) * size;
sizeOnSr = size / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * sizeOnSr;
- if (tr[i] == 1)
- self->pointerPos = 0.0;
- else {
- self->pointerPos += inc;
- self->pointerPos = Osc_clip(self->pointerPos, size);
- }
- pos = self->pointerPos + ph;
+ self->pointerPos += inc;
+ self->pointerPos = Osc_clip(self->pointerPos, size);
+ pos = self->pointerPos + (self->lastValue * feed);
if (pos >= size)
pos -= size;
+ else if (pos < 0)
+ pos += size;
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ self->data[i] = self->lastValue = tablelist[ipart] * (1.0 - fpart) + tablelist[ipart+1] * fpart;
}
}
static void
-OscTrig_readframes_ia(OscTrig *self) {
- MYFLT fr, pha, fpart;
- double inc, pos;
+OscLoop_readframes_ia(OscLoop *self) {
+ MYFLT fr, feed, pos, inc, fpart;
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);
+ MYFLT *fd = Stream_getData((Stream *)self->feedback_stream);
inc = fr * size / self->sr;
for (i=0; i<self->bufsize; i++) {
- pha = ph[i] * size;
- if (tr[i] == 1)
- self->pointerPos = 0.0;
- else {
- self->pointerPos += inc;
- self->pointerPos = Osc_clip(self->pointerPos, size);
- }
- pos = self->pointerPos + pha;
+ feed = _clip(fd[i]) * size;
+ self->pointerPos += inc;
+ self->pointerPos = Osc_clip(self->pointerPos, size);
+ pos = self->pointerPos + (self->lastValue * feed);
if (pos >= size)
pos -= size;
+ else if (pos < 0)
+ pos += size;
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ self->data[i] = self->lastValue = tablelist[ipart] * (1.0 - fpart) + tablelist[ipart+1] * fpart;
}
}
static void
-OscTrig_readframes_aa(OscTrig *self) {
- MYFLT pha, fpart, sizeOnSr;
- double inc, pos;
+OscLoop_readframes_aa(OscLoop *self) {
+ MYFLT inc, feed, pos, fpart, sizeOnSr;
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);
+ MYFLT *fd = Stream_getData((Stream *)self->feedback_stream);
sizeOnSr = size / self->sr;
for (i=0; i<self->bufsize; i++) {
inc = fr[i] * sizeOnSr;
- pha = ph[i] * size;
- if (tr[i] == 1)
- self->pointerPos = 0.0;
- else {
- self->pointerPos += inc;
- self->pointerPos = Osc_clip(self->pointerPos, size);
- }
- pos = self->pointerPos + pha;
+ feed = _clip(fd[i]) * size;
+ self->pointerPos += inc;
+ self->pointerPos = Osc_clip(self->pointerPos, size);
+ pos = self->pointerPos + (self->lastValue * feed);
if (pos >= size)
pos -= size;
+ else if (pos < 0)
+ pos += size;
ipart = (int)pos;
fpart = pos - ipart;
- self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ self->data[i] = self->lastValue = tablelist[ipart] * (1.0 - fpart) + tablelist[ipart+1] * fpart;
}
}
-static void OscTrig_postprocessing_ii(OscTrig *self) { POST_PROCESSING_II };
-static void OscTrig_postprocessing_ai(OscTrig *self) { POST_PROCESSING_AI };
-static void OscTrig_postprocessing_ia(OscTrig *self) { POST_PROCESSING_IA };
-static void OscTrig_postprocessing_aa(OscTrig *self) { POST_PROCESSING_AA };
-static void OscTrig_postprocessing_ireva(OscTrig *self) { POST_PROCESSING_IREVA };
-static void OscTrig_postprocessing_areva(OscTrig *self) { POST_PROCESSING_AREVA };
-static void OscTrig_postprocessing_revai(OscTrig *self) { POST_PROCESSING_REVAI };
-static void OscTrig_postprocessing_revaa(OscTrig *self) { POST_PROCESSING_REVAA };
-static void OscTrig_postprocessing_revareva(OscTrig *self) { POST_PROCESSING_REVAREVA };
+static void OscLoop_postprocessing_ii(OscLoop *self) { POST_PROCESSING_II };
+static void OscLoop_postprocessing_ai(OscLoop *self) { POST_PROCESSING_AI };
+static void OscLoop_postprocessing_ia(OscLoop *self) { POST_PROCESSING_IA };
+static void OscLoop_postprocessing_aa(OscLoop *self) { POST_PROCESSING_AA };
+static void OscLoop_postprocessing_ireva(OscLoop *self) { POST_PROCESSING_IREVA };
+static void OscLoop_postprocessing_areva(OscLoop *self) { POST_PROCESSING_AREVA };
+static void OscLoop_postprocessing_revai(OscLoop *self) { POST_PROCESSING_REVAI };
+static void OscLoop_postprocessing_revaa(OscLoop *self) { POST_PROCESSING_REVAA };
+static void OscLoop_postprocessing_revareva(OscLoop *self) { POST_PROCESSING_REVAREVA };
static void
-OscTrig_setProcMode(OscTrig *self)
+OscLoop_setProcMode(OscLoop *self)
{
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
@@ -2116,131 +2145,122 @@ OscTrig_setProcMode(OscTrig *self)
switch (procmode) {
case 0:
- self->proc_func_ptr = OscTrig_readframes_ii;
+ self->proc_func_ptr = OscLoop_readframes_ii;
break;
case 1:
- self->proc_func_ptr = OscTrig_readframes_ai;
+ self->proc_func_ptr = OscLoop_readframes_ai;
break;
case 10:
- self->proc_func_ptr = OscTrig_readframes_ia;
+ self->proc_func_ptr = OscLoop_readframes_ia;
break;
case 11:
- self->proc_func_ptr = OscTrig_readframes_aa;
+ self->proc_func_ptr = OscLoop_readframes_aa;
break;
}
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = OscTrig_postprocessing_ii;
+ self->muladd_func_ptr = OscLoop_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = OscTrig_postprocessing_ai;
+ self->muladd_func_ptr = OscLoop_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = OscTrig_postprocessing_revai;
+ self->muladd_func_ptr = OscLoop_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = OscTrig_postprocessing_ia;
+ self->muladd_func_ptr = OscLoop_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = OscTrig_postprocessing_aa;
+ self->muladd_func_ptr = OscLoop_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = OscTrig_postprocessing_revaa;
+ self->muladd_func_ptr = OscLoop_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = OscTrig_postprocessing_ireva;
+ self->muladd_func_ptr = OscLoop_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = OscTrig_postprocessing_areva;
+ self->muladd_func_ptr = OscLoop_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = OscTrig_postprocessing_revareva;
+ self->muladd_func_ptr = OscLoop_postprocessing_revareva;
break;
}
}
static void
-OscTrig_compute_next_data_frame(OscTrig *self)
+OscLoop_compute_next_data_frame(OscLoop *self)
{
(*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
static int
-OscTrig_traverse(OscTrig *self, visitproc visit, void *arg)
+OscLoop_traverse(OscLoop *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
- Py_VISIT(self->phase);
- Py_VISIT(self->phase_stream);
+ Py_VISIT(self->feedback);
+ Py_VISIT(self->feedback_stream);
Py_VISIT(self->freq);
Py_VISIT(self->freq_stream);
- Py_VISIT(self->trig);
- Py_VISIT(self->trig_stream);
return 0;
}
static int
-OscTrig_clear(OscTrig *self)
+OscLoop_clear(OscLoop *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
- Py_CLEAR(self->phase);
- Py_CLEAR(self->phase_stream);
+ Py_CLEAR(self->feedback);
+ Py_CLEAR(self->feedback_stream);
Py_CLEAR(self->freq);
Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->trig);
- Py_CLEAR(self->trig_stream);
return 0;
}
static void
-OscTrig_dealloc(OscTrig* self)
+OscLoop_dealloc(OscLoop* self)
{
pyo_DEALLOC
- OscTrig_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ OscLoop_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-OscTrig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+OscLoop_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *tabletmp, *trigtmp, *freqtmp=NULL, *phasetmp=NULL, *multmp=NULL, *addtmp=NULL;
- OscTrig *self;
- self = (OscTrig *)type->tp_alloc(type, 0);
+ 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->phase = PyFloat_FromDouble(0);
+ self->feedback = PyFloat_FromDouble(0);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
- self->pointerPos = 0.;
- self->interp = 2;
+ self->pointerPos = self->lastValue = 0.;
INIT_OBJECT_COMMON
- Stream_setFunctionPtr(self->stream, OscTrig_compute_next_data_frame);
- self->mode_func_ptr = OscTrig_setProcMode;
+ Stream_setFunctionPtr(self->stream, OscLoop_compute_next_data_frame);
+ self->mode_func_ptr = OscLoop_setProcMode;
- static char *kwlist[] = {"table", "trig", "freq", "phase", "interp", "mul", "add", NULL};
+ static char *kwlist[] = {"table", "freq", "feedback", "mul", "add", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OOiOO", kwlist, &tabletmp, &trigtmp, &freqtmp, &phasetmp, &self->interp, &multmp, &addtmp))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOO", kwlist, &tabletmp, &freqtmp, &feedbacktmp, &multmp, &addtmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PyErr_SetString(PyExc_TypeError, "\"table\" argument of OscTrig must be a PyoTableObject.\n");
+ 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 (trigtmp) {
- PyObject_CallMethod((PyObject *)self, "setTrig", "O", trigtmp);
- }
-
- if (phasetmp) {
- PyObject_CallMethod((PyObject *)self, "setPhase", "O", phasetmp);
+ if (feedbacktmp) {
+ PyObject_CallMethod((PyObject *)self, "setFeedback", "O", feedbacktmp);
}
if (freqtmp) {
@@ -2259,40 +2279,38 @@ OscTrig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
(*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 * 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 * OscTrig_play(OscTrig *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * OscTrig_out(OscTrig *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * OscTrig_stop(OscTrig *self) { STOP };
+static PyObject * OscLoop_play(OscLoop *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * OscLoop_out(OscLoop *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * OscLoop_stop(OscLoop *self) { STOP };
-static PyObject * OscTrig_multiply(OscTrig *self, PyObject *arg) { MULTIPLY };
-static PyObject * OscTrig_inplace_multiply(OscTrig *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * OscTrig_add(OscTrig *self, PyObject *arg) { ADD };
-static PyObject * OscTrig_inplace_add(OscTrig *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * OscTrig_sub(OscTrig *self, PyObject *arg) { SUB };
-static PyObject * OscTrig_inplace_sub(OscTrig *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * OscTrig_div(OscTrig *self, PyObject *arg) { DIV };
-static PyObject * OscTrig_inplace_div(OscTrig *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * OscLoop_multiply(OscLoop *self, PyObject *arg) { MULTIPLY };
+static PyObject * OscLoop_inplace_multiply(OscLoop *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * OscLoop_add(OscLoop *self, PyObject *arg) { ADD };
+static PyObject * OscLoop_inplace_add(OscLoop *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * OscLoop_sub(OscLoop *self, PyObject *arg) { SUB };
+static PyObject * OscLoop_inplace_sub(OscLoop *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * OscLoop_div(OscLoop *self, PyObject *arg) { DIV };
+static PyObject * OscLoop_inplace_div(OscLoop *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-OscTrig_getTable(OscTrig* self)
+OscLoop_getTable(OscLoop* self)
{
Py_INCREF(self->table);
return self->table;
};
static PyObject *
-OscTrig_setTable(OscTrig *self, PyObject *arg)
+OscLoop_setTable(OscLoop *self, PyObject *arg)
{
PyObject *tmp;
@@ -2307,35 +2325,7 @@ OscTrig_setTable(OscTrig *self, PyObject *arg)
}
static PyObject *
-OscTrig_setTrig(OscTrig *self, PyObject *arg)
-{
- PyObject *tmp, *streamtmp;
-
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
-
- tmp = arg;
- Py_INCREF(tmp);
- Py_XDECREF(self->trig);
- if (isNumber == 1) {
- Py_INCREF(Py_None);
- return Py_None;
- }
- else {
- self->trig = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->trig, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->trig_stream);
- self->trig_stream = (Stream *)streamtmp;
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *
-OscTrig_setFreq(OscTrig *self, PyObject *arg)
+OscLoop_setFreq(OscLoop *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -2366,7 +2356,7 @@ OscTrig_setFreq(OscTrig *self, PyObject *arg)
}
static PyObject *
-OscTrig_setPhase(OscTrig *self, PyObject *arg)
+OscLoop_setFeedback(OscLoop *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -2376,17 +2366,17 @@ OscTrig_setPhase(OscTrig *self, PyObject *arg)
tmp = arg;
Py_INCREF(tmp);
- Py_DECREF(self->phase);
+ Py_DECREF(self->feedback);
if (isNumber == 1) {
- self->phase = PyNumber_Float(tmp);
+ self->feedback = PyNumber_Float(tmp);
self->modebuffer[3] = 0;
}
else {
- self->phase = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->phase, "_getStream", NULL);
+ self->feedback = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->feedback, "_getStream", NULL);
Py_INCREF(streamtmp);
- Py_XDECREF(self->phase_stream);
- self->phase_stream = (Stream *)streamtmp;
+ Py_XDECREF(self->feedback_stream);
+ self->feedback_stream = (Stream *)streamtmp;
self->modebuffer[3] = 1;
}
@@ -2396,68 +2386,39 @@ OscTrig_setPhase(OscTrig *self, PyObject *arg)
return Py_None;
}
-static PyObject *
-OscTrig_setInterp(OscTrig *self, PyObject *arg)
-{
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
+static PyMemberDef OscLoop_members[] = {
+ {"server", T_OBJECT_EX, offsetof(OscLoop, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(OscLoop, stream), 0, "Stream object."},
+ {"table", T_OBJECT_EX, offsetof(OscLoop, table), 0, "Waveform table."},
+ {"freq", T_OBJECT_EX, offsetof(OscLoop, freq), 0, "Frequency in cycle per second."},
+ {"feedback", T_OBJECT_EX, offsetof(OscLoop, feedback), 0, "Oscillator feedback."},
+ {"mul", T_OBJECT_EX, offsetof(OscLoop, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(OscLoop, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
- if (isNumber == 1) {
- self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
+static PyMethodDef OscLoop_methods[] = {
+ {"getTable", (PyCFunction)OscLoop_getTable, METH_NOARGS, "Returns waveform table object."},
+ {"getServer", (PyCFunction)OscLoop_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)OscLoop_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)OscLoop_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)OscLoop_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)OscLoop_stop, METH_NOARGS, "Stops computing."},
+ {"setTable", (PyCFunction)OscLoop_setTable, METH_O, "Sets oscillator table."},
+ {"setFreq", (PyCFunction)OscLoop_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
+ {"setFeedback", (PyCFunction)OscLoop_setFeedback, METH_O, "Sets oscillator feedback."},
+ {"setMul", (PyCFunction)OscLoop_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)OscLoop_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)OscLoop_setSub, METH_O, "Sets oscillator inverse add factor."},
+ {"setDiv", (PyCFunction)OscLoop_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
- SET_INTERP_POINTER
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyObject *
-OscTrig_reset(OscTrig *self)
-{
- self->pointerPos = 0.0;
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyMemberDef OscTrig_members[] = {
- {"server", T_OBJECT_EX, offsetof(OscTrig, server), 0, "Pyo server."},
- {"stream", T_OBJECT_EX, offsetof(OscTrig, stream), 0, "Stream object."},
- {"table", T_OBJECT_EX, offsetof(OscTrig, table), 0, "Waveform table."},
- {"trig", T_OBJECT_EX, offsetof(OscTrig, trig), 0, "Trigger signal."},
- {"freq", T_OBJECT_EX, offsetof(OscTrig, freq), 0, "Frequency in cycle per second."},
- {"phase", T_OBJECT_EX, offsetof(OscTrig, phase), 0, "OscTrigillator phase."},
- {"mul", T_OBJECT_EX, offsetof(OscTrig, mul), 0, "Mul factor."},
- {"add", T_OBJECT_EX, offsetof(OscTrig, add), 0, "Add factor."},
- {NULL} /* Sentinel */
-};
-
-static PyMethodDef OscTrig_methods[] = {
- {"getTable", (PyCFunction)OscTrig_getTable, METH_NOARGS, "Returns waveform table object."},
- {"getServer", (PyCFunction)OscTrig_getServer, METH_NOARGS, "Returns server object."},
- {"_getStream", (PyCFunction)OscTrig_getStream, METH_NOARGS, "Returns stream object."},
- {"play", (PyCFunction)OscTrig_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
- {"out", (PyCFunction)OscTrig_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
- {"stop", (PyCFunction)OscTrig_stop, METH_NOARGS, "Stops computing."},
- {"setTable", (PyCFunction)OscTrig_setTable, METH_O, "Sets oscillator table."},
- {"setTrig", (PyCFunction)OscTrig_setTrig, METH_O, "Sets the reset trigger signal."},
- {"setFreq", (PyCFunction)OscTrig_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
- {"setPhase", (PyCFunction)OscTrig_setPhase, METH_O, "Sets oscillator phase."},
- {"setInterp", (PyCFunction)OscTrig_setInterp, METH_O, "Sets oscillator interpolation mode."},
- {"reset", (PyCFunction)OscTrig_reset, METH_NOARGS, "Resets pointer position to 0."},
- {"setMul", (PyCFunction)OscTrig_setMul, METH_O, "Sets oscillator mul factor."},
- {"setAdd", (PyCFunction)OscTrig_setAdd, METH_O, "Sets oscillator add factor."},
- {"setSub", (PyCFunction)OscTrig_setSub, METH_O, "Sets oscillator inverse add factor."},
- {"setDiv", (PyCFunction)OscTrig_setDiv, METH_O, "Sets inverse mul factor."},
- {NULL} /* Sentinel */
-};
-
-static PyNumberMethods OscTrig_as_number = {
- (binaryfunc)OscTrig_add, /*nb_add*/
- (binaryfunc)OscTrig_sub, /*nb_subtract*/
- (binaryfunc)OscTrig_multiply, /*nb_multiply*/
- (binaryfunc)OscTrig_div, /*nb_divide*/
+static PyNumberMethods OscLoop_as_number = {
+ (binaryfunc)OscLoop_add, /*nb_add*/
+ (binaryfunc)OscLoop_sub, /*nb_subtract*/
+ (binaryfunc)OscLoop_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2471,16 +2432,16 @@ static PyNumberMethods OscTrig_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
- (binaryfunc)OscTrig_inplace_add, /*inplace_add*/
- (binaryfunc)OscTrig_inplace_sub, /*inplace_subtract*/
- (binaryfunc)OscTrig_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)OscTrig_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)OscLoop_inplace_add, /*inplace_add*/
+ (binaryfunc)OscLoop_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)OscLoop_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2489,25 +2450,24 @@ static PyNumberMethods OscTrig_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)OscLoop_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)OscLoop_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
-PyTypeObject OscTrigType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.OscTrig_base", /*tp_name*/
- sizeof(OscTrig), /*tp_basicsize*/
+PyTypeObject OscLoopType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.OscLoop_base", /*tp_name*/
+ sizeof(OscLoop), /*tp_basicsize*/
0, /*tp_itemsize*/
- (destructor)OscTrig_dealloc, /*tp_dealloc*/
+ (destructor)OscLoop_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
- &OscTrig_as_number, /*tp_as_number*/
+ &OscLoop_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -2517,15 +2477,15 @@ PyTypeObject OscTrigType = {
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
- "OscTrig objects. Generates an oscillatory waveform with sample accurate reset signal.", /* tp_doc */
- (traverseproc)OscTrig_traverse, /* tp_traverse */
- (inquiry)OscTrig_clear, /* tp_clear */
+ "OscLoop objects. Generates an oscillatory waveform.", /* tp_doc */
+ (traverseproc)OscLoop_traverse, /* tp_traverse */
+ (inquiry)OscLoop_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- OscTrig_methods, /* tp_methods */
- OscTrig_members, /* tp_members */
+ OscLoop_methods, /* tp_methods */
+ OscLoop_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -2534,138 +2494,158 @@ PyTypeObject OscTrigType = {
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- OscTrig_new, /* tp_new */
+ OscLoop_new, /* tp_new */
};
-/**************/
-/* Phasor object */
-/**************/
typedef struct {
pyo_audio_HEAD
+ PyObject *table;
PyObject *freq;
Stream *freq_stream;
PyObject *phase;
Stream *phase_stream;
+ PyObject *trig;
+ Stream *trig_stream;
int modebuffer[4];
double pointerPos;
-} Phasor;
+ int interp; /* 0 = default to 2, 1 = nointerp, 2 = linear, 3 = cos, 4 = cubic */
+ MYFLT (*interp_func_ptr)(MYFLT *, int, MYFLT, int);
+} OscTrig;
static void
-Phasor_readframes_ii(Phasor *self) {
- MYFLT fr, ph;
+OscTrig_readframes_ii(OscTrig *self) {
+ MYFLT fr, ph, fpart;
double inc, pos;
- int i;
+ int i, ipart;
+ MYFLT *tablelist = TableStream_getData(self->table);
+ int size = TableStream_getSize(self->table);
fr = PyFloat_AS_DOUBLE(self->freq);
- ph = _clip(PyFloat_AS_DOUBLE(self->phase));
- inc = fr / self->sr;
+ 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)
+ self->pointerPos = 0.0;
+ else {
+ self->pointerPos += inc;
+ self->pointerPos = Osc_clip(self->pointerPos, size);
+ }
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;
- else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
+ if (pos >= size)
+ pos -= size;
+ ipart = (int)pos;
+ fpart = pos - ipart;
+ self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
}
}
static void
-Phasor_readframes_ai(Phasor *self) {
- MYFLT ph, oneOnSr;
+OscTrig_readframes_ai(OscTrig *self) {
+ MYFLT ph, fpart, sizeOnSr;
double inc, pos;
- int i;
+ int i, ipart;
+ MYFLT *tablelist = TableStream_getData(self->table);
+ int size = TableStream_getSize(self->table);
MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
- ph = _clip(PyFloat_AS_DOUBLE(self->phase));
+ ph = PyFloat_AS_DOUBLE(self->phase);
+ MYFLT *tr = Stream_getData((Stream *)self->trig_stream);
+ ph *= size;
- oneOnSr = 1.0 / self->sr;
+ sizeOnSr = size / self->sr;
for (i=0; i<self->bufsize; i++) {
+ inc = fr[i] * sizeOnSr;
+ if (tr[i] == 1)
+ self->pointerPos = 0.0;
+ else {
+ self->pointerPos += inc;
+ self->pointerPos = Osc_clip(self->pointerPos, size);
+ }
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)
- self->pointerPos += 1.0;
- else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
+ if (pos >= size)
+ pos -= size;
+ ipart = (int)pos;
+ fpart = pos - ipart;
+ self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
}
}
static void
-Phasor_readframes_ia(Phasor *self) {
- MYFLT fr, pha;
+OscTrig_readframes_ia(OscTrig *self) {
+ MYFLT fr, pha, fpart;
double inc, pos;
- int i;
+ 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 / self->sr;
+ MYFLT *tr = Stream_getData((Stream *)self->trig_stream);
+ inc = fr * size / self->sr;
for (i=0; i<self->bufsize; i++) {
- pha = _clip(ph[i]);
-
+ pha = ph[i] * size;
+ if (tr[i] == 1)
+ self->pointerPos = 0.0;
+ else {
+ self->pointerPos += inc;
+ self->pointerPos = Osc_clip(self->pointerPos, size);
+ }
pos = self->pointerPos + pha;
- if (pos > 1)
- pos -= 1.0;
- self->data[i] = pos;
-
- self->pointerPos += inc;
- if (self->pointerPos < 0)
- self->pointerPos += 1.0;
- else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
+ if (pos >= size)
+ pos -= size;
+ ipart = (int)pos;
+ fpart = pos - ipart;
+ self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
}
}
static void
-Phasor_readframes_aa(Phasor *self) {
- MYFLT pha, oneOnSr;
+OscTrig_readframes_aa(OscTrig *self) {
+ MYFLT pha, fpart, sizeOnSr;
double inc, pos;
- int i;
+ 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);
- oneOnSr = 1.0 / self->sr;
-
+ sizeOnSr = size / self->sr;
for (i=0; i<self->bufsize; i++) {
- pha = _clip(ph[i]);
-
+ inc = fr[i] * sizeOnSr;
+ pha = ph[i] * size;
+ if (tr[i] == 1)
+ self->pointerPos = 0.0;
+ else {
+ self->pointerPos += inc;
+ self->pointerPos = Osc_clip(self->pointerPos, size);
+ }
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)
- self->pointerPos += 1.0;
- else if (self->pointerPos >= 1)
- self->pointerPos -= 1.0;
+ if (pos >= size)
+ pos -= size;
+ ipart = (int)pos;
+ fpart = pos - ipart;
+ self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
}
}
-static void Phasor_postprocessing_ii(Phasor *self) { POST_PROCESSING_II };
-static void Phasor_postprocessing_ai(Phasor *self) { POST_PROCESSING_AI };
-static void Phasor_postprocessing_ia(Phasor *self) { POST_PROCESSING_IA };
-static void Phasor_postprocessing_aa(Phasor *self) { POST_PROCESSING_AA };
-static void Phasor_postprocessing_ireva(Phasor *self) { POST_PROCESSING_IREVA };
-static void Phasor_postprocessing_areva(Phasor *self) { POST_PROCESSING_AREVA };
-static void Phasor_postprocessing_revai(Phasor *self) { POST_PROCESSING_REVAI };
-static void Phasor_postprocessing_revaa(Phasor *self) { POST_PROCESSING_REVAA };
-static void Phasor_postprocessing_revareva(Phasor *self) { POST_PROCESSING_REVAREVA };
+static void OscTrig_postprocessing_ii(OscTrig *self) { POST_PROCESSING_II };
+static void OscTrig_postprocessing_ai(OscTrig *self) { POST_PROCESSING_AI };
+static void OscTrig_postprocessing_ia(OscTrig *self) { POST_PROCESSING_IA };
+static void OscTrig_postprocessing_aa(OscTrig *self) { POST_PROCESSING_AA };
+static void OscTrig_postprocessing_ireva(OscTrig *self) { POST_PROCESSING_IREVA };
+static void OscTrig_postprocessing_areva(OscTrig *self) { POST_PROCESSING_AREVA };
+static void OscTrig_postprocessing_revai(OscTrig *self) { POST_PROCESSING_REVAI };
+static void OscTrig_postprocessing_revaa(OscTrig *self) { POST_PROCESSING_REVAA };
+static void OscTrig_postprocessing_revareva(OscTrig *self) { POST_PROCESSING_REVAREVA };
static void
-Phasor_setProcMode(Phasor *self)
+OscTrig_setProcMode(OscTrig *self)
{
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
@@ -2673,119 +2653,137 @@ Phasor_setProcMode(Phasor *self)
switch (procmode) {
case 0:
- self->proc_func_ptr = Phasor_readframes_ii;
+ self->proc_func_ptr = OscTrig_readframes_ii;
break;
case 1:
- self->proc_func_ptr = Phasor_readframes_ai;
+ self->proc_func_ptr = OscTrig_readframes_ai;
break;
case 10:
- self->proc_func_ptr = Phasor_readframes_ia;
+ self->proc_func_ptr = OscTrig_readframes_ia;
break;
case 11:
- self->proc_func_ptr = Phasor_readframes_aa;
+ self->proc_func_ptr = OscTrig_readframes_aa;
break;
}
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = Phasor_postprocessing_ii;
+ self->muladd_func_ptr = OscTrig_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = Phasor_postprocessing_ai;
+ self->muladd_func_ptr = OscTrig_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = Phasor_postprocessing_revai;
+ self->muladd_func_ptr = OscTrig_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = Phasor_postprocessing_ia;
+ self->muladd_func_ptr = OscTrig_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = Phasor_postprocessing_aa;
+ self->muladd_func_ptr = OscTrig_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = Phasor_postprocessing_revaa;
+ self->muladd_func_ptr = OscTrig_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = Phasor_postprocessing_ireva;
+ self->muladd_func_ptr = OscTrig_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = Phasor_postprocessing_areva;
+ self->muladd_func_ptr = OscTrig_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = Phasor_postprocessing_revareva;
+ self->muladd_func_ptr = OscTrig_postprocessing_revareva;
break;
}
}
static void
-Phasor_compute_next_data_frame(Phasor *self)
+OscTrig_compute_next_data_frame(OscTrig *self)
{
(*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
static int
-Phasor_traverse(Phasor *self, visitproc visit, void *arg)
+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);
return 0;
}
static int
-Phasor_clear(Phasor *self)
+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);
return 0;
}
static void
-Phasor_dealloc(Phasor* self)
+OscTrig_dealloc(OscTrig* self)
{
pyo_DEALLOC
- Phasor_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ OscTrig_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-Phasor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+OscTrig_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *freqtmp=NULL, *phasetmp=NULL, *multmp=NULL, *addtmp=NULL;
- Phasor *self;
- self = (Phasor *)type->tp_alloc(type, 0);
+ PyObject *tabletmp, *trigtmp, *freqtmp=NULL, *phasetmp=NULL, *multmp=NULL, *addtmp=NULL;
+ OscTrig *self;
+ self = (OscTrig *)type->tp_alloc(type, 0);
- self->freq = PyFloat_FromDouble(100);
+ self->freq = PyFloat_FromDouble(1000);
self->phase = PyFloat_FromDouble(0);
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
self->pointerPos = 0.;
+ self->interp = 2;
INIT_OBJECT_COMMON
- Stream_setFunctionPtr(self->stream, Phasor_compute_next_data_frame);
- self->mode_func_ptr = Phasor_setProcMode;
+ Stream_setFunctionPtr(self->stream, OscTrig_compute_next_data_frame);
+ self->mode_func_ptr = OscTrig_setProcMode;
- static char *kwlist[] = {"freq", "phase", "mul", "add", NULL};
+ static char *kwlist[] = {"table", "trig", "freq", "phase", "interp", "mul", "add", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &freqtmp, &phasetmp, &multmp, &addtmp))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OOiOO", kwlist, &tabletmp, &trigtmp, &freqtmp, &phasetmp, &self->interp, &multmp, &addtmp))
Py_RETURN_NONE;
- if (freqtmp) {
- PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
+ if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
+ 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", "");
+
+ 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);
}
@@ -2798,31 +2796,83 @@ Phasor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
(*self->mode_func_ptr)(self);
+ SET_INTERP_POINTER
+
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 * 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 * Phasor_play(Phasor *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * Phasor_out(Phasor *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * Phasor_stop(Phasor *self) { STOP };
+static PyObject * OscTrig_play(OscTrig *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * OscTrig_out(OscTrig *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * OscTrig_stop(OscTrig *self) { STOP };
-static PyObject * Phasor_multiply(Phasor *self, PyObject *arg) { MULTIPLY };
-static PyObject * Phasor_inplace_multiply(Phasor *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * Phasor_add(Phasor *self, PyObject *arg) { ADD };
-static PyObject * Phasor_inplace_add(Phasor *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * Phasor_sub(Phasor *self, PyObject *arg) { SUB };
-static PyObject * Phasor_inplace_sub(Phasor *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * Phasor_div(Phasor *self, PyObject *arg) { DIV };
-static PyObject * Phasor_inplace_div(Phasor *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * OscTrig_multiply(OscTrig *self, PyObject *arg) { MULTIPLY };
+static PyObject * OscTrig_inplace_multiply(OscTrig *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * OscTrig_add(OscTrig *self, PyObject *arg) { ADD };
+static PyObject * OscTrig_inplace_add(OscTrig *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * OscTrig_sub(OscTrig *self, PyObject *arg) { SUB };
+static PyObject * OscTrig_inplace_sub(OscTrig *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * OscTrig_div(OscTrig *self, PyObject *arg) { DIV };
+static PyObject * OscTrig_inplace_div(OscTrig *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-Phasor_setFreq(Phasor *self, PyObject *arg)
+OscTrig_getTable(OscTrig* self)
+{
+ Py_INCREF(self->table);
+ return self->table;
+};
+
+static PyObject *
+OscTrig_setTable(OscTrig *self, PyObject *arg)
+{
+ PyObject *tmp;
+
+ ASSERT_ARG_NOT_NULL
+
+ 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;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_XDECREF(self->trig);
+ if (isNumber == 1) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ else {
+ self->trig = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->trig, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->trig_stream);
+ self->trig_stream = (Stream *)streamtmp;
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+OscTrig_setFreq(OscTrig *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -2853,7 +2903,7 @@ Phasor_setFreq(Phasor *self, PyObject *arg)
}
static PyObject *
-Phasor_setPhase(Phasor *self, PyObject *arg)
+OscTrig_setPhase(OscTrig *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -2884,268 +2934,397 @@ Phasor_setPhase(Phasor *self, PyObject *arg)
}
static PyObject *
-Phasor_reset(Phasor *self)
+OscTrig_setInterp(OscTrig *self, PyObject *arg)
+{
+ ASSERT_ARG_NOT_NULL
+
+ 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)
{
self->pointerPos = 0.0;
Py_INCREF(Py_None);
return Py_None;
}
-static PyMemberDef Phasor_members[] = {
-{"server", T_OBJECT_EX, offsetof(Phasor, server), 0, "Pyo server."},
-{"stream", T_OBJECT_EX, offsetof(Phasor, stream), 0, "Stream object."},
-{"freq", T_OBJECT_EX, offsetof(Phasor, freq), 0, "Frequency in cycle per second."},
-{"phase", T_OBJECT_EX, offsetof(Phasor, phase), 0, "Phasorillator phase."},
-{"mul", T_OBJECT_EX, offsetof(Phasor, mul), 0, "Mul factor."},
-{"add", T_OBJECT_EX, offsetof(Phasor, add), 0, "Add factor."},
-{NULL} /* Sentinel */
+static PyMemberDef OscTrig_members[] = {
+ {"server", T_OBJECT_EX, offsetof(OscTrig, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(OscTrig, stream), 0, "Stream object."},
+ {"table", T_OBJECT_EX, offsetof(OscTrig, table), 0, "Waveform table."},
+ {"trig", T_OBJECT_EX, offsetof(OscTrig, trig), 0, "Trigger signal."},
+ {"freq", T_OBJECT_EX, offsetof(OscTrig, freq), 0, "Frequency in cycle per second."},
+ {"phase", T_OBJECT_EX, offsetof(OscTrig, phase), 0, "OscTrigillator phase."},
+ {"mul", T_OBJECT_EX, offsetof(OscTrig, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(OscTrig, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
};
-static PyMethodDef Phasor_methods[] = {
-{"getServer", (PyCFunction)Phasor_getServer, METH_NOARGS, "Returns server object."},
-{"_getStream", (PyCFunction)Phasor_getStream, METH_NOARGS, "Returns stream object."},
-{"play", (PyCFunction)Phasor_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
-{"out", (PyCFunction)Phasor_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
-{"stop", (PyCFunction)Phasor_stop, METH_NOARGS, "Stops computing."},
-{"setFreq", (PyCFunction)Phasor_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
-{"setPhase", (PyCFunction)Phasor_setPhase, METH_O, "Sets oscillator phase."},
-{"reset", (PyCFunction)Phasor_reset, METH_NOARGS, "Resets pointer position to 0."},
-{"setMul", (PyCFunction)Phasor_setMul, METH_O, "Sets oscillator mul factor."},
-{"setAdd", (PyCFunction)Phasor_setAdd, METH_O, "Sets oscillator add factor."},
-{"setSub", (PyCFunction)Phasor_setSub, METH_O, "Sets oscillator inverse add factor."},
-{"setDiv", (PyCFunction)Phasor_setDiv, METH_O, "Sets inverse mul factor."},
-{NULL} /* Sentinel */
+static PyMethodDef OscTrig_methods[] = {
+ {"getTable", (PyCFunction)OscTrig_getTable, METH_NOARGS, "Returns waveform table object."},
+ {"getServer", (PyCFunction)OscTrig_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)OscTrig_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)OscTrig_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)OscTrig_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)OscTrig_stop, METH_NOARGS, "Stops computing."},
+ {"setTable", (PyCFunction)OscTrig_setTable, METH_O, "Sets oscillator table."},
+ {"setTrig", (PyCFunction)OscTrig_setTrig, METH_O, "Sets the reset trigger signal."},
+ {"setFreq", (PyCFunction)OscTrig_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
+ {"setPhase", (PyCFunction)OscTrig_setPhase, METH_O, "Sets oscillator phase."},
+ {"setInterp", (PyCFunction)OscTrig_setInterp, METH_O, "Sets oscillator interpolation mode."},
+ {"reset", (PyCFunction)OscTrig_reset, METH_NOARGS, "Resets pointer position to 0."},
+ {"setMul", (PyCFunction)OscTrig_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)OscTrig_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)OscTrig_setSub, METH_O, "Sets oscillator inverse add factor."},
+ {"setDiv", (PyCFunction)OscTrig_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
};
-static PyNumberMethods Phasor_as_number = {
-(binaryfunc)Phasor_add, /*nb_add*/
-(binaryfunc)Phasor_sub, /*nb_subtract*/
-(binaryfunc)Phasor_multiply, /*nb_multiply*/
-(binaryfunc)Phasor_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)Phasor_inplace_add, /*inplace_add*/
-(binaryfunc)Phasor_inplace_sub, /*inplace_subtract*/
-(binaryfunc)Phasor_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Phasor_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 */
+static PyNumberMethods OscTrig_as_number = {
+ (binaryfunc)OscTrig_add, /*nb_add*/
+ (binaryfunc)OscTrig_sub, /*nb_subtract*/
+ (binaryfunc)OscTrig_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*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*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)OscTrig_inplace_add, /*inplace_add*/
+ (binaryfunc)OscTrig_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)OscTrig_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+ (binaryfunc)OscTrig_div, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ (binaryfunc)OscTrig_inplace_div, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
};
-PyTypeObject PhasorType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
-"_pyo.Phasor_base", /*tp_name*/
-sizeof(Phasor), /*tp_basicsize*/
-0, /*tp_itemsize*/
-(destructor)Phasor_dealloc, /*tp_dealloc*/
-0, /*tp_print*/
-0, /*tp_getattr*/
-0, /*tp_setattr*/
-0, /*tp_compare*/
-0, /*tp_repr*/
-&Phasor_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*/
-"Phasor objects. Phase incrementor from 0 to 1.", /* tp_doc */
-(traverseproc)Phasor_traverse, /* tp_traverse */
-(inquiry)Phasor_clear, /* tp_clear */
-0, /* tp_richcompare */
-0, /* tp_weaklistoffset */
-0, /* tp_iter */
-0, /* tp_iternext */
-Phasor_methods, /* tp_methods */
-Phasor_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 */
-Phasor_new, /* tp_new */
+PyTypeObject OscTrigType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.OscTrig_base", /*tp_name*/
+ sizeof(OscTrig), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)OscTrig_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
+ 0, /*tp_repr*/
+ &OscTrig_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*/
+ "OscTrig objects. Generates an oscillatory waveform with sample accurate reset signal.", /* tp_doc */
+ (traverseproc)OscTrig_traverse, /* tp_traverse */
+ (inquiry)OscTrig_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ OscTrig_methods, /* tp_methods */
+ OscTrig_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 */
+ OscTrig_new, /* tp_new */
};
/**************/
-/* Pointer object */
+/* Phasor object */
/**************/
typedef struct {
pyo_audio_HEAD
- PyObject *table;
- PyObject *index;
- Stream *index_stream;
- int modebuffer[2];
-} Pointer;
+ PyObject *freq;
+ Stream *freq_stream;
+ PyObject *phase;
+ Stream *phase_stream;
+ int modebuffer[4];
+ double pointerPos;
+} Phasor;
static void
-Pointer_readframes_a(Pointer *self) {
- MYFLT fpart;
- double ph;
- int i, ipart;
- MYFLT *tablelist = TableStream_getData(self->table);
- int size = TableStream_getSize(self->table);
+Phasor_readframes_ii(Phasor *self) {
+ MYFLT fr, ph;
+ double inc, pos;
+ int i;
- MYFLT *pha = Stream_getData((Stream *)self->index_stream);
+ fr = PyFloat_AS_DOUBLE(self->freq);
+ ph = _clip(PyFloat_AS_DOUBLE(self->phase));
+ inc = fr / self->sr;
for (i=0; i<self->bufsize; i++) {
- ph = Osc_clip(pha[i] * size, size);
- ipart = (int)ph;
- fpart = ph - ipart;
- self->data[i] = tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * fpart;
+ 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;
+ else if (self->pointerPos >= 1)
+ self->pointerPos -= 1.0;
}
}
-static void Pointer_postprocessing_ii(Pointer *self) { POST_PROCESSING_II };
-static void Pointer_postprocessing_ai(Pointer *self) { POST_PROCESSING_AI };
-static void Pointer_postprocessing_ia(Pointer *self) { POST_PROCESSING_IA };
-static void Pointer_postprocessing_aa(Pointer *self) { POST_PROCESSING_AA };
-static void Pointer_postprocessing_ireva(Pointer *self) { POST_PROCESSING_IREVA };
-static void Pointer_postprocessing_areva(Pointer *self) { POST_PROCESSING_AREVA };
-static void Pointer_postprocessing_revai(Pointer *self) { POST_PROCESSING_REVAI };
-static void Pointer_postprocessing_revaa(Pointer *self) { POST_PROCESSING_REVAA };
-static void Pointer_postprocessing_revareva(Pointer *self) { POST_PROCESSING_REVAREVA };
-
static void
-Pointer_setProcMode(Pointer *self)
-{
- int muladdmode;
- muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+Phasor_readframes_ai(Phasor *self) {
+ MYFLT ph, oneOnSr;
+ double inc, pos;
+ int i;
- self->proc_func_ptr = Pointer_readframes_a;
+ MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
+ ph = _clip(PyFloat_AS_DOUBLE(self->phase));
- switch (muladdmode) {
- case 0:
- self->muladd_func_ptr = Pointer_postprocessing_ii;
- break;
- case 1:
- self->muladd_func_ptr = Pointer_postprocessing_ai;
- break;
- case 2:
- self->muladd_func_ptr = Pointer_postprocessing_revai;
- break;
- case 10:
- self->muladd_func_ptr = Pointer_postprocessing_ia;
- break;
- case 11:
- self->muladd_func_ptr = Pointer_postprocessing_aa;
- break;
- case 12:
- self->muladd_func_ptr = Pointer_postprocessing_revaa;
- break;
- case 20:
- self->muladd_func_ptr = Pointer_postprocessing_ireva;
- break;
- case 21:
- self->muladd_func_ptr = Pointer_postprocessing_areva;
- break;
- case 22:
- self->muladd_func_ptr = Pointer_postprocessing_revareva;
- break;
+ 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)
+ self->pointerPos += 1.0;
+ else if (self->pointerPos >= 1)
+ self->pointerPos -= 1.0;
}
}
static void
-Pointer_compute_next_data_frame(Pointer *self)
-{
- (*self->proc_func_ptr)(self);
- (*self->muladd_func_ptr)(self);
-}
+Phasor_readframes_ia(Phasor *self) {
+ MYFLT fr, pha;
+ double inc, pos;
+ int i;
-static int
-Pointer_traverse(Pointer *self, visitproc visit, void *arg)
-{
- pyo_VISIT
- Py_VISIT(self->table);
- Py_VISIT(self->index);
- Py_VISIT(self->index_stream);
- return 0;
-}
+ fr = PyFloat_AS_DOUBLE(self->freq);
+ MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
-static int
-Pointer_clear(Pointer *self)
-{
- pyo_CLEAR
- Py_CLEAR(self->table);
- Py_CLEAR(self->index);
- Py_CLEAR(self->index_stream);
- return 0;
-}
+ inc = fr / self->sr;
-static void
-Pointer_dealloc(Pointer* self)
-{
- pyo_DEALLOC
- Pointer_clear(self);
- self->ob_type->tp_free((PyObject*)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;
+
+ self->pointerPos += inc;
+ if (self->pointerPos < 0)
+ self->pointerPos += 1.0;
+ else if (self->pointerPos >= 1)
+ self->pointerPos -= 1.0;
+ }
+}
+
+static void
+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);
+
+ oneOnSr = 1.0 / self->sr;
+
+ 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)
+ self->pointerPos += 1.0;
+ else if (self->pointerPos >= 1)
+ self->pointerPos -= 1.0;
+ }
+}
+
+static void Phasor_postprocessing_ii(Phasor *self) { POST_PROCESSING_II };
+static void Phasor_postprocessing_ai(Phasor *self) { POST_PROCESSING_AI };
+static void Phasor_postprocessing_ia(Phasor *self) { POST_PROCESSING_IA };
+static void Phasor_postprocessing_aa(Phasor *self) { POST_PROCESSING_AA };
+static void Phasor_postprocessing_ireva(Phasor *self) { POST_PROCESSING_IREVA };
+static void Phasor_postprocessing_areva(Phasor *self) { POST_PROCESSING_AREVA };
+static void Phasor_postprocessing_revai(Phasor *self) { POST_PROCESSING_REVAI };
+static void Phasor_postprocessing_revaa(Phasor *self) { POST_PROCESSING_REVAA };
+static void Phasor_postprocessing_revareva(Phasor *self) { POST_PROCESSING_REVAREVA };
+
+static void
+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:
+ self->proc_func_ptr = Phasor_readframes_ii;
+ break;
+ case 1:
+ self->proc_func_ptr = Phasor_readframes_ai;
+ break;
+ case 10:
+ self->proc_func_ptr = Phasor_readframes_ia;
+ break;
+ case 11:
+ self->proc_func_ptr = Phasor_readframes_aa;
+ break;
+ }
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = Phasor_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = Phasor_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = Phasor_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = Phasor_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = Phasor_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = Phasor_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = Phasor_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = Phasor_postprocessing_areva;
+ break;
+ 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->muladd_func_ptr)(self);
+}
+
+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);
+ return 0;
+}
+
+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);
+ return 0;
+}
+
+static void
+Phasor_dealloc(Phasor* self)
+{
+ pyo_DEALLOC
+ Phasor_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
static PyObject *
-Pointer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+Phasor_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *tabletmp, *indextmp, *multmp=NULL, *addtmp=NULL;
- Pointer *self;
- self = (Pointer *)type->tp_alloc(type, 0);
+ 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;
self->modebuffer[1] = 0;
+ self->modebuffer[2] = 0;
+ self->modebuffer[3] = 0;
+ self->pointerPos = 0.;
INIT_OBJECT_COMMON
- Stream_setFunctionPtr(self->stream, Pointer_compute_next_data_frame);
- self->mode_func_ptr = Pointer_setProcMode;
+ Stream_setFunctionPtr(self->stream, Phasor_compute_next_data_frame);
+ self->mode_func_ptr = Phasor_setProcMode;
- static char *kwlist[] = {"table", "index", "mul", "add", NULL};
+ static char *kwlist[] = {"freq", "phase", "mul", "add", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, &tabletmp, &indextmp, &multmp, &addtmp))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &freqtmp, &phasetmp, &multmp, &addtmp))
Py_RETURN_NONE;
- if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PyErr_SetString(PyExc_TypeError, "\"table\" argument of Pointer must be a PyoTableObject.\n");
- Py_RETURN_NONE;
+ if (freqtmp) {
+ PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
}
- Py_XDECREF(self->table);
- self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
- if (indextmp) {
- PyObject_CallMethod((PyObject *)self, "setIndex", "O", indextmp);
+ if (phasetmp) {
+ PyObject_CallMethod((PyObject *)self, "setPhase", "O", phasetmp);
}
- PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
+ if (multmp) {
+ PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
+ }
if (addtmp) {
PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
@@ -3158,105 +3337,127 @@ Pointer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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_play(Pointer *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * Pointer_out(Pointer *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * Pointer_stop(Pointer *self) { STOP };
+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 * Pointer_multiply(Pointer *self, PyObject *arg) { MULTIPLY };
-static PyObject * Pointer_inplace_multiply(Pointer *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * Pointer_add(Pointer *self, PyObject *arg) { ADD };
-static PyObject * Pointer_inplace_add(Pointer *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * Pointer_sub(Pointer *self, PyObject *arg) { SUB };
-static PyObject * Pointer_inplace_sub(Pointer *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * Pointer_div(Pointer *self, PyObject *arg) { DIV };
-static PyObject * Pointer_inplace_div(Pointer *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * Phasor_play(Phasor *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Phasor_out(Phasor *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * Phasor_stop(Phasor *self) { STOP };
-static PyObject *
-Pointer_getTable(Pointer* self)
-{
- Py_INCREF(self->table);
- return self->table;
-};
+static PyObject * Phasor_multiply(Phasor *self, PyObject *arg) { MULTIPLY };
+static PyObject * Phasor_inplace_multiply(Phasor *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Phasor_add(Phasor *self, PyObject *arg) { ADD };
+static PyObject * Phasor_inplace_add(Phasor *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Phasor_sub(Phasor *self, PyObject *arg) { SUB };
+static PyObject * Phasor_inplace_sub(Phasor *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Phasor_div(Phasor *self, PyObject *arg) { DIV };
+static PyObject * Phasor_inplace_div(Phasor *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-Pointer_setTable(Pointer *self, PyObject *arg)
+Phasor_setFreq(Phasor *self, PyObject *arg)
{
- PyObject *tmp;
+ PyObject *tmp, *streamtmp;
ASSERT_ARG_NOT_NULL
+ int isNumber = PyNumber_Check(arg);
+
tmp = arg;
- Py_DECREF(self->table);
- self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
+ Py_INCREF(tmp);
+ Py_DECREF(self->freq);
+ if (isNumber == 1) {
+ self->freq = PyNumber_Float(tmp);
+ self->modebuffer[2] = 0;
+ }
+ else {
+ self->freq = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->freq, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->freq_stream);
+ self->freq_stream = (Stream *)streamtmp;
+ self->modebuffer[2] = 1;
+ }
+
+ (*self->mode_func_ptr)(self);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
-Pointer_setIndex(Pointer *self, PyObject *arg)
+Phasor_setPhase(Phasor *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
ASSERT_ARG_NOT_NULL
- 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;
- }
+ int isNumber = PyNumber_Check(arg);
+ tmp = arg;
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_DECREF(self->phase);
+ if (isNumber == 1) {
+ self->phase = PyNumber_Float(tmp);
+ self->modebuffer[3] = 0;
+ }
+ else {
+ self->phase = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->phase, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->phase_stream);
+ self->phase_stream = (Stream *)streamtmp;
+ self->modebuffer[3] = 1;
+ }
+
+ (*self->mode_func_ptr)(self);
Py_INCREF(Py_None);
return Py_None;
}
-static PyMemberDef Pointer_members[] = {
-{"server", T_OBJECT_EX, offsetof(Pointer, server), 0, "Pyo server."},
-{"stream", T_OBJECT_EX, offsetof(Pointer, stream), 0, "Stream object."},
-{"table", T_OBJECT_EX, offsetof(Pointer, table), 0, "Waveform table."},
-{"index", T_OBJECT_EX, offsetof(Pointer, index), 0, "Reader index."},
-{"mul", T_OBJECT_EX, offsetof(Pointer, mul), 0, "Mul factor."},
-{"add", T_OBJECT_EX, offsetof(Pointer, add), 0, "Add factor."},
+static PyObject *
+Phasor_reset(Phasor *self)
+{
+ self->pointerPos = 0.0;
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef Phasor_members[] = {
+{"server", T_OBJECT_EX, offsetof(Phasor, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(Phasor, stream), 0, "Stream object."},
+{"freq", T_OBJECT_EX, offsetof(Phasor, freq), 0, "Frequency in cycle per second."},
+{"phase", T_OBJECT_EX, offsetof(Phasor, phase), 0, "Phasorillator phase."},
+{"mul", T_OBJECT_EX, offsetof(Phasor, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(Phasor, add), 0, "Add factor."},
{NULL} /* Sentinel */
};
-static PyMethodDef Pointer_methods[] = {
-{"getTable", (PyCFunction)Pointer_getTable, METH_NOARGS, "Returns waveform table object."},
-{"getServer", (PyCFunction)Pointer_getServer, METH_NOARGS, "Returns server object."},
-{"_getStream", (PyCFunction)Pointer_getStream, METH_NOARGS, "Returns stream object."},
-{"play", (PyCFunction)Pointer_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
-{"out", (PyCFunction)Pointer_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
-{"stop", (PyCFunction)Pointer_stop, METH_NOARGS, "Stops computing."},
-{"setTable", (PyCFunction)Pointer_setTable, METH_O, "Sets oscillator table."},
-{"setIndex", (PyCFunction)Pointer_setIndex, METH_O, "Sets reader index."},
-{"setMul", (PyCFunction)Pointer_setMul, METH_O, "Sets oscillator mul factor."},
-{"setAdd", (PyCFunction)Pointer_setAdd, METH_O, "Sets oscillator add factor."},
-{"setSub", (PyCFunction)Pointer_setSub, METH_O, "Sets oscillator inverse add factor."},
-{"setDiv", (PyCFunction)Pointer_setDiv, METH_O, "Sets inverse mul factor."},
+static PyMethodDef Phasor_methods[] = {
+{"getServer", (PyCFunction)Phasor_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)Phasor_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)Phasor_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"out", (PyCFunction)Phasor_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"stop", (PyCFunction)Phasor_stop, METH_NOARGS, "Stops computing."},
+{"setFreq", (PyCFunction)Phasor_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
+{"setPhase", (PyCFunction)Phasor_setPhase, METH_O, "Sets oscillator phase."},
+{"reset", (PyCFunction)Phasor_reset, METH_NOARGS, "Resets pointer position to 0."},
+{"setMul", (PyCFunction)Phasor_setMul, METH_O, "Sets oscillator mul factor."},
+{"setAdd", (PyCFunction)Phasor_setAdd, METH_O, "Sets oscillator add factor."},
+{"setSub", (PyCFunction)Phasor_setSub, METH_O, "Sets oscillator inverse add factor."},
+{"setDiv", (PyCFunction)Phasor_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
-static PyNumberMethods Pointer_as_number = {
-(binaryfunc)Pointer_add, /*nb_add*/
-(binaryfunc)Pointer_sub, /*nb_subtract*/
-(binaryfunc)Pointer_multiply, /*nb_multiply*/
-(binaryfunc)Pointer_div, /*nb_divide*/
+static PyNumberMethods Phasor_as_number = {
+(binaryfunc)Phasor_add, /*nb_add*/
+(binaryfunc)Phasor_sub, /*nb_subtract*/
+(binaryfunc)Phasor_multiply, /*nb_multiply*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3270,16 +3471,16 @@ static PyNumberMethods Pointer_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
-(binaryfunc)Pointer_inplace_add, /*inplace_add*/
-(binaryfunc)Pointer_inplace_sub, /*inplace_subtract*/
-(binaryfunc)Pointer_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Pointer_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+(binaryfunc)Phasor_inplace_add, /*inplace_add*/
+(binaryfunc)Phasor_inplace_sub, /*inplace_subtract*/
+(binaryfunc)Phasor_inplace_multiply, /*inplace_multiply*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3288,25 +3489,24 @@ static PyNumberMethods Pointer_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Phasor_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Phasor_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
-PyTypeObject PointerType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
-"_pyo.Pointer_base", /*tp_name*/
-sizeof(Pointer), /*tp_basicsize*/
+PyTypeObject PhasorType = {
+PyVarObject_HEAD_INIT(NULL, 0)
+"_pyo.Phasor_base", /*tp_name*/
+sizeof(Phasor), /*tp_basicsize*/
0, /*tp_itemsize*/
-(destructor)Pointer_dealloc, /*tp_dealloc*/
+(destructor)Phasor_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
-&Pointer_as_number, /*tp_as_number*/
+&Phasor_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -3316,15 +3516,15 @@ sizeof(Pointer), /*tp_basicsize*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
-"Pointer objects. Read a waveform table with a pointer index.", /* tp_doc */
-(traverseproc)Pointer_traverse, /* tp_traverse */
-(inquiry)Pointer_clear, /* tp_clear */
+"Phasor objects. Phase incrementor from 0 to 1.", /* tp_doc */
+(traverseproc)Phasor_traverse, /* tp_traverse */
+(inquiry)Phasor_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
-Pointer_methods, /* tp_methods */
-Pointer_members, /* tp_members */
+Phasor_methods, /* tp_methods */
+Phasor_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -3333,11 +3533,11 @@ Pointer_members, /* tp_members */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
-Pointer_new, /* tp_new */
+Phasor_new, /* tp_new */
};
/**************/
-/* Pointer2 object */
+/* Pointer object */
/**************/
typedef struct {
pyo_audio_HEAD
@@ -3345,113 +3545,84 @@ typedef struct {
PyObject *index;
Stream *index_stream;
int modebuffer[2];
- int interp; /* 0 = default to 2, 1 = nointerp, 2 = linear, 3 = cos, 4 = cubic */
- int autosmooth; /* 0 = off, > 0 = on */
- MYFLT y1;
- MYFLT y2;
- MYFLT c;
- MYFLT lastPh;
- MYFLT (*interp_func_ptr)(MYFLT *, int, MYFLT, int);
-} Pointer2;
+} Pointer;
static void
-Pointer2_readframes_a(Pointer2 *self) {
- MYFLT fpart, phdiff, b, fr;
+Pointer_readframes_a(Pointer *self) {
+ MYFLT fpart;
double ph;
int i, ipart;
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);
- ipart = (int)ph;
- fpart = ph - ipart;
- self->y1 = self->y2 = self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
- }
- }
- else {
- for (i=0; i<self->bufsize; i++) {
- ph = Osc_clip(pha[i] * size, size);
- ipart = (int)ph;
- fpart = ph - ipart;
- self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
- phdiff = MYFABS(ph - self->lastPh);
- self->lastPh = ph;
- if (phdiff < 1) {
- fr = phdiff * tableSr * 0.45;
- b = 2.0 - MYCOS(TWOPI * fr / self->sr);
- self->c = (b - MYSQRT(b * b - 1.0));
- self->y1 = self->data[i] + (self->y1 - self->data[i]) * self->c;
- self->data[i] = self->y2 = self->y1 + (self->y2 - self->y1) * self->c;
- }
- else
- self->y1 = self->y2 = self->data[i];
- }
+ for (i=0; i<self->bufsize; i++) {
+ ph = Osc_clip(pha[i] * size, size);
+ ipart = (int)ph;
+ fpart = ph - ipart;
+ self->data[i] = tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * fpart;
}
}
-static void Pointer2_postprocessing_ii(Pointer2 *self) { POST_PROCESSING_II };
-static void Pointer2_postprocessing_ai(Pointer2 *self) { POST_PROCESSING_AI };
-static void Pointer2_postprocessing_ia(Pointer2 *self) { POST_PROCESSING_IA };
-static void Pointer2_postprocessing_aa(Pointer2 *self) { POST_PROCESSING_AA };
-static void Pointer2_postprocessing_ireva(Pointer2 *self) { POST_PROCESSING_IREVA };
-static void Pointer2_postprocessing_areva(Pointer2 *self) { POST_PROCESSING_AREVA };
-static void Pointer2_postprocessing_revai(Pointer2 *self) { POST_PROCESSING_REVAI };
-static void Pointer2_postprocessing_revaa(Pointer2 *self) { POST_PROCESSING_REVAA };
-static void Pointer2_postprocessing_revareva(Pointer2 *self) { POST_PROCESSING_REVAREVA };
+static void Pointer_postprocessing_ii(Pointer *self) { POST_PROCESSING_II };
+static void Pointer_postprocessing_ai(Pointer *self) { POST_PROCESSING_AI };
+static void Pointer_postprocessing_ia(Pointer *self) { POST_PROCESSING_IA };
+static void Pointer_postprocessing_aa(Pointer *self) { POST_PROCESSING_AA };
+static void Pointer_postprocessing_ireva(Pointer *self) { POST_PROCESSING_IREVA };
+static void Pointer_postprocessing_areva(Pointer *self) { POST_PROCESSING_AREVA };
+static void Pointer_postprocessing_revai(Pointer *self) { POST_PROCESSING_REVAI };
+static void Pointer_postprocessing_revaa(Pointer *self) { POST_PROCESSING_REVAA };
+static void Pointer_postprocessing_revareva(Pointer *self) { POST_PROCESSING_REVAREVA };
static void
-Pointer2_setProcMode(Pointer2 *self)
+Pointer_setProcMode(Pointer *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
- self->proc_func_ptr = Pointer2_readframes_a;
+ self->proc_func_ptr = Pointer_readframes_a;
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = Pointer2_postprocessing_ii;
+ self->muladd_func_ptr = Pointer_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = Pointer2_postprocessing_ai;
+ self->muladd_func_ptr = Pointer_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = Pointer2_postprocessing_revai;
+ self->muladd_func_ptr = Pointer_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = Pointer2_postprocessing_ia;
+ self->muladd_func_ptr = Pointer_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = Pointer2_postprocessing_aa;
+ self->muladd_func_ptr = Pointer_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = Pointer2_postprocessing_revaa;
+ self->muladd_func_ptr = Pointer_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = Pointer2_postprocessing_ireva;
+ self->muladd_func_ptr = Pointer_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = Pointer2_postprocessing_areva;
+ self->muladd_func_ptr = Pointer_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = Pointer2_postprocessing_revareva;
+ self->muladd_func_ptr = Pointer_postprocessing_revareva;
break;
}
}
static void
-Pointer2_compute_next_data_frame(Pointer2 *self)
+Pointer_compute_next_data_frame(Pointer *self)
{
(*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
static int
-Pointer2_traverse(Pointer2 *self, visitproc visit, void *arg)
+Pointer_traverse(Pointer *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
@@ -3461,7 +3632,7 @@ Pointer2_traverse(Pointer2 *self, visitproc visit, void *arg)
}
static int
-Pointer2_clear(Pointer2 *self)
+Pointer_clear(Pointer *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
@@ -3471,38 +3642,35 @@ Pointer2_clear(Pointer2 *self)
}
static void
-Pointer2_dealloc(Pointer2* self)
+Pointer_dealloc(Pointer* self)
{
pyo_DEALLOC
- Pointer2_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Pointer_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-Pointer2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+Pointer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
PyObject *tabletmp, *indextmp, *multmp=NULL, *addtmp=NULL;
- Pointer2 *self;
- self = (Pointer2 *)type->tp_alloc(type, 0);
+ Pointer *self;
+ self = (Pointer *)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;
+ Stream_setFunctionPtr(self->stream, Pointer_compute_next_data_frame);
+ self->mode_func_ptr = Pointer_setProcMode;
- static char *kwlist[] = {"table", "index", "interp", "autosmooth", "mul", "add", NULL};
+ static char *kwlist[] = {"table", "index", "mul", "add", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|iiOO", kwlist, &tabletmp, &indextmp, &self->interp, &self->autosmooth, &multmp, &addtmp))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, &tabletmp, &indextmp, &multmp, &addtmp))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PyErr_SetString(PyExc_TypeError, "\"table\" argument of Pointer2 must be a PyoTableObject.\n");
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Pointer must be a PyoTableObject.\n");
Py_RETURN_NONE;
}
Py_XDECREF(self->table);
@@ -3522,40 +3690,38 @@ Pointer2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
(*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 * 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 * Pointer2_play(Pointer2 *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * Pointer2_out(Pointer2 *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * Pointer2_stop(Pointer2 *self) { STOP };
+static PyObject * Pointer_play(Pointer *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Pointer_out(Pointer *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * Pointer_stop(Pointer *self) { STOP };
-static PyObject * Pointer2_multiply(Pointer2 *self, PyObject *arg) { MULTIPLY };
-static PyObject * Pointer2_inplace_multiply(Pointer2 *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * Pointer2_add(Pointer2 *self, PyObject *arg) { ADD };
-static PyObject * Pointer2_inplace_add(Pointer2 *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * Pointer2_sub(Pointer2 *self, PyObject *arg) { SUB };
-static PyObject * Pointer2_inplace_sub(Pointer2 *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * Pointer2_div(Pointer2 *self, PyObject *arg) { DIV };
-static PyObject * Pointer2_inplace_div(Pointer2 *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * Pointer_multiply(Pointer *self, PyObject *arg) { MULTIPLY };
+static PyObject * Pointer_inplace_multiply(Pointer *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Pointer_add(Pointer *self, PyObject *arg) { ADD };
+static PyObject * Pointer_inplace_add(Pointer *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Pointer_sub(Pointer *self, PyObject *arg) { SUB };
+static PyObject * Pointer_inplace_sub(Pointer *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Pointer_div(Pointer *self, PyObject *arg) { DIV };
+static PyObject * Pointer_inplace_div(Pointer *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-Pointer2_getTable(Pointer2* self)
+Pointer_getTable(Pointer* self)
{
Py_INCREF(self->table);
return self->table;
};
static PyObject *
-Pointer2_setTable(Pointer2 *self, PyObject *arg)
+Pointer_setTable(Pointer *self, PyObject *arg)
{
PyObject *tmp;
@@ -3570,7 +3736,7 @@ Pointer2_setTable(Pointer2 *self, PyObject *arg)
}
static PyObject *
-Pointer2_setIndex(Pointer2 *self, PyObject *arg)
+Pointer_setIndex(Pointer *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -3578,7 +3744,7 @@ Pointer2_setIndex(Pointer2 *self, PyObject *arg)
tmp = arg;
if (PyObject_HasAttrString((PyObject *)tmp, "server") == 0) {
- PyErr_SetString(PyExc_TypeError, "\"index\" argument of Pointer2 must be a PyoObject.\n");
+ PyErr_SetString(PyExc_TypeError, "\"index\" argument of Pointer must be a PyoObject.\n");
Py_RETURN_NONE;
}
@@ -3595,71 +3761,37 @@ Pointer2_setIndex(Pointer2 *self, PyObject *arg)
return Py_None;
}
-static PyObject *
-Pointer2_setInterp(Pointer2 *self, PyObject *arg)
-{
- ASSERT_ARG_NOT_NULL
-
- 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 *
-Pointer2_setAutoSmooth(Pointer2 *self, PyObject *arg)
-{
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
-
- if (isNumber == 1) {
- self->autosmooth = PyInt_AsLong(PyNumber_Int(arg));
- }
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
-static PyMemberDef Pointer2_members[] = {
-{"server", T_OBJECT_EX, offsetof(Pointer2, server), 0, "Pyo server."},
-{"stream", T_OBJECT_EX, offsetof(Pointer2, stream), 0, "Stream object."},
-{"table", T_OBJECT_EX, offsetof(Pointer2, table), 0, "Waveform table."},
-{"index", T_OBJECT_EX, offsetof(Pointer2, index), 0, "Reader index."},
-{"mul", T_OBJECT_EX, offsetof(Pointer2, mul), 0, "Mul factor."},
-{"add", T_OBJECT_EX, offsetof(Pointer2, add), 0, "Add factor."},
+static PyMemberDef Pointer_members[] = {
+{"server", T_OBJECT_EX, offsetof(Pointer, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(Pointer, stream), 0, "Stream object."},
+{"table", T_OBJECT_EX, offsetof(Pointer, table), 0, "Waveform table."},
+{"index", T_OBJECT_EX, offsetof(Pointer, index), 0, "Reader index."},
+{"mul", T_OBJECT_EX, offsetof(Pointer, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(Pointer, add), 0, "Add factor."},
{NULL} /* Sentinel */
};
-static PyMethodDef Pointer2_methods[] = {
-{"getTable", (PyCFunction)Pointer2_getTable, METH_NOARGS, "Returns waveform table object."},
-{"getServer", (PyCFunction)Pointer2_getServer, METH_NOARGS, "Returns server object."},
-{"_getStream", (PyCFunction)Pointer2_getStream, METH_NOARGS, "Returns stream object."},
-{"play", (PyCFunction)Pointer2_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
-{"out", (PyCFunction)Pointer2_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
-{"stop", (PyCFunction)Pointer2_stop, METH_NOARGS, "Stops computing."},
-{"setTable", (PyCFunction)Pointer2_setTable, METH_O, "Sets oscillator table."},
-{"setIndex", (PyCFunction)Pointer2_setIndex, METH_O, "Sets reader index."},
-{"setInterp", (PyCFunction)Pointer2_setInterp, METH_O, "Sets oscillator interpolation mode."},
-{"setAutoSmooth", (PyCFunction)Pointer2_setAutoSmooth, METH_O, "Activates auto smoother filter."},
-{"setMul", (PyCFunction)Pointer2_setMul, METH_O, "Sets oscillator mul factor."},
-{"setAdd", (PyCFunction)Pointer2_setAdd, METH_O, "Sets oscillator add factor."},
-{"setSub", (PyCFunction)Pointer2_setSub, METH_O, "Sets oscillator inverse add factor."},
-{"setDiv", (PyCFunction)Pointer2_setDiv, METH_O, "Sets inverse mul factor."},
+static PyMethodDef Pointer_methods[] = {
+{"getTable", (PyCFunction)Pointer_getTable, METH_NOARGS, "Returns waveform table object."},
+{"getServer", (PyCFunction)Pointer_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)Pointer_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)Pointer_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"out", (PyCFunction)Pointer_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"stop", (PyCFunction)Pointer_stop, METH_NOARGS, "Stops computing."},
+{"setTable", (PyCFunction)Pointer_setTable, METH_O, "Sets oscillator table."},
+{"setIndex", (PyCFunction)Pointer_setIndex, METH_O, "Sets reader index."},
+{"setMul", (PyCFunction)Pointer_setMul, METH_O, "Sets oscillator mul factor."},
+{"setAdd", (PyCFunction)Pointer_setAdd, METH_O, "Sets oscillator add factor."},
+{"setSub", (PyCFunction)Pointer_setSub, METH_O, "Sets oscillator inverse add factor."},
+{"setDiv", (PyCFunction)Pointer_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
-static PyNumberMethods Pointer2_as_number = {
-(binaryfunc)Pointer2_add, /*nb_add*/
-(binaryfunc)Pointer2_sub, /*nb_subtract*/
-(binaryfunc)Pointer2_multiply, /*nb_multiply*/
-(binaryfunc)Pointer2_div, /*nb_divide*/
+static PyNumberMethods Pointer_as_number = {
+(binaryfunc)Pointer_add, /*nb_add*/
+(binaryfunc)Pointer_sub, /*nb_subtract*/
+(binaryfunc)Pointer_multiply, /*nb_multiply*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3673,16 +3805,16 @@ static PyNumberMethods Pointer2_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
-(binaryfunc)Pointer2_inplace_add, /*inplace_add*/
-(binaryfunc)Pointer2_inplace_sub, /*inplace_subtract*/
-(binaryfunc)Pointer2_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Pointer2_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+(binaryfunc)Pointer_inplace_add, /*inplace_add*/
+(binaryfunc)Pointer_inplace_sub, /*inplace_subtract*/
+(binaryfunc)Pointer_inplace_multiply, /*inplace_multiply*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3691,25 +3823,24 @@ static PyNumberMethods Pointer2_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Pointer_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Pointer_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
-PyTypeObject Pointer2Type = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
-"_pyo.Pointer2_base", /*tp_name*/
-sizeof(Pointer2), /*tp_basicsize*/
+PyTypeObject PointerType = {
+PyVarObject_HEAD_INIT(NULL, 0)
+"_pyo.Pointer_base", /*tp_name*/
+sizeof(Pointer), /*tp_basicsize*/
0, /*tp_itemsize*/
-(destructor)Pointer2_dealloc, /*tp_dealloc*/
+(destructor)Pointer_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
-&Pointer2_as_number, /*tp_as_number*/
+&Pointer_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -3719,15 +3850,15 @@ sizeof(Pointer2), /*tp_basicsize*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
-"Pointer2 objects. High quality table reader with a pointer index.", /* tp_doc */
-(traverseproc)Pointer2_traverse, /* tp_traverse */
-(inquiry)Pointer2_clear, /* tp_clear */
+"Pointer objects. Read a waveform table with a pointer index.", /* tp_doc */
+(traverseproc)Pointer_traverse, /* tp_traverse */
+(inquiry)Pointer_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
-Pointer2_methods, /* tp_methods */
-Pointer2_members, /* tp_members */
+Pointer_methods, /* tp_methods */
+Pointer_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -3736,11 +3867,11 @@ Pointer2_members, /* tp_members */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
-Pointer2_new, /* tp_new */
+Pointer_new, /* tp_new */
};
/**************/
-/* TableIndex object */
+/* Pointer2 object */
/**************/
typedef struct {
pyo_audio_HEAD
@@ -3748,85 +3879,113 @@ typedef struct {
PyObject *index;
Stream *index_stream;
int modebuffer[2];
-} TableIndex;
+ int interp; /* 0 = default to 2, 1 = nointerp, 2 = linear, 3 = cos, 4 = cubic */
+ int autosmooth; /* 0 = off, > 0 = on */
+ MYFLT y1;
+ MYFLT y2;
+ MYFLT c;
+ MYFLT lastPh;
+ MYFLT (*interp_func_ptr)(MYFLT *, int, MYFLT, int);
+} Pointer2;
static void
-TableIndex_readframes_a(TableIndex *self) {
- int i, ind;
+Pointer2_readframes_a(Pointer2 *self) {
+ MYFLT fpart, phdiff, b, fr;
+ double ph;
+ int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
+ double tableSr = TableStream_getSamplingRate(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;
+ MYFLT *pha = Stream_getData((Stream *)self->index_stream);
- self->data[i] = tablelist[ind];
+ if (!self->autosmooth) {
+ for (i=0; i<self->bufsize; i++) {
+ 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);
+ }
+ }
+ else {
+ for (i=0; i<self->bufsize; i++) {
+ ph = Osc_clip(pha[i] * size, size);
+ ipart = (int)ph;
+ fpart = ph - ipart;
+ self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ phdiff = MYFABS(ph - self->lastPh);
+ self->lastPh = ph;
+ if (phdiff < 1) {
+ fr = phdiff * tableSr * 0.45;
+ b = 2.0 - MYCOS(TWOPI * fr / self->sr);
+ self->c = (b - MYSQRT(b * b - 1.0));
+ self->y1 = self->data[i] + (self->y1 - self->data[i]) * self->c;
+ self->data[i] = self->y2 = self->y1 + (self->y2 - self->y1) * self->c;
+ }
+ else
+ self->y1 = self->y2 = self->data[i];
+ }
}
}
-static void TableIndex_postprocessing_ii(TableIndex *self) { POST_PROCESSING_II };
-static void TableIndex_postprocessing_ai(TableIndex *self) { POST_PROCESSING_AI };
-static void TableIndex_postprocessing_ia(TableIndex *self) { POST_PROCESSING_IA };
-static void TableIndex_postprocessing_aa(TableIndex *self) { POST_PROCESSING_AA };
-static void TableIndex_postprocessing_ireva(TableIndex *self) { POST_PROCESSING_IREVA };
-static void TableIndex_postprocessing_areva(TableIndex *self) { POST_PROCESSING_AREVA };
-static void TableIndex_postprocessing_revai(TableIndex *self) { POST_PROCESSING_REVAI };
-static void TableIndex_postprocessing_revaa(TableIndex *self) { POST_PROCESSING_REVAA };
-static void TableIndex_postprocessing_revareva(TableIndex *self) { POST_PROCESSING_REVAREVA };
+static void Pointer2_postprocessing_ii(Pointer2 *self) { POST_PROCESSING_II };
+static void Pointer2_postprocessing_ai(Pointer2 *self) { POST_PROCESSING_AI };
+static void Pointer2_postprocessing_ia(Pointer2 *self) { POST_PROCESSING_IA };
+static void Pointer2_postprocessing_aa(Pointer2 *self) { POST_PROCESSING_AA };
+static void Pointer2_postprocessing_ireva(Pointer2 *self) { POST_PROCESSING_IREVA };
+static void Pointer2_postprocessing_areva(Pointer2 *self) { POST_PROCESSING_AREVA };
+static void Pointer2_postprocessing_revai(Pointer2 *self) { POST_PROCESSING_REVAI };
+static void Pointer2_postprocessing_revaa(Pointer2 *self) { POST_PROCESSING_REVAA };
+static void Pointer2_postprocessing_revareva(Pointer2 *self) { POST_PROCESSING_REVAREVA };
static void
-TableIndex_setProcMode(TableIndex *self)
+Pointer2_setProcMode(Pointer2 *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
- self->proc_func_ptr = TableIndex_readframes_a;
+ self->proc_func_ptr = Pointer2_readframes_a;
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = TableIndex_postprocessing_ii;
+ self->muladd_func_ptr = Pointer2_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = TableIndex_postprocessing_ai;
+ self->muladd_func_ptr = Pointer2_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = TableIndex_postprocessing_revai;
+ self->muladd_func_ptr = Pointer2_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = TableIndex_postprocessing_ia;
+ self->muladd_func_ptr = Pointer2_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = TableIndex_postprocessing_aa;
+ self->muladd_func_ptr = Pointer2_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = TableIndex_postprocessing_revaa;
+ self->muladd_func_ptr = Pointer2_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = TableIndex_postprocessing_ireva;
+ self->muladd_func_ptr = Pointer2_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = TableIndex_postprocessing_areva;
+ self->muladd_func_ptr = Pointer2_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = TableIndex_postprocessing_revareva;
+ self->muladd_func_ptr = Pointer2_postprocessing_revareva;
break;
}
}
static void
-TableIndex_compute_next_data_frame(TableIndex *self)
+Pointer2_compute_next_data_frame(Pointer2 *self)
{
(*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
static int
-TableIndex_traverse(TableIndex *self, visitproc visit, void *arg)
+Pointer2_traverse(Pointer2 *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
@@ -3836,7 +3995,7 @@ TableIndex_traverse(TableIndex *self, visitproc visit, void *arg)
}
static int
-TableIndex_clear(TableIndex *self)
+Pointer2_clear(Pointer2 *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
@@ -3846,35 +4005,38 @@ TableIndex_clear(TableIndex *self)
}
static void
-TableIndex_dealloc(TableIndex* self)
+Pointer2_dealloc(Pointer2* self)
{
pyo_DEALLOC
- TableIndex_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Pointer2_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-TableIndex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+Pointer2_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
PyObject *tabletmp, *indextmp, *multmp=NULL, *addtmp=NULL;
- TableIndex *self;
- self = (TableIndex *)type->tp_alloc(type, 0);
+ 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, TableIndex_compute_next_data_frame);
- self->mode_func_ptr = TableIndex_setProcMode;
+ Stream_setFunctionPtr(self->stream, Pointer2_compute_next_data_frame);
+ self->mode_func_ptr = Pointer2_setProcMode;
- static char *kwlist[] = {"table", "index", "mul", "add", NULL};
+ static char *kwlist[] = {"table", "index", "interp", "autosmooth", "mul", "add", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, &tabletmp, &indextmp, &multmp, &addtmp))
+ 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 ) {
- PyErr_SetString(PyExc_TypeError, "\"table\" argument of TableIndex must be a PyoTableObject.\n");
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Pointer2 must be a PyoTableObject.\n");
Py_RETURN_NONE;
}
Py_XDECREF(self->table);
@@ -3894,38 +4056,40 @@ TableIndex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
(*self->mode_func_ptr)(self);
+ SET_INTERP_POINTER
+
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_play(TableIndex *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * TableIndex_out(TableIndex *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * TableIndex_stop(TableIndex *self) { STOP };
+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 * TableIndex_multiply(TableIndex *self, PyObject *arg) { MULTIPLY };
-static PyObject * TableIndex_inplace_multiply(TableIndex *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * TableIndex_add(TableIndex *self, PyObject *arg) { ADD };
-static PyObject * TableIndex_inplace_add(TableIndex *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * TableIndex_sub(TableIndex *self, PyObject *arg) { SUB };
-static PyObject * TableIndex_inplace_sub(TableIndex *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * TableIndex_div(TableIndex *self, PyObject *arg) { DIV };
-static PyObject * TableIndex_inplace_div(TableIndex *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * Pointer2_play(Pointer2 *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Pointer2_out(Pointer2 *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * Pointer2_stop(Pointer2 *self) { STOP };
+
+static PyObject * Pointer2_multiply(Pointer2 *self, PyObject *arg) { MULTIPLY };
+static PyObject * Pointer2_inplace_multiply(Pointer2 *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Pointer2_add(Pointer2 *self, PyObject *arg) { ADD };
+static PyObject * Pointer2_inplace_add(Pointer2 *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Pointer2_sub(Pointer2 *self, PyObject *arg) { SUB };
+static PyObject * Pointer2_inplace_sub(Pointer2 *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Pointer2_div(Pointer2 *self, PyObject *arg) { DIV };
+static PyObject * Pointer2_inplace_div(Pointer2 *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-TableIndex_getTable(TableIndex* self)
+Pointer2_getTable(Pointer2* self)
{
Py_INCREF(self->table);
return self->table;
};
static PyObject *
-TableIndex_setTable(TableIndex *self, PyObject *arg)
+Pointer2_setTable(Pointer2 *self, PyObject *arg)
{
PyObject *tmp;
@@ -3940,7 +4104,7 @@ TableIndex_setTable(TableIndex *self, PyObject *arg)
}
static PyObject *
-TableIndex_setIndex(TableIndex *self, PyObject *arg)
+Pointer2_setIndex(Pointer2 *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -3948,7 +4112,7 @@ TableIndex_setIndex(TableIndex *self, PyObject *arg)
tmp = arg;
if (PyObject_HasAttrString((PyObject *)tmp, "server") == 0) {
- PyErr_SetString(PyExc_TypeError, "\"index\" argument of TableIndex must be a PyoObject.\n");
+ PyErr_SetString(PyExc_TypeError, "\"index\" argument of Pointer2 must be a PyoObject.\n");
Py_RETURN_NONE;
}
@@ -3965,118 +4129,151 @@ TableIndex_setIndex(TableIndex *self, PyObject *arg)
return Py_None;
}
-static PyMemberDef TableIndex_members[] = {
- {"server", T_OBJECT_EX, offsetof(TableIndex, server), 0, "Pyo server."},
- {"stream", T_OBJECT_EX, offsetof(TableIndex, stream), 0, "Stream object."},
- {"table", T_OBJECT_EX, offsetof(TableIndex, table), 0, "Waveform table."},
- {"index", T_OBJECT_EX, offsetof(TableIndex, index), 0, "Reader index."},
- {"mul", T_OBJECT_EX, offsetof(TableIndex, mul), 0, "Mul factor."},
- {"add", T_OBJECT_EX, offsetof(TableIndex, add), 0, "Add factor."},
- {NULL} /* Sentinel */
+static PyObject *
+Pointer2_setInterp(Pointer2 *self, PyObject *arg)
+{
+ ASSERT_ARG_NOT_NULL
+
+ 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 *
+Pointer2_setAutoSmooth(Pointer2 *self, PyObject *arg)
+{
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ if (isNumber == 1) {
+ self->autosmooth = PyInt_AsLong(PyNumber_Int(arg));
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef Pointer2_members[] = {
+{"server", T_OBJECT_EX, offsetof(Pointer2, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(Pointer2, stream), 0, "Stream object."},
+{"table", T_OBJECT_EX, offsetof(Pointer2, table), 0, "Waveform table."},
+{"index", T_OBJECT_EX, offsetof(Pointer2, index), 0, "Reader index."},
+{"mul", T_OBJECT_EX, offsetof(Pointer2, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(Pointer2, add), 0, "Add factor."},
+{NULL} /* Sentinel */
};
-static PyMethodDef TableIndex_methods[] = {
- {"getTable", (PyCFunction)TableIndex_getTable, METH_NOARGS, "Returns waveform table object."},
- {"getServer", (PyCFunction)TableIndex_getServer, METH_NOARGS, "Returns server object."},
- {"_getStream", (PyCFunction)TableIndex_getStream, METH_NOARGS, "Returns stream object."},
- {"play", (PyCFunction)TableIndex_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
- {"out", (PyCFunction)TableIndex_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
- {"stop", (PyCFunction)TableIndex_stop, METH_NOARGS, "Stops computing."},
- {"setTable", (PyCFunction)TableIndex_setTable, METH_O, "Sets oscillator table."},
- {"setIndex", (PyCFunction)TableIndex_setIndex, METH_O, "Sets reader index."},
- {"setMul", (PyCFunction)TableIndex_setMul, METH_O, "Sets oscillator mul factor."},
- {"setAdd", (PyCFunction)TableIndex_setAdd, METH_O, "Sets oscillator add factor."},
- {"setSub", (PyCFunction)TableIndex_setSub, METH_O, "Sets oscillator inverse add factor."},
- {"setDiv", (PyCFunction)TableIndex_setDiv, METH_O, "Sets inverse mul factor."},
- {NULL} /* Sentinel */
+static PyMethodDef Pointer2_methods[] = {
+{"getTable", (PyCFunction)Pointer2_getTable, METH_NOARGS, "Returns waveform table object."},
+{"getServer", (PyCFunction)Pointer2_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)Pointer2_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)Pointer2_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"out", (PyCFunction)Pointer2_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"stop", (PyCFunction)Pointer2_stop, METH_NOARGS, "Stops computing."},
+{"setTable", (PyCFunction)Pointer2_setTable, METH_O, "Sets oscillator table."},
+{"setIndex", (PyCFunction)Pointer2_setIndex, METH_O, "Sets reader index."},
+{"setInterp", (PyCFunction)Pointer2_setInterp, METH_O, "Sets oscillator interpolation mode."},
+{"setAutoSmooth", (PyCFunction)Pointer2_setAutoSmooth, METH_O, "Activates auto smoother filter."},
+{"setMul", (PyCFunction)Pointer2_setMul, METH_O, "Sets oscillator mul factor."},
+{"setAdd", (PyCFunction)Pointer2_setAdd, METH_O, "Sets oscillator add factor."},
+{"setSub", (PyCFunction)Pointer2_setSub, METH_O, "Sets oscillator inverse add factor."},
+{"setDiv", (PyCFunction)Pointer2_setDiv, METH_O, "Sets inverse mul factor."},
+{NULL} /* Sentinel */
};
-static PyNumberMethods TableIndex_as_number = {
- (binaryfunc)TableIndex_add, /*nb_add*/
- (binaryfunc)TableIndex_sub, /*nb_subtract*/
- (binaryfunc)TableIndex_multiply, /*nb_multiply*/
- (binaryfunc)TableIndex_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)TableIndex_inplace_add, /*inplace_add*/
- (binaryfunc)TableIndex_inplace_sub, /*inplace_subtract*/
- (binaryfunc)TableIndex_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)TableIndex_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 */
+static PyNumberMethods Pointer2_as_number = {
+(binaryfunc)Pointer2_add, /*nb_add*/
+(binaryfunc)Pointer2_sub, /*nb_subtract*/
+(binaryfunc)Pointer2_multiply, /*nb_multiply*/
+INITIALIZE_NB_DIVIDE_ZERO /*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*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+0, /*nb_int*/
+0, /*nb_long*/
+0, /*nb_float*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+(binaryfunc)Pointer2_inplace_add, /*inplace_add*/
+(binaryfunc)Pointer2_inplace_sub, /*inplace_subtract*/
+(binaryfunc)Pointer2_inplace_multiply, /*inplace_multiply*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+(binaryfunc)Pointer2_div, /*nb_true_divide*/
+0, /*nb_inplace_floor_divide*/
+(binaryfunc)Pointer2_inplace_div, /*nb_inplace_true_divide*/
+0, /* nb_index */
};
-PyTypeObject TableIndexType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.TableIndex_base", /*tp_name*/
- sizeof(TableIndex), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor)TableIndex_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- &TableIndex_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*/
- "TableIndex objects. Read a table by indexing without interpolation.", /* tp_doc */
- (traverseproc)TableIndex_traverse, /* tp_traverse */
- (inquiry)TableIndex_clear, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- TableIndex_methods, /* tp_methods */
- TableIndex_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 */
- TableIndex_new, /* tp_new */
+PyTypeObject Pointer2Type = {
+PyVarObject_HEAD_INIT(NULL, 0)
+"_pyo.Pointer2_base", /*tp_name*/
+sizeof(Pointer2), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)Pointer2_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_as_async (tp_compare in Python 2)*/
+0, /*tp_repr*/
+&Pointer2_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*/
+"Pointer2 objects. High quality table reader with a pointer index.", /* tp_doc */
+(traverseproc)Pointer2_traverse, /* tp_traverse */
+(inquiry)Pointer2_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+Pointer2_methods, /* tp_methods */
+Pointer2_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 */
+Pointer2_new, /* tp_new */
};
/**************/
-/* Lookup object */
+/* TableIndex object */
/**************/
typedef struct {
pyo_audio_HEAD
@@ -4084,93 +4281,85 @@ typedef struct {
PyObject *index;
Stream *index_stream;
int modebuffer[2];
-} Lookup;
-
-static MYFLT
-Lookup_clip(MYFLT x) {
- if (x < -1.0)
- return -1.0;
- else if (x > 1.0)
- return 1.0;
- else
- return x;
-}
+} TableIndex;
static void
-Lookup_readframes_a(Lookup *self) {
- MYFLT ph, fpart;
- int i, ipart;
+TableIndex_readframes_a(TableIndex *self) {
+ int i, ind;
MYFLT *tablelist = TableStream_getData(self->table);
int size = TableStream_getSize(self->table);
- MYFLT *pha = Stream_getData((Stream *)self->index_stream);
+ MYFLT *phase = Stream_getData((Stream *)self->index_stream);
for (i=0; i<self->bufsize; i++) {
- ph = (Lookup_clip(pha[i]) * 0.495 + 0.5) * size;
- ipart = (int)ph;
- fpart = ph - ipart;
- self->data[i] = tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * fpart;
+ ind = (int)phase[i];
+ if (ind < 0)
+ ind = 0;
+ else if (ind >= size)
+ ind = size - 1;
+
+ self->data[i] = tablelist[ind];
}
}
-static void Lookup_postprocessing_ii(Lookup *self) { POST_PROCESSING_II };
-static void Lookup_postprocessing_ai(Lookup *self) { POST_PROCESSING_AI };
-static void Lookup_postprocessing_ia(Lookup *self) { POST_PROCESSING_IA };
-static void Lookup_postprocessing_aa(Lookup *self) { POST_PROCESSING_AA };
-static void Lookup_postprocessing_ireva(Lookup *self) { POST_PROCESSING_IREVA };
-static void Lookup_postprocessing_areva(Lookup *self) { POST_PROCESSING_AREVA };
-static void Lookup_postprocessing_revai(Lookup *self) { POST_PROCESSING_REVAI };
-static void Lookup_postprocessing_revaa(Lookup *self) { POST_PROCESSING_REVAA };
-static void Lookup_postprocessing_revareva(Lookup *self) { POST_PROCESSING_REVAREVA };
+static void TableIndex_postprocessing_ii(TableIndex *self) { POST_PROCESSING_II };
+static void TableIndex_postprocessing_ai(TableIndex *self) { POST_PROCESSING_AI };
+static void TableIndex_postprocessing_ia(TableIndex *self) { POST_PROCESSING_IA };
+static void TableIndex_postprocessing_aa(TableIndex *self) { POST_PROCESSING_AA };
+static void TableIndex_postprocessing_ireva(TableIndex *self) { POST_PROCESSING_IREVA };
+static void TableIndex_postprocessing_areva(TableIndex *self) { POST_PROCESSING_AREVA };
+static void TableIndex_postprocessing_revai(TableIndex *self) { POST_PROCESSING_REVAI };
+static void TableIndex_postprocessing_revaa(TableIndex *self) { POST_PROCESSING_REVAA };
+static void TableIndex_postprocessing_revareva(TableIndex *self) { POST_PROCESSING_REVAREVA };
static void
-Lookup_setProcMode(Lookup *self)
+TableIndex_setProcMode(TableIndex *self)
{
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
- self->proc_func_ptr = Lookup_readframes_a;
+ self->proc_func_ptr = TableIndex_readframes_a;
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = Lookup_postprocessing_ii;
+ self->muladd_func_ptr = TableIndex_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = Lookup_postprocessing_ai;
+ self->muladd_func_ptr = TableIndex_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = Lookup_postprocessing_revai;
+ self->muladd_func_ptr = TableIndex_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = Lookup_postprocessing_ia;
+ self->muladd_func_ptr = TableIndex_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = Lookup_postprocessing_aa;
+ self->muladd_func_ptr = TableIndex_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = Lookup_postprocessing_revaa;
+ self->muladd_func_ptr = TableIndex_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = Lookup_postprocessing_ireva;
+ self->muladd_func_ptr = TableIndex_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = Lookup_postprocessing_areva;
+ self->muladd_func_ptr = TableIndex_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = Lookup_postprocessing_revareva;
+ self->muladd_func_ptr = TableIndex_postprocessing_revareva;
break;
}
}
static void
-Lookup_compute_next_data_frame(Lookup *self)
+TableIndex_compute_next_data_frame(TableIndex *self)
{
(*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
static int
-Lookup_traverse(Lookup *self, visitproc visit, void *arg)
+TableIndex_traverse(TableIndex *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->table);
@@ -4180,7 +4369,7 @@ Lookup_traverse(Lookup *self, visitproc visit, void *arg)
}
static int
-Lookup_clear(Lookup *self)
+TableIndex_clear(TableIndex *self)
{
pyo_CLEAR
Py_CLEAR(self->table);
@@ -4190,27 +4379,27 @@ Lookup_clear(Lookup *self)
}
static void
-Lookup_dealloc(Lookup* self)
+TableIndex_dealloc(TableIndex* self)
{
pyo_DEALLOC
- Lookup_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ TableIndex_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-Lookup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+TableIndex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
PyObject *tabletmp, *indextmp, *multmp=NULL, *addtmp=NULL;
- Lookup *self;
- self = (Lookup *)type->tp_alloc(type, 0);
+ TableIndex *self;
+ self = (TableIndex *)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;
+ Stream_setFunctionPtr(self->stream, TableIndex_compute_next_data_frame);
+ self->mode_func_ptr = TableIndex_setProcMode;
static char *kwlist[] = {"table", "index", "mul", "add", NULL};
@@ -4218,7 +4407,7 @@ Lookup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- PyErr_SetString(PyExc_TypeError, "\"table\" argument of Lookup must be a PyoTableObject.\n");
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of TableIndex must be a PyoTableObject.\n");
Py_RETURN_NONE;
}
Py_XDECREF(self->table);
@@ -4241,35 +4430,35 @@ Lookup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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 * 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 * Lookup_play(Lookup *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * Lookup_out(Lookup *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * Lookup_stop(Lookup *self) { STOP };
+static PyObject * TableIndex_play(TableIndex *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * TableIndex_out(TableIndex *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * TableIndex_stop(TableIndex *self) { STOP };
-static PyObject * Lookup_multiply(Lookup *self, PyObject *arg) { MULTIPLY };
-static PyObject * Lookup_inplace_multiply(Lookup *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * Lookup_add(Lookup *self, PyObject *arg) { ADD };
-static PyObject * Lookup_inplace_add(Lookup *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * Lookup_sub(Lookup *self, PyObject *arg) { SUB };
-static PyObject * Lookup_inplace_sub(Lookup *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * Lookup_div(Lookup *self, PyObject *arg) { DIV };
-static PyObject * Lookup_inplace_div(Lookup *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * TableIndex_multiply(TableIndex *self, PyObject *arg) { MULTIPLY };
+static PyObject * TableIndex_inplace_multiply(TableIndex *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * TableIndex_add(TableIndex *self, PyObject *arg) { ADD };
+static PyObject * TableIndex_inplace_add(TableIndex *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * TableIndex_sub(TableIndex *self, PyObject *arg) { SUB };
+static PyObject * TableIndex_inplace_sub(TableIndex *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * TableIndex_div(TableIndex *self, PyObject *arg) { DIV };
+static PyObject * TableIndex_inplace_div(TableIndex *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-Lookup_getTable(Lookup* self)
+TableIndex_getTable(TableIndex* self)
{
Py_INCREF(self->table);
return self->table;
};
static PyObject *
-Lookup_setTable(Lookup *self, PyObject *arg)
+TableIndex_setTable(TableIndex *self, PyObject *arg)
{
PyObject *tmp;
@@ -4284,7 +4473,7 @@ Lookup_setTable(Lookup *self, PyObject *arg)
}
static PyObject *
-Lookup_setIndex(Lookup *self, PyObject *arg)
+TableIndex_setIndex(TableIndex *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -4292,7 +4481,7 @@ Lookup_setIndex(Lookup *self, PyObject *arg)
tmp = arg;
if (PyObject_HasAttrString((PyObject *)tmp, "server") == 0) {
- PyErr_SetString(PyExc_TypeError, "\"index\" argument of Lookup must be a PyoObject.\n");
+ PyErr_SetString(PyExc_TypeError, "\"index\" argument of TableIndex must be a PyoObject.\n");
Py_RETURN_NONE;
}
@@ -4309,709 +4498,310 @@ Lookup_setIndex(Lookup *self, PyObject *arg)
return Py_None;
}
-static PyMemberDef Lookup_members[] = {
-{"server", T_OBJECT_EX, offsetof(Lookup, server), 0, "Pyo server."},
-{"stream", T_OBJECT_EX, offsetof(Lookup, stream), 0, "Stream object."},
-{"table", T_OBJECT_EX, offsetof(Lookup, table), 0, "Waveform table."},
-{"index", T_OBJECT_EX, offsetof(Lookup, index), 0, "Reader index."},
-{"mul", T_OBJECT_EX, offsetof(Lookup, mul), 0, "Mul factor."},
-{"add", T_OBJECT_EX, offsetof(Lookup, add), 0, "Add factor."},
-{NULL} /* Sentinel */
+static PyMemberDef TableIndex_members[] = {
+ {"server", T_OBJECT_EX, offsetof(TableIndex, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(TableIndex, stream), 0, "Stream object."},
+ {"table", T_OBJECT_EX, offsetof(TableIndex, table), 0, "Waveform table."},
+ {"index", T_OBJECT_EX, offsetof(TableIndex, index), 0, "Reader index."},
+ {"mul", T_OBJECT_EX, offsetof(TableIndex, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(TableIndex, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
};
-static PyMethodDef Lookup_methods[] = {
-{"getTable", (PyCFunction)Lookup_getTable, METH_NOARGS, "Returns waveform table object."},
-{"getServer", (PyCFunction)Lookup_getServer, METH_NOARGS, "Returns server object."},
-{"_getStream", (PyCFunction)Lookup_getStream, METH_NOARGS, "Returns stream object."},
-{"play", (PyCFunction)Lookup_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
-{"out", (PyCFunction)Lookup_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
-{"stop", (PyCFunction)Lookup_stop, METH_NOARGS, "Stops computing."},
-{"setTable", (PyCFunction)Lookup_setTable, METH_O, "Sets oscillator table."},
-{"setIndex", (PyCFunction)Lookup_setIndex, METH_O, "Sets reader index."},
-{"setMul", (PyCFunction)Lookup_setMul, METH_O, "Sets oscillator mul factor."},
-{"setAdd", (PyCFunction)Lookup_setAdd, METH_O, "Sets oscillator add factor."},
-{"setSub", (PyCFunction)Lookup_setSub, METH_O, "Sets oscillator inverse add factor."},
-{"setDiv", (PyCFunction)Lookup_setDiv, METH_O, "Sets inverse mul factor."},
-{NULL} /* Sentinel */
+static PyMethodDef TableIndex_methods[] = {
+ {"getTable", (PyCFunction)TableIndex_getTable, METH_NOARGS, "Returns waveform table object."},
+ {"getServer", (PyCFunction)TableIndex_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)TableIndex_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)TableIndex_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)TableIndex_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)TableIndex_stop, METH_NOARGS, "Stops computing."},
+ {"setTable", (PyCFunction)TableIndex_setTable, METH_O, "Sets oscillator table."},
+ {"setIndex", (PyCFunction)TableIndex_setIndex, METH_O, "Sets reader index."},
+ {"setMul", (PyCFunction)TableIndex_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)TableIndex_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)TableIndex_setSub, METH_O, "Sets oscillator inverse add factor."},
+ {"setDiv", (PyCFunction)TableIndex_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
};
-static PyNumberMethods Lookup_as_number = {
-(binaryfunc)Lookup_add, /*nb_add*/
-(binaryfunc)Lookup_sub, /*nb_subtract*/
-(binaryfunc)Lookup_multiply, /*nb_multiply*/
-(binaryfunc)Lookup_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)Lookup_inplace_add, /*inplace_add*/
-(binaryfunc)Lookup_inplace_sub, /*inplace_subtract*/
-(binaryfunc)Lookup_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Lookup_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 */
+static PyNumberMethods TableIndex_as_number = {
+ (binaryfunc)TableIndex_add, /*nb_add*/
+ (binaryfunc)TableIndex_sub, /*nb_subtract*/
+ (binaryfunc)TableIndex_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*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*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)TableIndex_inplace_add, /*inplace_add*/
+ (binaryfunc)TableIndex_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)TableIndex_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+ (binaryfunc)TableIndex_div, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ (binaryfunc)TableIndex_inplace_div, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
};
-PyTypeObject LookupType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
-"_pyo.Lookup_base", /*tp_name*/
-sizeof(Lookup), /*tp_basicsize*/
-0, /*tp_itemsize*/
-(destructor)Lookup_dealloc, /*tp_dealloc*/
-0, /*tp_print*/
-0, /*tp_getattr*/
-0, /*tp_setattr*/
-0, /*tp_compare*/
-0, /*tp_repr*/
-&Lookup_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*/
-"Lookup objects. Modify a signal by reading a table with the signal as the index.", /* tp_doc */
-(traverseproc)Lookup_traverse, /* tp_traverse */
-(inquiry)Lookup_clear, /* tp_clear */
-0, /* tp_richcompare */
-0, /* tp_weaklistoffset */
-0, /* tp_iter */
-0, /* tp_iternext */
-Lookup_methods, /* tp_methods */
-Lookup_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 */
-Lookup_new, /* tp_new */
+PyTypeObject TableIndexType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.TableIndex_base", /*tp_name*/
+ sizeof(TableIndex), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)TableIndex_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
+ 0, /*tp_repr*/
+ &TableIndex_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*/
+ "TableIndex objects. Read a table by indexing without interpolation.", /* tp_doc */
+ (traverseproc)TableIndex_traverse, /* tp_traverse */
+ (inquiry)TableIndex_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ TableIndex_methods, /* tp_methods */
+ TableIndex_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 */
+ TableIndex_new, /* tp_new */
};
/**************/
-/* Pulsar object */
+/* Lookup object */
/**************/
typedef struct {
pyo_audio_HEAD
PyObject *table;
- PyObject *env;
- PyObject *freq;
- Stream *freq_stream;
- PyObject *phase;
- Stream *phase_stream;
- PyObject *frac;
- Stream *frac_stream;
- int modebuffer[5];
- MYFLT pointerPos;
- int interp; /* 0 = default to 2, 1 = nointerp, 2 = linear, 3 = cos, 4 = cubic */
- MYFLT (*interp_func_ptr)(MYFLT *, int, MYFLT, int);
-} Pulsar;
-
-static void
-Pulsar_readframes_iii(Pulsar *self) {
- MYFLT fr, ph, frac, invfrac, pos, scl_pos, t_pos, e_pos, fpart, tmp;
- double inc;
- int i, ipart;
- MYFLT *tablelist = TableStream_getData(self->table);
- 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)
- self->pointerPos = 1.0 + self->pointerPos;
- else if (self->pointerPos >= 1.0)
- self->pointerPos -= 1.0;
- pos = self->pointerPos + ph;
- if (pos >= 1.0)
- pos -= 1.0;
- if (pos < frac) {
- scl_pos = pos * invfrac;
- t_pos = scl_pos * size;
- ipart = (int)t_pos;
- fpart = t_pos - ipart;
- tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ PyObject *index;
+ Stream *index_stream;
+ int modebuffer[2];
+} Lookup;
- 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;
- }
- }
+static MYFLT
+Lookup_clip(MYFLT x) {
+ if (x < -1.0)
+ return -1.0;
+ else if (x > 1.0)
+ return 1.0;
+ else
+ return x;
}
static void
-Pulsar_readframes_aii(Pulsar *self) {
- MYFLT ph, frac, invfrac, pos, scl_pos, t_pos, e_pos, fpart, tmp, oneOnSr;
- double inc;
+Lookup_readframes_a(Lookup *self) {
+ MYFLT ph, fpart;
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
- 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;
+ MYFLT *pha = Stream_getData((Stream *)self->index_stream);
- oneOnSr = 1.0 / self->sr;
for (i=0; i<self->bufsize; i++) {
- inc = fr[i] * oneOnSr;
- self->pointerPos += inc;
- if (self->pointerPos < 0)
- self->pointerPos = 1.0 + self->pointerPos;
- else if (self->pointerPos >= 1.0)
- self->pointerPos -= 1.0;
- pos = self->pointerPos + ph;
- if (pos >= 1.0)
- pos -= 1.0;
- if (pos < frac) {
- scl_pos = pos * invfrac;
- t_pos = scl_pos * size;
- 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;
- }
+ ph = (Lookup_clip(pha[i]) * 0.495 + 0.5) * size;
+ ipart = (int)ph;
+ fpart = ph - ipart;
+ self->data[i] = tablelist[ipart] + (tablelist[ipart+1] - tablelist[ipart]) * fpart;
}
}
-static void
-Pulsar_readframes_iai(Pulsar *self) {
- MYFLT fr, frac, invfrac, pos, scl_pos, t_pos, e_pos, fpart, tmp;
- double inc;
- int i, ipart;
- MYFLT *tablelist = TableStream_getData(self->table);
- MYFLT *envlist = TableStream_getData(self->env);
- int size = TableStream_getSize(self->table);
- int envsize = TableStream_getSize(self->env);
+static void Lookup_postprocessing_ii(Lookup *self) { POST_PROCESSING_II };
+static void Lookup_postprocessing_ai(Lookup *self) { POST_PROCESSING_AI };
+static void Lookup_postprocessing_ia(Lookup *self) { POST_PROCESSING_IA };
+static void Lookup_postprocessing_aa(Lookup *self) { POST_PROCESSING_AA };
+static void Lookup_postprocessing_ireva(Lookup *self) { POST_PROCESSING_IREVA };
+static void Lookup_postprocessing_areva(Lookup *self) { POST_PROCESSING_AREVA };
+static void Lookup_postprocessing_revai(Lookup *self) { POST_PROCESSING_REVAI };
+static void Lookup_postprocessing_revaa(Lookup *self) { POST_PROCESSING_REVAA };
+static void Lookup_postprocessing_revareva(Lookup *self) { POST_PROCESSING_REVAREVA };
- 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;
+static void
+Lookup_setProcMode(Lookup *self)
+{
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
- for (i=0; i<self->bufsize; i++) {
- self->pointerPos += inc;
- if (self->pointerPos < 0)
- self->pointerPos = 1.0 + self->pointerPos;
- else if (self->pointerPos >= 1.0)
- self->pointerPos -= 1.0;
- pos = self->pointerPos + ph[i];
- if (pos >= 1.0)
- pos -= 1.0;
- if (pos < frac) {
- scl_pos = pos * invfrac;
- t_pos = scl_pos * size;
- ipart = (int)t_pos;
- fpart = t_pos - ipart;
- tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ self->proc_func_ptr = Lookup_readframes_a;
- 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;
- }
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = Lookup_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = Lookup_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = Lookup_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = Lookup_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = Lookup_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = Lookup_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = Lookup_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = Lookup_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = Lookup_postprocessing_revareva;
+ break;
}
}
static void
-Pulsar_readframes_aai(Pulsar *self) {
- MYFLT frac, invfrac, pos, scl_pos, t_pos, e_pos, fpart, tmp, oneOnSr;
- double inc;
- int i, ipart;
- MYFLT *tablelist = TableStream_getData(self->table);
- MYFLT *envlist = TableStream_getData(self->env);
- int size = TableStream_getSize(self->table);
- int envsize = TableStream_getSize(self->env);
+Lookup_compute_next_data_frame(Lookup *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
- 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;
- self->pointerPos += inc;
- if (self->pointerPos < 0)
- self->pointerPos = 1.0 + self->pointerPos;
- else if (self->pointerPos >= 1.0)
- self->pointerPos -= 1.0;
- pos = self->pointerPos + ph[i];
- if (pos >= 1.0)
- pos -= 1.0;
- if (pos < frac) {
- scl_pos = pos * invfrac;
- t_pos = scl_pos * size;
- ipart = (int)t_pos;
- fpart = t_pos - ipart;
- tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+static int
+Lookup_traverse(Lookup *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->table);
+ Py_VISIT(self->index);
+ Py_VISIT(self->index_stream);
+ return 0;
+}
- 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;
- }
- }
+static int
+Lookup_clear(Lookup *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->table);
+ Py_CLEAR(self->index);
+ Py_CLEAR(self->index_stream);
+ return 0;
}
static void
-Pulsar_readframes_iia(Pulsar *self) {
- MYFLT fr, ph, pos, curfrac, scl_pos, t_pos, e_pos, fpart, tmp;
- double inc;
- int i, ipart;
- MYFLT *tablelist = TableStream_getData(self->table);
- 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;
+Lookup_dealloc(Lookup* self)
+{
+ pyo_DEALLOC
+ Lookup_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
- for (i=0; i<self->bufsize; i++) {
- curfrac = frac[i];
- self->pointerPos += inc;
- if (self->pointerPos < 0)
- self->pointerPos = 1.0 + self->pointerPos;
- else if (self->pointerPos >= 1.0)
- self->pointerPos -= 1.0;
- pos = self->pointerPos + ph;
- if (pos >= 1.0)
- pos -= 1.0;
- if (pos < curfrac) {
- scl_pos = pos / curfrac;
- t_pos = scl_pos * size;
- ipart = (int)t_pos;
- fpart = t_pos - ipart;
- tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+static PyObject *
+Lookup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ PyObject *tabletmp, *indextmp, *multmp=NULL, *addtmp=NULL;
+ Lookup *self;
+ self = (Lookup *)type->tp_alloc(type, 0);
- 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;
- }
- }
-}
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
-static void
-Pulsar_readframes_aia(Pulsar *self) {
- MYFLT ph, pos, curfrac, scl_pos, t_pos, e_pos, fpart, tmp, oneOnSr;
- double inc;
- int i, ipart;
- MYFLT *tablelist = TableStream_getData(self->table);
- MYFLT *envlist = TableStream_getData(self->env);
- int size = TableStream_getSize(self->table);
- int envsize = TableStream_getSize(self->env);
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, Lookup_compute_next_data_frame);
+ self->mode_func_ptr = Lookup_setProcMode;
- MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
- ph = PyFloat_AS_DOUBLE(self->phase);
- MYFLT *frac = Stream_getData((Stream *)self->frac_stream);
+ static char *kwlist[] = {"table", "index", "mul", "add", NULL};
- oneOnSr = 1.0 / self->sr;
- for (i=0; i<self->bufsize; i++) {
- curfrac = frac[i];
- inc = fr[i] * oneOnSr;
- self->pointerPos += inc;
- if (self->pointerPos < 0)
- self->pointerPos = 1.0 + self->pointerPos;
- else if (self->pointerPos >= 1.0)
- self->pointerPos -= 1.0;
- pos = self->pointerPos + ph;
- if (pos >= 1.0)
- pos -= 1.0;
- if (pos < curfrac) {
- scl_pos = pos / curfrac;
- t_pos = scl_pos * size;
- ipart = (int)t_pos;
- fpart = t_pos - ipart;
- tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO", kwlist, &tabletmp, &indextmp, &multmp, &addtmp))
+ Py_RETURN_NONE;
- 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;
- }
+ if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
+ PyErr_SetString(PyExc_TypeError, "\"table\" argument of Lookup must be a PyoTableObject.\n");
+ Py_RETURN_NONE;
}
-}
-
-static void
-Pulsar_readframes_iaa(Pulsar *self) {
- MYFLT fr, pos, curfrac, scl_pos, t_pos, e_pos, fpart, tmp;
- double inc;
- int i, ipart;
- MYFLT *tablelist = TableStream_getData(self->table);
- MYFLT *envlist = TableStream_getData(self->env);
- int size = TableStream_getSize(self->table);
- int envsize = TableStream_getSize(self->env);
+ Py_XDECREF(self->table);
+ self->table = PyObject_CallMethod((PyObject *)tabletmp, "getTableStream", "");
- 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;
+ if (indextmp) {
+ PyObject_CallMethod((PyObject *)self, "setIndex", "O", indextmp);
+ }
- for (i=0; i<self->bufsize; i++) {
- curfrac = frac[i];
- self->pointerPos += inc;
- if (self->pointerPos < 0)
- self->pointerPos = 1.0 + self->pointerPos;
- else if (self->pointerPos >= 1.0)
- self->pointerPos -= 1.0;
- pos = self->pointerPos + ph[i];
- if (pos >= 1.0)
- pos -= 1.0;
- if (pos < curfrac) {
- scl_pos = pos / curfrac;
- t_pos = scl_pos * size;
- ipart = (int)t_pos;
- fpart = t_pos - ipart;
- tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
- 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;
- }
+ if (addtmp) {
+ PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
}
-}
-
-static void
-Pulsar_readframes_aaa(Pulsar *self) {
- MYFLT pos, curfrac, scl_pos, t_pos, e_pos, fpart, tmp, oneOnSr;
- double inc;
- int i, ipart;
- MYFLT *tablelist = TableStream_getData(self->table);
- 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);
+ PyObject_CallMethod(self->server, "addStream", "O", self->stream);
- oneOnSr = 1.0 / self->sr;
- for (i=0; i<self->bufsize; i++) {
- curfrac = frac[i];
- inc = fr[i] * oneOnSr;
- self->pointerPos += inc;
- if (self->pointerPos < 0)
- self->pointerPos = 1.0 + self->pointerPos;
- else if (self->pointerPos >= 1.0)
- self->pointerPos -= 1.0;
- pos = self->pointerPos + ph[i];
- if (pos >= 1.0)
- pos -= 1.0;
- if (pos < curfrac) {
- scl_pos = pos / curfrac;
- t_pos = scl_pos * size;
- ipart = (int)t_pos;
- fpart = t_pos - ipart;
- tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ (*self->mode_func_ptr)(self);
- 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;
- }
- }
+ return (PyObject *)self;
}
-static void Pulsar_postprocessing_ii(Pulsar *self) { POST_PROCESSING_II };
-static void Pulsar_postprocessing_ai(Pulsar *self) { POST_PROCESSING_AI };
-static void Pulsar_postprocessing_ia(Pulsar *self) { POST_PROCESSING_IA };
-static void Pulsar_postprocessing_aa(Pulsar *self) { POST_PROCESSING_AA };
-static void Pulsar_postprocessing_ireva(Pulsar *self) { POST_PROCESSING_IREVA };
-static void Pulsar_postprocessing_areva(Pulsar *self) { POST_PROCESSING_AREVA };
-static void Pulsar_postprocessing_revai(Pulsar *self) { POST_PROCESSING_REVAI };
-static void Pulsar_postprocessing_revaa(Pulsar *self) { POST_PROCESSING_REVAA };
-static void Pulsar_postprocessing_revareva(Pulsar *self) { POST_PROCESSING_REVAREVA };
+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 void
-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:
- self->proc_func_ptr = Pulsar_readframes_iii;
- break;
- case 1:
- self->proc_func_ptr = Pulsar_readframes_aii;
- break;
- case 10:
- self->proc_func_ptr = Pulsar_readframes_iai;
- break;
- case 11:
- self->proc_func_ptr = Pulsar_readframes_aai;
- break;
- case 100:
- self->proc_func_ptr = Pulsar_readframes_iia;
- break;
- case 101:
- self->proc_func_ptr = Pulsar_readframes_aia;
- break;
- case 110:
- self->proc_func_ptr = Pulsar_readframes_iaa;
- break;
- case 111:
- self->proc_func_ptr = Pulsar_readframes_aaa;
- break;
- }
- switch (muladdmode) {
- case 0:
- self->muladd_func_ptr = Pulsar_postprocessing_ii;
- break;
- case 1:
- self->muladd_func_ptr = Pulsar_postprocessing_ai;
- break;
- case 2:
- self->muladd_func_ptr = Pulsar_postprocessing_revai;
- break;
- case 10:
- self->muladd_func_ptr = Pulsar_postprocessing_ia;
- break;
- case 11:
- self->muladd_func_ptr = Pulsar_postprocessing_aa;
- break;
- case 12:
- self->muladd_func_ptr = Pulsar_postprocessing_revaa;
- break;
- case 20:
- self->muladd_func_ptr = Pulsar_postprocessing_ireva;
- break;
- case 21:
- self->muladd_func_ptr = Pulsar_postprocessing_areva;
- break;
- 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->muladd_func_ptr)(self);
-}
-
-static int
-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->frac_stream);
- return 0;
-}
-
-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->frac_stream);
- return 0;
-}
-
-static void
-Pulsar_dealloc(Pulsar* self)
-{
- pyo_DEALLOC
- Pulsar_clear(self);
- self->ob_type->tp_free((PyObject*)self);
-}
-
-static PyObject *
-Pulsar_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- int i;
- 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);
- self->interp = 2;
- self->modebuffer[0] = 0;
- self->modebuffer[1] = 0;
- self->modebuffer[2] = 0;
- 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 ) {
- 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 ) {
- 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", "");
-
- if (phasetmp) {
- PyObject_CallMethod((PyObject *)self, "setPhase", "O", phasetmp);
- }
-
- if (freqtmp) {
- PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
- }
-
- 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_play(Pulsar *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * Pulsar_out(Pulsar *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * Pulsar_stop(Pulsar *self) { STOP };
+static PyObject * Lookup_play(Lookup *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Lookup_out(Lookup *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * Lookup_stop(Lookup *self) { STOP };
-static PyObject * Pulsar_multiply(Pulsar *self, PyObject *arg) { MULTIPLY };
-static PyObject * Pulsar_inplace_multiply(Pulsar *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * Pulsar_add(Pulsar *self, PyObject *arg) { ADD };
-static PyObject * Pulsar_inplace_add(Pulsar *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * Pulsar_sub(Pulsar *self, PyObject *arg) { SUB };
-static PyObject * Pulsar_inplace_sub(Pulsar *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * Pulsar_div(Pulsar *self, PyObject *arg) { DIV };
-static PyObject * Pulsar_inplace_div(Pulsar *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * Lookup_multiply(Lookup *self, PyObject *arg) { MULTIPLY };
+static PyObject * Lookup_inplace_multiply(Lookup *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Lookup_add(Lookup *self, PyObject *arg) { ADD };
+static PyObject * Lookup_inplace_add(Lookup *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Lookup_sub(Lookup *self, PyObject *arg) { SUB };
+static PyObject * Lookup_inplace_sub(Lookup *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Lookup_div(Lookup *self, PyObject *arg) { DIV };
+static PyObject * Lookup_inplace_div(Lookup *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-Pulsar_getTable(Pulsar* self)
+Lookup_getTable(Lookup* self)
{
Py_INCREF(self->table);
return self->table;
};
static PyObject *
-Pulsar_getEnv(Pulsar* self)
-{
- Py_INCREF(self->env);
- return self->env;
-};
-
-static PyObject *
-Pulsar_setTable(Pulsar *self, PyObject *arg)
+Lookup_setTable(Lookup *self, PyObject *arg)
{
PyObject *tmp;
@@ -5026,168 +4816,62 @@ Pulsar_setTable(Pulsar *self, PyObject *arg)
}
static PyObject *
-Pulsar_setEnv(Pulsar *self, PyObject *arg)
+Lookup_setIndex(Lookup *self, PyObject *arg)
{
- PyObject *tmp;
+ PyObject *tmp, *streamtmp;
ASSERT_ARG_NOT_NULL
tmp = arg;
- Py_DECREF(self->env);
- self->env = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
+ 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 PyObject *
-Pulsar_setFreq(Pulsar *self, PyObject *arg)
-{
- PyObject *tmp, *streamtmp;
-
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
+static PyMemberDef Lookup_members[] = {
+{"server", T_OBJECT_EX, offsetof(Lookup, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(Lookup, stream), 0, "Stream object."},
+{"table", T_OBJECT_EX, offsetof(Lookup, table), 0, "Waveform table."},
+{"index", T_OBJECT_EX, offsetof(Lookup, index), 0, "Reader index."},
+{"mul", T_OBJECT_EX, offsetof(Lookup, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(Lookup, add), 0, "Add factor."},
+{NULL} /* Sentinel */
+};
- tmp = arg;
- Py_INCREF(tmp);
- Py_DECREF(self->freq);
- if (isNumber == 1) {
- self->freq = PyNumber_Float(tmp);
- self->modebuffer[2] = 0;
- }
- else {
- self->freq = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->freq, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->freq_stream);
- 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;
-
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
-
- tmp = arg;
- Py_INCREF(tmp);
- Py_DECREF(self->phase);
- if (isNumber == 1) {
- self->phase = PyNumber_Float(tmp);
- self->modebuffer[3] = 0;
- }
- else {
- self->phase = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->phase, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->phase_stream);
- 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;
-
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
-
- tmp = arg;
- Py_INCREF(tmp);
- Py_DECREF(self->frac);
- if (isNumber == 1) {
- self->frac = PyNumber_Float(tmp);
- self->modebuffer[4] = 0;
- }
- else {
- self->frac = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->frac, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->frac_stream);
- 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)
-{
- ASSERT_ARG_NOT_NULL
-
- 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 PyMemberDef Pulsar_members[] = {
-{"server", T_OBJECT_EX, offsetof(Pulsar, server), 0, "Pyo server."},
-{"stream", T_OBJECT_EX, offsetof(Pulsar, stream), 0, "Stream object."},
-{"table", T_OBJECT_EX, offsetof(Pulsar, table), 0, "Waveform table."},
-{"freq", T_OBJECT_EX, offsetof(Pulsar, freq), 0, "Frequency in cycle per second."},
-{"phase", T_OBJECT_EX, offsetof(Pulsar, phase), 0, "Oscillator phase."},
-{"frac", T_OBJECT_EX, offsetof(Pulsar, frac), 0, "Table width inside whole length."},
-{"mul", T_OBJECT_EX, offsetof(Pulsar, mul), 0, "Mul factor."},
-{"add", T_OBJECT_EX, offsetof(Pulsar, add), 0, "Add factor."},
-{NULL} /* Sentinel */
-};
-
-static PyMethodDef Pulsar_methods[] = {
-{"getTable", (PyCFunction)Pulsar_getTable, METH_NOARGS, "Returns waveform table object."},
-{"getEnv", (PyCFunction)Pulsar_getEnv, METH_NOARGS, "Returns object envelope."},
-{"getServer", (PyCFunction)Pulsar_getServer, METH_NOARGS, "Returns server object."},
-{"_getStream", (PyCFunction)Pulsar_getStream, METH_NOARGS, "Returns stream object."},
-{"play", (PyCFunction)Pulsar_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
-{"out", (PyCFunction)Pulsar_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
-{"stop", (PyCFunction)Pulsar_stop, METH_NOARGS, "Stops computing."},
-{"setTable", (PyCFunction)Pulsar_setTable, METH_O, "Sets oscillator table."},
-{"setEnv", (PyCFunction)Pulsar_setEnv, METH_O, "Sets envelope table."},
-{"setFreq", (PyCFunction)Pulsar_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
-{"setPhase", (PyCFunction)Pulsar_setPhase, METH_O, "Sets oscillator phase."},
-{"setFrac", (PyCFunction)Pulsar_setFrac, METH_O, "Sets waveform width inside whole period length."},
-{"setInterp", (PyCFunction)Pulsar_setInterp, METH_O, "Sets Pulsar interpolation mode."},
-{"setMul", (PyCFunction)Pulsar_setMul, METH_O, "Sets oscillator mul factor."},
-{"setAdd", (PyCFunction)Pulsar_setAdd, METH_O, "Sets oscillator add factor."},
-{"setSub", (PyCFunction)Pulsar_setSub, METH_O, "Sets oscillator inverse add factor."},
-{"setDiv", (PyCFunction)Pulsar_setDiv, METH_O, "Sets inverse mul factor."},
+static PyMethodDef Lookup_methods[] = {
+{"getTable", (PyCFunction)Lookup_getTable, METH_NOARGS, "Returns waveform table object."},
+{"getServer", (PyCFunction)Lookup_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)Lookup_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)Lookup_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"out", (PyCFunction)Lookup_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"stop", (PyCFunction)Lookup_stop, METH_NOARGS, "Stops computing."},
+{"setTable", (PyCFunction)Lookup_setTable, METH_O, "Sets oscillator table."},
+{"setIndex", (PyCFunction)Lookup_setIndex, METH_O, "Sets reader index."},
+{"setMul", (PyCFunction)Lookup_setMul, METH_O, "Sets oscillator mul factor."},
+{"setAdd", (PyCFunction)Lookup_setAdd, METH_O, "Sets oscillator add factor."},
+{"setSub", (PyCFunction)Lookup_setSub, METH_O, "Sets oscillator inverse add factor."},
+{"setDiv", (PyCFunction)Lookup_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
-static PyNumberMethods Pulsar_as_number = {
-(binaryfunc)Pulsar_add, /*nb_add*/
-(binaryfunc)Pulsar_sub, /*nb_subtract*/
-(binaryfunc)Pulsar_multiply, /*nb_multiply*/
-(binaryfunc)Pulsar_div, /*nb_divide*/
+static PyNumberMethods Lookup_as_number = {
+(binaryfunc)Lookup_add, /*nb_add*/
+(binaryfunc)Lookup_sub, /*nb_subtract*/
+(binaryfunc)Lookup_multiply, /*nb_multiply*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5201,16 +4885,16 @@ static PyNumberMethods Pulsar_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
-(binaryfunc)Pulsar_inplace_add, /*inplace_add*/
-(binaryfunc)Pulsar_inplace_sub, /*inplace_subtract*/
-(binaryfunc)Pulsar_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Pulsar_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+(binaryfunc)Lookup_inplace_add, /*inplace_add*/
+(binaryfunc)Lookup_inplace_sub, /*inplace_subtract*/
+(binaryfunc)Lookup_inplace_multiply, /*inplace_multiply*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5219,25 +4903,24 @@ static PyNumberMethods Pulsar_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Lookup_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Lookup_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
-PyTypeObject PulsarType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
-"_pyo.Pulsar_base", /*tp_name*/
-sizeof(Pulsar), /*tp_basicsize*/
+PyTypeObject LookupType = {
+PyVarObject_HEAD_INIT(NULL, 0)
+"_pyo.Lookup_base", /*tp_name*/
+sizeof(Lookup), /*tp_basicsize*/
0, /*tp_itemsize*/
-(destructor)Pulsar_dealloc, /*tp_dealloc*/
+(destructor)Lookup_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
-&Pulsar_as_number, /*tp_as_number*/
+&Lookup_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -5247,15 +4930,15 @@ sizeof(Pulsar), /*tp_basicsize*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
-"Pulsar objects. Generates pulsar synthesis oscillator.", /* tp_doc */
-(traverseproc)Pulsar_traverse, /* tp_traverse */
-(inquiry)Pulsar_clear, /* tp_clear */
+"Lookup objects. Modify a signal by reading a table with the signal as the index.", /* tp_doc */
+(traverseproc)Lookup_traverse, /* tp_traverse */
+(inquiry)Lookup_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
-Pulsar_methods, /* tp_methods */
-Pulsar_members, /* tp_members */
+Lookup_methods, /* tp_methods */
+Lookup_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -5264,438 +4947,778 @@ Pulsar_members, /* tp_members */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
-Pulsar_new, /* tp_new */
+Lookup_new, /* tp_new */
};
/**************/
-/* TableRead object */
+/* Pulsar object */
/**************/
typedef struct {
pyo_audio_HEAD
PyObject *table;
+ PyObject *env;
PyObject *freq;
Stream *freq_stream;
- int loop;
- int go;
- int modebuffer[3];
- double pointerPos;
- MYFLT *trigsBuffer;
- TriggerStream *trig_stream;
- int init;
+ PyObject *phase;
+ Stream *phase_stream;
+ PyObject *frac;
+ Stream *frac_stream;
+ int modebuffer[5];
+ MYFLT pointerPos;
int interp; /* 0 = default to 2, 1 = nointerp, 2 = linear, 3 = cos, 4 = cubic */
MYFLT (*interp_func_ptr)(MYFLT *, int, MYFLT, int);
-} TableRead;
+} Pulsar;
static void
-TableRead_readframes_i(TableRead *self) {
- MYFLT fr, inc, fpart;
+Pulsar_readframes_iii(Pulsar *self) {
+ MYFLT fr, ph, frac, invfrac, pos, scl_pos, t_pos, e_pos, fpart, tmp;
+ double inc;
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
+ MYFLT *envlist = TableStream_getData(self->env);
int size = TableStream_getSize(self->table);
+ int envsize = TableStream_getSize(self->env);
fr = PyFloat_AS_DOUBLE(self->freq);
- inc = fr * size / self->sr;
-
- if (self->go == 0)
- PyObject_CallMethod((PyObject *)self, "stop", NULL);
+ 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->trigsBuffer[i] = 0.0;
- if (self->pointerPos < 0) {
- if (self->init == 0)
- self->trigsBuffer[i] = 1.0;
- else
- self->init = 0;
- self->pointerPos = size + self->pointerPos;
- }
- else if (self->pointerPos >= size) {
- self->trigsBuffer[i] = 1.0;
- if (self->loop == 1)
- self->pointerPos -= size;
- else
- self->go = 0;
- }
- if (self->go == 1) {
- ipart = (int)self->pointerPos;
- fpart = self->pointerPos - ipart;
- self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ self->pointerPos += inc;
+ if (self->pointerPos < 0)
+ self->pointerPos = 1.0 + self->pointerPos;
+ else if (self->pointerPos >= 1.0)
+ self->pointerPos -= 1.0;
+ pos = self->pointerPos + ph;
+ if (pos >= 1.0)
+ pos -= 1.0;
+ if (pos < frac) {
+ scl_pos = pos * invfrac;
+ t_pos = scl_pos * size;
+ 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
+ else {
self->data[i] = 0.0;
-
- self->pointerPos += inc;
+ }
}
}
static void
-TableRead_readframes_a(TableRead *self) {
- MYFLT inc, fpart, sizeOnSr;
+Pulsar_readframes_aii(Pulsar *self) {
+ MYFLT ph, frac, invfrac, pos, scl_pos, t_pos, e_pos, fpart, tmp, oneOnSr;
+ double inc;
int i, ipart;
MYFLT *tablelist = TableStream_getData(self->table);
+ 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;
- sizeOnSr = size / self->sr;
-
- if (self->go == 0)
- PyObject_CallMethod((PyObject *)self, "stop", NULL);
-
+ oneOnSr = 1.0 / self->sr;
for (i=0; i<self->bufsize; i++) {
- self->trigsBuffer[i] = 0.0;
- if (self->pointerPos < 0) {
- if (self->init == 0)
- self->trigsBuffer[i] = 1.0;
- else
- self->init = 0;
- self->pointerPos = size + self->pointerPos;
- }
- else if (self->pointerPos >= size) {
- self->trigsBuffer[i] = 1.0;
- if (self->loop == 1)
- self->pointerPos -= size;
- else
- self->go = 0;
- }
- if (self->go == 1) {
- ipart = (int)self->pointerPos;
- fpart = self->pointerPos - ipart;
- self->data[i] = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
+ inc = fr[i] * oneOnSr;
+ self->pointerPos += inc;
+ if (self->pointerPos < 0)
+ self->pointerPos = 1.0 + self->pointerPos;
+ else if (self->pointerPos >= 1.0)
+ self->pointerPos -= 1.0;
+ pos = self->pointerPos + ph;
+ if (pos >= 1.0)
+ pos -= 1.0;
+ if (pos < frac) {
+ scl_pos = pos * invfrac;
+ t_pos = scl_pos * size;
+ 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
+ else {
self->data[i] = 0.0;
-
- inc = fr[i] * sizeOnSr;
- self->pointerPos += inc;
+ }
}
}
-static void TableRead_postprocessing_ii(TableRead *self) { POST_PROCESSING_II };
-static void TableRead_postprocessing_ai(TableRead *self) { POST_PROCESSING_AI };
-static void TableRead_postprocessing_ia(TableRead *self) { POST_PROCESSING_IA };
-static void TableRead_postprocessing_aa(TableRead *self) { POST_PROCESSING_AA };
-static void TableRead_postprocessing_ireva(TableRead *self) { POST_PROCESSING_IREVA };
-static void TableRead_postprocessing_areva(TableRead *self) { POST_PROCESSING_AREVA };
-static void TableRead_postprocessing_revai(TableRead *self) { POST_PROCESSING_REVAI };
-static void TableRead_postprocessing_revaa(TableRead *self) { POST_PROCESSING_REVAA };
-static void TableRead_postprocessing_revareva(TableRead *self) { POST_PROCESSING_REVAREVA };
-
static void
-TableRead_setProcMode(TableRead *self)
-{
- int procmode, muladdmode;
- procmode = self->modebuffer[2];
- muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
-
- switch (procmode) {
- case 0:
- self->proc_func_ptr = TableRead_readframes_i;
- break;
- case 1:
- self->proc_func_ptr = TableRead_readframes_a;
- break;
- }
- switch (muladdmode) {
- case 0:
- self->muladd_func_ptr = TableRead_postprocessing_ii;
- break;
- case 1:
- self->muladd_func_ptr = TableRead_postprocessing_ai;
- break;
- case 2:
- self->muladd_func_ptr = TableRead_postprocessing_revai;
- break;
- case 10:
- self->muladd_func_ptr = TableRead_postprocessing_ia;
- break;
- case 11:
- self->muladd_func_ptr = TableRead_postprocessing_aa;
- break;
- case 12:
- self->muladd_func_ptr = TableRead_postprocessing_revaa;
- break;
- case 20:
- self->muladd_func_ptr = TableRead_postprocessing_ireva;
- break;
- case 21:
- self->muladd_func_ptr = TableRead_postprocessing_areva;
- break;
- case 22:
- self->muladd_func_ptr = TableRead_postprocessing_revareva;
- break;
- }
-}
+Pulsar_readframes_iai(Pulsar *self) {
+ MYFLT fr, frac, invfrac, pos, scl_pos, t_pos, e_pos, fpart, tmp;
+ double inc;
+ int i, ipart;
+ MYFLT *tablelist = TableStream_getData(self->table);
+ MYFLT *envlist = TableStream_getData(self->env);
+ int size = TableStream_getSize(self->table);
+ int envsize = TableStream_getSize(self->env);
-static void
-TableRead_compute_next_data_frame(TableRead *self)
-{
- (*self->proc_func_ptr)(self);
- (*self->muladd_func_ptr)(self);
-}
+ 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;
-static int
-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);
- return 0;
-}
+ for (i=0; i<self->bufsize; i++) {
+ self->pointerPos += inc;
+ if (self->pointerPos < 0)
+ self->pointerPos = 1.0 + self->pointerPos;
+ else if (self->pointerPos >= 1.0)
+ self->pointerPos -= 1.0;
+ pos = self->pointerPos + ph[i];
+ if (pos >= 1.0)
+ pos -= 1.0;
+ if (pos < frac) {
+ scl_pos = pos * invfrac;
+ t_pos = scl_pos * size;
+ ipart = (int)t_pos;
+ fpart = t_pos - ipart;
+ tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
-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);
- return 0;
+ 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;
+ }
+ }
}
static void
-TableRead_dealloc(TableRead* self)
-{
- pyo_DEALLOC
- free(self->trigsBuffer);
- TableRead_clear(self);
- self->ob_type->tp_free((PyObject*)self);
-}
+Pulsar_readframes_aai(Pulsar *self) {
+ MYFLT frac, invfrac, pos, scl_pos, t_pos, e_pos, fpart, tmp, oneOnSr;
+ double inc;
+ int i, ipart;
+ MYFLT *tablelist = TableStream_getData(self->table);
+ MYFLT *envlist = TableStream_getData(self->env);
+ int size = TableStream_getSize(self->table);
+ int envsize = TableStream_getSize(self->env);
-static PyObject *
-TableRead_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
-{
- int i;
- MYFLT *tablelist;
- PyObject *tabletmp, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
- TableRead *self;
- self = (TableRead *)type->tp_alloc(type, 0);
+ 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;
- self->freq = PyFloat_FromDouble(1);
- self->loop = 0;
- self->init = 1;
- self->modebuffer[0] = 0;
- self->modebuffer[1] = 0;
- self->modebuffer[2] = 0;
- self->pointerPos = 0.;
- self->interp = 2;
+ oneOnSr = 1.0 / self->sr;
+ for (i=0; i<self->bufsize; i++) {
+ inc = fr[i] * oneOnSr;
+ self->pointerPos += inc;
+ if (self->pointerPos < 0)
+ self->pointerPos = 1.0 + self->pointerPos;
+ else if (self->pointerPos >= 1.0)
+ self->pointerPos -= 1.0;
+ pos = self->pointerPos + ph[i];
+ if (pos >= 1.0)
+ pos -= 1.0;
+ if (pos < frac) {
+ scl_pos = pos * invfrac;
+ t_pos = scl_pos * size;
+ ipart = (int)t_pos;
+ fpart = t_pos - ipart;
+ tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
- INIT_OBJECT_COMMON
- Stream_setFunctionPtr(self->stream, TableRead_compute_next_data_frame);
- self->mode_func_ptr = TableRead_setProcMode;
+ 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;
+ }
+ }
+}
- static char *kwlist[] = {"table", "freq", "loop", "interp", "mul", "add", NULL};
+static void
+Pulsar_readframes_iia(Pulsar *self) {
+ MYFLT fr, ph, pos, curfrac, scl_pos, t_pos, e_pos, fpart, tmp;
+ double inc;
+ int i, ipart;
+ MYFLT *tablelist = TableStream_getData(self->table);
+ MYFLT *envlist = TableStream_getData(self->env);
+ int size = TableStream_getSize(self->table);
+ int envsize = TableStream_getSize(self->env);
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OiiOO", kwlist, &tabletmp, &freqtmp, &self->loop, &self->interp, &multmp, &addtmp))
- Py_RETURN_NONE;
+ fr = PyFloat_AS_DOUBLE(self->freq);
+ ph = PyFloat_AS_DOUBLE(self->phase);
+ MYFLT *frac = Stream_getData((Stream *)self->frac_stream);
+ inc = fr / self->sr;
- if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
- 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", "");
-
- if (freqtmp) {
- PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
- }
-
- if (multmp) {
- PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
- }
+ for (i=0; i<self->bufsize; i++) {
+ curfrac = frac[i];
+ self->pointerPos += inc;
+ if (self->pointerPos < 0)
+ self->pointerPos = 1.0 + self->pointerPos;
+ else if (self->pointerPos >= 1.0)
+ self->pointerPos -= 1.0;
+ pos = self->pointerPos + ph;
+ if (pos >= 1.0)
+ pos -= 1.0;
+ if (pos < curfrac) {
+ scl_pos = pos / curfrac;
+ t_pos = scl_pos * size;
+ ipart = (int)t_pos;
+ fpart = t_pos - ipart;
+ tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
- if (addtmp) {
- PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
+ 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;
+ }
}
+}
- PyObject_CallMethod(self->server, "addStream", "O", self->stream);
-
- self->trigsBuffer = (MYFLT *)realloc(self->trigsBuffer, self->bufsize * sizeof(MYFLT));
+static void
+Pulsar_readframes_aia(Pulsar *self) {
+ MYFLT ph, pos, curfrac, scl_pos, t_pos, e_pos, fpart, tmp, oneOnSr;
+ double inc;
+ int i, ipart;
+ MYFLT *tablelist = TableStream_getData(self->table);
+ MYFLT *envlist = TableStream_getData(self->env);
+ int size = TableStream_getSize(self->table);
+ int envsize = TableStream_getSize(self->env);
- tablelist = TableStream_getData(self->table);
+ 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++) {
- 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;
+ curfrac = frac[i];
+ inc = fr[i] * oneOnSr;
+ self->pointerPos += inc;
+ if (self->pointerPos < 0)
+ self->pointerPos = 1.0 + self->pointerPos;
+ else if (self->pointerPos >= 1.0)
+ self->pointerPos -= 1.0;
+ pos = self->pointerPos + ph;
+ if (pos >= 1.0)
+ pos -= 1.0;
+ if (pos < curfrac) {
+ scl_pos = pos / curfrac;
+ t_pos = scl_pos * size;
+ ipart = (int)t_pos;
+ fpart = t_pos - ipart;
+ tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
- return (PyObject *)self;
+ 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;
+ }
+ }
}
-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_play(TableRead *self, PyObject *args, PyObject *kwds)
-{
- self->pointerPos = 0.0;
- self->init = 1;
- self->go = 1;
- PLAY
-};
+static void
+Pulsar_readframes_iaa(Pulsar *self) {
+ MYFLT fr, pos, curfrac, scl_pos, t_pos, e_pos, fpart, tmp;
+ double inc;
+ int i, ipart;
+ MYFLT *tablelist = TableStream_getData(self->table);
+ MYFLT *envlist = TableStream_getData(self->env);
+ int size = TableStream_getSize(self->table);
+ int envsize = TableStream_getSize(self->env);
-static PyObject * TableRead_out(TableRead *self, PyObject *args, PyObject *kwds)
-{
- self->pointerPos = 0.0;
- self->init = 1;
- self->go = 1;
- OUT
-};
-static PyObject * TableRead_stop(TableRead *self)
-{
- self->go = 0;
- STOP
-};
+ 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;
-static PyObject * TableRead_multiply(TableRead *self, PyObject *arg) { MULTIPLY };
-static PyObject * TableRead_inplace_multiply(TableRead *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * TableRead_add(TableRead *self, PyObject *arg) { ADD };
-static PyObject * TableRead_inplace_add(TableRead *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * TableRead_sub(TableRead *self, PyObject *arg) { SUB };
-static PyObject * TableRead_inplace_sub(TableRead *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * TableRead_div(TableRead *self, PyObject *arg) { DIV };
-static PyObject * TableRead_inplace_div(TableRead *self, PyObject *arg) { INPLACE_DIV };
+ for (i=0; i<self->bufsize; i++) {
+ curfrac = frac[i];
+ self->pointerPos += inc;
+ if (self->pointerPos < 0)
+ self->pointerPos = 1.0 + self->pointerPos;
+ else if (self->pointerPos >= 1.0)
+ self->pointerPos -= 1.0;
+ pos = self->pointerPos + ph[i];
+ if (pos >= 1.0)
+ pos -= 1.0;
+ if (pos < curfrac) {
+ scl_pos = pos / curfrac;
+ t_pos = scl_pos * size;
+ ipart = (int)t_pos;
+ fpart = t_pos - ipart;
+ tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
-static PyObject *
-TableRead_getTable(TableRead* self)
-{
- Py_INCREF(self->table);
- return self->table;
-};
+ 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;
+ }
+ }
+}
-static PyObject *
-TableRead_setTable(TableRead *self, PyObject *arg)
-{
- PyObject *tmp;
+static void
+Pulsar_readframes_aaa(Pulsar *self) {
+ MYFLT pos, curfrac, scl_pos, t_pos, e_pos, fpart, tmp, oneOnSr;
+ double inc;
+ int i, ipart;
+ MYFLT *tablelist = TableStream_getData(self->table);
+ MYFLT *envlist = TableStream_getData(self->env);
+ int size = TableStream_getSize(self->table);
+ int envsize = TableStream_getSize(self->env);
- ASSERT_ARG_NOT_NULL
+ MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
+ MYFLT *ph = Stream_getData((Stream *)self->phase_stream);
+ MYFLT *frac = Stream_getData((Stream *)self->frac_stream);
- tmp = arg;
- Py_DECREF(self->table);
- self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
+ oneOnSr = 1.0 / self->sr;
+ for (i=0; i<self->bufsize; i++) {
+ curfrac = frac[i];
+ inc = fr[i] * oneOnSr;
+ self->pointerPos += inc;
+ if (self->pointerPos < 0)
+ self->pointerPos = 1.0 + self->pointerPos;
+ else if (self->pointerPos >= 1.0)
+ self->pointerPos -= 1.0;
+ pos = self->pointerPos + ph[i];
+ if (pos >= 1.0)
+ pos -= 1.0;
+ if (pos < curfrac) {
+ scl_pos = pos / curfrac;
+ t_pos = scl_pos * size;
+ ipart = (int)t_pos;
+ fpart = t_pos - ipart;
+ tmp = (*self->interp_func_ptr)(tablelist, ipart, fpart, size);
- Py_INCREF(Py_None);
- return Py_None;
+ 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;
+ }
+ }
}
-static PyObject *
-TableRead_setFreq(TableRead *self, PyObject *arg)
-{
- PyObject *tmp, *streamtmp;
-
- ASSERT_ARG_NOT_NULL
+static void Pulsar_postprocessing_ii(Pulsar *self) { POST_PROCESSING_II };
+static void Pulsar_postprocessing_ai(Pulsar *self) { POST_PROCESSING_AI };
+static void Pulsar_postprocessing_ia(Pulsar *self) { POST_PROCESSING_IA };
+static void Pulsar_postprocessing_aa(Pulsar *self) { POST_PROCESSING_AA };
+static void Pulsar_postprocessing_ireva(Pulsar *self) { POST_PROCESSING_IREVA };
+static void Pulsar_postprocessing_areva(Pulsar *self) { POST_PROCESSING_AREVA };
+static void Pulsar_postprocessing_revai(Pulsar *self) { POST_PROCESSING_REVAI };
+static void Pulsar_postprocessing_revaa(Pulsar *self) { POST_PROCESSING_REVAA };
+static void Pulsar_postprocessing_revareva(Pulsar *self) { POST_PROCESSING_REVAREVA };
- int isNumber = PyNumber_Check(arg);
+static void
+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;
- tmp = arg;
- Py_INCREF(tmp);
- Py_DECREF(self->freq);
- if (isNumber == 1) {
- self->freq = PyNumber_Float(tmp);
- self->modebuffer[2] = 0;
- }
- else {
- self->freq = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->freq, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->freq_stream);
- self->freq_stream = (Stream *)streamtmp;
- self->modebuffer[2] = 1;
- }
+ switch (procmode) {
+ case 0:
+ self->proc_func_ptr = Pulsar_readframes_iii;
+ break;
+ case 1:
+ self->proc_func_ptr = Pulsar_readframes_aii;
+ break;
+ case 10:
+ self->proc_func_ptr = Pulsar_readframes_iai;
+ break;
+ case 11:
+ self->proc_func_ptr = Pulsar_readframes_aai;
+ break;
+ case 100:
+ self->proc_func_ptr = Pulsar_readframes_iia;
+ break;
+ case 101:
+ self->proc_func_ptr = Pulsar_readframes_aia;
+ break;
+ case 110:
+ self->proc_func_ptr = Pulsar_readframes_iaa;
+ break;
+ case 111:
+ self->proc_func_ptr = Pulsar_readframes_aaa;
+ break;
+ }
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = Pulsar_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = Pulsar_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = Pulsar_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = Pulsar_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = Pulsar_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = Pulsar_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = Pulsar_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = Pulsar_postprocessing_areva;
+ break;
+ 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->muladd_func_ptr)(self);
+}
+
+static int
+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->frac_stream);
+ return 0;
+}
+
+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->frac_stream);
+ return 0;
+}
+
+static void
+Pulsar_dealloc(Pulsar* self)
+{
+ pyo_DEALLOC
+ Pulsar_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+static PyObject *
+Pulsar_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ 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);
+ self->interp = 2;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+ self->modebuffer[2] = 0;
+ 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 ) {
+ 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 ) {
+ 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", "");
+
+ if (phasetmp) {
+ PyObject_CallMethod((PyObject *)self, "setPhase", "O", phasetmp);
+ }
+
+ if (freqtmp) {
+ PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
+ }
+
+ 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_play(Pulsar *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Pulsar_out(Pulsar *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * Pulsar_stop(Pulsar *self) { STOP };
+
+static PyObject * Pulsar_multiply(Pulsar *self, PyObject *arg) { MULTIPLY };
+static PyObject * Pulsar_inplace_multiply(Pulsar *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Pulsar_add(Pulsar *self, PyObject *arg) { ADD };
+static PyObject * Pulsar_inplace_add(Pulsar *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Pulsar_sub(Pulsar *self, PyObject *arg) { SUB };
+static PyObject * Pulsar_inplace_sub(Pulsar *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Pulsar_div(Pulsar *self, PyObject *arg) { DIV };
+static PyObject * Pulsar_inplace_div(Pulsar *self, PyObject *arg) { INPLACE_DIV };
+
+static PyObject *
+Pulsar_getTable(Pulsar* self)
+{
+ Py_INCREF(self->table);
+ return self->table;
+};
+
+static PyObject *
+Pulsar_getEnv(Pulsar* self)
+{
+ Py_INCREF(self->env);
+ return self->env;
+};
+
+static PyObject *
+Pulsar_setTable(Pulsar *self, PyObject *arg)
+{
+ PyObject *tmp;
+
+ ASSERT_ARG_NOT_NULL
+
+ tmp = arg;
+ Py_DECREF(self->table);
+ self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
+
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
-TableRead_setLoop(TableRead *self, PyObject *arg)
+Pulsar_setEnv(Pulsar *self, PyObject *arg)
{
+ PyObject *tmp;
+
ASSERT_ARG_NOT_NULL
- self->loop = PyInt_AsLong(arg);
+ tmp = arg;
+ Py_DECREF(self->env);
+ self->env = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
static PyObject *
-TableRead_setInterp(TableRead *self, PyObject *arg)
+Pulsar_setFreq(Pulsar *self, PyObject *arg)
{
+ PyObject *tmp, *streamtmp;
+
ASSERT_ARG_NOT_NULL
- int isNumber = PyNumber_Check(arg);
+ int isNumber = PyNumber_Check(arg);
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->freq);
if (isNumber == 1) {
- self->interp = PyInt_AsLong(PyNumber_Int(arg));
- }
+ self->freq = PyNumber_Float(tmp);
+ self->modebuffer[2] = 0;
+ }
+ else {
+ self->freq = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->freq, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->freq_stream);
+ self->freq_stream = (Stream *)streamtmp;
+ self->modebuffer[2] = 1;
+ }
- SET_INTERP_POINTER
+ (*self->mode_func_ptr)(self);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
static PyObject *
-TableRead_reset(TableRead *self)
+Pulsar_setPhase(Pulsar *self, PyObject *arg)
{
- self->pointerPos = 0.0;
+ PyObject *tmp, *streamtmp;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->phase);
+ if (isNumber == 1) {
+ self->phase = PyNumber_Float(tmp);
+ self->modebuffer[3] = 0;
+ }
+ else {
+ self->phase = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->phase, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->phase_stream);
+ 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;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->frac);
+ if (isNumber == 1) {
+ self->frac = PyNumber_Float(tmp);
+ self->modebuffer[4] = 0;
+ }
+ else {
+ self->frac = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->frac, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->frac_stream);
+ 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)
+{
+ ASSERT_ARG_NOT_NULL
+
+ 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 PyMemberDef TableRead_members[] = {
-{"server", T_OBJECT_EX, offsetof(TableRead, server), 0, "Pyo server."},
-{"stream", T_OBJECT_EX, offsetof(TableRead, stream), 0, "Stream object."},
-{"trig_stream", T_OBJECT_EX, offsetof(TableRead, trig_stream), 0, "Trigger Stream object."},
-{"table", T_OBJECT_EX, offsetof(TableRead, table), 0, "Waveform table."},
-{"freq", T_OBJECT_EX, offsetof(TableRead, freq), 0, "Frequency in cycle per second."},
-{"mul", T_OBJECT_EX, offsetof(TableRead, mul), 0, "Mul factor."},
-{"add", T_OBJECT_EX, offsetof(TableRead, add), 0, "Add factor."},
+static PyMemberDef Pulsar_members[] = {
+{"server", T_OBJECT_EX, offsetof(Pulsar, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(Pulsar, stream), 0, "Stream object."},
+{"table", T_OBJECT_EX, offsetof(Pulsar, table), 0, "Waveform table."},
+{"freq", T_OBJECT_EX, offsetof(Pulsar, freq), 0, "Frequency in cycle per second."},
+{"phase", T_OBJECT_EX, offsetof(Pulsar, phase), 0, "Oscillator phase."},
+{"frac", T_OBJECT_EX, offsetof(Pulsar, frac), 0, "Table width inside whole length."},
+{"mul", T_OBJECT_EX, offsetof(Pulsar, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(Pulsar, add), 0, "Add factor."},
{NULL} /* Sentinel */
};
-static PyMethodDef TableRead_methods[] = {
-{"getTable", (PyCFunction)TableRead_getTable, METH_NOARGS, "Returns waveform table object."},
-{"getServer", (PyCFunction)TableRead_getServer, METH_NOARGS, "Returns server object."},
-{"_getStream", (PyCFunction)TableRead_getStream, METH_NOARGS, "Returns stream object."},
-{"_getTriggerStream", (PyCFunction)TableRead_getTriggerStream, METH_NOARGS, "Returns trigger stream object."},
-{"play", (PyCFunction)TableRead_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
-{"out", (PyCFunction)TableRead_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
-{"stop", (PyCFunction)TableRead_stop, METH_NOARGS, "Stops computing."},
-{"setTable", (PyCFunction)TableRead_setTable, METH_O, "Sets oscillator table."},
-{"setFreq", (PyCFunction)TableRead_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
-{"setLoop", (PyCFunction)TableRead_setLoop, METH_O, "Sets the looping mode."},
-{"setInterp", (PyCFunction)TableRead_setInterp, METH_O, "Sets reader interpolation mode."},
-{"reset", (PyCFunction)TableRead_reset, METH_NOARGS, "Resets pointer position to 0."},
-{"setMul", (PyCFunction)TableRead_setMul, METH_O, "Sets oscillator mul factor."},
-{"setAdd", (PyCFunction)TableRead_setAdd, METH_O, "Sets oscillator add factor."},
-{"setSub", (PyCFunction)TableRead_setSub, METH_O, "Sets oscillator inverse add factor."},
-{"setDiv", (PyCFunction)TableRead_setDiv, METH_O, "Sets inverse mul factor."},
+static PyMethodDef Pulsar_methods[] = {
+{"getTable", (PyCFunction)Pulsar_getTable, METH_NOARGS, "Returns waveform table object."},
+{"getEnv", (PyCFunction)Pulsar_getEnv, METH_NOARGS, "Returns object envelope."},
+{"getServer", (PyCFunction)Pulsar_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)Pulsar_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)Pulsar_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"out", (PyCFunction)Pulsar_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"stop", (PyCFunction)Pulsar_stop, METH_NOARGS, "Stops computing."},
+{"setTable", (PyCFunction)Pulsar_setTable, METH_O, "Sets oscillator table."},
+{"setEnv", (PyCFunction)Pulsar_setEnv, METH_O, "Sets envelope table."},
+{"setFreq", (PyCFunction)Pulsar_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
+{"setPhase", (PyCFunction)Pulsar_setPhase, METH_O, "Sets oscillator phase."},
+{"setFrac", (PyCFunction)Pulsar_setFrac, METH_O, "Sets waveform width inside whole period length."},
+{"setInterp", (PyCFunction)Pulsar_setInterp, METH_O, "Sets Pulsar interpolation mode."},
+{"setMul", (PyCFunction)Pulsar_setMul, METH_O, "Sets oscillator mul factor."},
+{"setAdd", (PyCFunction)Pulsar_setAdd, METH_O, "Sets oscillator add factor."},
+{"setSub", (PyCFunction)Pulsar_setSub, METH_O, "Sets oscillator inverse add factor."},
+{"setDiv", (PyCFunction)Pulsar_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
-static PyNumberMethods TableRead_as_number = {
-(binaryfunc)TableRead_add, /*nb_add*/
-(binaryfunc)TableRead_sub, /*nb_subtract*/
-(binaryfunc)TableRead_multiply, /*nb_multiply*/
-(binaryfunc)TableRead_div, /*nb_divide*/
+static PyNumberMethods Pulsar_as_number = {
+(binaryfunc)Pulsar_add, /*nb_add*/
+(binaryfunc)Pulsar_sub, /*nb_subtract*/
+(binaryfunc)Pulsar_multiply, /*nb_multiply*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5709,16 +5732,16 @@ static PyNumberMethods TableRead_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
-(binaryfunc)TableRead_inplace_add, /*inplace_add*/
-(binaryfunc)TableRead_inplace_sub, /*inplace_subtract*/
-(binaryfunc)TableRead_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)TableRead_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+(binaryfunc)Pulsar_inplace_add, /*inplace_add*/
+(binaryfunc)Pulsar_inplace_sub, /*inplace_subtract*/
+(binaryfunc)Pulsar_inplace_multiply, /*inplace_multiply*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5727,25 +5750,24 @@ static PyNumberMethods TableRead_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Pulsar_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Pulsar_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
-PyTypeObject TableReadType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
-"_pyo.TableRead_base", /*tp_name*/
-sizeof(TableRead), /*tp_basicsize*/
+PyTypeObject PulsarType = {
+PyVarObject_HEAD_INIT(NULL, 0)
+"_pyo.Pulsar_base", /*tp_name*/
+sizeof(Pulsar), /*tp_basicsize*/
0, /*tp_itemsize*/
-(destructor)TableRead_dealloc, /*tp_dealloc*/
+(destructor)Pulsar_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
-&TableRead_as_number, /*tp_as_number*/
+&Pulsar_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -5755,15 +5777,15 @@ sizeof(TableRead), /*tp_basicsize*/
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
-"TableRead objects. Generates an oscillatory waveform.", /* tp_doc */
-(traverseproc)TableRead_traverse, /* tp_traverse */
-(inquiry)TableRead_clear, /* tp_clear */
+"Pulsar objects. Generates pulsar synthesis oscillator.", /* tp_doc */
+(traverseproc)Pulsar_traverse, /* tp_traverse */
+(inquiry)Pulsar_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
-TableRead_methods, /* tp_methods */
-TableRead_members, /* tp_members */
+Pulsar_methods, /* tp_methods */
+Pulsar_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -5772,582 +5794,444 @@ TableRead_members, /* tp_members */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
-TableRead_new, /* tp_new */
+Pulsar_new, /* tp_new */
};
-/*************/
-/* Fm object */
-/*************/
+/**************/
+/* TableRead object */
+/**************/
typedef struct {
pyo_audio_HEAD
- PyObject *car;
- Stream *car_stream;
- PyObject *ratio;
- Stream *ratio_stream;
- PyObject *index;
- Stream *index_stream;
- int modebuffer[5];
- MYFLT pointerPos_car;
- MYFLT pointerPos_mod;
- MYFLT scaleFactor;
-} Fm;
+ PyObject *table;
+ PyObject *freq;
+ Stream *freq_stream;
+ int loop;
+ int go;
+ int modebuffer[3];
+ double pointerPos;
+ MYFLT *trigsBuffer;
+ TriggerStream *trig_stream;
+ 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;
static void
-Fm_readframes_iii(Fm *self) {
- MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
+TableRead_readframes_i(TableRead *self) {
+ MYFLT fr, inc, fpart;
int i, ipart;
+ MYFLT *tablelist = TableStream_getData(self->table);
+ int size = TableStream_getSize(self->table);
- MYFLT car = PyFloat_AS_DOUBLE(self->car);
- MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
- MYFLT ind = PyFloat_AS_DOUBLE(self->index);
+ fr = PyFloat_AS_DOUBLE(self->freq);
+ inc = fr * size / self->sr;
- mod_freq = car * rat;
- mod_amp = mod_freq * ind;
- mod_delta = mod_freq * self->scaleFactor;
+ if (self->go == 0)
+ PyObject_CallMethod((PyObject *)self, "stop", NULL);
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;
+ self->trigsBuffer[i] = 0.0;
+ if (self->pointerPos < 0) {
+ if (self->init == 0)
+ self->trigsBuffer[i] = 1.0;
+ else
+ self->init = 0;
+ self->pointerPos = size + self->pointerPos;
+ }
+ else if (self->pointerPos >= size && self->go) {
+ self->trigsBuffer[i] = 1.0;
+ if (self->loop == 1)
+ self->pointerPos -= size;
+ else
+ self->go = 0;
+ }
+ if (self->go == 1) {
+ 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;
- car_freq = car + mod_val;
- car_delta = car_freq * self->scaleFactor;
- self->pointerPos_car = Sine_clip(self->pointerPos_car);
- ipart = (int)self->pointerPos_car;
- fpart = self->pointerPos_car - ipart;
- self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos_car += car_delta;
+ self->pointerPos += inc;
}
}
static void
-Fm_readframes_aii(Fm *self) {
- MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
+TableRead_readframes_a(TableRead *self) {
+ MYFLT inc, fpart, sizeOnSr;
int i, ipart;
+ MYFLT *tablelist = TableStream_getData(self->table);
+ int size = TableStream_getSize(self->table);
- MYFLT *car = Stream_getData((Stream *)self->car_stream);
- MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
- MYFLT ind = PyFloat_AS_DOUBLE(self->index);
+ MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
- for (i=0; i<self->bufsize; i++) {
- mod_freq = car[i] * rat;
- mod_amp = mod_freq * ind;
- mod_delta = mod_freq * self->scaleFactor;
- 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;
+ sizeOnSr = size / self->sr;
- car_freq = car[i] + mod_val;
- car_delta = car_freq * self->scaleFactor;
- self->pointerPos_car = Sine_clip(self->pointerPos_car);
- ipart = (int)self->pointerPos_car;
- fpart = self->pointerPos_car - ipart;
- self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos_car += car_delta;
+ if (self->go == 0)
+ PyObject_CallMethod((PyObject *)self, "stop", NULL);
+
+ for (i=0; i<self->bufsize; i++) {
+ self->trigsBuffer[i] = 0.0;
+ if (self->pointerPos < 0) {
+ if (self->init == 0)
+ self->trigsBuffer[i] = 1.0;
+ else
+ self->init = 0;
+ self->pointerPos = size + self->pointerPos;
+ }
+ else if (self->pointerPos >= size && self->go) {
+ self->trigsBuffer[i] = 1.0;
+ if (self->loop == 1)
+ self->pointerPos -= size;
+ else
+ self->go = 0;
+ }
+ if (self->go == 1) {
+ 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;
}
}
+static void TableRead_postprocessing_ii(TableRead *self) { POST_PROCESSING_II };
+static void TableRead_postprocessing_ai(TableRead *self) { POST_PROCESSING_AI };
+static void TableRead_postprocessing_ia(TableRead *self) { POST_PROCESSING_IA };
+static void TableRead_postprocessing_aa(TableRead *self) { POST_PROCESSING_AA };
+static void TableRead_postprocessing_ireva(TableRead *self) { POST_PROCESSING_IREVA };
+static void TableRead_postprocessing_areva(TableRead *self) { POST_PROCESSING_AREVA };
+static void TableRead_postprocessing_revai(TableRead *self) { POST_PROCESSING_REVAI };
+static void TableRead_postprocessing_revaa(TableRead *self) { POST_PROCESSING_REVAA };
+static void TableRead_postprocessing_revareva(TableRead *self) { POST_PROCESSING_REVAREVA };
+
static void
-Fm_readframes_iai(Fm *self) {
- MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
- int i, ipart;
+TableRead_setProcMode(TableRead *self)
+{
+ int procmode, muladdmode;
+ procmode = self->modebuffer[2];
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
- MYFLT car = PyFloat_AS_DOUBLE(self->car);
- MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
- MYFLT ind = PyFloat_AS_DOUBLE(self->index);
+ switch (procmode) {
+ case 0:
+ self->proc_func_ptr = TableRead_readframes_i;
+ break;
+ case 1:
+ self->proc_func_ptr = TableRead_readframes_a;
+ break;
+ }
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = TableRead_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = TableRead_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = TableRead_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = TableRead_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = TableRead_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = TableRead_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = TableRead_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = TableRead_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = TableRead_postprocessing_revareva;
+ break;
+ }
+}
- for (i=0; i<self->bufsize; i++) {
- mod_freq = car * rat[i];
- mod_amp = mod_freq * ind;
- mod_delta = mod_freq * self->scaleFactor;
- 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;
+static void
+TableRead_compute_next_data_frame(TableRead *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
- car_freq = car + mod_val;
- car_delta = car_freq * self->scaleFactor;
- self->pointerPos_car = Sine_clip(self->pointerPos_car);
- ipart = (int)self->pointerPos_car;
- fpart = self->pointerPos_car - ipart;
- self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos_car += car_delta;
- }
+static int
+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);
+ return 0;
+}
+
+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);
+ return 0;
}
static void
-Fm_readframes_aai(Fm *self) {
- MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
- int i, ipart;
+TableRead_dealloc(TableRead* self)
+{
+ pyo_DEALLOC
+ free(self->trigsBuffer);
+ TableRead_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
- MYFLT *car = Stream_getData((Stream *)self->car_stream);
- MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
- MYFLT ind = PyFloat_AS_DOUBLE(self->index);
+static PyObject *
+TableRead_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ MYFLT *tablelist;
+ PyObject *tabletmp, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
+ TableRead *self;
+ self = (TableRead *)type->tp_alloc(type, 0);
- for (i=0; i<self->bufsize; i++) {
- mod_freq = car[i] * rat[i];
- mod_amp = mod_freq * ind;
- mod_delta = mod_freq * self->scaleFactor;
- 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;
+ self->freq = PyFloat_FromDouble(1);
+ self->loop = 0;
+ self->init = 1;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+ self->modebuffer[2] = 0;
+ self->pointerPos = 0.;
+ self->interp = 2;
- car_freq = car[i] + mod_val;
- car_delta = car_freq * self->scaleFactor;
- self->pointerPos_car = Sine_clip(self->pointerPos_car);
- ipart = (int)self->pointerPos_car;
- fpart = self->pointerPos_car - ipart;
- self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos_car += car_delta;
- }}
+ INIT_OBJECT_COMMON
+ Stream_setFunctionPtr(self->stream, TableRead_compute_next_data_frame);
+ self->mode_func_ptr = TableRead_setProcMode;
-static void
-Fm_readframes_iia(Fm *self) {
- MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
- int i, ipart;
+ static char *kwlist[] = {"table", "freq", "loop", "interp", "mul", "add", NULL};
- MYFLT car = PyFloat_AS_DOUBLE(self->car);
- MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
- MYFLT *ind = Stream_getData((Stream *)self->index_stream);
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OiiOO", kwlist, &tabletmp, &freqtmp, &self->loop, &self->interp, &multmp, &addtmp))
+ Py_RETURN_NONE;
- mod_freq = car * rat;
- mod_delta = mod_freq * self->scaleFactor;
+ if ( PyObject_HasAttrString((PyObject *)tabletmp, "getTableStream") == 0 ) {
+ 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", "");
- for (i=0; i<self->bufsize; i++) {
- mod_amp = mod_freq * ind[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;
+ if (freqtmp) {
+ PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
+ }
- car_freq = car + mod_val;
- car_delta = car_freq * self->scaleFactor;
- self->pointerPos_car = Sine_clip(self->pointerPos_car);
- ipart = (int)self->pointerPos_car;
- fpart = self->pointerPos_car - ipart;
- self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos_car += car_delta;
+ if (multmp) {
+ PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
}
-}
-static void
-Fm_readframes_aia(Fm *self) {
- MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
- int i, ipart;
+ if (addtmp) {
+ PyObject_CallMethod((PyObject *)self, "setAdd", "O", addtmp);
+ }
- MYFLT *car = Stream_getData((Stream *)self->car_stream);
- MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
- MYFLT *ind = Stream_getData((Stream *)self->index_stream);
+ 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++) {
- mod_freq = car[i] * rat;
- mod_amp = mod_freq * ind[i];
- mod_delta = mod_freq * self->scaleFactor;
- 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;
+ self->trigsBuffer[i] = 0.0;
+ self->data[i] = tablelist[0];
+ }
- car_freq = car[i] + mod_val;
- car_delta = car_freq * self->scaleFactor;
- self->pointerPos_car = Sine_clip(self->pointerPos_car);
- ipart = (int)self->pointerPos_car;
- fpart = self->pointerPos_car - ipart;
- self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos_car += car_delta;
- }
-}
+ MAKE_NEW_TRIGGER_STREAM(self->trig_stream, &TriggerStreamType, NULL);
+ TriggerStream_setData(self->trig_stream, self->trigsBuffer);
-static void
-Fm_readframes_iaa(Fm *self) {
- MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
- int i, ipart;
+ (*self->mode_func_ptr)(self);
- MYFLT car = PyFloat_AS_DOUBLE(self->car);
- MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
- MYFLT *ind = Stream_getData((Stream *)self->index_stream);
+ SET_INTERP_POINTER
- for (i=0; i<self->bufsize; i++) {
- mod_freq = car * rat[i];
- mod_amp = mod_freq * ind[i];
- mod_delta = mod_freq * self->scaleFactor;
- 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;
+ self->init = 1;
- car_freq = car + mod_val;
- car_delta = car_freq * self->scaleFactor;
- self->pointerPos_car = Sine_clip(self->pointerPos_car);
- ipart = (int)self->pointerPos_car;
- fpart = self->pointerPos_car - ipart;
- self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos_car += car_delta;
- }
+ return (PyObject *)self;
}
-static void
-Fm_readframes_aaa(Fm *self) {
- MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
- int i, ipart;
+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 };
- MYFLT *car = Stream_getData((Stream *)self->car_stream);
- MYFLT *rat = Stream_getData((Stream *)self->ratio_stream);
- MYFLT *ind = Stream_getData((Stream *)self->index_stream);
+static PyObject * TableRead_play(TableRead *self, PyObject *args, PyObject *kwds)
+{
+ self->pointerPos = 0.0;
+ self->init = 1;
+ self->go = 1;
+ PLAY
+};
- for (i=0; i<self->bufsize; i++) {
- mod_freq = car[i] * rat[i];
- mod_amp = mod_freq * ind[i];
- mod_delta = mod_freq * self->scaleFactor;
- 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;
+static PyObject * TableRead_out(TableRead *self, PyObject *args, PyObject *kwds)
+{
+ self->pointerPos = 0.0;
+ self->init = 1;
+ self->go = 1;
+ OUT
+};
+static PyObject * TableRead_stop(TableRead *self)
+{
+ self->go = 0;
+ STOP
+};
- car_freq = car[i] + mod_val;
- car_delta = car_freq * self->scaleFactor;
- self->pointerPos_car = Sine_clip(self->pointerPos_car);
- ipart = (int)self->pointerPos_car;
- fpart = self->pointerPos_car - ipart;
- self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
- self->pointerPos_car += car_delta;
- }
-}
+static PyObject * TableRead_multiply(TableRead *self, PyObject *arg) { MULTIPLY };
+static PyObject * TableRead_inplace_multiply(TableRead *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * TableRead_add(TableRead *self, PyObject *arg) { ADD };
+static PyObject * TableRead_inplace_add(TableRead *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * TableRead_sub(TableRead *self, PyObject *arg) { SUB };
+static PyObject * TableRead_inplace_sub(TableRead *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * TableRead_div(TableRead *self, PyObject *arg) { DIV };
+static PyObject * TableRead_inplace_div(TableRead *self, PyObject *arg) { INPLACE_DIV };
-static void Fm_postprocessing_ii(Fm *self) { POST_PROCESSING_II };
-static void Fm_postprocessing_ai(Fm *self) { POST_PROCESSING_AI };
-static void Fm_postprocessing_ia(Fm *self) { POST_PROCESSING_IA };
-static void Fm_postprocessing_aa(Fm *self) { POST_PROCESSING_AA };
-static void Fm_postprocessing_ireva(Fm *self) { POST_PROCESSING_IREVA };
-static void Fm_postprocessing_areva(Fm *self) { POST_PROCESSING_AREVA };
-static void Fm_postprocessing_revai(Fm *self) { POST_PROCESSING_REVAI };
-static void Fm_postprocessing_revaa(Fm *self) { POST_PROCESSING_REVAA };
-static void Fm_postprocessing_revareva(Fm *self) { POST_PROCESSING_REVAREVA };
+static PyObject *
+TableRead_getTable(TableRead* self)
+{
+ Py_INCREF(self->table);
+ return self->table;
+};
-static void
-Fm_setProcMode(Fm *self)
+static PyObject *
+TableRead_setTable(TableRead *self, PyObject *arg)
{
- int procmode, muladdmode;
- procmode = self->modebuffer[2] + self->modebuffer[3] * 10 + self->modebuffer[4] * 100;
- muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+ PyObject *tmp;
- switch (procmode) {
- case 0:
- self->proc_func_ptr = Fm_readframes_iii;
- break;
- case 1:
- self->proc_func_ptr = Fm_readframes_aii;
- break;
- case 10:
- self->proc_func_ptr = Fm_readframes_iai;
- break;
- case 11:
- self->proc_func_ptr = Fm_readframes_aai;
- break;
- case 100:
- self->proc_func_ptr = Fm_readframes_iia;
- break;
- case 101:
- self->proc_func_ptr = Fm_readframes_aia;
- break;
- case 110:
- self->proc_func_ptr = Fm_readframes_iaa;
- break;
- case 111:
- self->proc_func_ptr = Fm_readframes_aaa;
- break;
- }
+ ASSERT_ARG_NOT_NULL
- switch (muladdmode) {
- case 0:
- self->muladd_func_ptr = Fm_postprocessing_ii;
- break;
- case 1:
- self->muladd_func_ptr = Fm_postprocessing_ai;
- break;
- case 2:
- self->muladd_func_ptr = Fm_postprocessing_revai;
- break;
- case 10:
- self->muladd_func_ptr = Fm_postprocessing_ia;
- break;
- case 11:
- self->muladd_func_ptr = Fm_postprocessing_aa;
- break;
- case 12:
- self->muladd_func_ptr = Fm_postprocessing_revaa;
- break;
- case 20:
- self->muladd_func_ptr = Fm_postprocessing_ireva;
- break;
- case 21:
- self->muladd_func_ptr = Fm_postprocessing_areva;
- break;
- case 22:
- self->muladd_func_ptr = Fm_postprocessing_revareva;
- break;
- }
-}
+ tmp = arg;
+ Py_DECREF(self->table);
+ self->table = PyObject_CallMethod((PyObject *)tmp, "getTableStream", "");
-static void
-Fm_compute_next_data_frame(Fm *self)
-{
- (*self->proc_func_ptr)(self);
- (*self->muladd_func_ptr)(self);
+ Py_INCREF(Py_None);
+ return Py_None;
}
-static int
-Fm_traverse(Fm *self, visitproc visit, void *arg)
+static PyObject *
+TableRead_setFreq(TableRead *self, PyObject *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);
- return 0;
-}
+ PyObject *tmp, *streamtmp;
-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);
- return 0;
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->freq);
+ if (isNumber == 1) {
+ self->freq = PyNumber_Float(tmp);
+ self->modebuffer[2] = 0;
+ }
+ else {
+ self->freq = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->freq, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->freq_stream);
+ self->freq_stream = (Stream *)streamtmp;
+ self->modebuffer[2] = 1;
+ }
+
+ (*self->mode_func_ptr)(self);
+
+ Py_INCREF(Py_None);
+ return Py_None;
}
-static void
-Fm_dealloc(Fm* self)
+static PyObject *
+TableRead_setLoop(TableRead *self, PyObject *arg)
{
- pyo_DEALLOC
- Fm_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ ASSERT_ARG_NOT_NULL
+
+ self->loop = PyInt_AsLong(arg);
+
+ Py_INCREF(Py_None);
+ return Py_None;
}
static PyObject *
-Fm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+TableRead_setInterp(TableRead *self, PyObject *arg)
{
- int i;
- PyObject *cartmp=NULL, *ratiotmp=NULL, *indextmp=NULL, *multmp=NULL, *addtmp=NULL;
- Fm *self;
- self = (Fm *)type->tp_alloc(type, 0);
+ ASSERT_ARG_NOT_NULL
- self->car = PyFloat_FromDouble(100);
- self->ratio = PyFloat_FromDouble(0.5);
- self->index = PyFloat_FromDouble(5);
- self->modebuffer[0] = 0;
- self->modebuffer[1] = 0;
- self->modebuffer[2] = 0;
- 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;
-
- 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);
- }
-
- 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;
-}
-
-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_play(Fm *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * Fm_out(Fm *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * Fm_stop(Fm *self) { STOP };
-
-static PyObject * Fm_multiply(Fm *self, PyObject *arg) { MULTIPLY };
-static PyObject * Fm_inplace_multiply(Fm *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * Fm_add(Fm *self, PyObject *arg) { ADD };
-static PyObject * Fm_inplace_add(Fm *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * Fm_sub(Fm *self, PyObject *arg) { SUB };
-static PyObject * Fm_inplace_sub(Fm *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * Fm_div(Fm *self, PyObject *arg) { DIV };
-static PyObject * Fm_inplace_div(Fm *self, PyObject *arg) { INPLACE_DIV };
-
-static PyObject *
-Fm_setCarrier(Fm *self, PyObject *arg)
-{
- PyObject *tmp, *streamtmp;
-
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
-
- tmp = arg;
- Py_INCREF(tmp);
- Py_DECREF(self->car);
- if (isNumber == 1) {
- self->car = PyNumber_Float(tmp);
- self->modebuffer[2] = 0;
- }
- else {
- self->car = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->car, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->car_stream);
- 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;
-
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
+ int isNumber = PyNumber_Check(arg);
- tmp = arg;
- Py_INCREF(tmp);
- Py_DECREF(self->ratio);
if (isNumber == 1) {
- self->ratio = PyNumber_Float(tmp);
- self->modebuffer[3] = 0;
- }
- else {
- self->ratio = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->ratio, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->ratio_stream);
- self->ratio_stream = (Stream *)streamtmp;
- self->modebuffer[3] = 1;
- }
+ self->interp = PyInt_AsLong(PyNumber_Int(arg));
+ }
- (*self->mode_func_ptr)(self);
+ SET_INTERP_POINTER
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
static PyObject *
-Fm_setIndex(Fm *self, PyObject *arg)
+TableRead_reset(TableRead *self)
{
- PyObject *tmp, *streamtmp;
-
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
-
- tmp = arg;
- Py_INCREF(tmp);
- Py_DECREF(self->index);
- if (isNumber == 1) {
- self->index = PyNumber_Float(tmp);
- self->modebuffer[4] = 0;
- }
- else {
- self->index = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->index, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->index_stream);
- self->index_stream = (Stream *)streamtmp;
- self->modebuffer[4] = 1;
- }
-
- (*self->mode_func_ptr)(self);
-
- Py_INCREF(Py_None);
- return Py_None;
+ self->pointerPos = 0.0;
+ Py_INCREF(Py_None);
+ return Py_None;
}
-static PyMemberDef Fm_members[] = {
-{"server", T_OBJECT_EX, offsetof(Fm, server), 0, "Pyo server."},
-{"stream", T_OBJECT_EX, offsetof(Fm, stream), 0, "Stream object."},
-{"carrier", T_OBJECT_EX, offsetof(Fm, car), 0, "Frequency in cycle per second."},
-{"ratio", T_OBJECT_EX, offsetof(Fm, ratio), 0, "Ratio carrier:modulator (mod freq = car*mod)."},
-{"index", T_OBJECT_EX, offsetof(Fm, index), 0, "Modulation index (mod amp = mod freq*index)."},
-{"mul", T_OBJECT_EX, offsetof(Fm, mul), 0, "Mul factor."},
-{"add", T_OBJECT_EX, offsetof(Fm, add), 0, "Add factor."},
+static PyMemberDef TableRead_members[] = {
+{"server", T_OBJECT_EX, offsetof(TableRead, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(TableRead, stream), 0, "Stream object."},
+{"trig_stream", T_OBJECT_EX, offsetof(TableRead, trig_stream), 0, "Trigger Stream object."},
+{"table", T_OBJECT_EX, offsetof(TableRead, table), 0, "Waveform table."},
+{"freq", T_OBJECT_EX, offsetof(TableRead, freq), 0, "Frequency in cycle per second."},
+{"mul", T_OBJECT_EX, offsetof(TableRead, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(TableRead, add), 0, "Add factor."},
{NULL} /* Sentinel */
};
-static PyMethodDef Fm_methods[] = {
-{"getServer", (PyCFunction)Fm_getServer, METH_NOARGS, "Returns server object."},
-{"_getStream", (PyCFunction)Fm_getStream, METH_NOARGS, "Returns stream object."},
-{"play", (PyCFunction)Fm_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
-{"out", (PyCFunction)Fm_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
-{"stop", (PyCFunction)Fm_stop, METH_NOARGS, "Stops computing."},
-{"setCarrier", (PyCFunction)Fm_setCarrier, METH_O, "Sets carrier frequency in cycle per second."},
-{"setRatio", (PyCFunction)Fm_setRatio, METH_O, "Sets car:mod ratio."},
-{"setIndex", (PyCFunction)Fm_setIndex, METH_O, "Sets modulation index."},
-{"setMul", (PyCFunction)Fm_setMul, METH_O, "Sets Fm mul factor."},
-{"setAdd", (PyCFunction)Fm_setAdd, METH_O, "Sets Fm add factor."},
-{"setSub", (PyCFunction)Fm_setSub, METH_O, "Sets inverse add factor."},
-{"setDiv", (PyCFunction)Fm_setDiv, METH_O, "Sets inverse mul factor."},
+static PyMethodDef TableRead_methods[] = {
+{"getTable", (PyCFunction)TableRead_getTable, METH_NOARGS, "Returns waveform table object."},
+{"getServer", (PyCFunction)TableRead_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)TableRead_getStream, METH_NOARGS, "Returns stream object."},
+{"_getTriggerStream", (PyCFunction)TableRead_getTriggerStream, METH_NOARGS, "Returns trigger stream object."},
+{"play", (PyCFunction)TableRead_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"out", (PyCFunction)TableRead_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"stop", (PyCFunction)TableRead_stop, METH_NOARGS, "Stops computing."},
+{"setTable", (PyCFunction)TableRead_setTable, METH_O, "Sets oscillator table."},
+{"setFreq", (PyCFunction)TableRead_setFreq, METH_O, "Sets oscillator frequency in cycle per second."},
+{"setLoop", (PyCFunction)TableRead_setLoop, METH_O, "Sets the looping mode."},
+{"setInterp", (PyCFunction)TableRead_setInterp, METH_O, "Sets reader interpolation mode."},
+{"reset", (PyCFunction)TableRead_reset, METH_NOARGS, "Resets pointer position to 0."},
+{"setMul", (PyCFunction)TableRead_setMul, METH_O, "Sets oscillator mul factor."},
+{"setAdd", (PyCFunction)TableRead_setAdd, METH_O, "Sets oscillator add factor."},
+{"setSub", (PyCFunction)TableRead_setSub, METH_O, "Sets oscillator inverse add factor."},
+{"setDiv", (PyCFunction)TableRead_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
-static PyNumberMethods Fm_as_number = {
-(binaryfunc)Fm_add, /*nb_add*/
-(binaryfunc)Fm_sub, /*nb_subtract*/
-(binaryfunc)Fm_multiply, /*nb_multiply*/
-(binaryfunc)Fm_div, /*nb_divide*/
+static PyNumberMethods TableRead_as_number = {
+(binaryfunc)TableRead_add, /*nb_add*/
+(binaryfunc)TableRead_sub, /*nb_subtract*/
+(binaryfunc)TableRead_multiply, /*nb_multiply*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
0, /*nb_neg*/
0, /*nb_pos*/
-0, /*(unaryfunc)array_abs*/
+0, /*(unaryfunc)array_abs,*/
0, /*nb_nonzero*/
0, /*nb_invert*/
0, /*nb_lshift*/
@@ -6355,16 +6239,16 @@ static PyNumberMethods Fm_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
-(binaryfunc)Fm_inplace_add, /*inplace_add*/
-(binaryfunc)Fm_inplace_sub, /*inplace_subtract*/
-(binaryfunc)Fm_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Fm_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+(binaryfunc)TableRead_inplace_add, /*inplace_add*/
+(binaryfunc)TableRead_inplace_sub, /*inplace_subtract*/
+(binaryfunc)TableRead_inplace_multiply, /*inplace_multiply*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -6373,25 +6257,24 @@ static PyNumberMethods Fm_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)TableRead_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)TableRead_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
-PyTypeObject FmType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
-"_pyo.Fm_base", /*tp_name*/
-sizeof(Fm), /*tp_basicsize*/
+PyTypeObject TableReadType = {
+PyVarObject_HEAD_INIT(NULL, 0)
+"_pyo.TableRead_base", /*tp_name*/
+sizeof(TableRead), /*tp_basicsize*/
0, /*tp_itemsize*/
-(destructor)Fm_dealloc, /*tp_dealloc*/
+(destructor)TableRead_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
-&Fm_as_number, /*tp_as_number*/
+&TableRead_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -6400,16 +6283,16 @@ sizeof(Fm), /*tp_basicsize*/
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*/
-"Fm objects. Generates a frequency modulation synthesis.", /* tp_doc */
-(traverseproc)Fm_traverse, /* tp_traverse */
-(inquiry)Fm_clear, /* tp_clear */
+Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
+"TableRead objects. Generates an oscillatory waveform.", /* tp_doc */
+(traverseproc)TableRead_traverse, /* tp_traverse */
+(inquiry)TableRead_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
-Fm_methods, /* tp_methods */
-Fm_members, /* tp_members */
+TableRead_methods, /* tp_methods */
+TableRead_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -6418,11 +6301,11 @@ Fm_members, /* tp_members */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
-Fm_new, /* tp_new */
+TableRead_new, /* tp_new */
};
/*************/
-/* CrossFm object */
+/* Fm object */
/*************/
typedef struct {
pyo_audio_HEAD
@@ -6430,240 +6313,1925 @@ typedef struct {
Stream *car_stream;
PyObject *ratio;
Stream *ratio_stream;
- PyObject *ind1;
- Stream *ind1_stream;
- PyObject *ind2;
- Stream *ind2_stream;
- int modebuffer[6];
+ PyObject *index;
+ Stream *index_stream;
+ int modebuffer[5];
MYFLT pointerPos_car;
MYFLT pointerPos_mod;
MYFLT scaleFactor;
- MYFLT car_val;
-} CrossFm;
+} Fm;
static void
-CrossFm_readframes(CrossFm *self) {
- MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_amp, car_delta, fpart;
+Fm_readframes_iii(Fm *self) {
+ MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_delta, fpart;
int i, ipart;
- MYFLT car[self->bufsize];
- 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++) {
- car[i] = tmpcar;
- }
- }
- else {
- MYFLT *tmpcar = Stream_getData((Stream *)self->car_stream);
- for (i=0; i<self->bufsize; i++) {
- car[i] = tmpcar[i];
- }
- }
+ MYFLT car = PyFloat_AS_DOUBLE(self->car);
+ MYFLT rat = PyFloat_AS_DOUBLE(self->ratio);
+ MYFLT ind = PyFloat_AS_DOUBLE(self->index);
- if (self->modebuffer[3] == 0) {
- MYFLT tmprat = PyFloat_AS_DOUBLE(self->ratio);
- for (i=0; i<self->bufsize; i++) {
- rat[i] = tmprat;
- }
- }
- else {
- MYFLT *tmprat = Stream_getData((Stream *)self->ratio_stream);
- for (i=0; i<self->bufsize; i++) {
- rat[i] = tmprat[i];
- }
+ 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);
+ ipart = (int)self->pointerPos_car;
+ fpart = self->pointerPos_car - ipart;
+ self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos_car += car_delta;
}
+}
- if (self->modebuffer[4] == 0) {
- MYFLT tmpind1 = PyFloat_AS_DOUBLE(self->ind1);
- for (i=0; i<self->bufsize; i++) {
- ind1[i] = tmpind1;
- }
+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);
+
+ for (i=0; i<self->bufsize; i++) {
+ mod_freq = car[i] * rat;
+ mod_amp = mod_freq * ind;
+ mod_delta = mod_freq * self->scaleFactor;
+ 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[i] + mod_val;
+ car_delta = car_freq * self->scaleFactor;
+ self->pointerPos_car = Sine_clip(self->pointerPos_car);
+ ipart = (int)self->pointerPos_car;
+ fpart = self->pointerPos_car - ipart;
+ self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos_car += car_delta;
}
- else {
- MYFLT *tmpind1 = Stream_getData((Stream *)self->ind1_stream);
- for (i=0; i<self->bufsize; i++) {
- ind1[i] = tmpind1[i];
- }
+}
+
+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);
+
+ for (i=0; i<self->bufsize; i++) {
+ mod_freq = car * rat[i];
+ mod_amp = mod_freq * ind;
+ mod_delta = mod_freq * self->scaleFactor;
+ 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);
+ ipart = (int)self->pointerPos_car;
+ fpart = self->pointerPos_car - ipart;
+ self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos_car += car_delta;
}
+}
- if (self->modebuffer[5] == 0) {
- MYFLT tmpind2 = PyFloat_AS_DOUBLE(self->ind2);
- for (i=0; i<self->bufsize; i++) {
- ind2[i] = tmpind2;
- }
+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);
+
+ for (i=0; i<self->bufsize; i++) {
+ mod_freq = car[i] * rat[i];
+ mod_amp = mod_freq * ind;
+ mod_delta = mod_freq * self->scaleFactor;
+ 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[i] + mod_val;
+ car_delta = car_freq * self->scaleFactor;
+ self->pointerPos_car = Sine_clip(self->pointerPos_car);
+ ipart = (int)self->pointerPos_car;
+ fpart = self->pointerPos_car - ipart;
+ self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos_car += car_delta;
+ }}
+
+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);
+ 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);
+ ipart = (int)self->pointerPos_car;
+ fpart = self->pointerPos_car - ipart;
+ self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos_car += car_delta;
}
- else {
- MYFLT *tmpind2 = Stream_getData((Stream *)self->ind2_stream);
- for (i=0; i<self->bufsize; i++) {
- ind2[i] = tmpind2[i];
- }
+}
+
+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];
+ mod_delta = mod_freq * self->scaleFactor;
+ 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[i] + mod_val;
+ car_delta = car_freq * self->scaleFactor;
+ self->pointerPos_car = Sine_clip(self->pointerPos_car);
+ ipart = (int)self->pointerPos_car;
+ fpart = self->pointerPos_car - ipart;
+ self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos_car += car_delta;
}
+}
+
+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++) {
- car_amp = car[i] * ind1[i];
- mod_freq = car[i] * rat[i];
- mod_amp = mod_freq * ind2[i];
- mod_delta = (mod_freq + self->car_val * car_amp) * self->scaleFactor;
+ mod_freq = car * rat[i];
+ mod_amp = mod_freq * ind[i];
+ mod_delta = mod_freq * self->scaleFactor;
self->pointerPos_mod = Sine_clip(self->pointerPos_mod);
ipart = (int)self->pointerPos_mod;
fpart = self->pointerPos_mod - ipart;
- mod_val = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ 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 * mod_amp);
+ car_freq = car + mod_val;
car_delta = car_freq * self->scaleFactor;
self->pointerPos_car = Sine_clip(self->pointerPos_car);
ipart = (int)self->pointerPos_car;
fpart = self->pointerPos_car - ipart;
- self->car_val = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
self->pointerPos_car += car_delta;
- self->data[i] = (self->car_val + mod_val) * 0.5;
}
}
-static void CrossFm_postprocessing_ii(CrossFm *self) { POST_PROCESSING_II };
-static void CrossFm_postprocessing_ai(CrossFm *self) { POST_PROCESSING_AI };
-static void CrossFm_postprocessing_ia(CrossFm *self) { POST_PROCESSING_IA };
-static void CrossFm_postprocessing_aa(CrossFm *self) { POST_PROCESSING_AA };
-static void CrossFm_postprocessing_ireva(CrossFm *self) { POST_PROCESSING_IREVA };
-static void CrossFm_postprocessing_areva(CrossFm *self) { POST_PROCESSING_AREVA };
-static void CrossFm_postprocessing_revai(CrossFm *self) { POST_PROCESSING_REVAI };
-static void CrossFm_postprocessing_revaa(CrossFm *self) { POST_PROCESSING_REVAA };
-static void CrossFm_postprocessing_revareva(CrossFm *self) { POST_PROCESSING_REVAREVA };
+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];
+ mod_delta = mod_freq * self->scaleFactor;
+ 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[i] + mod_val;
+ car_delta = car_freq * self->scaleFactor;
+ self->pointerPos_car = Sine_clip(self->pointerPos_car);
+ ipart = (int)self->pointerPos_car;
+ fpart = self->pointerPos_car - ipart;
+ self->data[i] = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos_car += car_delta;
+ }
+}
+
+static void Fm_postprocessing_ii(Fm *self) { POST_PROCESSING_II };
+static void Fm_postprocessing_ai(Fm *self) { POST_PROCESSING_AI };
+static void Fm_postprocessing_ia(Fm *self) { POST_PROCESSING_IA };
+static void Fm_postprocessing_aa(Fm *self) { POST_PROCESSING_AA };
+static void Fm_postprocessing_ireva(Fm *self) { POST_PROCESSING_IREVA };
+static void Fm_postprocessing_areva(Fm *self) { POST_PROCESSING_AREVA };
+static void Fm_postprocessing_revai(Fm *self) { POST_PROCESSING_REVAI };
+static void Fm_postprocessing_revaa(Fm *self) { POST_PROCESSING_REVAA };
+static void Fm_postprocessing_revareva(Fm *self) { POST_PROCESSING_REVAREVA };
+
+static void
+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:
+ self->proc_func_ptr = Fm_readframes_iii;
+ break;
+ case 1:
+ self->proc_func_ptr = Fm_readframes_aii;
+ break;
+ case 10:
+ self->proc_func_ptr = Fm_readframes_iai;
+ break;
+ case 11:
+ self->proc_func_ptr = Fm_readframes_aai;
+ break;
+ case 100:
+ self->proc_func_ptr = Fm_readframes_iia;
+ break;
+ case 101:
+ self->proc_func_ptr = Fm_readframes_aia;
+ break;
+ case 110:
+ self->proc_func_ptr = Fm_readframes_iaa;
+ break;
+ case 111:
+ self->proc_func_ptr = Fm_readframes_aaa;
+ break;
+ }
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = Fm_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = Fm_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = Fm_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = Fm_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = Fm_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = Fm_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = Fm_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = Fm_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = Fm_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+Fm_compute_next_data_frame(Fm *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+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);
+ return 0;
+}
+
+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);
+ return 0;
+}
+
+static void
+Fm_dealloc(Fm* self)
+{
+ pyo_DEALLOC
+ Fm_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+static PyObject *
+Fm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ 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);
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+ self->modebuffer[2] = 0;
+ 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;
+
+ 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);
+ }
+
+ 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;
+}
+
+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_play(Fm *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Fm_out(Fm *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * Fm_stop(Fm *self) { STOP };
+
+static PyObject * Fm_multiply(Fm *self, PyObject *arg) { MULTIPLY };
+static PyObject * Fm_inplace_multiply(Fm *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Fm_add(Fm *self, PyObject *arg) { ADD };
+static PyObject * Fm_inplace_add(Fm *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Fm_sub(Fm *self, PyObject *arg) { SUB };
+static PyObject * Fm_inplace_sub(Fm *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Fm_div(Fm *self, PyObject *arg) { DIV };
+static PyObject * Fm_inplace_div(Fm *self, PyObject *arg) { INPLACE_DIV };
+
+static PyObject *
+Fm_setCarrier(Fm *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->car);
+ if (isNumber == 1) {
+ self->car = PyNumber_Float(tmp);
+ self->modebuffer[2] = 0;
+ }
+ else {
+ self->car = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->car, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->car_stream);
+ 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;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->ratio);
+ if (isNumber == 1) {
+ self->ratio = PyNumber_Float(tmp);
+ self->modebuffer[3] = 0;
+ }
+ else {
+ self->ratio = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->ratio, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->ratio_stream);
+ 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;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->index);
+ if (isNumber == 1) {
+ self->index = PyNumber_Float(tmp);
+ self->modebuffer[4] = 0;
+ }
+ else {
+ self->index = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->index, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->index_stream);
+ 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."},
+{"stream", T_OBJECT_EX, offsetof(Fm, stream), 0, "Stream object."},
+{"carrier", T_OBJECT_EX, offsetof(Fm, car), 0, "Frequency in cycle per second."},
+{"ratio", T_OBJECT_EX, offsetof(Fm, ratio), 0, "Ratio carrier:modulator (mod freq = car*mod)."},
+{"index", T_OBJECT_EX, offsetof(Fm, index), 0, "Modulation index (mod amp = mod freq*index)."},
+{"mul", T_OBJECT_EX, offsetof(Fm, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(Fm, add), 0, "Add factor."},
+{NULL} /* Sentinel */
+};
+
+static PyMethodDef Fm_methods[] = {
+{"getServer", (PyCFunction)Fm_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)Fm_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)Fm_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"out", (PyCFunction)Fm_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"stop", (PyCFunction)Fm_stop, METH_NOARGS, "Stops computing."},
+{"setCarrier", (PyCFunction)Fm_setCarrier, METH_O, "Sets carrier frequency in cycle per second."},
+{"setRatio", (PyCFunction)Fm_setRatio, METH_O, "Sets car:mod ratio."},
+{"setIndex", (PyCFunction)Fm_setIndex, METH_O, "Sets modulation index."},
+{"setMul", (PyCFunction)Fm_setMul, METH_O, "Sets Fm mul factor."},
+{"setAdd", (PyCFunction)Fm_setAdd, METH_O, "Sets Fm add factor."},
+{"setSub", (PyCFunction)Fm_setSub, METH_O, "Sets inverse add factor."},
+{"setDiv", (PyCFunction)Fm_setDiv, METH_O, "Sets inverse mul factor."},
+{NULL} /* Sentinel */
+};
+
+static PyNumberMethods Fm_as_number = {
+(binaryfunc)Fm_add, /*nb_add*/
+(binaryfunc)Fm_sub, /*nb_subtract*/
+(binaryfunc)Fm_multiply, /*nb_multiply*/
+INITIALIZE_NB_DIVIDE_ZERO /*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*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+0, /*nb_int*/
+0, /*nb_long*/
+0, /*nb_float*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+(binaryfunc)Fm_inplace_add, /*inplace_add*/
+(binaryfunc)Fm_inplace_sub, /*inplace_subtract*/
+(binaryfunc)Fm_inplace_multiply, /*inplace_multiply*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+(binaryfunc)Fm_div, /*nb_true_divide*/
+0, /*nb_inplace_floor_divide*/
+(binaryfunc)Fm_inplace_div, /*nb_inplace_true_divide*/
+0, /* nb_index */
+};
+
+PyTypeObject FmType = {
+PyVarObject_HEAD_INIT(NULL, 0)
+"_pyo.Fm_base", /*tp_name*/
+sizeof(Fm), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)Fm_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_as_async (tp_compare in Python 2)*/
+0, /*tp_repr*/
+&Fm_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*/
+"Fm objects. Generates a frequency modulation synthesis.", /* tp_doc */
+(traverseproc)Fm_traverse, /* tp_traverse */
+(inquiry)Fm_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+Fm_methods, /* tp_methods */
+Fm_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 */
+Fm_new, /* tp_new */
+};
+
+/*************/
+/* CrossFm object */
+/*************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *car;
+ Stream *car_stream;
+ PyObject *ratio;
+ Stream *ratio_stream;
+ PyObject *ind1;
+ Stream *ind1_stream;
+ PyObject *ind2;
+ Stream *ind2_stream;
+ int modebuffer[6];
+ MYFLT pointerPos_car;
+ MYFLT pointerPos_mod;
+ MYFLT scaleFactor;
+ MYFLT car_val;
+} CrossFm;
+
+static void
+CrossFm_readframes(CrossFm *self) {
+ MYFLT mod_freq, mod_amp, mod_delta, mod_val, car_freq, car_amp, car_delta, fpart;
+ int i, ipart;
+ MYFLT car[self->bufsize];
+ 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++) {
+ car[i] = tmpcar;
+ }
+ }
+ else {
+ MYFLT *tmpcar = Stream_getData((Stream *)self->car_stream);
+ for (i=0; i<self->bufsize; i++) {
+ car[i] = tmpcar[i];
+ }
+ }
+
+ if (self->modebuffer[3] == 0) {
+ MYFLT tmprat = PyFloat_AS_DOUBLE(self->ratio);
+ for (i=0; i<self->bufsize; i++) {
+ rat[i] = tmprat;
+ }
+ }
+ else {
+ MYFLT *tmprat = Stream_getData((Stream *)self->ratio_stream);
+ for (i=0; i<self->bufsize; i++) {
+ 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++) {
+ ind2[i] = tmpind2[i];
+ }
+ }
+
+ for (i=0; i<self->bufsize; i++) {
+ car_amp = car[i] * ind1[i];
+ mod_freq = car[i] * rat[i];
+ mod_amp = mod_freq * ind2[i];
+ mod_delta = (mod_freq + self->car_val * car_amp) * self->scaleFactor;
+ self->pointerPos_mod = Sine_clip(self->pointerPos_mod);
+ ipart = (int)self->pointerPos_mod;
+ 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);
+ ipart = (int)self->pointerPos_car;
+ fpart = self->pointerPos_car - ipart;
+ self->car_val = SINE_ARRAY[ipart] * (1.0 - fpart) + SINE_ARRAY[ipart+1] * fpart;
+ self->pointerPos_car += car_delta;
+ self->data[i] = (self->car_val + mod_val) * 0.5;
+ }
+}
+
+static void CrossFm_postprocessing_ii(CrossFm *self) { POST_PROCESSING_II };
+static void CrossFm_postprocessing_ai(CrossFm *self) { POST_PROCESSING_AI };
+static void CrossFm_postprocessing_ia(CrossFm *self) { POST_PROCESSING_IA };
+static void CrossFm_postprocessing_aa(CrossFm *self) { POST_PROCESSING_AA };
+static void CrossFm_postprocessing_ireva(CrossFm *self) { POST_PROCESSING_IREVA };
+static void CrossFm_postprocessing_areva(CrossFm *self) { POST_PROCESSING_AREVA };
+static void CrossFm_postprocessing_revai(CrossFm *self) { POST_PROCESSING_REVAI };
+static void CrossFm_postprocessing_revaa(CrossFm *self) { POST_PROCESSING_REVAA };
+static void CrossFm_postprocessing_revareva(CrossFm *self) { POST_PROCESSING_REVAREVA };
+
+static void
+CrossFm_setProcMode(CrossFm *self)
+{
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+
+ self->proc_func_ptr = CrossFm_readframes;
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = CrossFm_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = CrossFm_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = CrossFm_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = CrossFm_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = CrossFm_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = CrossFm_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = CrossFm_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = CrossFm_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = CrossFm_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+CrossFm_compute_next_data_frame(CrossFm *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+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);
+ return 0;
+}
+
+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);
+ return 0;
+}
+
+static void
+CrossFm_dealloc(CrossFm* self)
+{
+ pyo_DEALLOC
+ CrossFm_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+static PyObject *
+CrossFm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ 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);
+ self->ind2 = PyFloat_FromDouble(2);
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
+ self->modebuffer[2] = 0;
+ self->modebuffer[3] = 0;
+ self->modebuffer[4] = 0;
+ 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);
+ }
+
+ 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_play(CrossFm *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * CrossFm_out(CrossFm *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * CrossFm_stop(CrossFm *self) { STOP };
+
+static PyObject * CrossFm_multiply(CrossFm *self, PyObject *arg) { MULTIPLY };
+static PyObject * CrossFm_inplace_multiply(CrossFm *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * CrossFm_add(CrossFm *self, PyObject *arg) { ADD };
+static PyObject * CrossFm_inplace_add(CrossFm *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * CrossFm_sub(CrossFm *self, PyObject *arg) { SUB };
+static PyObject * CrossFm_inplace_sub(CrossFm *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * CrossFm_div(CrossFm *self, PyObject *arg) { DIV };
+static PyObject * CrossFm_inplace_div(CrossFm *self, PyObject *arg) { INPLACE_DIV };
+
+static PyObject *
+CrossFm_setCarrier(CrossFm *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->car);
+ if (isNumber == 1) {
+ self->car = PyNumber_Float(tmp);
+ self->modebuffer[2] = 0;
+ }
+ else {
+ self->car = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->car, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->car_stream);
+ 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;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->ratio);
+ if (isNumber == 1) {
+ self->ratio = PyNumber_Float(tmp);
+ self->modebuffer[3] = 0;
+ }
+ else {
+ self->ratio = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->ratio, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->ratio_stream);
+ 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;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->ind1);
+ if (isNumber == 1) {
+ self->ind1 = PyNumber_Float(tmp);
+ self->modebuffer[4] = 0;
+ }
+ else {
+ self->ind1 = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->ind1, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->ind1_stream);
+ 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;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->ind2);
+ if (isNumber == 1) {
+ self->ind2 = PyNumber_Float(tmp);
+ self->modebuffer[5] = 0;
+ }
+ else {
+ self->ind2 = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->ind2, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->ind2_stream);
+ 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."},
+ {"stream", T_OBJECT_EX, offsetof(CrossFm, stream), 0, "Stream object."},
+ {"carrier", T_OBJECT_EX, offsetof(CrossFm, car), 0, "Frequency in cycle per second."},
+ {"ratio", T_OBJECT_EX, offsetof(CrossFm, ratio), 0, "Ratio carrier:modulator (mod freq = car*mod)."},
+ {"ind1", T_OBJECT_EX, offsetof(CrossFm, ind1), 0, "Modulation ind1 (car amp = car freq*ind1)."},
+ {"ind2", T_OBJECT_EX, offsetof(CrossFm, ind2), 0, "Modulation ind2 (mod amp = mod freq*ind2)."},
+ {"mul", T_OBJECT_EX, offsetof(CrossFm, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(CrossFm, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef CrossFm_methods[] = {
+ {"getServer", (PyCFunction)CrossFm_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)CrossFm_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)CrossFm_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)CrossFm_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)CrossFm_stop, METH_NOARGS, "Stops computing."},
+ {"setCarrier", (PyCFunction)CrossFm_setCarrier, METH_O, "Sets carrier frequency in cycle per second."},
+ {"setRatio", (PyCFunction)CrossFm_setRatio, METH_O, "Sets car:mod ratio."},
+ {"setInd1", (PyCFunction)CrossFm_setInd1, METH_O, "Sets carrier index."},
+ {"setInd2", (PyCFunction)CrossFm_setInd2, METH_O, "Sets modulation index."},
+ {"setMul", (PyCFunction)CrossFm_setMul, METH_O, "Sets CrossFm mul factor."},
+ {"setAdd", (PyCFunction)CrossFm_setAdd, METH_O, "Sets CrossFm add factor."},
+ {"setSub", (PyCFunction)CrossFm_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)CrossFm_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods CrossFm_as_number = {
+ (binaryfunc)CrossFm_add, /*nb_add*/
+ (binaryfunc)CrossFm_sub, /*nb_subtract*/
+ (binaryfunc)CrossFm_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*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*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)CrossFm_inplace_add, /*inplace_add*/
+ (binaryfunc)CrossFm_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)CrossFm_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+ (binaryfunc)CrossFm_div, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ (binaryfunc)CrossFm_inplace_div, /*nb_inplace_true_divide*/
+ 0, /* nb_ind1 */
+};
+
+PyTypeObject CrossFmType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.CrossFm_base", /*tp_name*/
+ sizeof(CrossFm), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)CrossFm_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
+ 0, /*tp_repr*/
+ &CrossFm_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*/
+ "CrossFm objects. Generates a cross frequency modulation synthesis.", /* tp_doc */
+ (traverseproc)CrossFm_traverse, /* tp_traverse */
+ (inquiry)CrossFm_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ CrossFm_methods, /* tp_methods */
+ CrossFm_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 */
+ CrossFm_new, /* tp_new */
+};
+
+/*************/
+/* Blit object */
+/*************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *freq;
+ Stream *freq_stream;
+ PyObject *harms;
+ 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);
+
+ nHarms = (int)hrms;
+ m = 2.0 * nHarms + 1.0;
+ p = self->sr / freq;
+ rate = PI / p;
+
+ for (i=0; i<self->bufsize; i++) {
+ if (self->phase <= 0.0)
+ val = 1.0;
+ else {
+ val = MYSIN(m * self->phase);
+ val /= m * MYSIN(self->phase);
+ }
+ self->phase += rate;
+ if (self->phase >= PI)
+ self->phase -= PI;
+
+ self->data[i] = val;
+ }
+}
+
+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;
+ if (self->phase <= 0.0)
+ val = 1.0;
+ else {
+ val = MYSIN(m * self->phase);
+ val /= m * MYSIN(self->phase);
+ }
+ self->phase += rate;
+ if (self->phase >= PI)
+ self->phase -= PI;
+
+ self->data[i] = val;
+ }
+}
+
+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;
+ if (self->phase <= 0.0)
+ val = 1.0;
+ else {
+ val = MYSIN(m * self->phase);
+ val /= m * MYSIN(self->phase);
+ }
+ self->phase += rate;
+ if (self->phase >= PI)
+ self->phase -= PI;
+
+ self->data[i] = val;
+ }
+}
+
+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;
+ p = self->sr / freq[i];
+ rate = PI / p;
+ if (self->phase <= 0.0)
+ val = 1.0;
+ else {
+ val = MYSIN(m * self->phase);
+ val /= m * MYSIN(self->phase);
+ }
+ self->phase += rate;
+ if (self->phase >= PI)
+ self->phase -= PI;
+
+ self->data[i] = val;
+ }
+}
+
+static void Blit_postprocessing_ii(Blit *self) { POST_PROCESSING_II };
+static void Blit_postprocessing_ai(Blit *self) { POST_PROCESSING_AI };
+static void Blit_postprocessing_ia(Blit *self) { POST_PROCESSING_IA };
+static void Blit_postprocessing_aa(Blit *self) { POST_PROCESSING_AA };
+static void Blit_postprocessing_ireva(Blit *self) { POST_PROCESSING_IREVA };
+static void Blit_postprocessing_areva(Blit *self) { POST_PROCESSING_AREVA };
+static void Blit_postprocessing_revai(Blit *self) { POST_PROCESSING_REVAI };
+static void Blit_postprocessing_revaa(Blit *self) { POST_PROCESSING_REVAA };
+static void Blit_postprocessing_revareva(Blit *self) { POST_PROCESSING_REVAREVA };
+
+static void
+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:
+ self->proc_func_ptr = Blit_readframes_ii;
+ break;
+ case 1:
+ self->proc_func_ptr = Blit_readframes_ai;
+ break;
+ case 10:
+ self->proc_func_ptr = Blit_readframes_ia;
+ break;
+ case 11:
+ self->proc_func_ptr = Blit_readframes_aa;
+ break;
+ }
+
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = Blit_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = Blit_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = Blit_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = Blit_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = Blit_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = Blit_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = Blit_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = Blit_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = Blit_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+Blit_compute_next_data_frame(Blit *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+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);
+ return 0;
+}
+
+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);
+ return 0;
+}
+
+static void
+Blit_dealloc(Blit* self)
+{
+ pyo_DEALLOC
+ Blit_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+static PyObject *
+Blit_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ 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;
+ self->modebuffer[1] = 0;
+ 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);
+ }
+
+ 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 * 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_play(Blit *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Blit_out(Blit *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * Blit_stop(Blit *self) { STOP };
+
+static PyObject * Blit_multiply(Blit *self, PyObject *arg) { MULTIPLY };
+static PyObject * Blit_inplace_multiply(Blit *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Blit_add(Blit *self, PyObject *arg) { ADD };
+static PyObject * Blit_inplace_add(Blit *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Blit_sub(Blit *self, PyObject *arg) { SUB };
+static PyObject * Blit_inplace_sub(Blit *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Blit_div(Blit *self, PyObject *arg) { DIV };
+static PyObject * Blit_inplace_div(Blit *self, PyObject *arg) { INPLACE_DIV };
+
+static PyObject *
+Blit_setFreq(Blit *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->freq);
+ if (isNumber == 1) {
+ self->freq = PyNumber_Float(tmp);
+ self->modebuffer[2] = 0;
+ }
+ else {
+ self->freq = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->freq, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->freq_stream);
+ 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;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->harms);
+ if (isNumber == 1) {
+ self->harms = PyNumber_Float(tmp);
+ self->modebuffer[3] = 0;
+ }
+ else {
+ self->harms = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->harms, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->harms_stream);
+ 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."},
+ {"stream", T_OBJECT_EX, offsetof(Blit, stream), 0, "Stream object."},
+ {"freq", T_OBJECT_EX, offsetof(Blit, freq), 0, "Frequency in cycle per second."},
+ {"harms", T_OBJECT_EX, offsetof(Blit, harms), 0, "Number of harmonics."},
+ {"mul", T_OBJECT_EX, offsetof(Blit, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(Blit, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef Blit_methods[] = {
+ {"getServer", (PyCFunction)Blit_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)Blit_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)Blit_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundfreqd."},
+ {"out", (PyCFunction)Blit_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundfreqd channel speficied by argument."},
+ {"stop", (PyCFunction)Blit_stop, METH_NOARGS, "Stops computing."},
+ {"setFreq", (PyCFunction)Blit_setFreq, METH_O, "Sets frequency in cycle per second."},
+ {"setHarms", (PyCFunction)Blit_setHarms, METH_O, "Sets the number of harmonics."},
+ {"setMul", (PyCFunction)Blit_setMul, METH_O, "Sets Blit mul factor."},
+ {"setAdd", (PyCFunction)Blit_setAdd, METH_O, "Sets Blit add factor."},
+ {"setSub", (PyCFunction)Blit_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)Blit_setDiv, METH_O, "Sets inverse mul factor."},
+ {NULL} /* Sentinel */
+};
+
+static PyNumberMethods Blit_as_number = {
+ (binaryfunc)Blit_add, /*nb_add*/
+ (binaryfunc)Blit_sub, /*nb_subtract*/
+ (binaryfunc)Blit_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*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*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)Blit_inplace_add, /*inplace_add*/
+ (binaryfunc)Blit_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)Blit_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+ (binaryfunc)Blit_div, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ (binaryfunc)Blit_inplace_div, /*nb_inplace_true_divide*/
+ 0, /* nb_cutoff */
+};
+
+PyTypeObject BlitType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.Blit_base", /*tp_name*/
+ sizeof(Blit), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Blit_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
+ 0, /*tp_repr*/
+ &Blit_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*/
+ "Blit objects. Generates a band limited impulse train.", /* tp_doc */
+ (traverseproc)Blit_traverse, /* tp_traverse */
+ (inquiry)Blit_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ Blit_methods, /* tp_methods */
+ Blit_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 */
+ Blit_new, /* tp_new */
+};
+
+/* Rossler object */
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *pitch;
+ Stream *pitch_stream;
+ PyObject *chaos;
+ Stream *chaos_stream;
+ MYFLT *altBuffer;
+ MYFLT vDX;
+ MYFLT vDY;
+ MYFLT vDZ;
+ MYFLT vX;
+ MYFLT vY;
+ MYFLT vZ;
+ MYFLT pA;
+ MYFLT pB;
+ MYFLT scalePitch;
+ int modebuffer[4];
+} Rossler;
+
+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)
+ pit = 1.0;
+ else if (pit > 1.0)
+ pit = 1000.0;
+ else
+ pit = pit * 999.0 + 1.0;
+ delta = self->scalePitch * pit;
+
+ if (chao < 0.0)
+ chao = 3.0;
+ else if (chao > 1.0)
+ 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;
+ }
+}
+
+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)
+ chao = 3.0;
+ else if (chao > 1.0)
+ chao = 10.0;
+ else
+ chao = chao * 7.0 + 3.0;
+
+ for (i=0; i<self->bufsize; i++) {
+ pit = fr[i];
+ if (pit < 0.0)
+ pit = 1.0;
+ else if (pit > 1.0)
+ pit = 1000.0;
+ else
+ pit = pit * 999.0 + 1.0;
+ delta = self->scalePitch * pit;
+ 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;
+ }
+}
+
+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);
+
+ if (pit < 0.0)
+ pit = 1.0;
+ else if (pit > 1.0)
+ pit = 1000.0;
+ 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)
+ chao = 3.0;
+ else if (chao > 1.0)
+ chao = 10.0;
+ else
+ 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;
+ }
+}
+
+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);
+
+ for (i=0; i<self->bufsize; i++) {
+ pit = fr[i];
+ if (pit < 0.0)
+ pit = 1.0;
+ else if (pit > 1.0)
+ pit = 1000.0;
+ 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;
+ 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;
+ }
+}
+
+static void Rossler_postprocessing_ii(Rossler *self) { POST_PROCESSING_II };
+static void Rossler_postprocessing_ai(Rossler *self) { POST_PROCESSING_AI };
+static void Rossler_postprocessing_ia(Rossler *self) { POST_PROCESSING_IA };
+static void Rossler_postprocessing_aa(Rossler *self) { POST_PROCESSING_AA };
+static void Rossler_postprocessing_ireva(Rossler *self) { POST_PROCESSING_IREVA };
+static void Rossler_postprocessing_areva(Rossler *self) { POST_PROCESSING_AREVA };
+static void Rossler_postprocessing_revai(Rossler *self) { POST_PROCESSING_REVAI };
+static void Rossler_postprocessing_revaa(Rossler *self) { POST_PROCESSING_REVAA };
+static void Rossler_postprocessing_revareva(Rossler *self) { POST_PROCESSING_REVAREVA };
static void
-CrossFm_setProcMode(CrossFm *self)
+Rossler_setProcMode(Rossler *self)
{
- int muladdmode;
+ int procmode, muladdmode;
+ procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
- self->proc_func_ptr = CrossFm_readframes;
+ switch (procmode) {
+ case 0:
+ self->proc_func_ptr = Rossler_readframes_ii;
+ break;
+ case 1:
+ self->proc_func_ptr = Rossler_readframes_ai;
+ break;
+ case 10:
+ self->proc_func_ptr = Rossler_readframes_ia;
+ break;
+ case 11:
+ self->proc_func_ptr = Rossler_readframes_aa;
+ break;
+ }
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = CrossFm_postprocessing_ii;
+ self->muladd_func_ptr = Rossler_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = CrossFm_postprocessing_ai;
+ self->muladd_func_ptr = Rossler_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = CrossFm_postprocessing_revai;
+ self->muladd_func_ptr = Rossler_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = CrossFm_postprocessing_ia;
+ self->muladd_func_ptr = Rossler_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = CrossFm_postprocessing_aa;
+ self->muladd_func_ptr = Rossler_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = CrossFm_postprocessing_revaa;
+ self->muladd_func_ptr = Rossler_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = CrossFm_postprocessing_ireva;
+ self->muladd_func_ptr = Rossler_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = CrossFm_postprocessing_areva;
+ self->muladd_func_ptr = Rossler_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = CrossFm_postprocessing_revareva;
+ self->muladd_func_ptr = Rossler_postprocessing_revareva;
break;
}
}
static void
-CrossFm_compute_next_data_frame(CrossFm *self)
+Rossler_compute_next_data_frame(Rossler *self)
{
(*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
static int
-CrossFm_traverse(CrossFm *self, visitproc visit, void *arg)
+Rossler_traverse(Rossler *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->pitch);
+ Py_VISIT(self->pitch_stream);
+ Py_VISIT(self->chaos);
+ Py_VISIT(self->chaos_stream);
return 0;
}
static int
-CrossFm_clear(CrossFm *self)
+Rossler_clear(Rossler *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->pitch);
+ Py_CLEAR(self->pitch_stream);
+ Py_CLEAR(self->chaos);
+ Py_CLEAR(self->chaos_stream);
return 0;
}
static void
-CrossFm_dealloc(CrossFm* self)
+Rossler_dealloc(Rossler* self)
{
pyo_DEALLOC
- CrossFm_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ free(self->altBuffer);
+ Rossler_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-CrossFm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+Rossler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *cartmp=NULL, *ratiotmp=NULL, *ind1tmp=NULL, *ind2tmp=NULL, *multmp=NULL, *addtmp=NULL;
- CrossFm *self;
- self = (CrossFm *)type->tp_alloc(type, 0);
+ PyObject *pitchtmp=NULL, *chaostmp=NULL, *multmp=NULL, *addtmp=NULL;
+ Rossler *self;
+ self = (Rossler *)type->tp_alloc(type, 0);
- self->car = PyFloat_FromDouble(100);
- self->ratio = PyFloat_FromDouble(0.5);
- self->ind1 = PyFloat_FromDouble(2);
- self->ind2 = PyFloat_FromDouble(2);
+ 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;
+ self->vX = self->vY = self->vZ = 1.0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
self->modebuffer[3] = 0;
- self->modebuffer[4] = 0;
- 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;
+ Stream_setFunctionPtr(self->stream, Rossler_compute_next_data_frame);
+ self->mode_func_ptr = Rossler_setProcMode;
- self->scaleFactor = 512.0 / self->sr;
+ self->scalePitch = 2.91 / self->sr;
- static char *kwlist[] = {"carrier", "ratio", "ind1", "ind2", "mul", "add", NULL};
+ static char *kwlist[] = {"pitch", "chaos", "mul", "add", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOO", kwlist, &cartmp, &ratiotmp, &ind1tmp, &ind2tmp, &multmp, &addtmp))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &pitchtmp, &chaostmp, &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);
+ if (pitchtmp) {
+ PyObject_CallMethod((PyObject *)self, "setPitch", "O", pitchtmp);
}
- if (ind2tmp) {
- PyObject_CallMethod((PyObject *)self, "setInd2", "O", ind2tmp);
+ if (chaostmp) {
+ PyObject_CallMethod((PyObject *)self, "setChaos", "O", chaostmp);
}
if (multmp) {
@@ -6676,95 +8244,39 @@ CrossFm_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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_play(CrossFm *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * CrossFm_out(CrossFm *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * CrossFm_stop(CrossFm *self) { STOP };
-
-static PyObject * CrossFm_multiply(CrossFm *self, PyObject *arg) { MULTIPLY };
-static PyObject * CrossFm_inplace_multiply(CrossFm *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * CrossFm_add(CrossFm *self, PyObject *arg) { ADD };
-static PyObject * CrossFm_inplace_add(CrossFm *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * CrossFm_sub(CrossFm *self, PyObject *arg) { SUB };
-static PyObject * CrossFm_inplace_sub(CrossFm *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * CrossFm_div(CrossFm *self, PyObject *arg) { DIV };
-static PyObject * CrossFm_inplace_div(CrossFm *self, PyObject *arg) { INPLACE_DIV };
-
-static PyObject *
-CrossFm_setCarrier(CrossFm *self, PyObject *arg)
-{
- PyObject *tmp, *streamtmp;
-
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
+ self->altBuffer = (MYFLT *)realloc(self->altBuffer, self->bufsize * sizeof(MYFLT));
- tmp = arg;
- Py_INCREF(tmp);
- Py_DECREF(self->car);
- if (isNumber == 1) {
- self->car = PyNumber_Float(tmp);
- self->modebuffer[2] = 0;
- }
- else {
- self->car = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->car, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->car_stream);
- self->car_stream = (Stream *)streamtmp;
- self->modebuffer[2] = 1;
- }
+ for (i=0; i<self->bufsize; i++) {
+ self->altBuffer[i] = 0.0;
+ }
(*self->mode_func_ptr)(self);
- Py_INCREF(Py_None);
- return Py_None;
+ return (PyObject *)self;
}
-static PyObject *
-CrossFm_setRatio(CrossFm *self, PyObject *arg)
-{
- PyObject *tmp, *streamtmp;
-
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
-
- tmp = arg;
- Py_INCREF(tmp);
- Py_DECREF(self->ratio);
- if (isNumber == 1) {
- self->ratio = PyNumber_Float(tmp);
- self->modebuffer[3] = 0;
- }
- else {
- self->ratio = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->ratio, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->ratio_stream);
- self->ratio_stream = (Stream *)streamtmp;
- self->modebuffer[3] = 1;
- }
+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 };
- (*self->mode_func_ptr)(self);
+static PyObject * Rossler_play(Rossler *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Rossler_out(Rossler *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * Rossler_stop(Rossler *self) { STOP };
- Py_INCREF(Py_None);
- return Py_None;
-}
+static PyObject * Rossler_multiply(Rossler *self, PyObject *arg) { MULTIPLY };
+static PyObject * Rossler_inplace_multiply(Rossler *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Rossler_add(Rossler *self, PyObject *arg) { ADD };
+static PyObject * Rossler_inplace_add(Rossler *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Rossler_sub(Rossler *self, PyObject *arg) { SUB };
+static PyObject * Rossler_inplace_sub(Rossler *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Rossler_div(Rossler *self, PyObject *arg) { DIV };
+static PyObject * Rossler_inplace_div(Rossler *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-CrossFm_setInd1(CrossFm *self, PyObject *arg)
+Rossler_setPitch(Rossler *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -6774,18 +8286,18 @@ CrossFm_setInd1(CrossFm *self, PyObject *arg)
tmp = arg;
Py_INCREF(tmp);
- Py_DECREF(self->ind1);
+ Py_DECREF(self->pitch);
if (isNumber == 1) {
- self->ind1 = PyNumber_Float(tmp);
- self->modebuffer[4] = 0;
+ self->pitch = PyNumber_Float(tmp);
+ self->modebuffer[2] = 0;
}
else {
- self->ind1 = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->ind1, "_getStream", NULL);
+ self->pitch = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->pitch, "_getStream", NULL);
Py_INCREF(streamtmp);
- Py_XDECREF(self->ind1_stream);
- self->ind1_stream = (Stream *)streamtmp;
- self->modebuffer[4] = 1;
+ Py_XDECREF(self->pitch_stream);
+ self->pitch_stream = (Stream *)streamtmp;
+ self->modebuffer[2] = 1;
}
(*self->mode_func_ptr)(self);
@@ -6795,7 +8307,7 @@ CrossFm_setInd1(CrossFm *self, PyObject *arg)
}
static PyObject *
-CrossFm_setInd2(CrossFm *self, PyObject *arg)
+Rossler_setChaos(Rossler *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -6805,18 +8317,18 @@ CrossFm_setInd2(CrossFm *self, PyObject *arg)
tmp = arg;
Py_INCREF(tmp);
- Py_DECREF(self->ind2);
+ Py_DECREF(self->chaos);
if (isNumber == 1) {
- self->ind2 = PyNumber_Float(tmp);
- self->modebuffer[5] = 0;
+ self->chaos = PyNumber_Float(tmp);
+ self->modebuffer[3] = 0;
}
else {
- self->ind2 = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->ind2, "_getStream", NULL);
+ self->chaos = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->chaos, "_getStream", NULL);
Py_INCREF(streamtmp);
- Py_XDECREF(self->ind2_stream);
- self->ind2_stream = (Stream *)streamtmp;
- self->modebuffer[5] = 1;
+ Py_XDECREF(self->chaos_stream);
+ self->chaos_stream = (Stream *)streamtmp;
+ self->modebuffer[3] = 1;
}
(*self->mode_func_ptr)(self);
@@ -6825,40 +8337,42 @@ CrossFm_setInd2(CrossFm *self, PyObject *arg)
return Py_None;
}
-static PyMemberDef CrossFm_members[] = {
- {"server", T_OBJECT_EX, offsetof(CrossFm, server), 0, "Pyo server."},
- {"stream", T_OBJECT_EX, offsetof(CrossFm, stream), 0, "Stream object."},
- {"carrier", T_OBJECT_EX, offsetof(CrossFm, car), 0, "Frequency in cycle per second."},
- {"ratio", T_OBJECT_EX, offsetof(CrossFm, ratio), 0, "Ratio carrier:modulator (mod freq = car*mod)."},
- {"ind1", T_OBJECT_EX, offsetof(CrossFm, ind1), 0, "Modulation ind1 (car amp = car freq*ind1)."},
- {"ind2", T_OBJECT_EX, offsetof(CrossFm, ind2), 0, "Modulation ind2 (mod amp = mod freq*ind2)."},
- {"mul", T_OBJECT_EX, offsetof(CrossFm, mul), 0, "Mul factor."},
- {"add", T_OBJECT_EX, offsetof(CrossFm, add), 0, "Add factor."},
+MYFLT *
+Rossler_getAltBuffer(Rossler *self)
+{
+ return (MYFLT *)self->altBuffer;
+}
+
+static PyMemberDef Rossler_members[] = {
+ {"server", T_OBJECT_EX, offsetof(Rossler, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(Rossler, stream), 0, "Stream object."},
+ {"pitch", T_OBJECT_EX, offsetof(Rossler, pitch), 0, "Pitch."},
+ {"chaos", T_OBJECT_EX, offsetof(Rossler, chaos), 0, "Chaotic behavior."},
+ {"mul", T_OBJECT_EX, offsetof(Rossler, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(Rossler, add), 0, "Add factor."},
{NULL} /* Sentinel */
};
-static PyMethodDef CrossFm_methods[] = {
- {"getServer", (PyCFunction)CrossFm_getServer, METH_NOARGS, "Returns server object."},
- {"_getStream", (PyCFunction)CrossFm_getStream, METH_NOARGS, "Returns stream object."},
- {"play", (PyCFunction)CrossFm_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
- {"out", (PyCFunction)CrossFm_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
- {"stop", (PyCFunction)CrossFm_stop, METH_NOARGS, "Stops computing."},
- {"setCarrier", (PyCFunction)CrossFm_setCarrier, METH_O, "Sets carrier frequency in cycle per second."},
- {"setRatio", (PyCFunction)CrossFm_setRatio, METH_O, "Sets car:mod ratio."},
- {"setInd1", (PyCFunction)CrossFm_setInd1, METH_O, "Sets carrier index."},
- {"setInd2", (PyCFunction)CrossFm_setInd2, METH_O, "Sets modulation index."},
- {"setMul", (PyCFunction)CrossFm_setMul, METH_O, "Sets CrossFm mul factor."},
- {"setAdd", (PyCFunction)CrossFm_setAdd, METH_O, "Sets CrossFm add factor."},
- {"setSub", (PyCFunction)CrossFm_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)CrossFm_setDiv, METH_O, "Sets inverse mul factor."},
+static PyMethodDef Rossler_methods[] = {
+ {"getServer", (PyCFunction)Rossler_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)Rossler_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)Rossler_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)Rossler_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)Rossler_stop, METH_NOARGS, "Stops computing."},
+ {"setPitch", (PyCFunction)Rossler_setPitch, METH_O, "Sets oscillator pitch."},
+ {"setChaos", (PyCFunction)Rossler_setChaos, METH_O, "Sets oscillator chaotic behavior."},
+ {"setMul", (PyCFunction)Rossler_setMul, METH_O, "Sets Rossler mul factor."},
+ {"setAdd", (PyCFunction)Rossler_setAdd, METH_O, "Sets Rossler add factor."},
+ {"setSub", (PyCFunction)Rossler_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)Rossler_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
-static PyNumberMethods CrossFm_as_number = {
- (binaryfunc)CrossFm_add, /*nb_add*/
- (binaryfunc)CrossFm_sub, /*nb_subtract*/
- (binaryfunc)CrossFm_multiply, /*nb_multiply*/
- (binaryfunc)CrossFm_div, /*nb_divide*/
+static PyNumberMethods Rossler_as_number = {
+ (binaryfunc)Rossler_add, /*nb_add*/
+ (binaryfunc)Rossler_sub, /*nb_subtract*/
+ (binaryfunc)Rossler_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -6872,16 +8386,16 @@ static PyNumberMethods CrossFm_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
- (binaryfunc)CrossFm_inplace_add, /*inplace_add*/
- (binaryfunc)CrossFm_inplace_sub, /*inplace_subtract*/
- (binaryfunc)CrossFm_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)CrossFm_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)Rossler_inplace_add, /*inplace_add*/
+ (binaryfunc)Rossler_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)Rossler_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -6890,25 +8404,24 @@ static PyNumberMethods CrossFm_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Rossler_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
- 0, /* nb_ind1 */
+ (binaryfunc)Rossler_inplace_div, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
};
-PyTypeObject CrossFmType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.CrossFm_base", /*tp_name*/
- sizeof(CrossFm), /*tp_basicsize*/
+PyTypeObject RosslerType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.Rossler_base", /*tp_name*/
+ sizeof(Rossler), /*tp_basicsize*/
0, /*tp_itemsize*/
- (destructor)CrossFm_dealloc, /*tp_dealloc*/
+ (destructor)Rossler_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
- &CrossFm_as_number, /*tp_as_number*/
+ &Rossler_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -6918,15 +8431,15 @@ PyTypeObject CrossFmType = {
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
- "CrossFm objects. Generates a cross frequency modulation synthesis.", /* tp_doc */
- (traverseproc)CrossFm_traverse, /* tp_traverse */
- (inquiry)CrossFm_clear, /* tp_clear */
+ "Rossler objects. Rossler attractor.", /* tp_doc */
+ (traverseproc)Rossler_traverse, /* tp_traverse */
+ (inquiry)Rossler_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- CrossFm_methods, /* tp_methods */
- CrossFm_members, /* tp_members */
+ Rossler_methods, /* tp_methods */
+ Rossler_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -6935,266 +8448,120 @@ PyTypeObject CrossFmType = {
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- CrossFm_new, /* tp_new */
+ Rossler_new, /* tp_new */
};
-/*************/
-/* Blit object */
-/*************/
typedef struct {
pyo_audio_HEAD
- PyObject *freq;
- Stream *freq_stream;
- PyObject *harms;
- 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);
-
- nHarms = (int)hrms;
- m = 2.0 * nHarms + 1.0;
- p = self->sr / freq;
- rate = PI / p;
-
- for (i=0; i<self->bufsize; i++) {
- if (self->phase <= 0.0)
- val = 1.0;
- else {
- val = MYSIN(m * self->phase);
- val /= m * MYSIN(self->phase);
- }
- self->phase += rate;
- if (self->phase >= PI)
- self->phase -= PI;
-
- self->data[i] = val;
- }
-}
-
-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;
- if (self->phase <= 0.0)
- val = 1.0;
- else {
- val = MYSIN(m * self->phase);
- val /= m * MYSIN(self->phase);
- }
- self->phase += rate;
- if (self->phase >= PI)
- self->phase -= PI;
-
- self->data[i] = val;
- }
-}
-
-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;
- if (self->phase <= 0.0)
- val = 1.0;
- else {
- val = MYSIN(m * self->phase);
- val /= m * MYSIN(self->phase);
- }
- self->phase += rate;
- if (self->phase >= PI)
- self->phase -= PI;
-
- self->data[i] = val;
- }
-}
-
-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;
- p = self->sr / freq[i];
- rate = PI / p;
- if (self->phase <= 0.0)
- val = 1.0;
- else {
- val = MYSIN(m * self->phase);
- val /= m * MYSIN(self->phase);
- }
- self->phase += rate;
- if (self->phase >= PI)
- self->phase -= PI;
-
- self->data[i] = val;
- }
-}
-
-static void Blit_postprocessing_ii(Blit *self) { POST_PROCESSING_II };
-static void Blit_postprocessing_ai(Blit *self) { POST_PROCESSING_AI };
-static void Blit_postprocessing_ia(Blit *self) { POST_PROCESSING_IA };
-static void Blit_postprocessing_aa(Blit *self) { POST_PROCESSING_AA };
-static void Blit_postprocessing_ireva(Blit *self) { POST_PROCESSING_IREVA };
-static void Blit_postprocessing_areva(Blit *self) { POST_PROCESSING_AREVA };
-static void Blit_postprocessing_revai(Blit *self) { POST_PROCESSING_REVAI };
-static void Blit_postprocessing_revaa(Blit *self) { POST_PROCESSING_REVAA };
-static void Blit_postprocessing_revareva(Blit *self) { POST_PROCESSING_REVAREVA };
+ Rossler *mainRossler;
+ int modebuffer[2];
+} RosslerAlt;
-static void
-Blit_setProcMode(Blit *self)
-{
- int procmode, muladdmode;
- procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
- muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
+static void RosslerAlt_postprocessing_ii(RosslerAlt *self) { POST_PROCESSING_II };
+static void RosslerAlt_postprocessing_ai(RosslerAlt *self) { POST_PROCESSING_AI };
+static void RosslerAlt_postprocessing_ia(RosslerAlt *self) { POST_PROCESSING_IA };
+static void RosslerAlt_postprocessing_aa(RosslerAlt *self) { POST_PROCESSING_AA };
+static void RosslerAlt_postprocessing_ireva(RosslerAlt *self) { POST_PROCESSING_IREVA };
+static void RosslerAlt_postprocessing_areva(RosslerAlt *self) { POST_PROCESSING_AREVA };
+static void RosslerAlt_postprocessing_revai(RosslerAlt *self) { POST_PROCESSING_REVAI };
+static void RosslerAlt_postprocessing_revaa(RosslerAlt *self) { POST_PROCESSING_REVAA };
+static void RosslerAlt_postprocessing_revareva(RosslerAlt *self) { POST_PROCESSING_REVAREVA };
- switch (procmode) {
- case 0:
- self->proc_func_ptr = Blit_readframes_ii;
- break;
- case 1:
- self->proc_func_ptr = Blit_readframes_ai;
- break;
- case 10:
- self->proc_func_ptr = Blit_readframes_ia;
- break;
- case 11:
- self->proc_func_ptr = Blit_readframes_aa;
- break;
- }
+static void
+RosslerAlt_setProcMode(RosslerAlt *self) {
+ int muladdmode;
+ muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
- switch (muladdmode) {
+ switch (muladdmode) {
case 0:
- self->muladd_func_ptr = Blit_postprocessing_ii;
+ self->muladd_func_ptr = RosslerAlt_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = Blit_postprocessing_ai;
+ self->muladd_func_ptr = RosslerAlt_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = Blit_postprocessing_revai;
+ self->muladd_func_ptr = RosslerAlt_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = Blit_postprocessing_ia;
+ self->muladd_func_ptr = RosslerAlt_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = Blit_postprocessing_aa;
+ self->muladd_func_ptr = RosslerAlt_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = Blit_postprocessing_revaa;
+ self->muladd_func_ptr = RosslerAlt_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = Blit_postprocessing_ireva;
+ self->muladd_func_ptr = RosslerAlt_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = Blit_postprocessing_areva;
+ self->muladd_func_ptr = RosslerAlt_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = Blit_postprocessing_revareva;
+ self->muladd_func_ptr = RosslerAlt_postprocessing_revareva;
break;
}
}
static void
-Blit_compute_next_data_frame(Blit *self)
+RosslerAlt_compute_next_data_frame(RosslerAlt *self)
{
- (*self->proc_func_ptr)(self);
+ int i;
+ MYFLT *tmp;
+ tmp = Rossler_getAltBuffer((Rossler *)self->mainRossler);
+ for (i=0; i<self->bufsize; i++) {
+ self->data[i] = tmp[i];
+ }
(*self->muladd_func_ptr)(self);
}
static int
-Blit_traverse(Blit *self, visitproc visit, void *arg)
+RosslerAlt_traverse(RosslerAlt *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->mainRossler);
return 0;
}
static int
-Blit_clear(Blit *self)
+RosslerAlt_clear(RosslerAlt *self)
{
pyo_CLEAR
- Py_CLEAR(self->freq);
- Py_CLEAR(self->freq_stream);
- Py_CLEAR(self->harms);
- Py_CLEAR(self->harms_stream);
+ Py_CLEAR(self->mainRossler);
return 0;
}
static void
-Blit_dealloc(Blit* self)
+RosslerAlt_dealloc(RosslerAlt* self)
{
pyo_DEALLOC
- Blit_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ RosslerAlt_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-Blit_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+RosslerAlt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *freqtmp=NULL, *harmstmp=NULL, *multmp=NULL, *addtmp=NULL;
- Blit *self;
- self = (Blit *)type->tp_alloc(type, 0);
+ PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
+ RosslerAlt *self;
+ self = (RosslerAlt *)type->tp_alloc(type, 0);
- self->freq = PyFloat_FromDouble(100);
- self->harms = PyFloat_FromDouble(40);
- self->modebuffer[0] = 0;
- self->modebuffer[1] = 0;
- self->modebuffer[2] = 0;
- self->modebuffer[3] = 0;
- self->phase = 0.0;
+ self->modebuffer[0] = 0;
+ self->modebuffer[1] = 0;
INIT_OBJECT_COMMON
- Stream_setFunctionPtr(self->stream, Blit_compute_next_data_frame);
- self->mode_func_ptr = Blit_setProcMode;
+ Stream_setFunctionPtr(self->stream, RosslerAlt_compute_next_data_frame);
+ self->mode_func_ptr = RosslerAlt_setProcMode;
- static char *kwlist[] = {"freq", "harms", "mul", "add", NULL};
+ static char *kwlist[] = {"mainRossler", "mul", "alt", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO", kwlist, &freqtmp, &harmstmp, &multmp, &addtmp))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &maintmp, &multmp, &addtmp))
Py_RETURN_NONE;
- if (freqtmp) {
- PyObject_CallMethod((PyObject *)self, "setFreq", "O", freqtmp);
- }
-
- if (harmstmp) {
- PyObject_CallMethod((PyObject *)self, "setHarms", "O", harmstmp);
- }
+ Py_XDECREF(self->mainRossler);
+ Py_INCREF(maintmp);
+ self->mainRossler = (Rossler *)maintmp;
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
@@ -7211,168 +8578,100 @@ Blit_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return (PyObject *)self;
}
-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_play(Blit *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * Blit_out(Blit *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * Blit_stop(Blit *self) { STOP };
-
-static PyObject * Blit_multiply(Blit *self, PyObject *arg) { MULTIPLY };
-static PyObject * Blit_inplace_multiply(Blit *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * Blit_add(Blit *self, PyObject *arg) { ADD };
-static PyObject * Blit_inplace_add(Blit *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * Blit_sub(Blit *self, PyObject *arg) { SUB };
-static PyObject * Blit_inplace_sub(Blit *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * Blit_div(Blit *self, PyObject *arg) { DIV };
-static PyObject * Blit_inplace_div(Blit *self, PyObject *arg) { INPLACE_DIV };
-
-static PyObject *
-Blit_setFreq(Blit *self, PyObject *arg)
-{
- PyObject *tmp, *streamtmp;
-
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
-
- tmp = arg;
- Py_INCREF(tmp);
- Py_DECREF(self->freq);
- if (isNumber == 1) {
- self->freq = PyNumber_Float(tmp);
- self->modebuffer[2] = 0;
- }
- else {
- self->freq = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->freq, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->freq_stream);
- 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;
-
- ASSERT_ARG_NOT_NULL
-
- int isNumber = PyNumber_Check(arg);
-
- tmp = arg;
- Py_INCREF(tmp);
- Py_DECREF(self->harms);
- if (isNumber == 1) {
- self->harms = PyNumber_Float(tmp);
- self->modebuffer[3] = 0;
- }
- else {
- self->harms = tmp;
- streamtmp = PyObject_CallMethod((PyObject *)self->harms, "_getStream", NULL);
- Py_INCREF(streamtmp);
- Py_XDECREF(self->harms_stream);
- self->harms_stream = (Stream *)streamtmp;
- self->modebuffer[3] = 1;
- }
-
- (*self->mode_func_ptr)(self);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
+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 PyMemberDef Blit_members[] = {
- {"server", T_OBJECT_EX, offsetof(Blit, server), 0, "Pyo server."},
- {"stream", T_OBJECT_EX, offsetof(Blit, stream), 0, "Stream object."},
- {"freq", T_OBJECT_EX, offsetof(Blit, freq), 0, "Frequency in cycle per second."},
- {"harms", T_OBJECT_EX, offsetof(Blit, harms), 0, "Number of harmonics."},
- {"mul", T_OBJECT_EX, offsetof(Blit, mul), 0, "Mul factor."},
- {"add", T_OBJECT_EX, offsetof(Blit, add), 0, "Add factor."},
- {NULL} /* Sentinel */
-};
+static PyObject * RosslerAlt_play(RosslerAlt *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * RosslerAlt_out(RosslerAlt *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * RosslerAlt_stop(RosslerAlt *self) { STOP };
-static PyMethodDef Blit_methods[] = {
- {"getServer", (PyCFunction)Blit_getServer, METH_NOARGS, "Returns server object."},
- {"_getStream", (PyCFunction)Blit_getStream, METH_NOARGS, "Returns stream object."},
- {"play", (PyCFunction)Blit_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundfreqd."},
- {"out", (PyCFunction)Blit_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundfreqd channel speficied by argument."},
- {"stop", (PyCFunction)Blit_stop, METH_NOARGS, "Stops computing."},
- {"setFreq", (PyCFunction)Blit_setFreq, METH_O, "Sets frequency in cycle per second."},
- {"setHarms", (PyCFunction)Blit_setHarms, METH_O, "Sets the number of harmonics."},
- {"setMul", (PyCFunction)Blit_setMul, METH_O, "Sets Blit mul factor."},
- {"setAdd", (PyCFunction)Blit_setAdd, METH_O, "Sets Blit add factor."},
- {"setSub", (PyCFunction)Blit_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)Blit_setDiv, METH_O, "Sets inverse mul factor."},
- {NULL} /* Sentinel */
-};
+static PyObject * RosslerAlt_multiply(RosslerAlt *self, PyObject *arg) { MULTIPLY };
+static PyObject * RosslerAlt_inplace_multiply(RosslerAlt *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * RosslerAlt_add(RosslerAlt *self, PyObject *arg) { ADD };
+static PyObject * RosslerAlt_inplace_add(RosslerAlt *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * RosslerAlt_sub(RosslerAlt *self, PyObject *arg) { SUB };
+static PyObject * RosslerAlt_inplace_sub(RosslerAlt *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * RosslerAlt_div(RosslerAlt *self, PyObject *arg) { DIV };
+static PyObject * RosslerAlt_inplace_div(RosslerAlt *self, PyObject *arg) { INPLACE_DIV };
-static PyNumberMethods Blit_as_number = {
- (binaryfunc)Blit_add, /*nb_add*/
- (binaryfunc)Blit_sub, /*nb_subtract*/
- (binaryfunc)Blit_multiply, /*nb_multiply*/
- (binaryfunc)Blit_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)Blit_inplace_add, /*inplace_add*/
- (binaryfunc)Blit_inplace_sub, /*inplace_subtract*/
- (binaryfunc)Blit_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Blit_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_cutoff */
+static PyMemberDef RosslerAlt_members[] = {
+ {"server", T_OBJECT_EX, offsetof(RosslerAlt, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(RosslerAlt, stream), 0, "Stream object."},
+ {"mul", T_OBJECT_EX, offsetof(RosslerAlt, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(RosslerAlt, add), 0, "Add factor."},
+ {NULL} /* Sentinel */
};
-PyTypeObject BlitType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.Blit_base", /*tp_name*/
- sizeof(Blit), /*tp_basicsize*/
+static PyMethodDef RosslerAlt_methods[] = {
+ {"getServer", (PyCFunction)RosslerAlt_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)RosslerAlt_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)RosslerAlt_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)RosslerAlt_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)RosslerAlt_stop, METH_NOARGS, "Stops computing."},
+ {"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."},
+ {NULL} /* Sentinel */
+};
+static PyNumberMethods RosslerAlt_as_number = {
+ (binaryfunc)RosslerAlt_add, /*nb_add*/
+ (binaryfunc)RosslerAlt_sub, /*nb_subtract*/
+ (binaryfunc)RosslerAlt_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*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*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+ 0, /*nb_int*/
+ 0, /*nb_long*/
+ 0, /*nb_float*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)RosslerAlt_inplace_add, /*inplace_add*/
+ (binaryfunc)RosslerAlt_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)RosslerAlt_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+ (binaryfunc)RosslerAlt_div, /*nb_true_divide*/
+ 0, /*nb_inplace_floor_divide*/
+ (binaryfunc)RosslerAlt_inplace_div, /*nb_inplace_true_divide*/
+ 0, /* nb_index */
+};
+
+PyTypeObject RosslerAltType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.RosslerAlt_base", /*tp_name*/
+ sizeof(RosslerAlt), /*tp_basicsize*/
0, /*tp_itemsize*/
- (destructor)Blit_dealloc, /*tp_dealloc*/
+ (destructor)RosslerAlt_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
- &Blit_as_number, /*tp_as_number*/
+ &RosslerAlt_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -7382,15 +8681,15 @@ PyTypeObject BlitType = {
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
- "Blit objects. Generates a band limited impulse train.", /* tp_doc */
- (traverseproc)Blit_traverse, /* tp_traverse */
- (inquiry)Blit_clear, /* tp_clear */
+ "RosslerAlt objects. Sends the alternate signal of a Rossler attractor.", /* tp_doc */
+ (traverseproc)RosslerAlt_traverse, /* tp_traverse */
+ (inquiry)RosslerAlt_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- Blit_methods, /* tp_methods */
- Blit_members, /* tp_members */
+ RosslerAlt_methods, /* tp_methods */
+ RosslerAlt_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -7399,10 +8698,10 @@ PyTypeObject BlitType = {
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- Blit_new, /* tp_new */
+ RosslerAlt_new, /* tp_new */
};
-/* Rossler object */
+/* Lorenz object */
typedef struct {
pyo_audio_HEAD
PyObject *pitch;
@@ -7418,12 +8717,12 @@ typedef struct {
MYFLT vZ;
MYFLT pA;
MYFLT pB;
- MYFLT scalePitch;
+ MYFLT oneOnSr;
int modebuffer[4];
-} Rossler;
+} Lorenz;
static void
-Rossler_readframes_ii(Rossler *self) {
+Lorenz_readframes_ii(Lorenz *self) {
MYFLT delta, pit, chao;
int i;
@@ -7432,70 +8731,70 @@ Rossler_readframes_ii(Rossler *self) {
if (pit < 0.0)
pit = 1.0;
else if (pit > 1.0)
- pit = 1000.0;
+ pit = 750.0;
else
- pit = pit * 999.0 + 1.0;
- delta = self->scalePitch * pit;
+ pit = pit * 749.0 + 1.0;
+ delta = self->oneOnSr * pit;
if (chao < 0.0)
- chao = 3.0;
+ chao = 0.5;
else if (chao > 1.0)
- chao = 10.0;
+ chao = 3.0;
else
- chao = chao * 7.0 + 3.0;
+ chao = chao * 2.5 + 0.5;
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->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 * ROSSLER_SCALE;
- self->altBuffer[i] = self->vY * ROSSLER_ALT_SCALE;
+ self->data[i] = self->vX * LORENZ_SCALE;
+ self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
}
}
static void
-Rossler_readframes_ai(Rossler *self) {
+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)
- chao = 3.0;
+ chao = 0.5;
else if (chao > 1.0)
- chao = 10.0;
+ chao = 3.0;
else
- chao = chao * 7.0 + 3.0;
+ chao = chao * 2.5 + 0.5;
for (i=0; i<self->bufsize; i++) {
pit = fr[i];
if (pit < 0.0)
pit = 1.0;
else if (pit > 1.0)
- pit = 1000.0;
+ pit = 750.0;
else
- pit = pit * 999.0 + 1.0;
- delta = self->scalePitch * pit;
- self->vDX = -self->vY - self->vZ;
- self->vDY = self->vX + self->pA * self->vY;
- self->vDZ = self->pB + self->vZ * (self->vX - chao);
+ pit = pit * 749.0 + 1.0;
+ delta = self->oneOnSr * pit;
+ 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 * ROSSLER_SCALE;
- self->altBuffer[i] = self->vY * ROSSLER_ALT_SCALE;
+ self->data[i] = self->vX * LORENZ_SCALE;
+ self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
}
}
static void
-Rossler_readframes_ia(Rossler *self) {
+Lorenz_readframes_ia(Lorenz *self) {
MYFLT delta, pit, chao;
int i;
@@ -7505,34 +8804,34 @@ Rossler_readframes_ia(Rossler *self) {
if (pit < 0.0)
pit = 1.0;
else if (pit > 1.0)
- pit = 1000.0;
+ pit = 750.0;
else
- pit = pit * 999.0 + 1.0;
- delta = self->scalePitch * pit;
+ pit = pit * 749.0 + 1.0;
+ delta = self->oneOnSr * pit;
for (i=0; i<self->bufsize; i++) {
chao = ch[i];
if (chao < 0.0)
- chao = 3.0;
+ chao = 0.5;
else if (chao > 1.0)
- chao = 10.0;
+ chao = 3.0;
else
- 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);
+ 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 * ROSSLER_SCALE;
- self->altBuffer[i] = self->vY * ROSSLER_ALT_SCALE;
+ self->data[i] = self->vX * LORENZ_SCALE;
+ self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
}
}
static void
-Rossler_readframes_aa(Rossler *self) {
+Lorenz_readframes_aa(Lorenz *self) {
MYFLT delta, pit, chao;
int i;
@@ -7544,43 +8843,43 @@ Rossler_readframes_aa(Rossler *self) {
if (pit < 0.0)
pit = 1.0;
else if (pit > 1.0)
- pit = 1000.0;
+ pit = 750.0;
else
- pit = pit * 999.0 + 1.0;
- delta = self->scalePitch * pit;
+ pit = pit * 749.0 + 1.0;
+ delta = self->oneOnSr * pit;
chao = ch[i];
if (chao < 0.0)
- chao = 3.0;
+ chao = 0.5;
else if (chao > 1.0)
- chao = 10.0;
+ chao = 3.0;
else
- 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);
+ 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 * ROSSLER_SCALE;
- self->altBuffer[i] = self->vY * ROSSLER_ALT_SCALE;
+ self->data[i] = self->vX * LORENZ_SCALE;
+ self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
}
}
-static void Rossler_postprocessing_ii(Rossler *self) { POST_PROCESSING_II };
-static void Rossler_postprocessing_ai(Rossler *self) { POST_PROCESSING_AI };
-static void Rossler_postprocessing_ia(Rossler *self) { POST_PROCESSING_IA };
-static void Rossler_postprocessing_aa(Rossler *self) { POST_PROCESSING_AA };
-static void Rossler_postprocessing_ireva(Rossler *self) { POST_PROCESSING_IREVA };
-static void Rossler_postprocessing_areva(Rossler *self) { POST_PROCESSING_AREVA };
-static void Rossler_postprocessing_revai(Rossler *self) { POST_PROCESSING_REVAI };
-static void Rossler_postprocessing_revaa(Rossler *self) { POST_PROCESSING_REVAA };
-static void Rossler_postprocessing_revareva(Rossler *self) { POST_PROCESSING_REVAREVA };
+static void Lorenz_postprocessing_ii(Lorenz *self) { POST_PROCESSING_II };
+static void Lorenz_postprocessing_ai(Lorenz *self) { POST_PROCESSING_AI };
+static void Lorenz_postprocessing_ia(Lorenz *self) { POST_PROCESSING_IA };
+static void Lorenz_postprocessing_aa(Lorenz *self) { POST_PROCESSING_AA };
+static void Lorenz_postprocessing_ireva(Lorenz *self) { POST_PROCESSING_IREVA };
+static void Lorenz_postprocessing_areva(Lorenz *self) { POST_PROCESSING_AREVA };
+static void Lorenz_postprocessing_revai(Lorenz *self) { POST_PROCESSING_REVAI };
+static void Lorenz_postprocessing_revaa(Lorenz *self) { POST_PROCESSING_REVAA };
+static void Lorenz_postprocessing_revareva(Lorenz *self) { POST_PROCESSING_REVAREVA };
static void
-Rossler_setProcMode(Rossler *self)
+Lorenz_setProcMode(Lorenz *self)
{
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
@@ -7588,59 +8887,59 @@ Rossler_setProcMode(Rossler *self)
switch (procmode) {
case 0:
- self->proc_func_ptr = Rossler_readframes_ii;
+ self->proc_func_ptr = Lorenz_readframes_ii;
break;
case 1:
- self->proc_func_ptr = Rossler_readframes_ai;
+ self->proc_func_ptr = Lorenz_readframes_ai;
break;
case 10:
- self->proc_func_ptr = Rossler_readframes_ia;
+ self->proc_func_ptr = Lorenz_readframes_ia;
break;
case 11:
- self->proc_func_ptr = Rossler_readframes_aa;
+ self->proc_func_ptr = Lorenz_readframes_aa;
break;
}
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = Rossler_postprocessing_ii;
+ self->muladd_func_ptr = Lorenz_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = Rossler_postprocessing_ai;
+ self->muladd_func_ptr = Lorenz_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = Rossler_postprocessing_revai;
+ self->muladd_func_ptr = Lorenz_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = Rossler_postprocessing_ia;
+ self->muladd_func_ptr = Lorenz_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = Rossler_postprocessing_aa;
+ self->muladd_func_ptr = Lorenz_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = Rossler_postprocessing_revaa;
+ self->muladd_func_ptr = Lorenz_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = Rossler_postprocessing_ireva;
+ self->muladd_func_ptr = Lorenz_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = Rossler_postprocessing_areva;
+ self->muladd_func_ptr = Lorenz_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = Rossler_postprocessing_revareva;
+ self->muladd_func_ptr = Lorenz_postprocessing_revareva;
break;
}
}
static void
-Rossler_compute_next_data_frame(Rossler *self)
+Lorenz_compute_next_data_frame(Lorenz *self)
{
(*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
static int
-Rossler_traverse(Rossler *self, visitproc visit, void *arg)
+Lorenz_traverse(Lorenz *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->pitch);
@@ -7651,7 +8950,7 @@ Rossler_traverse(Rossler *self, visitproc visit, void *arg)
}
static int
-Rossler_clear(Rossler *self)
+Lorenz_clear(Lorenz *self)
{
pyo_CLEAR
Py_CLEAR(self->pitch);
@@ -7662,26 +8961,26 @@ Rossler_clear(Rossler *self)
}
static void
-Rossler_dealloc(Rossler* self)
+Lorenz_dealloc(Lorenz* self)
{
pyo_DEALLOC
free(self->altBuffer);
- Rossler_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Lorenz_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-Rossler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+Lorenz_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
PyObject *pitchtmp=NULL, *chaostmp=NULL, *multmp=NULL, *addtmp=NULL;
- Rossler *self;
- self = (Rossler *)type->tp_alloc(type, 0);
+ Lorenz *self;
+ self = (Lorenz *)type->tp_alloc(type, 0);
self->pitch = PyFloat_FromDouble(0.25);
self->chaos = PyFloat_FromDouble(0.5);
- self->pA = 0.15;
- self->pB = 0.20;
+ self->pA = 10.0;
+ self->pB = 28.0;
self->vDX = self->vDY = self->vDZ = 0.0;
self->vX = self->vY = self->vZ = 1.0;
self->modebuffer[0] = 0;
@@ -7690,10 +8989,10 @@ Rossler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
INIT_OBJECT_COMMON
- Stream_setFunctionPtr(self->stream, Rossler_compute_next_data_frame);
- self->mode_func_ptr = Rossler_setProcMode;
+ Stream_setFunctionPtr(self->stream, Lorenz_compute_next_data_frame);
+ self->mode_func_ptr = Lorenz_setProcMode;
- self->scalePitch = 2.91 / self->sr;
+ self->oneOnSr = 1.0 / self->sr;
static char *kwlist[] = {"pitch", "chaos", "mul", "add", NULL};
@@ -7727,30 +9026,30 @@ Rossler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
(*self->mode_func_ptr)(self);
return (PyObject *)self;
-}
-
-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_play(Rossler *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * Rossler_out(Rossler *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * Rossler_stop(Rossler *self) { STOP };
+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 * Rossler_multiply(Rossler *self, PyObject *arg) { MULTIPLY };
-static PyObject * Rossler_inplace_multiply(Rossler *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * Rossler_add(Rossler *self, PyObject *arg) { ADD };
-static PyObject * Rossler_inplace_add(Rossler *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * Rossler_sub(Rossler *self, PyObject *arg) { SUB };
-static PyObject * Rossler_inplace_sub(Rossler *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * Rossler_div(Rossler *self, PyObject *arg) { DIV };
-static PyObject * Rossler_inplace_div(Rossler *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * Lorenz_play(Lorenz *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * Lorenz_out(Lorenz *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * Lorenz_stop(Lorenz *self) { STOP };
+
+static PyObject * Lorenz_multiply(Lorenz *self, PyObject *arg) { MULTIPLY };
+static PyObject * Lorenz_inplace_multiply(Lorenz *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * Lorenz_add(Lorenz *self, PyObject *arg) { ADD };
+static PyObject * Lorenz_inplace_add(Lorenz *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * Lorenz_sub(Lorenz *self, PyObject *arg) { SUB };
+static PyObject * Lorenz_inplace_sub(Lorenz *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * Lorenz_div(Lorenz *self, PyObject *arg) { DIV };
+static PyObject * Lorenz_inplace_div(Lorenz *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-Rossler_setPitch(Rossler *self, PyObject *arg)
+Lorenz_setPitch(Lorenz *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -7781,7 +9080,7 @@ Rossler_setPitch(Rossler *self, PyObject *arg)
}
static PyObject *
-Rossler_setChaos(Rossler *self, PyObject *arg)
+Lorenz_setChaos(Lorenz *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -7812,41 +9111,41 @@ Rossler_setChaos(Rossler *self, PyObject *arg)
}
MYFLT *
-Rossler_getAltBuffer(Rossler *self)
+Lorenz_getAltBuffer(Lorenz *self)
{
return (MYFLT *)self->altBuffer;
}
-static PyMemberDef Rossler_members[] = {
- {"server", T_OBJECT_EX, offsetof(Rossler, server), 0, "Pyo server."},
- {"stream", T_OBJECT_EX, offsetof(Rossler, stream), 0, "Stream object."},
- {"pitch", T_OBJECT_EX, offsetof(Rossler, pitch), 0, "Pitch."},
- {"chaos", T_OBJECT_EX, offsetof(Rossler, chaos), 0, "Chaotic behavior."},
- {"mul", T_OBJECT_EX, offsetof(Rossler, mul), 0, "Mul factor."},
- {"add", T_OBJECT_EX, offsetof(Rossler, add), 0, "Add factor."},
+static PyMemberDef Lorenz_members[] = {
+ {"server", T_OBJECT_EX, offsetof(Lorenz, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(Lorenz, stream), 0, "Stream object."},
+ {"pitch", T_OBJECT_EX, offsetof(Lorenz, pitch), 0, "Pitch."},
+ {"chaos", T_OBJECT_EX, offsetof(Lorenz, chaos), 0, "Chaotic behavior."},
+ {"mul", T_OBJECT_EX, offsetof(Lorenz, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(Lorenz, add), 0, "Add factor."},
{NULL} /* Sentinel */
};
-static PyMethodDef Rossler_methods[] = {
- {"getServer", (PyCFunction)Rossler_getServer, METH_NOARGS, "Returns server object."},
- {"_getStream", (PyCFunction)Rossler_getStream, METH_NOARGS, "Returns stream object."},
- {"play", (PyCFunction)Rossler_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
- {"out", (PyCFunction)Rossler_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
- {"stop", (PyCFunction)Rossler_stop, METH_NOARGS, "Stops computing."},
- {"setPitch", (PyCFunction)Rossler_setPitch, METH_O, "Sets oscillator pitch."},
- {"setChaos", (PyCFunction)Rossler_setChaos, METH_O, "Sets oscillator chaotic behavior."},
- {"setMul", (PyCFunction)Rossler_setMul, METH_O, "Sets Rossler mul factor."},
- {"setAdd", (PyCFunction)Rossler_setAdd, METH_O, "Sets Rossler add factor."},
- {"setSub", (PyCFunction)Rossler_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)Rossler_setDiv, METH_O, "Sets inverse mul factor."},
+static PyMethodDef Lorenz_methods[] = {
+ {"getServer", (PyCFunction)Lorenz_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)Lorenz_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)Lorenz_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)Lorenz_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)Lorenz_stop, METH_NOARGS, "Stops computing."},
+ {"setPitch", (PyCFunction)Lorenz_setPitch, METH_O, "Sets oscillator pitch."},
+ {"setChaos", (PyCFunction)Lorenz_setChaos, METH_O, "Sets oscillator chaotic behavior."},
+ {"setMul", (PyCFunction)Lorenz_setMul, METH_O, "Sets Lorenz mul factor."},
+ {"setAdd", (PyCFunction)Lorenz_setAdd, METH_O, "Sets Lorenz add factor."},
+ {"setSub", (PyCFunction)Lorenz_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)Lorenz_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
-static PyNumberMethods Rossler_as_number = {
- (binaryfunc)Rossler_add, /*nb_add*/
- (binaryfunc)Rossler_sub, /*nb_subtract*/
- (binaryfunc)Rossler_multiply, /*nb_multiply*/
- (binaryfunc)Rossler_div, /*nb_divide*/
+static PyNumberMethods Lorenz_as_number = {
+ (binaryfunc)Lorenz_add, /*nb_add*/
+ (binaryfunc)Lorenz_sub, /*nb_subtract*/
+ (binaryfunc)Lorenz_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -7860,16 +9159,16 @@ static PyNumberMethods Rossler_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
- (binaryfunc)Rossler_inplace_add, /*inplace_add*/
- (binaryfunc)Rossler_inplace_sub, /*inplace_subtract*/
- (binaryfunc)Rossler_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Rossler_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)Lorenz_inplace_add, /*inplace_add*/
+ (binaryfunc)Lorenz_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)Lorenz_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -7878,25 +9177,24 @@ static PyNumberMethods Rossler_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Lorenz_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Lorenz_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
-PyTypeObject RosslerType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.Rossler_base", /*tp_name*/
- sizeof(Rossler), /*tp_basicsize*/
+PyTypeObject LorenzType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.Lorenz_base", /*tp_name*/
+ sizeof(Lorenz), /*tp_basicsize*/
0, /*tp_itemsize*/
- (destructor)Rossler_dealloc, /*tp_dealloc*/
+ (destructor)Lorenz_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
- &Rossler_as_number, /*tp_as_number*/
+ &Lorenz_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -7906,15 +9204,15 @@ PyTypeObject RosslerType = {
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
- "Rossler objects. Rossler attractor.", /* tp_doc */
- (traverseproc)Rossler_traverse, /* tp_traverse */
- (inquiry)Rossler_clear, /* tp_clear */
+ "Lorenz objects. Lorenz attractor.", /* tp_doc */
+ (traverseproc)Lorenz_traverse, /* tp_traverse */
+ (inquiry)Lorenz_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- Rossler_methods, /* tp_methods */
- Rossler_members, /* tp_members */
+ Lorenz_methods, /* tp_methods */
+ Lorenz_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -7923,67 +9221,67 @@ PyTypeObject RosslerType = {
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- Rossler_new, /* tp_new */
+ Lorenz_new, /* tp_new */
};
typedef struct {
pyo_audio_HEAD
- Rossler *mainRossler;
+ Lorenz *mainLorenz;
int modebuffer[2];
-} RosslerAlt;
+} LorenzAlt;
-static void RosslerAlt_postprocessing_ii(RosslerAlt *self) { POST_PROCESSING_II };
-static void RosslerAlt_postprocessing_ai(RosslerAlt *self) { POST_PROCESSING_AI };
-static void RosslerAlt_postprocessing_ia(RosslerAlt *self) { POST_PROCESSING_IA };
-static void RosslerAlt_postprocessing_aa(RosslerAlt *self) { POST_PROCESSING_AA };
-static void RosslerAlt_postprocessing_ireva(RosslerAlt *self) { POST_PROCESSING_IREVA };
-static void RosslerAlt_postprocessing_areva(RosslerAlt *self) { POST_PROCESSING_AREVA };
-static void RosslerAlt_postprocessing_revai(RosslerAlt *self) { POST_PROCESSING_REVAI };
-static void RosslerAlt_postprocessing_revaa(RosslerAlt *self) { POST_PROCESSING_REVAA };
-static void RosslerAlt_postprocessing_revareva(RosslerAlt *self) { POST_PROCESSING_REVAREVA };
+static void LorenzAlt_postprocessing_ii(LorenzAlt *self) { POST_PROCESSING_II };
+static void LorenzAlt_postprocessing_ai(LorenzAlt *self) { POST_PROCESSING_AI };
+static void LorenzAlt_postprocessing_ia(LorenzAlt *self) { POST_PROCESSING_IA };
+static void LorenzAlt_postprocessing_aa(LorenzAlt *self) { POST_PROCESSING_AA };
+static void LorenzAlt_postprocessing_ireva(LorenzAlt *self) { POST_PROCESSING_IREVA };
+static void LorenzAlt_postprocessing_areva(LorenzAlt *self) { POST_PROCESSING_AREVA };
+static void LorenzAlt_postprocessing_revai(LorenzAlt *self) { POST_PROCESSING_REVAI };
+static void LorenzAlt_postprocessing_revaa(LorenzAlt *self) { POST_PROCESSING_REVAA };
+static void LorenzAlt_postprocessing_revareva(LorenzAlt *self) { POST_PROCESSING_REVAREVA };
static void
-RosslerAlt_setProcMode(RosslerAlt *self) {
+LorenzAlt_setProcMode(LorenzAlt *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = RosslerAlt_postprocessing_ii;
+ self->muladd_func_ptr = LorenzAlt_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = RosslerAlt_postprocessing_ai;
+ self->muladd_func_ptr = LorenzAlt_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = RosslerAlt_postprocessing_revai;
+ self->muladd_func_ptr = LorenzAlt_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = RosslerAlt_postprocessing_ia;
+ self->muladd_func_ptr = LorenzAlt_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = RosslerAlt_postprocessing_aa;
+ self->muladd_func_ptr = LorenzAlt_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = RosslerAlt_postprocessing_revaa;
+ self->muladd_func_ptr = LorenzAlt_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = RosslerAlt_postprocessing_ireva;
+ self->muladd_func_ptr = LorenzAlt_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = RosslerAlt_postprocessing_areva;
+ self->muladd_func_ptr = LorenzAlt_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = RosslerAlt_postprocessing_revareva;
+ self->muladd_func_ptr = LorenzAlt_postprocessing_revareva;
break;
}
}
static void
-RosslerAlt_compute_next_data_frame(RosslerAlt *self)
+LorenzAlt_compute_next_data_frame(LorenzAlt *self)
{
int i;
MYFLT *tmp;
- tmp = Rossler_getAltBuffer((Rossler *)self->mainRossler);
+ tmp = Lorenz_getAltBuffer((Lorenz *)self->mainLorenz);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i];
}
@@ -7991,52 +9289,52 @@ RosslerAlt_compute_next_data_frame(RosslerAlt *self)
}
static int
-RosslerAlt_traverse(RosslerAlt *self, visitproc visit, void *arg)
+LorenzAlt_traverse(LorenzAlt *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->mainRossler);
+ Py_VISIT(self->mainLorenz);
return 0;
}
static int
-RosslerAlt_clear(RosslerAlt *self)
+LorenzAlt_clear(LorenzAlt *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainRossler);
+ Py_CLEAR(self->mainLorenz);
return 0;
}
static void
-RosslerAlt_dealloc(RosslerAlt* self)
+LorenzAlt_dealloc(LorenzAlt* self)
{
pyo_DEALLOC
- RosslerAlt_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ LorenzAlt_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-RosslerAlt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+LorenzAlt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
- RosslerAlt *self;
- self = (RosslerAlt *)type->tp_alloc(type, 0);
+ LorenzAlt *self;
+ self = (LorenzAlt *)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;
+ Stream_setFunctionPtr(self->stream, LorenzAlt_compute_next_data_frame);
+ self->mode_func_ptr = LorenzAlt_setProcMode;
- static char *kwlist[] = {"mainRossler", "mul", "alt", NULL};
+ static char *kwlist[] = {"mainLorenz", "mul", "alt", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &maintmp, &multmp, &addtmp))
Py_RETURN_NONE;
- Py_XDECREF(self->mainRossler);
+ Py_XDECREF(self->mainLorenz);
Py_INCREF(maintmp);
- self->mainRossler = (Rossler *)maintmp;
+ self->mainLorenz = (Lorenz *)maintmp;
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
@@ -8053,51 +9351,51 @@ RosslerAlt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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 * 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 * RosslerAlt_play(RosslerAlt *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * RosslerAlt_out(RosslerAlt *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * RosslerAlt_stop(RosslerAlt *self) { STOP };
+static PyObject * LorenzAlt_play(LorenzAlt *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * LorenzAlt_out(LorenzAlt *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * LorenzAlt_stop(LorenzAlt *self) { STOP };
-static PyObject * RosslerAlt_multiply(RosslerAlt *self, PyObject *arg) { MULTIPLY };
-static PyObject * RosslerAlt_inplace_multiply(RosslerAlt *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * RosslerAlt_add(RosslerAlt *self, PyObject *arg) { ADD };
-static PyObject * RosslerAlt_inplace_add(RosslerAlt *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * RosslerAlt_sub(RosslerAlt *self, PyObject *arg) { SUB };
-static PyObject * RosslerAlt_inplace_sub(RosslerAlt *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * RosslerAlt_div(RosslerAlt *self, PyObject *arg) { DIV };
-static PyObject * RosslerAlt_inplace_div(RosslerAlt *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * LorenzAlt_multiply(LorenzAlt *self, PyObject *arg) { MULTIPLY };
+static PyObject * LorenzAlt_inplace_multiply(LorenzAlt *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * LorenzAlt_add(LorenzAlt *self, PyObject *arg) { ADD };
+static PyObject * LorenzAlt_inplace_add(LorenzAlt *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * LorenzAlt_sub(LorenzAlt *self, PyObject *arg) { SUB };
+static PyObject * LorenzAlt_inplace_sub(LorenzAlt *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * LorenzAlt_div(LorenzAlt *self, PyObject *arg) { DIV };
+static PyObject * LorenzAlt_inplace_div(LorenzAlt *self, PyObject *arg) { INPLACE_DIV };
-static PyMemberDef RosslerAlt_members[] = {
- {"server", T_OBJECT_EX, offsetof(RosslerAlt, server), 0, "Pyo server."},
- {"stream", T_OBJECT_EX, offsetof(RosslerAlt, stream), 0, "Stream object."},
- {"mul", T_OBJECT_EX, offsetof(RosslerAlt, mul), 0, "Mul factor."},
- {"add", T_OBJECT_EX, offsetof(RosslerAlt, add), 0, "Add factor."},
+static PyMemberDef LorenzAlt_members[] = {
+ {"server", T_OBJECT_EX, offsetof(LorenzAlt, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(LorenzAlt, stream), 0, "Stream object."},
+ {"mul", T_OBJECT_EX, offsetof(LorenzAlt, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(LorenzAlt, add), 0, "Add factor."},
{NULL} /* Sentinel */
};
-static PyMethodDef RosslerAlt_methods[] = {
- {"getServer", (PyCFunction)RosslerAlt_getServer, METH_NOARGS, "Returns server object."},
- {"_getStream", (PyCFunction)RosslerAlt_getStream, METH_NOARGS, "Returns stream object."},
- {"play", (PyCFunction)RosslerAlt_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
- {"out", (PyCFunction)RosslerAlt_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
- {"stop", (PyCFunction)RosslerAlt_stop, METH_NOARGS, "Stops computing."},
- {"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."},
+static PyMethodDef LorenzAlt_methods[] = {
+ {"getServer", (PyCFunction)LorenzAlt_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)LorenzAlt_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)LorenzAlt_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)LorenzAlt_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)LorenzAlt_stop, METH_NOARGS, "Stops computing."},
+ {"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."},
{NULL} /* Sentinel */
};
-static PyNumberMethods RosslerAlt_as_number = {
- (binaryfunc)RosslerAlt_add, /*nb_add*/
- (binaryfunc)RosslerAlt_sub, /*nb_subtract*/
- (binaryfunc)RosslerAlt_multiply, /*nb_multiply*/
- (binaryfunc)RosslerAlt_div, /*nb_divide*/
+static PyNumberMethods LorenzAlt_as_number = {
+ (binaryfunc)LorenzAlt_add, /*nb_add*/
+ (binaryfunc)LorenzAlt_sub, /*nb_subtract*/
+ (binaryfunc)LorenzAlt_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -8111,16 +9409,16 @@ static PyNumberMethods RosslerAlt_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
- (binaryfunc)RosslerAlt_inplace_add, /*inplace_add*/
- (binaryfunc)RosslerAlt_inplace_sub, /*inplace_subtract*/
- (binaryfunc)RosslerAlt_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)RosslerAlt_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)LorenzAlt_inplace_add, /*inplace_add*/
+ (binaryfunc)LorenzAlt_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)LorenzAlt_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -8129,25 +9427,24 @@ static PyNumberMethods RosslerAlt_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)LorenzAlt_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)LorenzAlt_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
-PyTypeObject RosslerAltType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.RosslerAlt_base", /*tp_name*/
- sizeof(RosslerAlt), /*tp_basicsize*/
+PyTypeObject LorenzAltType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.LorenzAlt_base", /*tp_name*/
+ sizeof(LorenzAlt), /*tp_basicsize*/
0, /*tp_itemsize*/
- (destructor)RosslerAlt_dealloc, /*tp_dealloc*/
+ (destructor)LorenzAlt_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
- &RosslerAlt_as_number, /*tp_as_number*/
+ &LorenzAlt_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -8157,15 +9454,15 @@ PyTypeObject RosslerAltType = {
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
- "RosslerAlt objects. Sends the alternate signal of a Rossler attractor.", /* tp_doc */
- (traverseproc)RosslerAlt_traverse, /* tp_traverse */
- (inquiry)RosslerAlt_clear, /* tp_clear */
+ "LorenzAlt objects. Sends the alternate signal of a Lorenz attractor.", /* tp_doc */
+ (traverseproc)LorenzAlt_traverse, /* tp_traverse */
+ (inquiry)LorenzAlt_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- RosslerAlt_methods, /* tp_methods */
- RosslerAlt_members, /* tp_members */
+ LorenzAlt_methods, /* tp_methods */
+ LorenzAlt_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -8174,10 +9471,10 @@ PyTypeObject RosslerAltType = {
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- RosslerAlt_new, /* tp_new */
+ LorenzAlt_new, /* tp_new */
};
-/* Lorenz object */
+/* ChenLee object */
typedef struct {
pyo_audio_HEAD
PyObject *pitch;
@@ -8195,10 +9492,10 @@ typedef struct {
MYFLT pB;
MYFLT oneOnSr;
int modebuffer[4];
-} Lorenz;
+} ChenLee;
static void
-Lorenz_readframes_ii(Lorenz *self) {
+ChenLee_readframes_ii(ChenLee *self) {
MYFLT delta, pit, chao;
int i;
@@ -8207,70 +9504,74 @@ Lorenz_readframes_ii(Lorenz *self) {
if (pit < 0.0)
pit = 1.0;
else if (pit > 1.0)
- pit = 750.0;
+ pit = 125.0;
else
- pit = pit * 749.0 + 1.0;
+ pit = pit * 124.0 + 1.0;
delta = self->oneOnSr * pit;
if (chao < 0.0)
- chao = 0.5;
+ chao = 4.0;
else if (chao > 1.0)
- chao = 3.0;
+ chao = 2.51;
else
- chao = chao * 2.5 + 0.5;
+ chao = (1.0 - chao) * 1.49 + 2.51;
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->vDX = -self->vY * self->vZ + self->pA * self->vX;
+ self->vDY = self->vX * self->vZ - self->pB * self->vY;
+ self->vDZ = self->vX * self->vY / 3.0 - chao * self->vZ;
self->vX += self->vDX * delta;
+ self->vX = (self->vX > 50.0) ? 50.0 : (self->vX < -50.0) ? -50.0 : self->vX;
self->vY += self->vDY * delta;
+ self->vY = (self->vY > 50.0) ? 50.0 : (self->vY < -50.0) ? -50.0 : self->vY;
self->vZ += self->vDZ * delta;
- self->data[i] = self->vX * LORENZ_SCALE;
- self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
+ self->data[i] = self->vX * CHENLEE_SCALE;
+ self->altBuffer[i] = self->vY * CHENLEE_ALT_SCALE;
}
}
static void
-Lorenz_readframes_ai(Lorenz *self) {
+ChenLee_readframes_ai(ChenLee *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)
- chao = 0.5;
+ chao = 4.0;
else if (chao > 1.0)
- chao = 3.0;
+ chao = 2.51;
else
- chao = chao * 2.5 + 0.5;
+ chao = (1.0 - chao) * 1.49 + 2.51;
for (i=0; i<self->bufsize; i++) {
pit = fr[i];
if (pit < 0.0)
pit = 1.0;
else if (pit > 1.0)
- pit = 750.0;
+ pit = 125.0;
else
- pit = pit * 749.0 + 1.0;
+ pit = pit * 124.0 + 1.0;
delta = self->oneOnSr * pit;
- 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->vDX = -self->vY * self->vZ + self->pA * self->vX;
+ self->vDY = self->vX * self->vZ - self->pB * self->vY;
+ self->vDZ = self->vX * self->vY / 3.0 - chao * self->vZ;
self->vX += self->vDX * delta;
+ self->vX = (self->vX > 50.0) ? 50.0 : (self->vX < -50.0) ? -50.0 : self->vX;
self->vY += self->vDY * delta;
+ self->vY = (self->vY > 50.0) ? 50.0 : (self->vY < -50.0) ? -50.0 : self->vY;
self->vZ += self->vDZ * delta;
- self->data[i] = self->vX * LORENZ_SCALE;
- self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
+ self->data[i] = self->vX * CHENLEE_SCALE;
+ self->altBuffer[i] = self->vY * CHENLEE_ALT_SCALE;
}
}
static void
-Lorenz_readframes_ia(Lorenz *self) {
+ChenLee_readframes_ia(ChenLee *self) {
MYFLT delta, pit, chao;
int i;
@@ -8280,34 +9581,36 @@ Lorenz_readframes_ia(Lorenz *self) {
if (pit < 0.0)
pit = 1.0;
else if (pit > 1.0)
- pit = 750.0;
+ pit = 125.0;
else
- pit = pit * 749.0 + 1.0;
+ pit = pit * 124.0 + 1.0;
delta = self->oneOnSr * pit;
for (i=0; i<self->bufsize; i++) {
chao = ch[i];
if (chao < 0.0)
- chao = 0.5;
+ chao = 4.0;
else if (chao > 1.0)
- chao = 3.0;
+ chao = 2.51;
else
- 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;
+ chao = (1.0 - chao) * 1.49 + 2.51;
+ self->vDX = -self->vY * self->vZ + self->pA * self->vX;
+ self->vDY = self->vX * self->vZ - self->pB * self->vY;
+ self->vDZ = self->vX * self->vY / 3.0 - chao * self->vZ;
self->vX += self->vDX * delta;
+ self->vX = (self->vX > 50.0) ? 50.0 : (self->vX < -50.0) ? -50.0 : self->vX;
self->vY += self->vDY * delta;
+ self->vY = (self->vY > 50.0) ? 50.0 : (self->vY < -50.0) ? -50.0 : self->vY;
self->vZ += self->vDZ * delta;
- self->data[i] = self->vX * LORENZ_SCALE;
- self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
+ self->data[i] = self->vX * CHENLEE_SCALE;
+ self->altBuffer[i] = self->vY * CHENLEE_ALT_SCALE;
}
}
static void
-Lorenz_readframes_aa(Lorenz *self) {
+ChenLee_readframes_aa(ChenLee *self) {
MYFLT delta, pit, chao;
int i;
@@ -8319,43 +9622,45 @@ Lorenz_readframes_aa(Lorenz *self) {
if (pit < 0.0)
pit = 1.0;
else if (pit > 1.0)
- pit = 750.0;
+ pit = 125.0;
else
- pit = pit * 749.0 + 1.0;
+ pit = pit * 124.0 + 1.0;
delta = self->oneOnSr * pit;
chao = ch[i];
if (chao < 0.0)
- chao = 0.5;
+ chao = 4.0;
else if (chao > 1.0)
- chao = 3.0;
+ chao = 2.51;
else
- 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;
+ chao = (1.0 - chao) * 1.49 + 2.51;
+ self->vDX = -self->vY * self->vZ + self->pA * self->vX;
+ self->vDY = self->vX * self->vZ - self->pB * self->vY;
+ self->vDZ = self->vX * self->vY / 3.0 - chao * self->vZ;
self->vX += self->vDX * delta;
+ self->vX = (self->vX > 50.0) ? 50.0 : (self->vX < -50.0) ? -50.0 : self->vX;
self->vY += self->vDY * delta;
+ self->vY = (self->vY > 50.0) ? 50.0 : (self->vY < -50.0) ? -50.0 : self->vY;
self->vZ += self->vDZ * delta;
- self->data[i] = self->vX * LORENZ_SCALE;
- self->altBuffer[i] = self->vY * LORENZ_ALT_SCALE;
+ self->data[i] = self->vX * CHENLEE_SCALE;
+ self->altBuffer[i] = self->vY * CHENLEE_ALT_SCALE;
}
}
-static void Lorenz_postprocessing_ii(Lorenz *self) { POST_PROCESSING_II };
-static void Lorenz_postprocessing_ai(Lorenz *self) { POST_PROCESSING_AI };
-static void Lorenz_postprocessing_ia(Lorenz *self) { POST_PROCESSING_IA };
-static void Lorenz_postprocessing_aa(Lorenz *self) { POST_PROCESSING_AA };
-static void Lorenz_postprocessing_ireva(Lorenz *self) { POST_PROCESSING_IREVA };
-static void Lorenz_postprocessing_areva(Lorenz *self) { POST_PROCESSING_AREVA };
-static void Lorenz_postprocessing_revai(Lorenz *self) { POST_PROCESSING_REVAI };
-static void Lorenz_postprocessing_revaa(Lorenz *self) { POST_PROCESSING_REVAA };
-static void Lorenz_postprocessing_revareva(Lorenz *self) { POST_PROCESSING_REVAREVA };
+static void ChenLee_postprocessing_ii(ChenLee *self) { POST_PROCESSING_II };
+static void ChenLee_postprocessing_ai(ChenLee *self) { POST_PROCESSING_AI };
+static void ChenLee_postprocessing_ia(ChenLee *self) { POST_PROCESSING_IA };
+static void ChenLee_postprocessing_aa(ChenLee *self) { POST_PROCESSING_AA };
+static void ChenLee_postprocessing_ireva(ChenLee *self) { POST_PROCESSING_IREVA };
+static void ChenLee_postprocessing_areva(ChenLee *self) { POST_PROCESSING_AREVA };
+static void ChenLee_postprocessing_revai(ChenLee *self) { POST_PROCESSING_REVAI };
+static void ChenLee_postprocessing_revaa(ChenLee *self) { POST_PROCESSING_REVAA };
+static void ChenLee_postprocessing_revareva(ChenLee *self) { POST_PROCESSING_REVAREVA };
static void
-Lorenz_setProcMode(Lorenz *self)
+ChenLee_setProcMode(ChenLee *self)
{
int procmode, muladdmode;
procmode = self->modebuffer[2] + self->modebuffer[3] * 10;
@@ -8363,59 +9668,59 @@ Lorenz_setProcMode(Lorenz *self)
switch (procmode) {
case 0:
- self->proc_func_ptr = Lorenz_readframes_ii;
+ self->proc_func_ptr = ChenLee_readframes_ii;
break;
case 1:
- self->proc_func_ptr = Lorenz_readframes_ai;
+ self->proc_func_ptr = ChenLee_readframes_ai;
break;
case 10:
- self->proc_func_ptr = Lorenz_readframes_ia;
+ self->proc_func_ptr = ChenLee_readframes_ia;
break;
case 11:
- self->proc_func_ptr = Lorenz_readframes_aa;
+ self->proc_func_ptr = ChenLee_readframes_aa;
break;
}
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = Lorenz_postprocessing_ii;
+ self->muladd_func_ptr = ChenLee_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = Lorenz_postprocessing_ai;
+ self->muladd_func_ptr = ChenLee_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = Lorenz_postprocessing_revai;
+ self->muladd_func_ptr = ChenLee_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = Lorenz_postprocessing_ia;
+ self->muladd_func_ptr = ChenLee_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = Lorenz_postprocessing_aa;
+ self->muladd_func_ptr = ChenLee_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = Lorenz_postprocessing_revaa;
+ self->muladd_func_ptr = ChenLee_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = Lorenz_postprocessing_ireva;
+ self->muladd_func_ptr = ChenLee_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = Lorenz_postprocessing_areva;
+ self->muladd_func_ptr = ChenLee_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = Lorenz_postprocessing_revareva;
+ self->muladd_func_ptr = ChenLee_postprocessing_revareva;
break;
}
}
static void
-Lorenz_compute_next_data_frame(Lorenz *self)
+ChenLee_compute_next_data_frame(ChenLee *self)
{
(*self->proc_func_ptr)(self);
(*self->muladd_func_ptr)(self);
}
static int
-Lorenz_traverse(Lorenz *self, visitproc visit, void *arg)
+ChenLee_traverse(ChenLee *self, visitproc visit, void *arg)
{
pyo_VISIT
Py_VISIT(self->pitch);
@@ -8426,7 +9731,7 @@ Lorenz_traverse(Lorenz *self, visitproc visit, void *arg)
}
static int
-Lorenz_clear(Lorenz *self)
+ChenLee_clear(ChenLee *self)
{
pyo_CLEAR
Py_CLEAR(self->pitch);
@@ -8437,26 +9742,26 @@ Lorenz_clear(Lorenz *self)
}
static void
-Lorenz_dealloc(Lorenz* self)
+ChenLee_dealloc(ChenLee* self)
{
pyo_DEALLOC
free(self->altBuffer);
- Lorenz_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ ChenLee_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-Lorenz_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ChenLee_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
PyObject *pitchtmp=NULL, *chaostmp=NULL, *multmp=NULL, *addtmp=NULL;
- Lorenz *self;
- self = (Lorenz *)type->tp_alloc(type, 0);
+ ChenLee *self;
+ self = (ChenLee *)type->tp_alloc(type, 0);
self->pitch = PyFloat_FromDouble(0.25);
self->chaos = PyFloat_FromDouble(0.5);
- self->pA = 10.0;
- self->pB = 28.0;
+ self->pA = 5.0;
+ self->pB = 10.0;
self->vDX = self->vDY = self->vDZ = 0.0;
self->vX = self->vY = self->vZ = 1.0;
self->modebuffer[0] = 0;
@@ -8465,8 +9770,8 @@ Lorenz_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->modebuffer[3] = 0;
INIT_OBJECT_COMMON
- Stream_setFunctionPtr(self->stream, Lorenz_compute_next_data_frame);
- self->mode_func_ptr = Lorenz_setProcMode;
+ Stream_setFunctionPtr(self->stream, ChenLee_compute_next_data_frame);
+ self->mode_func_ptr = ChenLee_setProcMode;
self->oneOnSr = 1.0 / self->sr;
@@ -8504,28 +9809,28 @@ Lorenz_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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 * ChenLee_getServer(ChenLee* self) { GET_SERVER };
+static PyObject * ChenLee_getStream(ChenLee* self) { GET_STREAM };
+static PyObject * ChenLee_setMul(ChenLee *self, PyObject *arg) { SET_MUL };
+static PyObject * ChenLee_setAdd(ChenLee *self, PyObject *arg) { SET_ADD };
+static PyObject * ChenLee_setSub(ChenLee *self, PyObject *arg) { SET_SUB };
+static PyObject * ChenLee_setDiv(ChenLee *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 };
-static PyObject * Lorenz_stop(Lorenz *self) { STOP };
+static PyObject * ChenLee_play(ChenLee *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * ChenLee_out(ChenLee *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * ChenLee_stop(ChenLee *self) { STOP };
-static PyObject * Lorenz_multiply(Lorenz *self, PyObject *arg) { MULTIPLY };
-static PyObject * Lorenz_inplace_multiply(Lorenz *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * Lorenz_add(Lorenz *self, PyObject *arg) { ADD };
-static PyObject * Lorenz_inplace_add(Lorenz *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * Lorenz_sub(Lorenz *self, PyObject *arg) { SUB };
-static PyObject * Lorenz_inplace_sub(Lorenz *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * Lorenz_div(Lorenz *self, PyObject *arg) { DIV };
-static PyObject * Lorenz_inplace_div(Lorenz *self, PyObject *arg) { INPLACE_DIV };
+static PyObject * ChenLee_multiply(ChenLee *self, PyObject *arg) { MULTIPLY };
+static PyObject * ChenLee_inplace_multiply(ChenLee *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * ChenLee_add(ChenLee *self, PyObject *arg) { ADD };
+static PyObject * ChenLee_inplace_add(ChenLee *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * ChenLee_sub(ChenLee *self, PyObject *arg) { SUB };
+static PyObject * ChenLee_inplace_sub(ChenLee *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * ChenLee_div(ChenLee *self, PyObject *arg) { DIV };
+static PyObject * ChenLee_inplace_div(ChenLee *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
-Lorenz_setPitch(Lorenz *self, PyObject *arg)
+ChenLee_setPitch(ChenLee *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -8556,7 +9861,7 @@ Lorenz_setPitch(Lorenz *self, PyObject *arg)
}
static PyObject *
-Lorenz_setChaos(Lorenz *self, PyObject *arg)
+ChenLee_setChaos(ChenLee *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -8587,41 +9892,41 @@ Lorenz_setChaos(Lorenz *self, PyObject *arg)
}
MYFLT *
-Lorenz_getAltBuffer(Lorenz *self)
+ChenLee_getAltBuffer(ChenLee *self)
{
return (MYFLT *)self->altBuffer;
}
-static PyMemberDef Lorenz_members[] = {
- {"server", T_OBJECT_EX, offsetof(Lorenz, server), 0, "Pyo server."},
- {"stream", T_OBJECT_EX, offsetof(Lorenz, stream), 0, "Stream object."},
- {"pitch", T_OBJECT_EX, offsetof(Lorenz, pitch), 0, "Pitch."},
- {"chaos", T_OBJECT_EX, offsetof(Lorenz, chaos), 0, "Chaotic behavior."},
- {"mul", T_OBJECT_EX, offsetof(Lorenz, mul), 0, "Mul factor."},
- {"add", T_OBJECT_EX, offsetof(Lorenz, add), 0, "Add factor."},
+static PyMemberDef ChenLee_members[] = {
+ {"server", T_OBJECT_EX, offsetof(ChenLee, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(ChenLee, stream), 0, "Stream object."},
+ {"pitch", T_OBJECT_EX, offsetof(ChenLee, pitch), 0, "Pitch."},
+ {"chaos", T_OBJECT_EX, offsetof(ChenLee, chaos), 0, "Chaotic behavior."},
+ {"mul", T_OBJECT_EX, offsetof(ChenLee, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(ChenLee, add), 0, "Add factor."},
{NULL} /* Sentinel */
};
-static PyMethodDef Lorenz_methods[] = {
- {"getServer", (PyCFunction)Lorenz_getServer, METH_NOARGS, "Returns server object."},
- {"_getStream", (PyCFunction)Lorenz_getStream, METH_NOARGS, "Returns stream object."},
- {"play", (PyCFunction)Lorenz_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
- {"out", (PyCFunction)Lorenz_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
- {"stop", (PyCFunction)Lorenz_stop, METH_NOARGS, "Stops computing."},
- {"setPitch", (PyCFunction)Lorenz_setPitch, METH_O, "Sets oscillator pitch."},
- {"setChaos", (PyCFunction)Lorenz_setChaos, METH_O, "Sets oscillator chaotic behavior."},
- {"setMul", (PyCFunction)Lorenz_setMul, METH_O, "Sets Lorenz mul factor."},
- {"setAdd", (PyCFunction)Lorenz_setAdd, METH_O, "Sets Lorenz add factor."},
- {"setSub", (PyCFunction)Lorenz_setSub, METH_O, "Sets inverse add factor."},
- {"setDiv", (PyCFunction)Lorenz_setDiv, METH_O, "Sets inverse mul factor."},
+static PyMethodDef ChenLee_methods[] = {
+ {"getServer", (PyCFunction)ChenLee_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)ChenLee_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)ChenLee_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)ChenLee_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)ChenLee_stop, METH_NOARGS, "Stops computing."},
+ {"setPitch", (PyCFunction)ChenLee_setPitch, METH_O, "Sets oscillator pitch."},
+ {"setChaos", (PyCFunction)ChenLee_setChaos, METH_O, "Sets oscillator chaotic behavior."},
+ {"setMul", (PyCFunction)ChenLee_setMul, METH_O, "Sets ChenLee mul factor."},
+ {"setAdd", (PyCFunction)ChenLee_setAdd, METH_O, "Sets ChenLee add factor."},
+ {"setSub", (PyCFunction)ChenLee_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)ChenLee_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
-static PyNumberMethods Lorenz_as_number = {
- (binaryfunc)Lorenz_add, /*nb_add*/
- (binaryfunc)Lorenz_sub, /*nb_subtract*/
- (binaryfunc)Lorenz_multiply, /*nb_multiply*/
- (binaryfunc)Lorenz_div, /*nb_divide*/
+static PyNumberMethods ChenLee_as_number = {
+ (binaryfunc)ChenLee_add, /*nb_add*/
+ (binaryfunc)ChenLee_sub, /*nb_subtract*/
+ (binaryfunc)ChenLee_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -8635,16 +9940,16 @@ static PyNumberMethods Lorenz_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
- (binaryfunc)Lorenz_inplace_add, /*inplace_add*/
- (binaryfunc)Lorenz_inplace_sub, /*inplace_subtract*/
- (binaryfunc)Lorenz_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Lorenz_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)ChenLee_inplace_add, /*inplace_add*/
+ (binaryfunc)ChenLee_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)ChenLee_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -8653,25 +9958,24 @@ static PyNumberMethods Lorenz_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)ChenLee_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)ChenLee_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
-PyTypeObject LorenzType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.Lorenz_base", /*tp_name*/
- sizeof(Lorenz), /*tp_basicsize*/
+PyTypeObject ChenLeeType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.ChenLee_base", /*tp_name*/
+ sizeof(ChenLee), /*tp_basicsize*/
0, /*tp_itemsize*/
- (destructor)Lorenz_dealloc, /*tp_dealloc*/
+ (destructor)ChenLee_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
- &Lorenz_as_number, /*tp_as_number*/
+ &ChenLee_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -8681,15 +9985,15 @@ PyTypeObject LorenzType = {
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
- "Lorenz objects. Lorenz attractor.", /* tp_doc */
- (traverseproc)Lorenz_traverse, /* tp_traverse */
- (inquiry)Lorenz_clear, /* tp_clear */
+ "ChenLee objects. ChenLee attractor.", /* tp_doc */
+ (traverseproc)ChenLee_traverse, /* tp_traverse */
+ (inquiry)ChenLee_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- Lorenz_methods, /* tp_methods */
- Lorenz_members, /* tp_members */
+ ChenLee_methods, /* tp_methods */
+ ChenLee_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -8698,67 +10002,67 @@ PyTypeObject LorenzType = {
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- Lorenz_new, /* tp_new */
+ ChenLee_new, /* tp_new */
};
typedef struct {
pyo_audio_HEAD
- Lorenz *mainLorenz;
+ ChenLee *mainChenLee;
int modebuffer[2];
-} LorenzAlt;
+} ChenLeeAlt;
-static void LorenzAlt_postprocessing_ii(LorenzAlt *self) { POST_PROCESSING_II };
-static void LorenzAlt_postprocessing_ai(LorenzAlt *self) { POST_PROCESSING_AI };
-static void LorenzAlt_postprocessing_ia(LorenzAlt *self) { POST_PROCESSING_IA };
-static void LorenzAlt_postprocessing_aa(LorenzAlt *self) { POST_PROCESSING_AA };
-static void LorenzAlt_postprocessing_ireva(LorenzAlt *self) { POST_PROCESSING_IREVA };
-static void LorenzAlt_postprocessing_areva(LorenzAlt *self) { POST_PROCESSING_AREVA };
-static void LorenzAlt_postprocessing_revai(LorenzAlt *self) { POST_PROCESSING_REVAI };
-static void LorenzAlt_postprocessing_revaa(LorenzAlt *self) { POST_PROCESSING_REVAA };
-static void LorenzAlt_postprocessing_revareva(LorenzAlt *self) { POST_PROCESSING_REVAREVA };
+static void ChenLeeAlt_postprocessing_ii(ChenLeeAlt *self) { POST_PROCESSING_II };
+static void ChenLeeAlt_postprocessing_ai(ChenLeeAlt *self) { POST_PROCESSING_AI };
+static void ChenLeeAlt_postprocessing_ia(ChenLeeAlt *self) { POST_PROCESSING_IA };
+static void ChenLeeAlt_postprocessing_aa(ChenLeeAlt *self) { POST_PROCESSING_AA };
+static void ChenLeeAlt_postprocessing_ireva(ChenLeeAlt *self) { POST_PROCESSING_IREVA };
+static void ChenLeeAlt_postprocessing_areva(ChenLeeAlt *self) { POST_PROCESSING_AREVA };
+static void ChenLeeAlt_postprocessing_revai(ChenLeeAlt *self) { POST_PROCESSING_REVAI };
+static void ChenLeeAlt_postprocessing_revaa(ChenLeeAlt *self) { POST_PROCESSING_REVAA };
+static void ChenLeeAlt_postprocessing_revareva(ChenLeeAlt *self) { POST_PROCESSING_REVAREVA };
static void
-LorenzAlt_setProcMode(LorenzAlt *self) {
+ChenLeeAlt_setProcMode(ChenLeeAlt *self) {
int muladdmode;
muladdmode = self->modebuffer[0] + self->modebuffer[1] * 10;
switch (muladdmode) {
case 0:
- self->muladd_func_ptr = LorenzAlt_postprocessing_ii;
+ self->muladd_func_ptr = ChenLeeAlt_postprocessing_ii;
break;
case 1:
- self->muladd_func_ptr = LorenzAlt_postprocessing_ai;
+ self->muladd_func_ptr = ChenLeeAlt_postprocessing_ai;
break;
case 2:
- self->muladd_func_ptr = LorenzAlt_postprocessing_revai;
+ self->muladd_func_ptr = ChenLeeAlt_postprocessing_revai;
break;
case 10:
- self->muladd_func_ptr = LorenzAlt_postprocessing_ia;
+ self->muladd_func_ptr = ChenLeeAlt_postprocessing_ia;
break;
case 11:
- self->muladd_func_ptr = LorenzAlt_postprocessing_aa;
+ self->muladd_func_ptr = ChenLeeAlt_postprocessing_aa;
break;
case 12:
- self->muladd_func_ptr = LorenzAlt_postprocessing_revaa;
+ self->muladd_func_ptr = ChenLeeAlt_postprocessing_revaa;
break;
case 20:
- self->muladd_func_ptr = LorenzAlt_postprocessing_ireva;
+ self->muladd_func_ptr = ChenLeeAlt_postprocessing_ireva;
break;
case 21:
- self->muladd_func_ptr = LorenzAlt_postprocessing_areva;
+ self->muladd_func_ptr = ChenLeeAlt_postprocessing_areva;
break;
case 22:
- self->muladd_func_ptr = LorenzAlt_postprocessing_revareva;
+ self->muladd_func_ptr = ChenLeeAlt_postprocessing_revareva;
break;
}
}
static void
-LorenzAlt_compute_next_data_frame(LorenzAlt *self)
+ChenLeeAlt_compute_next_data_frame(ChenLeeAlt *self)
{
int i;
MYFLT *tmp;
- tmp = Lorenz_getAltBuffer((Lorenz *)self->mainLorenz);
+ tmp = ChenLee_getAltBuffer((ChenLee *)self->mainChenLee);
for (i=0; i<self->bufsize; i++) {
self->data[i] = tmp[i];
}
@@ -8766,52 +10070,52 @@ LorenzAlt_compute_next_data_frame(LorenzAlt *self)
}
static int
-LorenzAlt_traverse(LorenzAlt *self, visitproc visit, void *arg)
+ChenLeeAlt_traverse(ChenLeeAlt *self, visitproc visit, void *arg)
{
pyo_VISIT
- Py_VISIT(self->mainLorenz);
+ Py_VISIT(self->mainChenLee);
return 0;
}
static int
-LorenzAlt_clear(LorenzAlt *self)
+ChenLeeAlt_clear(ChenLeeAlt *self)
{
pyo_CLEAR
- Py_CLEAR(self->mainLorenz);
+ Py_CLEAR(self->mainChenLee);
return 0;
}
static void
-LorenzAlt_dealloc(LorenzAlt* self)
+ChenLeeAlt_dealloc(ChenLeeAlt* self)
{
pyo_DEALLOC
- LorenzAlt_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ ChenLeeAlt_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
-LorenzAlt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ChenLeeAlt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
PyObject *maintmp=NULL, *multmp=NULL, *addtmp=NULL;
- LorenzAlt *self;
- self = (LorenzAlt *)type->tp_alloc(type, 0);
+ ChenLeeAlt *self;
+ self = (ChenLeeAlt *)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;
+ Stream_setFunctionPtr(self->stream, ChenLeeAlt_compute_next_data_frame);
+ self->mode_func_ptr = ChenLeeAlt_setProcMode;
- static char *kwlist[] = {"mainLorenz", "mul", "alt", NULL};
+ static char *kwlist[] = {"mainChenLee", "mul", "alt", NULL};
if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &maintmp, &multmp, &addtmp))
Py_RETURN_NONE;
- Py_XDECREF(self->mainLorenz);
+ Py_XDECREF(self->mainChenLee);
Py_INCREF(maintmp);
- self->mainLorenz = (Lorenz *)maintmp;
+ self->mainChenLee = (ChenLee *)maintmp;
if (multmp) {
PyObject_CallMethod((PyObject *)self, "setMul", "O", multmp);
@@ -8828,51 +10132,51 @@ LorenzAlt_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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_play(LorenzAlt *self, PyObject *args, PyObject *kwds) { PLAY };
-static PyObject * LorenzAlt_out(LorenzAlt *self, PyObject *args, PyObject *kwds) { OUT };
-static PyObject * LorenzAlt_stop(LorenzAlt *self) { STOP };
-
-static PyObject * LorenzAlt_multiply(LorenzAlt *self, PyObject *arg) { MULTIPLY };
-static PyObject * LorenzAlt_inplace_multiply(LorenzAlt *self, PyObject *arg) { INPLACE_MULTIPLY };
-static PyObject * LorenzAlt_add(LorenzAlt *self, PyObject *arg) { ADD };
-static PyObject * LorenzAlt_inplace_add(LorenzAlt *self, PyObject *arg) { INPLACE_ADD };
-static PyObject * LorenzAlt_sub(LorenzAlt *self, PyObject *arg) { SUB };
-static PyObject * LorenzAlt_inplace_sub(LorenzAlt *self, PyObject *arg) { INPLACE_SUB };
-static PyObject * LorenzAlt_div(LorenzAlt *self, PyObject *arg) { DIV };
-static PyObject * LorenzAlt_inplace_div(LorenzAlt *self, PyObject *arg) { INPLACE_DIV };
-
-static PyMemberDef LorenzAlt_members[] = {
- {"server", T_OBJECT_EX, offsetof(LorenzAlt, server), 0, "Pyo server."},
- {"stream", T_OBJECT_EX, offsetof(LorenzAlt, stream), 0, "Stream object."},
- {"mul", T_OBJECT_EX, offsetof(LorenzAlt, mul), 0, "Mul factor."},
- {"add", T_OBJECT_EX, offsetof(LorenzAlt, add), 0, "Add factor."},
+static PyObject * ChenLeeAlt_getServer(ChenLeeAlt* self) { GET_SERVER };
+static PyObject * ChenLeeAlt_getStream(ChenLeeAlt* self) { GET_STREAM };
+static PyObject * ChenLeeAlt_setMul(ChenLeeAlt *self, PyObject *arg) { SET_MUL };
+static PyObject * ChenLeeAlt_setAdd(ChenLeeAlt *self, PyObject *arg) { SET_ADD };
+static PyObject * ChenLeeAlt_setSub(ChenLeeAlt *self, PyObject *arg) { SET_SUB };
+static PyObject * ChenLeeAlt_setDiv(ChenLeeAlt *self, PyObject *arg) { SET_DIV };
+
+static PyObject * ChenLeeAlt_play(ChenLeeAlt *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * ChenLeeAlt_out(ChenLeeAlt *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * ChenLeeAlt_stop(ChenLeeAlt *self) { STOP };
+
+static PyObject * ChenLeeAlt_multiply(ChenLeeAlt *self, PyObject *arg) { MULTIPLY };
+static PyObject * ChenLeeAlt_inplace_multiply(ChenLeeAlt *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * ChenLeeAlt_add(ChenLeeAlt *self, PyObject *arg) { ADD };
+static PyObject * ChenLeeAlt_inplace_add(ChenLeeAlt *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * ChenLeeAlt_sub(ChenLeeAlt *self, PyObject *arg) { SUB };
+static PyObject * ChenLeeAlt_inplace_sub(ChenLeeAlt *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * ChenLeeAlt_div(ChenLeeAlt *self, PyObject *arg) { DIV };
+static PyObject * ChenLeeAlt_inplace_div(ChenLeeAlt *self, PyObject *arg) { INPLACE_DIV };
+
+static PyMemberDef ChenLeeAlt_members[] = {
+ {"server", T_OBJECT_EX, offsetof(ChenLeeAlt, server), 0, "Pyo server."},
+ {"stream", T_OBJECT_EX, offsetof(ChenLeeAlt, stream), 0, "Stream object."},
+ {"mul", T_OBJECT_EX, offsetof(ChenLeeAlt, mul), 0, "Mul factor."},
+ {"add", T_OBJECT_EX, offsetof(ChenLeeAlt, add), 0, "Add factor."},
{NULL} /* Sentinel */
};
-static PyMethodDef LorenzAlt_methods[] = {
- {"getServer", (PyCFunction)LorenzAlt_getServer, METH_NOARGS, "Returns server object."},
- {"_getStream", (PyCFunction)LorenzAlt_getStream, METH_NOARGS, "Returns stream object."},
- {"play", (PyCFunction)LorenzAlt_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
- {"out", (PyCFunction)LorenzAlt_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
- {"stop", (PyCFunction)LorenzAlt_stop, METH_NOARGS, "Stops computing."},
- {"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."},
+static PyMethodDef ChenLeeAlt_methods[] = {
+ {"getServer", (PyCFunction)ChenLeeAlt_getServer, METH_NOARGS, "Returns server object."},
+ {"_getStream", (PyCFunction)ChenLeeAlt_getStream, METH_NOARGS, "Returns stream object."},
+ {"play", (PyCFunction)ChenLeeAlt_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+ {"out", (PyCFunction)ChenLeeAlt_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+ {"stop", (PyCFunction)ChenLeeAlt_stop, METH_NOARGS, "Stops computing."},
+ {"setMul", (PyCFunction)ChenLeeAlt_setMul, METH_O, "Sets oscillator mul factor."},
+ {"setAdd", (PyCFunction)ChenLeeAlt_setAdd, METH_O, "Sets oscillator add factor."},
+ {"setSub", (PyCFunction)ChenLeeAlt_setSub, METH_O, "Sets inverse add factor."},
+ {"setDiv", (PyCFunction)ChenLeeAlt_setDiv, METH_O, "Sets inverse mul factor."},
{NULL} /* Sentinel */
};
-static PyNumberMethods LorenzAlt_as_number = {
- (binaryfunc)LorenzAlt_add, /*nb_add*/
- (binaryfunc)LorenzAlt_sub, /*nb_subtract*/
- (binaryfunc)LorenzAlt_multiply, /*nb_multiply*/
- (binaryfunc)LorenzAlt_div, /*nb_divide*/
+static PyNumberMethods ChenLeeAlt_as_number = {
+ (binaryfunc)ChenLeeAlt_add, /*nb_add*/
+ (binaryfunc)ChenLeeAlt_sub, /*nb_subtract*/
+ (binaryfunc)ChenLeeAlt_multiply, /*nb_multiply*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -8886,16 +10190,16 @@ static PyNumberMethods LorenzAlt_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
- (binaryfunc)LorenzAlt_inplace_add, /*inplace_add*/
- (binaryfunc)LorenzAlt_inplace_sub, /*inplace_subtract*/
- (binaryfunc)LorenzAlt_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)LorenzAlt_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+ (binaryfunc)ChenLeeAlt_inplace_add, /*inplace_add*/
+ (binaryfunc)ChenLeeAlt_inplace_sub, /*inplace_subtract*/
+ (binaryfunc)ChenLeeAlt_inplace_multiply, /*inplace_multiply*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -8904,25 +10208,24 @@ static PyNumberMethods LorenzAlt_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)ChenLeeAlt_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)ChenLeeAlt_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
-PyTypeObject LorenzAltType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "_pyo.LorenzAlt_base", /*tp_name*/
- sizeof(LorenzAlt), /*tp_basicsize*/
+PyTypeObject ChenLeeAltType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.ChenLeeAlt_base", /*tp_name*/
+ sizeof(ChenLeeAlt), /*tp_basicsize*/
0, /*tp_itemsize*/
- (destructor)LorenzAlt_dealloc, /*tp_dealloc*/
+ (destructor)ChenLeeAlt_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
- &LorenzAlt_as_number, /*tp_as_number*/
+ &ChenLeeAlt_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
@@ -8932,15 +10235,15 @@ PyTypeObject LorenzAltType = {
0, /*tp_setattro*/
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
- "LorenzAlt objects. Sends the alternate signal of a Lorenz attractor.", /* tp_doc */
- (traverseproc)LorenzAlt_traverse, /* tp_traverse */
- (inquiry)LorenzAlt_clear, /* tp_clear */
+ "ChenLeeAlt objects. Sends the alternate signal of a ChenLee attractor.", /* tp_doc */
+ (traverseproc)ChenLeeAlt_traverse, /* tp_traverse */
+ (inquiry)ChenLeeAlt_clear, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- LorenzAlt_methods, /* tp_methods */
- LorenzAlt_members, /* tp_members */
+ ChenLeeAlt_methods, /* tp_methods */
+ ChenLeeAlt_members, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
@@ -8949,7 +10252,7 @@ PyTypeObject LorenzAltType = {
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
- LorenzAlt_new, /* tp_new */
+ ChenLeeAlt_new, /* tp_new */
};
/*************/
@@ -9407,7 +10710,7 @@ SumOsc_dealloc(SumOsc* self)
{
pyo_DEALLOC
SumOsc_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -9611,7 +10914,7 @@ static PyNumberMethods SumOsc_as_number = {
(binaryfunc)SumOsc_add, /*nb_add*/
(binaryfunc)SumOsc_sub, /*nb_subtract*/
(binaryfunc)SumOsc_multiply, /*nb_multiply*/
-(binaryfunc)SumOsc_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -9625,16 +10928,16 @@ static PyNumberMethods SumOsc_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)SumOsc_inplace_add, /*inplace_add*/
(binaryfunc)SumOsc_inplace_sub, /*inplace_subtract*/
(binaryfunc)SumOsc_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)SumOsc_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -9643,15 +10946,14 @@ static PyNumberMethods SumOsc_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)SumOsc_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)SumOsc_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SumOscType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SumOsc_base", /*tp_name*/
sizeof(SumOsc), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -9659,7 +10961,7 @@ sizeof(SumOsc), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&SumOsc_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -10252,7 +11554,7 @@ SuperSaw_dealloc(SuperSaw* self)
{
pyo_DEALLOC
SuperSaw_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -10464,7 +11766,7 @@ static PyNumberMethods SuperSaw_as_number = {
(binaryfunc)SuperSaw_add, /*nb_add*/
(binaryfunc)SuperSaw_sub, /*nb_subtract*/
(binaryfunc)SuperSaw_multiply, /*nb_multiply*/
-(binaryfunc)SuperSaw_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -10478,16 +11780,16 @@ static PyNumberMethods SuperSaw_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)SuperSaw_inplace_add, /*inplace_add*/
(binaryfunc)SuperSaw_inplace_sub, /*inplace_subtract*/
(binaryfunc)SuperSaw_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)SuperSaw_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -10496,15 +11798,14 @@ static PyNumberMethods SuperSaw_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)SuperSaw_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)SuperSaw_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SuperSawType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SuperSaw_base", /*tp_name*/
sizeof(SuperSaw), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -10512,7 +11813,7 @@ sizeof(SuperSaw), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&SuperSaw_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -10767,7 +12068,7 @@ RCOsc_dealloc(RCOsc* self)
{
pyo_DEALLOC
RCOsc_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -10938,7 +12239,7 @@ static PyNumberMethods RCOsc_as_number = {
(binaryfunc)RCOsc_add, /*nb_add*/
(binaryfunc)RCOsc_sub, /*nb_subtract*/
(binaryfunc)RCOsc_multiply, /*nb_multiply*/
-(binaryfunc)RCOsc_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -10952,16 +12253,16 @@ static PyNumberMethods RCOsc_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)RCOsc_inplace_add, /*inplace_add*/
(binaryfunc)RCOsc_inplace_sub, /*inplace_subtract*/
(binaryfunc)RCOsc_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)RCOsc_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -10970,15 +12271,14 @@ static PyNumberMethods RCOsc_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)RCOsc_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)RCOsc_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject RCOscType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.RCOsc_base", /*tp_name*/
sizeof(RCOsc), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -10986,7 +12286,7 @@ sizeof(RCOsc), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&RCOsc_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -11150,7 +12450,7 @@ TableScale_dealloc(TableScale* self)
{
pyo_DEALLOC
TableScale_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -11297,7 +12597,7 @@ static PyNumberMethods TableScale_as_number = {
(binaryfunc)TableScale_add, /*nb_add*/
(binaryfunc)TableScale_sub, /*nb_subtract*/
(binaryfunc)TableScale_multiply, /*nb_multiply*/
-(binaryfunc)TableScale_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -11311,16 +12611,16 @@ static PyNumberMethods TableScale_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TableScale_inplace_add, /*inplace_add*/
(binaryfunc)TableScale_inplace_sub, /*inplace_subtract*/
(binaryfunc)TableScale_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)TableScale_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -11329,15 +12629,14 @@ static PyNumberMethods TableScale_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)TableScale_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)TableScale_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TableScaleType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TableScale_base", /*tp_name*/
sizeof(TableScale), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -11345,7 +12644,7 @@ sizeof(TableScale), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TableScale_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/oscmodule.c b/src/objects/oscmodule.c
index 937a395..f654edb 100644
--- a/src/objects/oscmodule.c
+++ b/src/objects/oscmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -29,7 +30,7 @@
static void error(int num, const char *msg, const char *path)
{
- printf("liblo server error %d in path %s: %s\n", num, path, msg);
+ PySys_WriteStdout("liblo server error %d in path %s: %s\n", num, path, msg);
}
/* main OSC receiver */
@@ -45,7 +46,7 @@ int OscReceiver_handler(const char *path, const char *types, lo_arg **argv, int
void *data, void *user_data)
{
OscReceiver *self = user_data;
- PyDict_SetItem(self->dict, PyString_FromString(path), PyFloat_FromDouble(argv[0]->FLOAT_VALUE));
+ PyDict_SetItem(self->dict, PyUnicode_FromString(path), PyFloat_FromDouble(argv[0]->FLOAT_VALUE));
return 0;
}
@@ -86,7 +87,7 @@ OscReceiver_dealloc(OscReceiver* self)
lo_server_free(self->osc_server);
pyo_DEALLOC
OscReceiver_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -137,7 +138,7 @@ static PyObject *
OscReceiver_addAddress(OscReceiver *self, PyObject *arg)
{
int i;
- if (PyString_Check(arg) || PyUnicode_Check(arg)) {
+ if (PY_STRING_CHECK(arg)) {
PyDict_SetItem(self->dict, arg, PyFloat_FromDouble(0.));
}
else if (PyList_Check(arg)) {
@@ -146,15 +147,14 @@ OscReceiver_addAddress(OscReceiver *self, PyObject *arg)
PyDict_SetItem(self->dict, PyList_GET_ITEM(arg, i), PyFloat_FromDouble(0.));
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
OscReceiver_delAddress(OscReceiver *self, PyObject *arg)
{
int i;
- if (PyString_Check(arg) || PyUnicode_Check(arg)) {
+ if (PY_STRING_CHECK(arg)) {
PyDict_DelItem(self->dict, arg);
}
else if (PyList_Check(arg)) {
@@ -163,8 +163,7 @@ OscReceiver_delAddress(OscReceiver *self, PyObject *arg)
PyDict_DelItem(self->dict, PyList_GET_ITEM(arg, i));
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -200,8 +199,7 @@ static PyMethodDef OscReceiver_methods[] = {
};
PyTypeObject OscReceiverType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.OscReceiver_base", /*tp_name*/
sizeof(OscReceiver), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -209,7 +207,7 @@ sizeof(OscReceiver), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -306,7 +304,6 @@ OscReceive_compute_next_data_frame(OscReceive *self)
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;
}
@@ -343,7 +340,7 @@ OscReceive_dealloc(OscReceive* self)
{
pyo_DEALLOC
OscReceive_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -385,7 +382,7 @@ OscReceive_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
- if (!PyString_Check(pathtmp) && !PyUnicode_Check(pathtmp)) {
+ if (!PY_STRING_CHECK(pathtmp)) {
PyErr_SetString(PyExc_TypeError, "The address attributes must be a string or a unicode.");
Py_RETURN_NONE;
}
@@ -406,8 +403,7 @@ OscReceive_setInterpolation(OscReceive *self, PyObject *arg)
self->interpolation = PyInt_AsLong(arg);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject * OscReceive_getServer(OscReceive* self) { GET_SERVER };
@@ -454,7 +450,7 @@ static PyNumberMethods OscReceive_as_number = {
(binaryfunc)OscReceive_add, /*nb_add*/
(binaryfunc)OscReceive_sub, /*nb_subtract*/
(binaryfunc)OscReceive_multiply, /*nb_multiply*/
- (binaryfunc)OscReceive_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -468,16 +464,16 @@ static PyNumberMethods OscReceive_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)OscReceive_inplace_add, /*inplace_add*/
(binaryfunc)OscReceive_inplace_sub, /*inplace_subtract*/
(binaryfunc)OscReceive_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)OscReceive_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -486,15 +482,14 @@ static PyNumberMethods OscReceive_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)OscReceive_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)OscReceive_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject OscReceiveType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.OscReceive_base", /*tp_name*/
sizeof(OscReceive), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -502,7 +497,7 @@ PyTypeObject OscReceiveType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&OscReceive_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -557,14 +552,15 @@ OscSend_compute_next_data_frame(OscSend *self)
MYFLT *in = Stream_getData((Stream *)self->input_stream);
float value = (float)in[0];
- if (PyString_Check(self->address_path))
- path = PyString_AsString(self->address_path);
+ if (PyBytes_Check(self->address_path))
+ path = PyBytes_AsString(self->address_path);
else
- path = PyString_AsString(PyUnicode_AsASCIIString(self->address_path));
+ path = PY_UNICODE_AS_UNICODE(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));
+ PySys_WriteStdout("OSC error %d: %s\n",
+ lo_address_errno(self->address),
+ lo_address_errstr(self->address));
}
}
}
@@ -594,7 +590,7 @@ OscSend_dealloc(OscSend* self)
{
pyo_DEALLOC
OscSend_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -621,8 +617,8 @@ OscSend_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
- if (!PyString_Check(pathtmp) && !PyUnicode_Check(pathtmp)) {
- PyErr_SetString(PyExc_TypeError, "The address attributes must be a string or a unicode.");
+ if (!PY_STRING_CHECK(pathtmp)) {
+ PyErr_SetString(PyExc_TypeError, "The address attributes must be a string or a unicode (bytes or string in Python 3).");
Py_RETURN_NONE;
}
@@ -646,8 +642,7 @@ OscSend_setBufferRate(OscSend *self, PyObject *arg)
if (self->bufrate < 1)
self->bufrate = 1;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject * OscSend_getServer(OscSend* self) { GET_SERVER };
@@ -673,8 +668,7 @@ static PyMethodDef OscSend_methods[] = {
};
PyTypeObject OscSendType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.OscSend_base", /*tp_name*/
sizeof(OscSend), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -682,7 +676,7 @@ sizeof(OscSend), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -740,10 +734,10 @@ OscDataSend_compute_next_data_frame(OscDataSend *self)
lo_message *msg;
if (self->something_to_send == 1) {
- if (PyString_Check(self->address_path))
- path = PyString_AsString(self->address_path);
+ if (PyBytes_Check(self->address_path))
+ path = PyBytes_AsString(self->address_path);
else
- path = PyString_AsString(PyUnicode_AsASCIIString(self->address_path));
+ path = PY_UNICODE_AS_UNICODE(self->address_path);
msg = lo_message_new();
for (i=0; i<self->num_items; i++) {
@@ -761,17 +755,17 @@ OscDataSend_compute_next_data_frame(OscDataSend *self)
lo_message_add_double(msg, (double)PyFloat_AsDouble(PyList_GET_ITEM(self->value, i)));
break;
case LO_STRING:
- lo_message_add_string(msg, PyString_AsString(PyList_GET_ITEM(self->value, i)));
+ lo_message_add_string(msg, PY_STRING_AS_STRING(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]);
+ lo_message_add_char(msg, (char)PY_STRING_AS_STRING(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];
+ blobdata[j] = (char)PY_STRING_AS_STRING(PyList_GET_ITEM(datalist, j))[0];
}
blob = lo_blob_new(blobsize * sizeof(char), blobdata);
lo_message_add_blob(msg, blob);
@@ -797,7 +791,7 @@ OscDataSend_compute_next_data_frame(OscDataSend *self)
}
}
if (lo_send_message(self->address, path, msg) == -1) {
- printf("OSC error %d: %s\n", lo_address_errno(self->address),
+ PySys_WriteStdout("OSC error %d: %s\n", lo_address_errno(self->address),
lo_address_errstr(self->address));
}
self->something_to_send = 0;
@@ -832,7 +826,7 @@ OscDataSend_dealloc(OscDataSend* self)
{
pyo_DEALLOC
OscDataSend_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -855,8 +849,8 @@ OscDataSend_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
- if (!PyString_Check(pathtmp) && !PyUnicode_Check(pathtmp)) {
- PyErr_SetString(PyExc_TypeError, "The address attributes must be of type string or unicode.");
+ if (!PY_STRING_CHECK(pathtmp)) {
+ PyErr_SetString(PyExc_TypeError, "The address attributes must be of type string or unicode (bytes or string in Python 3).");
Py_RETURN_NONE;
}
@@ -894,10 +888,9 @@ OscDataSend_send(OscDataSend *self, PyObject *arg)
self->something_to_send = 1;
}
else
- printf("OscDataSend: argument to send() method must be a list of values.\n");
+ PySys_WriteStdout("OscDataSend: argument to send() method must be a list of values.\n");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyMemberDef OscDataSend_members[] = {
@@ -916,8 +909,7 @@ static PyMethodDef OscDataSend_methods[] = {
};
PyTypeObject OscDataSendType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.OscDataSend_base", /*tp_name*/
sizeof(OscDataSend), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -925,7 +917,7 @@ PyTypeObject OscDataSendType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -976,25 +968,26 @@ int OscDataReceive_handler(const char *path, const char *types, lo_arg **argv, i
uint32_t blobsize = 0;
PyObject *charlist = NULL;
tup = PyTuple_New(argc+1);
- int i, ok = 0, j = 0;
+ int i, ok = 0;
+ uint32_t j = 0;
Py_ssize_t lsize = PyList_Size(self->address_path);
for (i=0; i<lsize; i++) {
- if (PyString_Check(PyList_GET_ITEM(self->address_path, i))) {
- if (lo_pattern_match(path, PyString_AsString(PyList_GET_ITEM(self->address_path, i)))) {
+ if (PyBytes_Check(PyList_GET_ITEM(self->address_path, i))) {
+ if (lo_pattern_match(path, PyBytes_AsString(PyList_GET_ITEM(self->address_path, i)))) {
ok = 1;
break;
}
}
else {
- if (lo_pattern_match(path, PyString_AsString(PyUnicode_AsASCIIString(PyList_GET_ITEM(self->address_path, i))))) {
+ if (lo_pattern_match(path, PY_UNICODE_AS_UNICODE(PyList_GET_ITEM(self->address_path, i)))) {
ok = 1;
break;
}
}
}
if (ok) {
- PyTuple_SET_ITEM(tup, 0, PyString_FromString(path));
+ PyTuple_SET_ITEM(tup, 0, PyUnicode_FromString(path));
for (i=0; i<argc; i++) {
switch (types[i]) {
case LO_INT32:
@@ -1010,10 +1003,10 @@ int OscDataReceive_handler(const char *path, const char *types, lo_arg **argv, i
PyTuple_SET_ITEM(tup, i+1, PyFloat_FromDouble(argv[i]->d));
break;
case LO_STRING:
- PyTuple_SET_ITEM(tup, i+1, PyString_FromString(&argv[i]->s));
+ PyTuple_SET_ITEM(tup, i+1, PyUnicode_FromString(&argv[i]->s));
break;
case LO_CHAR:
- PyTuple_SET_ITEM(tup, i+1, PyString_FromFormat("%c", argv[i]->c));
+ PyTuple_SET_ITEM(tup, i+1, PyUnicode_FromFormat("%c", argv[i]->c));
break;
case LO_BLOB:
blob = (lo_blob)argv[i];
@@ -1021,7 +1014,7 @@ int OscDataReceive_handler(const char *path, const char *types, lo_arg **argv, i
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]));
+ PyList_SET_ITEM(charlist, j, PyUnicode_FromFormat("%c", blobdata[j]));
}
PyTuple_SET_ITEM(tup, i+1, charlist);
break;
@@ -1088,7 +1081,7 @@ OscDataReceive_dealloc(OscDataReceive* self)
lo_server_free(self->osc_server);
pyo_DEALLOC
OscDataReceive_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1140,7 +1133,7 @@ static PyObject *
OscDataReceive_addAddress(OscDataReceive *self, PyObject *arg) {
int i;
if (arg != NULL) {
- if (PyString_Check(arg) || PyUnicode_Check(arg))
+ if (PY_STRING_CHECK(arg))
PyList_Append(self->address_path, arg);
else if (PyList_Check(arg)) {
Py_ssize_t len = PyList_Size(arg);
@@ -1150,8 +1143,7 @@ OscDataReceive_addAddress(OscDataReceive *self, PyObject *arg) {
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1162,8 +1154,7 @@ OscDataReceive_delAddress(OscDataReceive *self, PyObject *arg) {
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyMemberDef OscDataReceive_members[] = {
@@ -1183,8 +1174,7 @@ static PyMethodDef OscDataReceive_methods[] = {
};
PyTypeObject OscDataReceiveType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.OscDataReceive_base", /*tp_name*/
sizeof(OscDataReceive), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1192,7 +1182,7 @@ PyTypeObject OscDataReceiveType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1246,7 +1236,7 @@ int OscListReceiver_handler(const char *path, const char *types, lo_arg **argv,
for (i=0; i<self->num; i++) {
PyList_SET_ITEM(flist, i, PyFloat_FromDouble(argv[i]->FLOAT_VALUE));
}
- PyDict_SetItem(self->dict, PyString_FromString(path), flist);
+ PyDict_SetItem(self->dict, PyUnicode_FromString(path), flist);
return 0;
}
@@ -1288,7 +1278,7 @@ OscListReceiver_dealloc(OscListReceiver* self)
lo_server_free(self->osc_server);
pyo_DEALLOC
OscListReceiver_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1347,7 +1337,7 @@ OscListReceiver_addAddress(OscListReceiver *self, PyObject *arg)
PyObject *flist;
int i, j;
- if (PyString_Check(arg) || PyUnicode_Check(arg)) {
+ if (PY_STRING_CHECK(arg)) {
flist = PyList_New(self->num);
for (j=0; j<self->num; j++) {
PyList_SET_ITEM(flist, j, PyFloat_FromDouble(0.));
@@ -1364,15 +1354,14 @@ OscListReceiver_addAddress(OscListReceiver *self, PyObject *arg)
PyDict_SetItem(self->dict, PyList_GET_ITEM(arg, i), flist);
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
OscListReceiver_delAddress(OscListReceiver *self, PyObject *arg)
{
int i;
- if (PyString_Check(arg) || PyUnicode_Check(arg)) {
+ if (PY_STRING_CHECK(arg)) {
PyDict_DelItem(self->dict, arg);
}
else if (PyList_Check(arg)) {
@@ -1382,8 +1371,7 @@ OscListReceiver_delAddress(OscListReceiver *self, PyObject *arg)
PyDict_DelItem(self->dict, PyList_GET_ITEM(arg, i));
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -1419,8 +1407,7 @@ static PyMethodDef OscListReceiver_methods[] = {
};
PyTypeObject OscListReceiverType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.OscListReceiver_base", /*tp_name*/
sizeof(OscListReceiver), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1428,7 +1415,7 @@ PyTypeObject OscListReceiverType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1564,7 +1551,7 @@ OscListReceive_dealloc(OscListReceive* self)
{
pyo_DEALLOC
OscListReceive_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1607,7 +1594,7 @@ OscListReceive_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
- if (!PyString_Check(pathtmp) && !PyUnicode_Check(pathtmp)) {
+ if (!PY_STRING_CHECK(pathtmp)) {
PyErr_SetString(PyExc_TypeError, "OscListReceive: the address attributes must be a string or a unicode.");
Py_RETURN_NONE;
}
@@ -1628,8 +1615,7 @@ OscListReceive_setInterpolation(OscListReceive *self, PyObject *arg)
self->interpolation = PyInt_AsLong(arg);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject * OscListReceive_getServer(OscListReceive* self) { GET_SERVER };
@@ -1676,7 +1662,7 @@ static PyNumberMethods OscListReceive_as_number = {
(binaryfunc)OscListReceive_add, /*nb_add*/
(binaryfunc)OscListReceive_sub, /*nb_subtract*/
(binaryfunc)OscListReceive_multiply, /*nb_multiply*/
- (binaryfunc)OscListReceive_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1690,16 +1676,16 @@ static PyNumberMethods OscListReceive_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)OscListReceive_inplace_add, /*inplace_add*/
(binaryfunc)OscListReceive_inplace_sub, /*inplace_subtract*/
(binaryfunc)OscListReceive_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)OscListReceive_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1708,15 +1694,14 @@ static PyNumberMethods OscListReceive_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)OscListReceive_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)OscListReceive_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject OscListReceiveType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.OscListReceive_base", /*tp_name*/
sizeof(OscListReceive), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1724,7 +1709,7 @@ PyTypeObject OscListReceiveType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&OscListReceive_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/panmodule.c b/src/objects/panmodule.c
index 3482505..df741b3 100644
--- a/src/objects/panmodule.c
+++ b/src/objects/panmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -268,7 +269,7 @@ Panner_dealloc(Panner* self)
pyo_DEALLOC
free(self->buffer_streams);
Panner_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -404,8 +405,7 @@ static PyMethodDef Panner_methods[] = {
};
PyTypeObject PannerType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Panner_base", /*tp_name*/
sizeof(Panner), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -413,7 +413,7 @@ sizeof(Panner), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -536,7 +536,7 @@ Pan_dealloc(Pan* self)
{
pyo_DEALLOC
Pan_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -623,7 +623,7 @@ static PyNumberMethods Pan_as_number = {
(binaryfunc)Pan_add, /*nb_add*/
(binaryfunc)Pan_sub, /*nb_subtract*/
(binaryfunc)Pan_multiply, /*nb_multiply*/
-(binaryfunc)Pan_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -637,16 +637,16 @@ static PyNumberMethods Pan_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Pan_inplace_add, /*inplace_add*/
(binaryfunc)Pan_inplace_sub, /*inplace_subtract*/
(binaryfunc)Pan_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Pan_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -655,15 +655,14 @@ static PyNumberMethods Pan_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Pan_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Pan_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject PanType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Pan_base", /*tp_name*/
sizeof(Pan), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -671,7 +670,7 @@ sizeof(Pan), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Pan_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -919,7 +918,7 @@ SPanner_dealloc(SPanner* self)
pyo_DEALLOC
free(self->buffer_streams);
SPanner_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1023,8 +1022,7 @@ static PyMethodDef SPanner_methods[] = {
};
PyTypeObject SPannerType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SPanner_base", /*tp_name*/
sizeof(SPanner), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1032,7 +1030,7 @@ sizeof(SPanner), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1155,7 +1153,7 @@ SPan_dealloc(SPan* self)
{
pyo_DEALLOC
SPan_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1242,7 +1240,7 @@ static PyNumberMethods SPan_as_number = {
(binaryfunc)SPan_add, /*nb_add*/
(binaryfunc)SPan_sub, /*nb_subtract*/
(binaryfunc)SPan_multiply, /*nb_multiply*/
-(binaryfunc)SPan_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1256,16 +1254,16 @@ static PyNumberMethods SPan_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)SPan_inplace_add, /*inplace_add*/
(binaryfunc)SPan_inplace_sub, /*inplace_subtract*/
(binaryfunc)SPan_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)SPan_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1274,15 +1272,14 @@ static PyNumberMethods SPan_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)SPan_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)SPan_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SPanType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SPan_base", /*tp_name*/
sizeof(SPan), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1290,7 +1287,7 @@ sizeof(SPan), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&SPan_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1468,7 +1465,7 @@ Switcher_dealloc(Switcher* self)
pyo_DEALLOC
free(self->buffer_streams);
Switcher_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1569,8 +1566,7 @@ static PyMethodDef Switcher_methods[] = {
};
PyTypeObject SwitcherType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Switcher_base", /*tp_name*/
sizeof(Switcher), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1578,7 +1574,7 @@ PyTypeObject SwitcherType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1701,7 +1697,7 @@ Switch_dealloc(Switch* self)
{
pyo_DEALLOC
Switch_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1788,7 +1784,7 @@ static PyNumberMethods Switch_as_number = {
(binaryfunc)Switch_add, /*nb_add*/
(binaryfunc)Switch_sub, /*nb_subtract*/
(binaryfunc)Switch_multiply, /*nb_multiply*/
- (binaryfunc)Switch_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1802,16 +1798,16 @@ static PyNumberMethods Switch_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Switch_inplace_add, /*inplace_add*/
(binaryfunc)Switch_inplace_sub, /*inplace_subtract*/
(binaryfunc)Switch_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Switch_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1820,15 +1816,14 @@ static PyNumberMethods Switch_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Switch_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Switch_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SwitchType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Switch_base", /*tp_name*/
sizeof(Switch), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1836,7 +1831,7 @@ PyTypeObject SwitchType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Switch_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1992,7 +1987,7 @@ VoiceManager_dealloc(VoiceManager* self)
if (self->voices != NULL)
free(self->voices);
VoiceManager_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2106,7 +2101,7 @@ static PyNumberMethods VoiceManager_as_number = {
(binaryfunc)VoiceManager_add, /*nb_add*/
(binaryfunc)VoiceManager_sub, /*nb_subtract*/
(binaryfunc)VoiceManager_multiply, /*nb_multiply*/
-(binaryfunc)VoiceManager_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2120,16 +2115,16 @@ static PyNumberMethods VoiceManager_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)VoiceManager_inplace_add, /*inplace_add*/
(binaryfunc)VoiceManager_inplace_sub, /*inplace_subtract*/
(binaryfunc)VoiceManager_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)VoiceManager_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2138,15 +2133,14 @@ static PyNumberMethods VoiceManager_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)VoiceManager_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)VoiceManager_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject VoiceManagerType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.VoiceManager_base", /*tp_name*/
sizeof(VoiceManager), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2154,7 +2148,7 @@ sizeof(VoiceManager), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&VoiceManager_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2306,7 +2300,7 @@ Mixer_dealloc(Mixer* self)
pyo_DEALLOC
free(self->buffer_streams);
Mixer_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2466,7 +2460,7 @@ Mixer_setAmp(Mixer *self, PyObject *args, PyObject *kwds)
}
if (! PyNumber_Check(amp)) {
- printf("Amplitude must be a number!n");
+ PySys_WriteStdout("Mixer: amp argument must be a number!n");
Py_INCREF(Py_None);
return Py_None;
}
@@ -2499,8 +2493,7 @@ static PyMethodDef Mixer_methods[] = {
};
PyTypeObject MixerType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Mixer_base", /*tp_name*/
sizeof(Mixer), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2508,7 +2501,7 @@ PyTypeObject MixerType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2631,7 +2624,7 @@ MixerVoice_dealloc(MixerVoice* self)
{
pyo_DEALLOC
MixerVoice_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2716,7 +2709,7 @@ static PyNumberMethods MixerVoice_as_number = {
(binaryfunc)MixerVoice_add, /*nb_add*/
(binaryfunc)MixerVoice_sub, /*nb_subtract*/
(binaryfunc)MixerVoice_multiply, /*nb_multiply*/
- (binaryfunc)MixerVoice_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2730,16 +2723,16 @@ static PyNumberMethods MixerVoice_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)MixerVoice_inplace_add, /*inplace_add*/
(binaryfunc)MixerVoice_inplace_sub, /*inplace_subtract*/
(binaryfunc)MixerVoice_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)MixerVoice_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2748,15 +2741,14 @@ static PyNumberMethods MixerVoice_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)MixerVoice_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)MixerVoice_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject MixerVoiceType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MixerVoice_base", /*tp_name*/
sizeof(MixerVoice), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2764,7 +2756,7 @@ PyTypeObject MixerVoiceType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&MixerVoice_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2966,7 +2958,7 @@ Selector_dealloc(Selector* self)
{
pyo_DEALLOC
Selector_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3115,7 +3107,7 @@ static PyNumberMethods Selector_as_number = {
(binaryfunc)Selector_add, /*nb_add*/
(binaryfunc)Selector_sub, /*nb_subtract*/
(binaryfunc)Selector_multiply, /*nb_multiply*/
-(binaryfunc)Selector_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3129,16 +3121,16 @@ static PyNumberMethods Selector_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Selector_inplace_add, /*inplace_add*/
(binaryfunc)Selector_inplace_sub, /*inplace_subtract*/
(binaryfunc)Selector_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Selector_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3147,15 +3139,14 @@ static PyNumberMethods Selector_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Selector_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Selector_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SelectorType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Selector_base", /*tp_name*/
sizeof(Selector), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3163,7 +3154,7 @@ sizeof(Selector), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Selector_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/patternmodule.c b/src/objects/patternmodule.c
index 956760e..a54553f 100644
--- a/src/objects/patternmodule.c
+++ b/src/objects/patternmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -30,6 +31,7 @@ typedef struct {
PyObject *callable;
PyObject *time;
Stream *time_stream;
+ PyObject *arg;
int modebuffer[1];
MYFLT sampleToSec;
double currentTime;
@@ -38,54 +40,75 @@ typedef struct {
static void
Pattern_generate_i(Pattern *self) {
+ int i;
MYFLT tm;
- int i, flag;
- PyObject *result;
+ PyObject *tuple, *result;
- flag = 0;
tm = PyFloat_AS_DOUBLE(self->time);
+ if (self->init) {
+ self->init = 0;
+ self->currentTime = tm;
+ }
+
for (i=0; i<self->bufsize; i++) {
if (self->currentTime >= tm) {
- flag = 1;
- self->currentTime = 0.;
+ self->currentTime = 0.0;
+ if (self->arg == Py_None) {
+ result = PyObject_Call((PyObject *)self->callable, PyTuple_New(0), NULL);
+ if (result == NULL) {
+ PyErr_Print();
+ return;
+ }
+ } else {
+ tuple = PyTuple_New(1);
+ PyTuple_SET_ITEM(tuple, 0, self->arg);
+ result = PyObject_Call((PyObject *)self->callable, tuple, NULL);
+ if (result == NULL) {
+ PyErr_Print();
+ return;
+ }
+ }
}
-
self->currentTime += self->sampleToSec;
}
- if (flag == 1 || self->init == 1) {
- self->init = 0;
- result = PyObject_Call((PyObject *)self->callable, PyTuple_New(0), NULL);
- if (result == NULL)
- PyErr_Print();
- }
}
static void
Pattern_generate_a(Pattern *self) {
- int i, flag;
- PyObject *result;
+ int i;
+ PyObject *tuple, *result;
MYFLT *tm = Stream_getData((Stream *)self->time_stream);
- flag = 0;
+ if (self->init) {
+ self->init = 0;
+ self->currentTime = tm[0];
+ }
+
for (i=0; i<self->bufsize; i++) {
if (self->currentTime >= tm[i]) {
- flag = 1;
- self->currentTime = 0.;
+ self->currentTime = 0.0;
+ if (self->arg == Py_None) {
+ result = PyObject_Call((PyObject *)self->callable, PyTuple_New(0), NULL);
+ if (result == NULL) {
+ PyErr_Print();
+ return;
+ }
+ } else {
+ tuple = PyTuple_New(1);
+ PyTuple_SET_ITEM(tuple, 0, self->arg);
+ result = PyObject_Call((PyObject *)self->callable, tuple, NULL);
+ if (result == NULL) {
+ PyErr_Print();
+ return;
+ }
+ }
}
-
self->currentTime += self->sampleToSec;
}
- if (flag == 1 || self->init == 1) {
- self->init = 0;
- result = PyObject_Call((PyObject *)self->callable, PyTuple_New(0), NULL);
- if (result == NULL)
- PyErr_Print();
- }
}
-
static void
Pattern_setProcMode(Pattern *self)
{
@@ -113,6 +136,7 @@ Pattern_traverse(Pattern *self, visitproc visit, void *arg)
Py_VISIT(self->callable);
Py_VISIT(self->time);
Py_VISIT(self->time_stream);
+ Py_VISIT(self->arg);
return 0;
}
@@ -123,6 +147,7 @@ Pattern_clear(Pattern *self)
Py_CLEAR(self->callable);
Py_CLEAR(self->time);
Py_CLEAR(self->time_stream);
+ Py_CLEAR(self->arg);
return 0;
}
@@ -131,20 +156,21 @@ Pattern_dealloc(Pattern* self)
{
pyo_DEALLOC
Pattern_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
Pattern_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int i;
- PyObject *timetmp=NULL, *calltmp=NULL;
+ PyObject *timetmp=NULL, *calltmp=NULL, *argtmp=NULL;
Pattern *self;
self = (Pattern *)type->tp_alloc(type, 0);
self->time = PyFloat_FromDouble(1.);
self->modebuffer[0] = 0;
self->init = 1;
+ self->arg = Py_None;
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, Pattern_compute_next_data_frame);
@@ -155,9 +181,9 @@ Pattern_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sampleToSec = 1. / self->sr;
self->currentTime = 0.;
- static char *kwlist[] = {"callable", "time", NULL};
+ static char *kwlist[] = {"callable", "time", "arg", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|O", kwlist, &calltmp, &timetmp))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &calltmp, &timetmp, &argtmp))
Py_RETURN_NONE;
if (calltmp) {
@@ -168,6 +194,10 @@ Pattern_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject_CallMethod((PyObject *)self, "setTime", "O", timetmp);
}
+ if (argtmp) {
+ PyObject_CallMethod((PyObject *)self, "setArg", "O", argtmp);
+ }
+
PyObject_CallMethod(self->server, "addStream", "O", self->stream);
(*self->mode_func_ptr)(self);
@@ -238,6 +268,20 @@ Pattern_setTime(Pattern *self, PyObject *arg)
return Py_None;
}
+static PyObject *
+Pattern_setArg(Pattern *self, PyObject *arg)
+{
+ PyObject *tmp;
+
+ tmp = arg;
+ Py_XDECREF(self->arg);
+ Py_INCREF(tmp);
+ self->arg = tmp;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyMemberDef Pattern_members[] = {
{"server", T_OBJECT_EX, offsetof(Pattern, server), 0, "Pyo server."},
{"stream", T_OBJECT_EX, offsetof(Pattern, stream), 0, "Stream object."},
@@ -252,12 +296,12 @@ static PyMethodDef Pattern_methods[] = {
{"stop", (PyCFunction)Pattern_stop, METH_NOARGS, "Stops computing."},
{"setTime", (PyCFunction)Pattern_setTime, METH_O, "Sets time factor."},
{"setFunction", (PyCFunction)Pattern_setFunction, METH_O, "Sets the function to be called."},
+{"setArg", (PyCFunction)Pattern_setArg, METH_O, "Sets function's argument."},
{NULL} /* Sentinel */
};
PyTypeObject PatternType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Pattern_base", /*tp_name*/
sizeof(Pattern), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -265,7 +309,7 @@ sizeof(Pattern), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -360,7 +404,7 @@ Score_dealloc(Score* self)
{
pyo_DEALLOC
Score_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -412,8 +456,7 @@ static PyMethodDef Score_methods[] = {
};
PyTypeObject ScoreType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Score_base", /*tp_name*/
sizeof(Score), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -421,7 +464,7 @@ sizeof(Score), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -523,7 +566,7 @@ CallAfter_dealloc(CallAfter* self)
{
pyo_DEALLOC
CallAfter_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -572,7 +615,10 @@ CallAfter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static PyObject * CallAfter_getServer(CallAfter* self) { GET_SERVER };
static PyObject * CallAfter_getStream(CallAfter* self) { GET_STREAM };
-static PyObject * CallAfter_play(CallAfter *self, PyObject *args, PyObject *kwds) { PLAY };
+static PyObject * CallAfter_play(CallAfter *self, PyObject *args, PyObject *kwds) {
+ self->currentTime = 0.;
+ PLAY
+};
static PyObject * CallAfter_stop(CallAfter *self) { STOP };
static PyMemberDef CallAfter_members[] = {
@@ -590,8 +636,7 @@ static PyMethodDef CallAfter_methods[] = {
};
PyTypeObject CallAfterType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.CallAfter_base", /*tp_name*/
sizeof(CallAfter), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -599,7 +644,7 @@ sizeof(CallAfter), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/phasevocmodule.c b/src/objects/phasevocmodule.c
index fbf19d3..f2b9666 100644
--- a/src/objects/phasevocmodule.c
+++ b/src/objects/phasevocmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -210,7 +211,7 @@ PVAnal_dealloc(PVAnal* self)
free(self->freq);
free(self->count);
PVAnal_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -244,7 +245,7 @@ PVAnal_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
while (k < self->size)
k *= 2;
self->size = k;
- printf("FFT size must be a power-of-2, using the next power-of-2 greater than size : %d\n", self->size);
+ PySys_WriteStdout("FFT size must be a power-of-2, using the next power-of-2 greater than size : %d\n", self->size);
}
self->count = (int *)realloc(self->count, self->bufsize * sizeof(int));
@@ -274,7 +275,7 @@ PVAnal_setSize(PVAnal *self, PyObject *arg)
while (k < self->size)
k *= 2;
self->size = k;
- printf("FFT size must be a power-of-2, using the next power-of-2 greater than size : %d\n", self->size);
+ PySys_WriteStdout("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);
}
@@ -294,7 +295,7 @@ PVAnal_setOverlaps(PVAnal *self, PyObject *arg)
while (k < self->olaps)
k *= 2;
self->olaps = k;
- printf("FFT overlaps must be a power-of-2, using the next power-of-2 greater than olaps : %d\n", self->olaps);
+ PySys_WriteStdout("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);
}
@@ -336,8 +337,7 @@ static PyMethodDef PVAnal_methods[] = {
};
PyTypeObject PVAnalType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVAnal_base", /*tp_name*/
sizeof(PVAnal), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -345,7 +345,7 @@ sizeof(PVAnal), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -587,7 +587,7 @@ PVSynth_dealloc(PVSynth* self)
free(self->twiddle);
free(self->window);
PVSynth_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -729,7 +729,7 @@ static PyNumberMethods PVSynth_as_number = {
(binaryfunc)PVSynth_add, /*nb_add*/
(binaryfunc)PVSynth_sub, /*nb_subtract*/
(binaryfunc)PVSynth_multiply, /*nb_multiply*/
-(binaryfunc)PVSynth_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -743,16 +743,16 @@ static PyNumberMethods PVSynth_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)PVSynth_inplace_add, /*inplace_add*/
(binaryfunc)PVSynth_inplace_sub, /*inplace_subtract*/
(binaryfunc)PVSynth_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)PVSynth_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -761,15 +761,14 @@ static PyNumberMethods PVSynth_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)PVSynth_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)PVSynth_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject PVSynthType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVSynth_base", /*tp_name*/
sizeof(PVSynth), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -777,7 +776,7 @@ sizeof(PVSynth), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&PVSynth_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1053,7 +1052,7 @@ PVAddSynth_dealloc(PVAddSynth* self)
free(self->amp);
free(self->freq);
PVAddSynth_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1277,7 +1276,7 @@ static PyNumberMethods PVAddSynth_as_number = {
(binaryfunc)PVAddSynth_add, /*nb_add*/
(binaryfunc)PVAddSynth_sub, /*nb_subtract*/
(binaryfunc)PVAddSynth_multiply, /*nb_multiply*/
-(binaryfunc)PVAddSynth_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1291,16 +1290,16 @@ static PyNumberMethods PVAddSynth_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)PVAddSynth_inplace_add, /*inplace_add*/
(binaryfunc)PVAddSynth_inplace_sub, /*inplace_subtract*/
(binaryfunc)PVAddSynth_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)PVAddSynth_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1309,15 +1308,14 @@ static PyNumberMethods PVAddSynth_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)PVAddSynth_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)PVAddSynth_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject PVAddSynthType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVAddSynth_base", /*tp_name*/
sizeof(PVAddSynth), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1325,7 +1323,7 @@ sizeof(PVAddSynth), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&PVAddSynth_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1538,7 +1536,7 @@ PVTranspose_dealloc(PVTranspose* self)
free(self->freq);
free(self->count);
PVTranspose_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1675,8 +1673,7 @@ static PyMethodDef PVTranspose_methods[] = {
};
PyTypeObject PVTransposeType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVTranspose_base", /*tp_name*/
sizeof(PVTranspose), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1684,7 +1681,7 @@ sizeof(PVTranspose), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2052,7 +2049,7 @@ PVVerb_dealloc(PVVerb* self)
free(self->l_freq);
free(self->count);
PVVerb_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2227,8 +2224,7 @@ static PyMethodDef PVVerb_methods[] = {
};
PyTypeObject PVVerbType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVVerb_base", /*tp_name*/
sizeof(PVVerb), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2236,7 +2232,7 @@ sizeof(PVVerb), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2280,6 +2276,7 @@ typedef struct {
Stream *thresh_stream;
PyObject *damp;
Stream *damp_stream;
+ int inverse;
int size;
int olaps;
int hsize;
@@ -2337,13 +2334,24 @@ PVGate_process_ii(PVGate *self) {
for (i=0; i<self->bufsize; i++) {
self->count[i] = count[i];
if (count[i] >= (self->size-1)) {
- for (k=0; k<self->hsize; k++) {
- mag = magn[self->overcount][k];
- if (mag < thresh)
- self->magn[self->overcount][k] = mag * damp;
- else
- self->magn[self->overcount][k] = mag;
- self->freq[self->overcount][k] = freq[self->overcount][k];
+ if (self->inverse == 0) {
+ for (k=0; k<self->hsize; k++) {
+ mag = magn[self->overcount][k];
+ if (mag < thresh)
+ self->magn[self->overcount][k] = mag * damp;
+ else
+ self->magn[self->overcount][k] = mag;
+ self->freq[self->overcount][k] = freq[self->overcount][k];
+ }
+ } else {
+ for (k=0; k<self->hsize; k++) {
+ mag = magn[self->overcount][k];
+ if (mag > thresh)
+ self->magn[self->overcount][k] = mag * damp;
+ else
+ self->magn[self->overcount][k] = mag;
+ self->freq[self->overcount][k] = freq[self->overcount][k];
+ }
}
self->overcount++;
if (self->overcount >= self->olaps)
@@ -2375,13 +2383,24 @@ PVGate_process_ai(PVGate *self) {
if (count[i] >= (self->size-1)) {
thresh = rvt[i];
thresh = MYPOW(10.0, thresh * 0.05);
- for (k=0; k<self->hsize; k++) {
- mag = magn[self->overcount][k];
- if (mag < thresh)
- self->magn[self->overcount][k] = mag * damp;
- else
- self->magn[self->overcount][k] = mag;
- self->freq[self->overcount][k] = freq[self->overcount][k];
+ if (self->inverse == 0) {
+ for (k=0; k<self->hsize; k++) {
+ mag = magn[self->overcount][k];
+ if (mag < thresh)
+ self->magn[self->overcount][k] = mag * damp;
+ else
+ self->magn[self->overcount][k] = mag;
+ self->freq[self->overcount][k] = freq[self->overcount][k];
+ }
+ } else {
+ for (k=0; k<self->hsize; k++) {
+ mag = magn[self->overcount][k];
+ if (mag > thresh)
+ self->magn[self->overcount][k] = mag * damp;
+ else
+ self->magn[self->overcount][k] = mag;
+ self->freq[self->overcount][k] = freq[self->overcount][k];
+ }
}
self->overcount++;
if (self->overcount >= self->olaps)
@@ -2413,13 +2432,24 @@ PVGate_process_ia(PVGate *self) {
self->count[i] = count[i];
if (count[i] >= (self->size-1)) {
damp = dmp[i];
- for (k=0; k<self->hsize; k++) {
- mag = magn[self->overcount][k];
- if (mag < thresh)
- self->magn[self->overcount][k] = mag * damp;
- else
- self->magn[self->overcount][k] = mag;
- self->freq[self->overcount][k] = freq[self->overcount][k];
+ if (self->inverse == 0) {
+ for (k=0; k<self->hsize; k++) {
+ mag = magn[self->overcount][k];
+ if (mag < thresh)
+ self->magn[self->overcount][k] = mag * damp;
+ else
+ self->magn[self->overcount][k] = mag;
+ self->freq[self->overcount][k] = freq[self->overcount][k];
+ }
+ } else {
+ for (k=0; k<self->hsize; k++) {
+ mag = magn[self->overcount][k];
+ if (mag > thresh)
+ self->magn[self->overcount][k] = mag * damp;
+ else
+ self->magn[self->overcount][k] = mag;
+ self->freq[self->overcount][k] = freq[self->overcount][k];
+ }
}
self->overcount++;
if (self->overcount >= self->olaps)
@@ -2452,13 +2482,24 @@ PVGate_process_aa(PVGate *self) {
thresh = rvt[i];
thresh = MYPOW(10.0, thresh * 0.05);
damp = dmp[i];
- for (k=0; k<self->hsize; k++) {
- mag = magn[self->overcount][k];
- if (mag < thresh)
- self->magn[self->overcount][k] = mag * damp;
- else
- self->magn[self->overcount][k] = mag;
- self->freq[self->overcount][k] = freq[self->overcount][k];
+ if (self->inverse == 0) {
+ for (k=0; k<self->hsize; k++) {
+ mag = magn[self->overcount][k];
+ if (mag < thresh)
+ self->magn[self->overcount][k] = mag * damp;
+ else
+ self->magn[self->overcount][k] = mag;
+ self->freq[self->overcount][k] = freq[self->overcount][k];
+ }
+ } else {
+ for (k=0; k<self->hsize; k++) {
+ mag = magn[self->overcount][k];
+ if (mag > thresh)
+ self->magn[self->overcount][k] = mag * damp;
+ else
+ self->magn[self->overcount][k] = mag;
+ self->freq[self->overcount][k] = freq[self->overcount][k];
+ }
}
self->overcount++;
if (self->overcount >= self->olaps)
@@ -2536,7 +2577,7 @@ PVGate_dealloc(PVGate* self)
free(self->freq);
free(self->count);
PVGate_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2551,13 +2592,14 @@ PVGate_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->damp = PyFloat_FromDouble(0.0);
self->size = 1024;
self->olaps = 4;
+ self->inverse = 0;
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, PVGate_compute_next_data_frame);
self->mode_func_ptr = PVGate_setProcMode;
- static char *kwlist[] = {"input", "thresh", "damp", NULL};
+ static char *kwlist[] = {"input", "thresh", "damp", "inverse", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OO", kwlist, &inputtmp, &threshtmp, &damptmp))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "O|OOi", kwlist, &inputtmp, &threshtmp, &damptmp, &self->inverse))
Py_RETURN_NONE;
if ( PyObject_HasAttrString((PyObject *)inputtmp, "pv_stream") == 0 ) {
@@ -2688,6 +2730,19 @@ PVGate_setDamp(PVGate *self, PyObject *arg)
return Py_None;
}
+static PyObject *
+PVGate_setInverse(PVGate *self, PyObject *arg)
+{
+ ASSERT_ARG_NOT_NULL
+
+ if (PyInt_Check(arg)) {
+ self->inverse = PyInt_AsLong(arg);
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyMemberDef PVGate_members[] = {
{"server", T_OBJECT_EX, offsetof(PVGate, server), 0, "Pyo server."},
{"stream", T_OBJECT_EX, offsetof(PVGate, stream), 0, "Stream object."},
@@ -2705,14 +2760,14 @@ static PyMethodDef PVGate_methods[] = {
{"setInput", (PyCFunction)PVGate_setInput, METH_O, "Sets a new input object."},
{"setThresh", (PyCFunction)PVGate_setThresh, METH_O, "Sets the Threshold factor."},
{"setDamp", (PyCFunction)PVGate_setDamp, METH_O, "Sets the damping factor."},
+{"setInverse", (PyCFunction)PVGate_setInverse, METH_O, "Sets the inverse mode."},
{"play", (PyCFunction)PVGate_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"stop", (PyCFunction)PVGate_stop, METH_NOARGS, "Stops computing."},
{NULL} /* Sentinel */
};
PyTypeObject PVGateType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVGate_base", /*tp_name*/
sizeof(PVGate), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2720,7 +2775,7 @@ sizeof(PVGate), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2927,7 +2982,7 @@ PVCross_dealloc(PVCross* self)
free(self->freq);
free(self->count);
PVCross_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3101,8 +3156,7 @@ static PyMethodDef PVCross_methods[] = {
};
PyTypeObject PVCrossType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVCross_base", /*tp_name*/
sizeof(PVCross), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3110,7 +3164,7 @@ sizeof(PVCross), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3265,7 +3319,7 @@ PVMult_dealloc(PVMult* self)
free(self->freq);
free(self->count);
PVMult_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3401,8 +3455,7 @@ static PyMethodDef PVMult_methods[] = {
};
PyTypeObject PVMultType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVMult_base", /*tp_name*/
sizeof(PVMult), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3410,7 +3463,7 @@ sizeof(PVMult), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3627,7 +3680,7 @@ PVMorph_dealloc(PVMorph* self)
free(self->freq);
free(self->count);
PVMorph_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3801,8 +3854,7 @@ static PyMethodDef PVMorph_methods[] = {
};
PyTypeObject PVMorphType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVMorph_base", /*tp_name*/
sizeof(PVMorph), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3810,7 +3862,7 @@ sizeof(PVMorph), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4063,7 +4115,7 @@ PVFilter_dealloc(PVFilter* self)
free(self->freq);
free(self->count);
PVFilter_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4248,8 +4300,7 @@ static PyMethodDef PVFilter_methods[] = {
};
PyTypeObject PVFilterType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVFilter_base", /*tp_name*/
sizeof(PVFilter), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4257,7 +4308,7 @@ sizeof(PVFilter), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4540,7 +4591,7 @@ PVDelay_dealloc(PVDelay* self)
free(self->freq_buf);
free(self->count);
PVDelay_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4718,8 +4769,7 @@ static PyMethodDef PVDelay_methods[] = {
};
PyTypeObject PVDelayType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVDelay_base", /*tp_name*/
sizeof(PVDelay), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4727,7 +4777,7 @@ sizeof(PVDelay), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4994,7 +5044,7 @@ PVBuffer_dealloc(PVBuffer* self)
free(self->freq_buf);
free(self->count);
PVBuffer_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5168,8 +5218,7 @@ static PyMethodDef PVBuffer_methods[] = {
};
PyTypeObject PVBufferType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVBuffer_base", /*tp_name*/
sizeof(PVBuffer), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5177,7 +5226,7 @@ sizeof(PVBuffer), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5394,7 +5443,7 @@ PVShift_dealloc(PVShift* self)
free(self->freq);
free(self->count);
PVShift_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5531,8 +5580,7 @@ static PyMethodDef PVShift_methods[] = {
};
PyTypeObject PVShiftType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVShift_base", /*tp_name*/
sizeof(PVShift), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5540,7 +5588,7 @@ sizeof(PVShift), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5865,7 +5913,7 @@ PVAmpMod_dealloc(PVAmpMod* self)
free(self->pointers);
free(self->count);
PVAmpMod_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -6055,8 +6103,7 @@ static PyMethodDef PVAmpMod_methods[] = {
};
PyTypeObject PVAmpModType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVAmpMod_base", /*tp_name*/
sizeof(PVAmpMod), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -6064,7 +6111,7 @@ sizeof(PVAmpMod), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -6463,7 +6510,7 @@ PVFreqMod_dealloc(PVFreqMod* self)
free(self->pointers);
free(self->count);
PVFreqMod_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -6691,8 +6738,7 @@ static PyMethodDef PVFreqMod_methods[] = {
};
PyTypeObject PVFreqModType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVFreqMod_base", /*tp_name*/
sizeof(PVFreqMod), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -6700,7 +6746,7 @@ sizeof(PVFreqMod), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -6995,7 +7041,7 @@ PVBufLoops_dealloc(PVBufLoops* self)
free(self->speeds);
free(self->pointers);
PVBufLoops_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -7207,8 +7253,7 @@ static PyMethodDef PVBufLoops_methods[] = {
};
PyTypeObject PVBufLoopsType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVBufLoops_base", /*tp_name*/
sizeof(PVBufLoops), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -7216,7 +7261,7 @@ sizeof(PVBufLoops), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -7421,7 +7466,7 @@ PVBufTabLoops_dealloc(PVBufTabLoops* self)
free(self->count);
free(self->pointers);
PVBufTabLoops_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -7558,8 +7603,7 @@ static PyMethodDef PVBufTabLoops_methods[] = {
};
PyTypeObject PVBufTabLoopsType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVBufTabLoops_base", /*tp_name*/
sizeof(PVBufTabLoops), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -7567,7 +7611,7 @@ sizeof(PVBufTabLoops), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -7729,7 +7773,7 @@ PVMix_dealloc(PVMix* self)
free(self->freq);
free(self->count);
PVMix_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -7865,8 +7909,7 @@ static PyMethodDef PVMix_methods[] = {
};
PyTypeObject PVMixType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.PVMix_base", /*tp_name*/
sizeof(PVMix), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -7874,7 +7917,7 @@ sizeof(PVMix), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/randommodule.c b/src/objects/randommodule.c
index fc25ac6..af31037 100644
--- a/src/objects/randommodule.c
+++ b/src/objects/randommodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include <math.h>
#include "structmember.h"
#include "pyomodule.h"
@@ -345,7 +346,7 @@ Randi_dealloc(Randi* self)
{
pyo_DEALLOC
Randi_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -561,7 +562,7 @@ static PyNumberMethods Randi_as_number = {
(binaryfunc)Randi_add, /*nb_add*/
(binaryfunc)Randi_sub, /*nb_subtract*/
(binaryfunc)Randi_multiply, /*nb_multiply*/
-(binaryfunc)Randi_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -575,16 +576,16 @@ static PyNumberMethods Randi_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Randi_inplace_add, /*inplace_add*/
(binaryfunc)Randi_inplace_sub, /*inplace_subtract*/
(binaryfunc)Randi_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Randi_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -593,15 +594,14 @@ static PyNumberMethods Randi_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Randi_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Randi_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject RandiType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Randi_base", /*tp_name*/
sizeof(Randi), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -609,7 +609,7 @@ sizeof(Randi), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Randi_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -945,7 +945,7 @@ Randh_dealloc(Randh* self)
{
pyo_DEALLOC
Randh_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1161,7 +1161,7 @@ static PyNumberMethods Randh_as_number = {
(binaryfunc)Randh_add, /*nb_add*/
(binaryfunc)Randh_sub, /*nb_subtract*/
(binaryfunc)Randh_multiply, /*nb_multiply*/
-(binaryfunc)Randh_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1175,16 +1175,16 @@ static PyNumberMethods Randh_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Randh_inplace_add, /*inplace_add*/
(binaryfunc)Randh_inplace_sub, /*inplace_subtract*/
(binaryfunc)Randh_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Randh_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1193,15 +1193,14 @@ static PyNumberMethods Randh_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Randh_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Randh_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject RandhType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Randh_base", /*tp_name*/
sizeof(Randh), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1209,7 +1208,7 @@ sizeof(Randh), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Randh_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1380,7 +1379,7 @@ Choice_dealloc(Choice* self)
pyo_DEALLOC
free(self->choice);
Choice_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1536,7 +1535,7 @@ static PyNumberMethods Choice_as_number = {
(binaryfunc)Choice_add, /*nb_add*/
(binaryfunc)Choice_sub, /*nb_subtract*/
(binaryfunc)Choice_multiply, /*nb_multiply*/
-(binaryfunc)Choice_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1550,16 +1549,16 @@ static PyNumberMethods Choice_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Choice_inplace_add, /*inplace_add*/
(binaryfunc)Choice_inplace_sub, /*inplace_subtract*/
(binaryfunc)Choice_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Choice_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1568,15 +1567,14 @@ static PyNumberMethods Choice_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Choice_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Choice_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ChoiceType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Choice_base", /*tp_name*/
sizeof(Choice), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1584,7 +1582,7 @@ sizeof(Choice), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Choice_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1806,7 +1804,7 @@ RandInt_dealloc(RandInt* self)
{
pyo_DEALLOC
RandInt_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1971,7 +1969,7 @@ static PyNumberMethods RandInt_as_number = {
(binaryfunc)RandInt_add, /*nb_add*/
(binaryfunc)RandInt_sub, /*nb_subtract*/
(binaryfunc)RandInt_multiply, /*nb_multiply*/
-(binaryfunc)RandInt_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1985,16 +1983,16 @@ static PyNumberMethods RandInt_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)RandInt_inplace_add, /*inplace_add*/
(binaryfunc)RandInt_inplace_sub, /*inplace_subtract*/
(binaryfunc)RandInt_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)RandInt_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2003,15 +2001,14 @@ static PyNumberMethods RandInt_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)RandInt_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)RandInt_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject RandIntType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.RandInt_base", /*tp_name*/
sizeof(RandInt), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2019,7 +2016,7 @@ sizeof(RandInt), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&RandInt_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2264,7 +2261,7 @@ RandDur_dealloc(RandDur* self)
{
pyo_DEALLOC
RandDur_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2445,7 +2442,7 @@ static PyNumberMethods RandDur_as_number = {
(binaryfunc)RandDur_add, /*nb_add*/
(binaryfunc)RandDur_sub, /*nb_subtract*/
(binaryfunc)RandDur_multiply, /*nb_multiply*/
- (binaryfunc)RandDur_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2459,16 +2456,16 @@ static PyNumberMethods RandDur_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)RandDur_inplace_add, /*inplace_add*/
(binaryfunc)RandDur_inplace_sub, /*inplace_subtract*/
(binaryfunc)RandDur_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)RandDur_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2477,15 +2474,14 @@ static PyNumberMethods RandDur_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)RandDur_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)RandDur_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject RandDurType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.RandDur_base", /*tp_name*/
sizeof(RandDur), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2493,7 +2489,7 @@ PyTypeObject RandDurType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&RandDur_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2704,21 +2700,21 @@ Xnoise_poisson(Xnoise *self) {
// x1 = max value, x2 = max step
static MYFLT
Xnoise_walker(Xnoise *self) {
- int modulo, dir;
+ unsigned int modulo, dir;
if (self->xx2 < 0.002) self->xx2 = 0.002;
- modulo = (int)(self->xx2 * 1000.0);
- dir = pyorand() % 2;
+ modulo = (unsigned int)(self->xx2 * 1000.0);
+ dir = pyorand() % 100;
- if (dir == 0)
- self->walkerValue = self->walkerValue + (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ if (dir < 50)
+ self->walkerValue += ((MYFLT)(pyorand() % modulo) * 0.001);
else
- self->walkerValue = self->walkerValue - (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ self->walkerValue -= ((MYFLT)(pyorand() % modulo) * 0.001);
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
- if (self->walkerValue < 0.0)
+ else if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
return self->walkerValue;
@@ -2727,7 +2723,7 @@ Xnoise_walker(Xnoise *self) {
// x1 = max value, x2 = max step
static MYFLT
Xnoise_loopseg(Xnoise *self) {
- int modulo, dir;
+ unsigned int modulo, dir;
if (self->loopChoice == 0) {
@@ -2735,17 +2731,17 @@ Xnoise_loopseg(Xnoise *self) {
if (self->xx2 < 0.002) self->xx2 = 0.002;
- modulo = (int)(self->xx2 * 1000.0);
- dir = pyorand() % 2;
+ modulo = (unsigned int)(self->xx2 * 1000.0);
+ dir = pyorand() % 100;
- if (dir == 0)
- self->walkerValue = self->walkerValue + (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ if (dir < 50)
+ self->walkerValue += ((MYFLT)(pyorand() % modulo) * 0.001);
else
- self->walkerValue = self->walkerValue - (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ self->walkerValue -= ((MYFLT)(pyorand() % modulo) * 0.001);
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
- if (self->walkerValue < 0.0)
+ else if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
self->loop_buffer[self->loopCountRec++] = self->walkerValue;
@@ -3113,7 +3109,7 @@ Xnoise_dealloc(Xnoise* self)
{
pyo_DEALLOC
Xnoise_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3349,7 +3345,7 @@ static PyNumberMethods Xnoise_as_number = {
(binaryfunc)Xnoise_add, /*nb_add*/
(binaryfunc)Xnoise_sub, /*nb_subtract*/
(binaryfunc)Xnoise_multiply, /*nb_multiply*/
- (binaryfunc)Xnoise_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3363,16 +3359,16 @@ static PyNumberMethods Xnoise_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Xnoise_inplace_add, /*inplace_add*/
(binaryfunc)Xnoise_inplace_sub, /*inplace_subtract*/
(binaryfunc)Xnoise_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Xnoise_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3381,15 +3377,14 @@ static PyNumberMethods Xnoise_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Xnoise_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Xnoise_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject XnoiseType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Xnoise_base", /*tp_name*/
sizeof(Xnoise), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3397,7 +3392,7 @@ PyTypeObject XnoiseType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Xnoise_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3636,21 +3631,21 @@ XnoiseMidi_poisson(XnoiseMidi *self) {
// x1 = max value, x2 = max step
static MYFLT
XnoiseMidi_walker(XnoiseMidi *self) {
- int modulo, dir;
+ unsigned int modulo, dir;
if (self->xx2 < 0.002) self->xx2 = 0.002;
- modulo = (int)(self->xx2 * 1000.0);
- dir = pyorand() % 2;
+ modulo = (unsigned int)(self->xx2 * 1000.0);
+ dir = pyorand() % 100;
- if (dir == 0)
- self->walkerValue = self->walkerValue + (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ if (dir < 50)
+ self->walkerValue += ((MYFLT)(pyorand() % modulo) * 0.001);
else
- self->walkerValue = self->walkerValue - (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ self->walkerValue -= ((MYFLT)(pyorand() % modulo) * 0.001);
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
- if (self->walkerValue < 0.0)
+ else if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
return self->walkerValue;
@@ -3659,7 +3654,7 @@ XnoiseMidi_walker(XnoiseMidi *self) {
// x1 = max value, x2 = max step
static MYFLT
XnoiseMidi_loopseg(XnoiseMidi *self) {
- int modulo, dir;
+ unsigned int modulo, dir;
if (self->loopChoice == 0) {
@@ -3667,17 +3662,17 @@ XnoiseMidi_loopseg(XnoiseMidi *self) {
if (self->xx2 < 0.002) self->xx2 = 0.002;
- modulo = (int)(self->xx2 * 1000.0);
- dir = pyorand() % 2;
+ modulo = (unsigned int)(self->xx2 * 1000.0);
+ dir = pyorand() % 100;
- if (dir == 0)
- self->walkerValue = self->walkerValue + (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ if (dir < 50)
+ self->walkerValue += ((MYFLT)(pyorand() % modulo) * 0.001);
else
- self->walkerValue = self->walkerValue - (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ self->walkerValue -= ((MYFLT)(pyorand() % modulo) * 0.001);
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
- if (self->walkerValue < 0.0)
+ else if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
self->loop_buffer[self->loopCountRec++] = self->walkerValue;
@@ -4053,7 +4048,7 @@ XnoiseMidi_dealloc(XnoiseMidi* self)
{
pyo_DEALLOC
XnoiseMidi_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4186,7 +4181,7 @@ XnoiseMidi_setScale(XnoiseMidi *self, PyObject *arg)
if (tmp >= 0 && tmp <= 2)
self->scale = tmp;
else
- printf("scale attribute must be an integer {0, 1, 2}\n");
+ PySys_WriteStdout("XnoiseMidi: scale attribute must be an integer {0, 1, 2}\n");
}
Py_INCREF(Py_None);
@@ -4340,7 +4335,7 @@ static PyNumberMethods XnoiseMidi_as_number = {
(binaryfunc)XnoiseMidi_add, /*nb_add*/
(binaryfunc)XnoiseMidi_sub, /*nb_subtract*/
(binaryfunc)XnoiseMidi_multiply, /*nb_multiply*/
- (binaryfunc)XnoiseMidi_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4354,16 +4349,16 @@ static PyNumberMethods XnoiseMidi_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)XnoiseMidi_inplace_add, /*inplace_add*/
(binaryfunc)XnoiseMidi_inplace_sub, /*inplace_subtract*/
(binaryfunc)XnoiseMidi_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)XnoiseMidi_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4372,15 +4367,14 @@ static PyNumberMethods XnoiseMidi_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)XnoiseMidi_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)XnoiseMidi_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject XnoiseMidiType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.XnoiseMidi_base", /*tp_name*/
sizeof(XnoiseMidi), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4388,7 +4382,7 @@ PyTypeObject XnoiseMidiType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&XnoiseMidi_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4602,21 +4596,21 @@ XnoiseDur_poisson(XnoiseDur *self) {
// x1 = max value, x2 = max step
static MYFLT
XnoiseDur_walker(XnoiseDur *self) {
- int modulo, dir;
+ unsigned int modulo, dir;
if (self->xx2 < 0.002) self->xx2 = 0.002;
- modulo = (int)(self->xx2 * 1000.0);
- dir = pyorand() % 2;
+ modulo = (unsigned int)(self->xx2 * 1000.0);
+ dir = pyorand() % 100;
- if (dir == 0)
- self->walkerValue = self->walkerValue + (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ if (dir < 50)
+ self->walkerValue += ((MYFLT)(pyorand() % modulo) * 0.001);
else
- self->walkerValue = self->walkerValue - (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ self->walkerValue -= ((MYFLT)(pyorand() % modulo) * 0.001);
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
- if (self->walkerValue < 0.0)
+ else if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
return self->walkerValue;
@@ -4625,7 +4619,7 @@ XnoiseDur_walker(XnoiseDur *self) {
// x1 = max value, x2 = max step
static MYFLT
XnoiseDur_loopseg(XnoiseDur *self) {
- int modulo, dir;
+ unsigned int modulo, dir;
if (self->loopChoice == 0) {
@@ -4633,17 +4627,17 @@ XnoiseDur_loopseg(XnoiseDur *self) {
if (self->xx2 < 0.002) self->xx2 = 0.002;
- modulo = (int)(self->xx2 * 1000.0);
- dir = pyorand() % 2;
+ modulo = (unsigned int)(self->xx2 * 1000.0);
+ dir = pyorand() % 100;
- if (dir == 0)
- self->walkerValue = self->walkerValue + (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ if (dir < 50)
+ self->walkerValue += ((MYFLT)(pyorand() % modulo) * 0.001);
else
- self->walkerValue = self->walkerValue - (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ self->walkerValue -= ((MYFLT)(pyorand() % modulo) * 0.001);
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
- if (self->walkerValue < 0.0)
+ else if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
self->loop_buffer[self->loopCountRec++] = self->walkerValue;
@@ -4853,7 +4847,7 @@ XnoiseDur_dealloc(XnoiseDur* self)
{
pyo_DEALLOC
XnoiseDur_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5143,7 +5137,7 @@ static PyNumberMethods XnoiseDur_as_number = {
(binaryfunc)XnoiseDur_add, /*nb_add*/
(binaryfunc)XnoiseDur_sub, /*nb_subtract*/
(binaryfunc)XnoiseDur_multiply, /*nb_multiply*/
- (binaryfunc)XnoiseDur_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5157,16 +5151,16 @@ static PyNumberMethods XnoiseDur_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)XnoiseDur_inplace_add, /*inplace_add*/
(binaryfunc)XnoiseDur_inplace_sub, /*inplace_subtract*/
(binaryfunc)XnoiseDur_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)XnoiseDur_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5175,15 +5169,14 @@ static PyNumberMethods XnoiseDur_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)XnoiseDur_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)XnoiseDur_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject XnoiseDurType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.XnoiseDur_base", /*tp_name*/
sizeof(XnoiseDur), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5191,7 +5184,7 @@ PyTypeObject XnoiseDurType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&XnoiseDur_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5412,7 +5405,7 @@ Urn_dealloc(Urn* self)
free(self->list);
free(self->trigsBuffer);
Urn_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5568,7 +5561,7 @@ static PyNumberMethods Urn_as_number = {
(binaryfunc)Urn_add, /*nb_add*/
(binaryfunc)Urn_sub, /*nb_subtract*/
(binaryfunc)Urn_multiply, /*nb_multiply*/
-(binaryfunc)Urn_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5582,16 +5575,16 @@ static PyNumberMethods Urn_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Urn_inplace_add, /*inplace_add*/
(binaryfunc)Urn_inplace_sub, /*inplace_subtract*/
(binaryfunc)Urn_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Urn_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5600,15 +5593,14 @@ static PyNumberMethods Urn_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Urn_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Urn_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject UrnType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Urn_base", /*tp_name*/
sizeof(Urn), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5616,7 +5608,7 @@ sizeof(Urn), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Urn_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5646,4 +5638,458 @@ Urn_members, /* tp_members */
0, /* tp_init */
0, /* tp_alloc */
Urn_new, /* tp_new */
-};
\ No newline at end of file
+};
+
+/****************/
+/**** LogiMap ***/
+/****************/
+typedef struct {
+ pyo_audio_HEAD
+ PyObject *chaos;
+ PyObject *freq;
+ Stream *chaos_stream;
+ Stream *freq_stream;
+ MYFLT init;
+ MYFLT value;
+ MYFLT time;
+ int modebuffer[4]; // need at least 2 slots for mul & add
+} LogiMap;
+
+static void
+LogiMap_generate_ii(LogiMap *self) {
+ int i;
+ MYFLT inc;
+ MYFLT ch = PyFloat_AS_DOUBLE(self->chaos);
+ MYFLT fr = PyFloat_AS_DOUBLE(self->freq);
+ inc = fr / self->sr;
+
+ if (ch <= 0.0)
+ ch = 0.001;
+ else if (ch >= 1.0)
+ ch = 0.999;
+
+ for (i=0; i<self->bufsize; i++) {
+ self->time += inc;
+ if (self->time >= 1.0) {
+ self->time -= 1.0;
+ self->value = (ch + 3) * self->value * (1.0 - self->value);
+ }
+ self->data[i] = self->value;
+ }
+}
+
+static void
+LogiMap_generate_ai(LogiMap *self) {
+ int i;
+ MYFLT inc, ch = 0.0;
+ MYFLT *chaos = Stream_getData((Stream *)self->chaos_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 >= 1.0) {
+ self->time -= 1.0;
+ ch = chaos[i];
+ if (ch <= 0.0)
+ ch = 0.001;
+ else if (ch >= 1.0)
+ ch = 0.999;
+ self->value = (ch + 3) * self->value * (1.0 - self->value);
+ }
+ self->data[i] = self->value;
+ }
+}
+
+static void
+LogiMap_generate_ia(LogiMap *self) {
+ int i;
+ MYFLT inc;
+ MYFLT ch = PyFloat_AS_DOUBLE(self->chaos);
+ MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
+
+ if (ch <= 0.0)
+ ch = 0.001;
+ else if (ch >= 1.0)
+ ch = 0.999;
+
+ for (i=0; i<self->bufsize; i++) {
+ inc = fr[i] / self->sr;
+ self->time += inc;
+ if (self->time >= 1.0) {
+ self->time -= 1.0;
+ self->value = (ch + 3) * self->value * (1.0 - self->value);
+ }
+ self->data[i] = self->value;
+ }
+}
+
+static void
+LogiMap_generate_aa(LogiMap *self) {
+ int i;
+ MYFLT inc, ch = 0.0;
+ MYFLT *chaos = Stream_getData((Stream *)self->chaos_stream);
+ MYFLT *fr = Stream_getData((Stream *)self->freq_stream);
+
+ for (i=0; i<self->bufsize; i++) {
+ inc = fr[i] / self->sr;
+ self->time += inc;
+ if (self->time >= 1.0) {
+ self->time -= 1.0;
+ ch = chaos[i];
+ if (ch <= 0.0)
+ ch = 0.001;
+ else if (ch >= 1.0)
+ ch = 0.999;
+ self->value = (ch + 3) * self->value * (1.0 - self->value);
+ }
+ self->data[i] = self->value;
+ }
+}
+
+static void LogiMap_postprocessing_ii(LogiMap *self) { POST_PROCESSING_II };
+static void LogiMap_postprocessing_ai(LogiMap *self) { POST_PROCESSING_AI };
+static void LogiMap_postprocessing_ia(LogiMap *self) { POST_PROCESSING_IA };
+static void LogiMap_postprocessing_aa(LogiMap *self) { POST_PROCESSING_AA };
+static void LogiMap_postprocessing_ireva(LogiMap *self) { POST_PROCESSING_IREVA };
+static void LogiMap_postprocessing_areva(LogiMap *self) { POST_PROCESSING_AREVA };
+static void LogiMap_postprocessing_revai(LogiMap *self) { POST_PROCESSING_REVAI };
+static void LogiMap_postprocessing_revaa(LogiMap *self) { POST_PROCESSING_REVAA };
+static void LogiMap_postprocessing_revareva(LogiMap *self) { POST_PROCESSING_REVAREVA };
+
+static void
+LogiMap_setProcMode(LogiMap *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 = LogiMap_generate_ii;
+ break;
+ case 1:
+ self->proc_func_ptr = LogiMap_generate_ai;
+ break;
+ case 10:
+ self->proc_func_ptr = LogiMap_generate_ia;
+ break;
+ case 11:
+ self->proc_func_ptr = LogiMap_generate_aa;
+ break;
+ }
+ switch (muladdmode) {
+ case 0:
+ self->muladd_func_ptr = LogiMap_postprocessing_ii;
+ break;
+ case 1:
+ self->muladd_func_ptr = LogiMap_postprocessing_ai;
+ break;
+ case 2:
+ self->muladd_func_ptr = LogiMap_postprocessing_revai;
+ break;
+ case 10:
+ self->muladd_func_ptr = LogiMap_postprocessing_ia;
+ break;
+ case 11:
+ self->muladd_func_ptr = LogiMap_postprocessing_aa;
+ break;
+ case 12:
+ self->muladd_func_ptr = LogiMap_postprocessing_revaa;
+ break;
+ case 20:
+ self->muladd_func_ptr = LogiMap_postprocessing_ireva;
+ break;
+ case 21:
+ self->muladd_func_ptr = LogiMap_postprocessing_areva;
+ break;
+ case 22:
+ self->muladd_func_ptr = LogiMap_postprocessing_revareva;
+ break;
+ }
+}
+
+static void
+LogiMap_compute_next_data_frame(LogiMap *self)
+{
+ (*self->proc_func_ptr)(self);
+ (*self->muladd_func_ptr)(self);
+}
+
+static int
+LogiMap_traverse(LogiMap *self, visitproc visit, void *arg)
+{
+ pyo_VISIT
+ Py_VISIT(self->freq);
+ Py_VISIT(self->freq_stream);
+ Py_VISIT(self->chaos);
+ Py_VISIT(self->chaos_stream);
+ return 0;
+}
+
+static int
+LogiMap_clear(LogiMap *self)
+{
+ pyo_CLEAR
+ Py_CLEAR(self->freq);
+ Py_CLEAR(self->freq_stream);
+ Py_CLEAR(self->chaos);
+ Py_CLEAR(self->chaos_stream);
+ return 0;
+}
+
+static void
+LogiMap_dealloc(LogiMap* self)
+{
+ pyo_DEALLOC
+ LogiMap_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+static PyObject *
+LogiMap_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ int i;
+ MYFLT init;
+ PyObject *chaostmp=NULL, *freqtmp=NULL, *multmp=NULL, *addtmp=NULL;
+ LogiMap *self;
+ self = (LogiMap *)type->tp_alloc(type, 0);
+
+ self->chaos = PyFloat_FromDouble(0.6);
+ self->freq = PyFloat_FromDouble(1.);
+ self->time = 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, LogiMap_compute_next_data_frame);
+ self->mode_func_ptr = LogiMap_setProcMode;
+
+ static char *kwlist[] = {"chaos", "freq", "init", "mul", "add", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__OOFOO, kwlist, &chaostmp, &freqtmp, &init, &multmp, &addtmp))
+ Py_RETURN_NONE;
+
+ if (chaostmp) {
+ PyObject_CallMethod((PyObject *)self, "setChaos", "O", chaostmp);
+ }
+
+ 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);
+
+ if (init <= 0)
+ init = 0.001;
+ else if (init >= 1.0)
+ init = 0.999;
+ self->value = self->init = init;
+
+ (*self->mode_func_ptr)(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * LogiMap_getServer(LogiMap* self) { GET_SERVER };
+static PyObject * LogiMap_getStream(LogiMap* self) { GET_STREAM };
+static PyObject * LogiMap_setMul(LogiMap *self, PyObject *arg) { SET_MUL };
+static PyObject * LogiMap_setAdd(LogiMap *self, PyObject *arg) { SET_ADD };
+static PyObject * LogiMap_setSub(LogiMap *self, PyObject *arg) { SET_SUB };
+static PyObject * LogiMap_setDiv(LogiMap *self, PyObject *arg) { SET_DIV };
+
+static PyObject * LogiMap_play(LogiMap *self, PyObject *args, PyObject *kwds) {
+ self->value = self->init;
+ PLAY
+};
+static PyObject * LogiMap_out(LogiMap *self, PyObject *args, PyObject *kwds) { OUT };
+static PyObject * LogiMap_stop(LogiMap *self) { STOP };
+
+static PyObject * LogiMap_multiply(LogiMap *self, PyObject *arg) { MULTIPLY };
+static PyObject * LogiMap_inplace_multiply(LogiMap *self, PyObject *arg) { INPLACE_MULTIPLY };
+static PyObject * LogiMap_add(LogiMap *self, PyObject *arg) { ADD };
+static PyObject * LogiMap_inplace_add(LogiMap *self, PyObject *arg) { INPLACE_ADD };
+static PyObject * LogiMap_sub(LogiMap *self, PyObject *arg) { SUB };
+static PyObject * LogiMap_inplace_sub(LogiMap *self, PyObject *arg) { INPLACE_SUB };
+static PyObject * LogiMap_div(LogiMap *self, PyObject *arg) { DIV };
+static PyObject * LogiMap_inplace_div(LogiMap *self, PyObject *arg) { INPLACE_DIV };
+
+static PyObject *
+LogiMap_setChaos(LogiMap *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->chaos);
+ if (isNumber == 1) {
+ self->chaos = PyNumber_Float(tmp);
+ self->modebuffer[2] = 0;
+ }
+ else {
+ self->chaos = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->chaos, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->chaos_stream);
+ self->chaos_stream = (Stream *)streamtmp;
+ self->modebuffer[2] = 1;
+ }
+
+ (*self->mode_func_ptr)(self);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+LogiMap_setFreq(LogiMap *self, PyObject *arg)
+{
+ PyObject *tmp, *streamtmp;
+
+ ASSERT_ARG_NOT_NULL
+
+ int isNumber = PyNumber_Check(arg);
+
+ tmp = arg;
+ Py_INCREF(tmp);
+ Py_DECREF(self->freq);
+ if (isNumber == 1) {
+ self->freq = PyNumber_Float(tmp);
+ self->modebuffer[3] = 0;
+ }
+ else {
+ self->freq = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->freq, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->freq_stream);
+ self->freq_stream = (Stream *)streamtmp;
+ self->modebuffer[3] = 1;
+ }
+
+ (*self->mode_func_ptr)(self);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMemberDef LogiMap_members[] = {
+{"server", T_OBJECT_EX, offsetof(LogiMap, server), 0, "Pyo server."},
+{"stream", T_OBJECT_EX, offsetof(LogiMap, stream), 0, "Stream object."},
+{"chaos", T_OBJECT_EX, offsetof(LogiMap, chaos), 0, "chaosimum possible value."},
+{"freq", T_OBJECT_EX, offsetof(LogiMap, freq), 0, "Polling frequency."},
+{"mul", T_OBJECT_EX, offsetof(LogiMap, mul), 0, "Mul factor."},
+{"add", T_OBJECT_EX, offsetof(LogiMap, add), 0, "Add factor."},
+{NULL} /* Sentinel */
+};
+
+static PyMethodDef LogiMap_methods[] = {
+{"getServer", (PyCFunction)LogiMap_getServer, METH_NOARGS, "Returns server object."},
+{"_getStream", (PyCFunction)LogiMap_getStream, METH_NOARGS, "Returns stream object."},
+{"play", (PyCFunction)LogiMap_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
+{"out", (PyCFunction)LogiMap_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
+{"stop", (PyCFunction)LogiMap_stop, METH_NOARGS, "Stops computing."},
+{"setChaos", (PyCFunction)LogiMap_setChaos, METH_O, "Sets the randomization degree."},
+{"setFreq", (PyCFunction)LogiMap_setFreq, METH_O, "Sets polling frequency."},
+{"setMul", (PyCFunction)LogiMap_setMul, METH_O, "Sets oscillator mul factor."},
+{"setAdd", (PyCFunction)LogiMap_setAdd, METH_O, "Sets oscillator add factor."},
+{"setSub", (PyCFunction)LogiMap_setSub, METH_O, "Sets inverse add factor."},
+{"setDiv", (PyCFunction)LogiMap_setDiv, METH_O, "Sets inverse mul factor."},
+{NULL} /* Sentinel */
+};
+
+static PyNumberMethods LogiMap_as_number = {
+(binaryfunc)LogiMap_add, /*nb_add*/
+(binaryfunc)LogiMap_sub, /*nb_subtract*/
+(binaryfunc)LogiMap_multiply, /*nb_multiply*/
+INITIALIZE_NB_DIVIDE_ZERO /*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*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
+0, /*nb_int*/
+0, /*nb_long*/
+0, /*nb_float*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
+(binaryfunc)LogiMap_inplace_add, /*inplace_add*/
+(binaryfunc)LogiMap_inplace_sub, /*inplace_subtract*/
+(binaryfunc)LogiMap_inplace_multiply, /*inplace_multiply*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*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*/
+(binaryfunc)LogiMap_div, /*nb_true_divide*/
+0, /*nb_inplace_floor_divide*/
+(binaryfunc)LogiMap_inplace_div, /*nb_inplace_true_divide*/
+0, /* nb_index */
+};
+
+PyTypeObject LogiMapType = {
+PyVarObject_HEAD_INIT(NULL, 0)
+"_pyo.LogiMap_base", /*tp_name*/
+sizeof(LogiMap), /*tp_basicsize*/
+0, /*tp_itemsize*/
+(destructor)LogiMap_dealloc, /*tp_dealloc*/
+0, /*tp_print*/
+0, /*tp_getattr*/
+0, /*tp_setattr*/
+0, /*tp_as_async (tp_compare in Python 2)*/
+0, /*tp_repr*/
+&LogiMap_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*/
+"LogiMap objects. Random generator based on the logistic equation.", /* tp_doc */
+(traverseproc)LogiMap_traverse, /* tp_traverse */
+(inquiry)LogiMap_clear, /* tp_clear */
+0, /* tp_richcompare */
+0, /* tp_weaklistoffset */
+0, /* tp_iter */
+0, /* tp_iternext */
+LogiMap_methods, /* tp_methods */
+LogiMap_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 */
+LogiMap_new, /* tp_new */
+};
diff --git a/src/objects/recordmodule.c b/src/objects/recordmodule.c
index 1fd0e1d..c9696ff 100644
--- a/src/objects/recordmodule.c
+++ b/src/objects/recordmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -111,7 +112,7 @@ Record_dealloc(Record* self)
pyo_DEALLOC
free(self->buffer);
Record_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -120,6 +121,7 @@ Record_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
int i, buflen;
int fileformat = 0;
int sampletype = 0;
+ double quality = 0.4;
PyObject *input_listtmp;
Record *self;
self = (Record *)type->tp_alloc(type, 0);
@@ -132,9 +134,9 @@ Record_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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};
+ static char *kwlist[] = {"input", "filename", "chnls", "fileformat", "sampletype", "buffering", "quality", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "Os|iiii", kwlist, &input_listtmp, &self->recpath, &self->chnls, &fileformat, &sampletype, &self->buffering))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "Os|iiiid", kwlist, &input_listtmp, &self->recpath, &self->chnls, &fileformat, &sampletype, &self->buffering, &quality))
Py_RETURN_NONE;
Py_XDECREF(self->input_list);
@@ -203,10 +205,15 @@ Record_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
/* Open the output file. */
if (! (self->recfile = sf_open(self->recpath, SFM_WRITE, &self->recinfo))) {
- printf ("Not able to open output file %s.\n", self->recpath);
+ PySys_WriteStdout("Record: not able to open output file %s.\n", self->recpath);
Py_RETURN_NONE;
}
+ // Sets the encoding quality for FLAC and OGG compressed formats
+ if (fileformat == 5 || fileformat == 7) {
+ sf_command(self->recfile, SFC_SET_VBR_ENCODING_QUALITY, &quality, sizeof(double));
+ }
+
buflen = self->bufsize * self->chnls * self->buffering;
self->buffer = (MYFLT *)realloc(self->buffer, buflen * sizeof(MYFLT));
for (i=0; i<buflen; i++) {
@@ -246,8 +253,7 @@ static PyMethodDef Record_methods[] = {
};
PyTypeObject RecordType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Record_base", /*tp_name*/
sizeof(Record), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -255,7 +261,7 @@ sizeof(Record), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -370,7 +376,7 @@ ControlRec_dealloc(ControlRec* self)
if (self->buffer != NULL)
free(self->buffer);
ControlRec_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -470,8 +476,7 @@ static PyMethodDef ControlRec_methods[] = {
};
PyTypeObject ControlRecType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.ControlRec_base", /*tp_name*/
sizeof(ControlRec), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -479,7 +484,7 @@ PyTypeObject ControlRecType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -645,7 +650,7 @@ ControlRead_dealloc(ControlRead* self)
free(self->values);
free(self->trigsBuffer);
ControlRead_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -821,7 +826,7 @@ static PyNumberMethods ControlRead_as_number = {
(binaryfunc)ControlRead_add, /*nb_add*/
(binaryfunc)ControlRead_sub, /*nb_subtract*/
(binaryfunc)ControlRead_multiply, /*nb_multiply*/
- (binaryfunc)ControlRead_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -835,16 +840,16 @@ static PyNumberMethods ControlRead_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)ControlRead_inplace_add, /*inplace_add*/
(binaryfunc)ControlRead_inplace_sub, /*inplace_subtract*/
(binaryfunc)ControlRead_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)ControlRead_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -853,15 +858,14 @@ static PyNumberMethods ControlRead_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)ControlRead_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)ControlRead_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ControlReadType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.ControlRead_base", /*tp_name*/
sizeof(ControlRead), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -869,7 +873,7 @@ PyTypeObject ControlReadType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&ControlRead_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -985,7 +989,7 @@ NoteinRec_dealloc(NoteinRec* self)
{
pyo_DEALLOC
NoteinRec_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1077,8 +1081,7 @@ static PyMethodDef NoteinRec_methods[] = {
};
PyTypeObject NoteinRecType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.NoteinRec_base", /*tp_name*/
sizeof(NoteinRec), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1086,7 +1089,7 @@ PyTypeObject NoteinRecType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1248,7 +1251,7 @@ NoteinRead_dealloc(NoteinRead* self)
free(self->timestamps);
free(self->trigsBuffer);
NoteinRead_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1410,7 +1413,7 @@ static PyNumberMethods NoteinRead_as_number = {
(binaryfunc)NoteinRead_add, /*nb_add*/
(binaryfunc)NoteinRead_sub, /*nb_subtract*/
(binaryfunc)NoteinRead_multiply, /*nb_multiply*/
- (binaryfunc)NoteinRead_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1424,16 +1427,16 @@ static PyNumberMethods NoteinRead_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)NoteinRead_inplace_add, /*inplace_add*/
(binaryfunc)NoteinRead_inplace_sub, /*inplace_subtract*/
(binaryfunc)NoteinRead_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)NoteinRead_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1442,15 +1445,14 @@ static PyNumberMethods NoteinRead_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)NoteinRead_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)NoteinRead_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject NoteinReadType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.NoteinRead_base", /*tp_name*/
sizeof(NoteinRead), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1458,7 +1460,7 @@ PyTypeObject NoteinReadType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&NoteinRead_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/selectmodule.c b/src/objects/selectmodule.c
index 3d084d4..98ffe3c 100644
--- a/src/objects/selectmodule.c
+++ b/src/objects/selectmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -134,7 +135,7 @@ Select_dealloc(Select* self)
{
pyo_DEALLOC
Select_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -233,7 +234,7 @@ static PyNumberMethods Select_as_number = {
(binaryfunc)Select_add, /*nb_add*/
(binaryfunc)Select_sub, /*nb_subtract*/
(binaryfunc)Select_multiply, /*nb_multiply*/
- (binaryfunc)Select_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -247,16 +248,16 @@ static PyNumberMethods Select_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Select_inplace_add, /*inplace_add*/
(binaryfunc)Select_inplace_sub, /*inplace_subtract*/
(binaryfunc)Select_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Select_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -265,15 +266,14 @@ static PyNumberMethods Select_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Select_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Select_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SelectType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Select_base", /*tp_name*/
sizeof(Select), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -281,7 +281,7 @@ sizeof(Select), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Select_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -420,7 +420,7 @@ Change_dealloc(Change* self)
{
pyo_DEALLOC
Change_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -504,7 +504,7 @@ static PyNumberMethods Change_as_number = {
(binaryfunc)Change_add, /*nb_add*/
(binaryfunc)Change_sub, /*nb_subtract*/
(binaryfunc)Change_multiply, /*nb_multiply*/
- (binaryfunc)Change_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -518,16 +518,16 @@ static PyNumberMethods Change_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Change_inplace_add, /*inplace_add*/
(binaryfunc)Change_inplace_sub, /*inplace_subtract*/
(binaryfunc)Change_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Change_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -536,15 +536,14 @@ static PyNumberMethods Change_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Change_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Change_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ChangeType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Change_base", /*tp_name*/
sizeof(Change), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -552,7 +551,7 @@ sizeof(Change), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Change_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/sfplayermodule.c b/src/objects/sfplayermodule.c
index 50b1e9e..0dee321 100644
--- a/src/objects/sfplayermodule.c
+++ b/src/objects/sfplayermodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -52,30 +53,6 @@ typedef struct {
MYFLT (*interp_func_ptr)(MYFLT *, int, MYFLT, int);
} SfPlayer;
-MYFLT max_arr(MYFLT *a,int n)
-{
- int i;
- MYFLT m;
- m=*a;
- for (i=1; i<n; i++) {
- if (m < *(a+i))
- m = *(a+i);
- }
- return m;
-}
-
-MYFLT min_arr(MYFLT *a,int n)
-{
- int i;
- MYFLT m;
- m=*a;
- for (i=1; i<n; i++) {
- if (m > *(a+i))
- m = *(a+i);
- }
- return m;
-}
-
static void
SfPlayer_readframes_i(SfPlayer *self) {
MYFLT sp, frac, bufpos, delta, startPos;
@@ -290,7 +267,7 @@ SfPlayer_dealloc(SfPlayer* self)
free(self->trigsBuffer);
free(self->samplesBuffer);
SfPlayer_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -332,7 +309,7 @@ SfPlayer_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sf = sf_open(self->path, SFM_READ, &self->info);
if (self->sf == NULL)
{
- printf("Failed to open the file.\n");
+ PySys_WriteStdout("SfPlayer: failed to open the file.\n");
}
self->sndSize = self->info.frames;
self->sndSr = self->info.samplerate;
@@ -405,8 +382,7 @@ SfPlayer_setSpeed(SfPlayer *self, PyObject *arg)
(*self->mode_func_ptr)(self);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -417,7 +393,7 @@ SfPlayer_setSound(SfPlayer *self, PyObject *arg)
ASSERT_ARG_NOT_NULL
- self->path = PyString_AsString(arg);
+ self->path = PY_STRING_AS_STRING(arg);
sf_close(self->sf);
@@ -426,7 +402,7 @@ SfPlayer_setSound(SfPlayer *self, PyObject *arg)
self->sf = sf_open(self->path, SFM_READ, &self->info);
if (self->sf == NULL)
{
- printf("Failed to open the file.\n");
+ PySys_WriteStdout("SfPlayer: failed to open the file.\n");
}
self->sndSize = self->info.frames;
self->sndSr = self->info.samplerate;
@@ -438,8 +414,7 @@ SfPlayer_setSound(SfPlayer *self, PyObject *arg)
self->startPos = 0.0;
self->pointerPos = self->startPos;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -449,8 +424,7 @@ SfPlayer_setLoop(SfPlayer *self, PyObject *arg)
self->loop = PyInt_AsLong(arg);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -466,8 +440,7 @@ SfPlayer_setOffset(SfPlayer *self, PyObject *arg)
self->startPos = 0.0;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -483,8 +456,7 @@ SfPlayer_setInterp(SfPlayer *self, PyObject *arg)
SET_INTERP_POINTER
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
MYFLT *
@@ -517,8 +489,7 @@ static PyMethodDef SfPlayer_methods[] = {
};
PyTypeObject SfPlayerType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SfPlayer_base", /*tp_name*/
sizeof(SfPlayer), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -526,7 +497,7 @@ sizeof(SfPlayer), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -649,7 +620,7 @@ SfPlay_dealloc(SfPlay* self)
{
pyo_DEALLOC
SfPlay_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -737,7 +708,7 @@ static PyNumberMethods SfPlay_as_number = {
(binaryfunc)SfPlay_add, /*nb_add*/
(binaryfunc)SfPlay_sub, /*nb_subtract*/
(binaryfunc)SfPlay_multiply, /*nb_multiply*/
-(binaryfunc)SfPlay_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -751,16 +722,16 @@ static PyNumberMethods SfPlay_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)SfPlay_inplace_add, /*inplace_add*/
(binaryfunc)SfPlay_inplace_sub, /*inplace_subtract*/
(binaryfunc)SfPlay_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)SfPlay_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -769,15 +740,14 @@ static PyNumberMethods SfPlay_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)SfPlay_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)SfPlay_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SfPlayType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SfPlay_base", /*tp_name*/
sizeof(SfPlay), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -785,7 +755,7 @@ sizeof(SfPlay), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&SfPlay_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1086,7 +1056,7 @@ SfMarkerShuffler_dealloc(SfMarkerShuffler* self)
free(self->samplesBuffer);
free(self->markers);
SfMarkerShuffler_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1136,7 +1106,7 @@ SfMarkerShuffler_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sf = sf_open(self->path, SFM_READ, &self->info);
if (self->sf == NULL)
{
- printf("Failed to open the file.\n");
+ PySys_WriteStdout("SfMarkerShuffler: failed to open the file.\n");
Py_RETURN_NONE;
}
self->sndSize = self->info.frames;
@@ -1214,8 +1184,7 @@ SfMarkerShuffler_setInterp(SfMarkerShuffler *self, PyObject *arg)
else if (self->interp == 4)
self->interp_func_ptr = cubic;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
MYFLT *
@@ -1243,8 +1212,7 @@ static PyMethodDef SfMarkerShuffler_methods[] = {
};
PyTypeObject SfMarkerShufflerType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SfMarkerShuffler_base", /*tp_name*/
sizeof(SfMarkerShuffler), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1252,7 +1220,7 @@ sizeof(SfMarkerShuffler), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1375,7 +1343,7 @@ SfMarkerShuffle_dealloc(SfMarkerShuffle* self)
{
pyo_DEALLOC
SfMarkerShuffle_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1463,7 +1431,7 @@ static PyNumberMethods SfMarkerShuffle_as_number = {
(binaryfunc)SfMarkerShuffle_add, /*nb_add*/
(binaryfunc)SfMarkerShuffle_sub, /*nb_subtract*/
(binaryfunc)SfMarkerShuffle_multiply, /*nb_multiply*/
-(binaryfunc)SfMarkerShuffle_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1477,16 +1445,16 @@ static PyNumberMethods SfMarkerShuffle_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)SfMarkerShuffle_inplace_add, /*inplace_add*/
(binaryfunc)SfMarkerShuffle_inplace_sub, /*inplace_subtract*/
(binaryfunc)SfMarkerShuffle_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)SfMarkerShuffle_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1495,15 +1463,14 @@ static PyNumberMethods SfMarkerShuffle_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)SfMarkerShuffle_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)SfMarkerShuffle_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SfMarkerShuffleType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SfMarkerShuffle_base", /*tp_name*/
sizeof(SfMarkerShuffle), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1511,7 +1478,7 @@ sizeof(SfMarkerShuffle), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&SfMarkerShuffle_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1826,7 +1793,7 @@ SfMarkerLooper_dealloc(SfMarkerLooper* self)
free(self->samplesBuffer);
free(self->markers);
SfMarkerLooper_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1884,7 +1851,7 @@ SfMarkerLooper_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->sf = sf_open(self->path, SFM_READ, &self->info);
if (self->sf == NULL)
{
- printf("Failed to open the file.\n");
+ PySys_WriteStdout("SfMarkerLooper: failed to open the file.\n");
Py_RETURN_NONE;
}
self->sndSize = self->info.frames;
@@ -1989,8 +1956,7 @@ SfMarkerLooper_setInterp(SfMarkerLooper *self, PyObject *arg)
else if (self->interp == 4)
self->interp_func_ptr = cubic;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
MYFLT *
@@ -2020,8 +1986,7 @@ static PyMethodDef SfMarkerLooper_methods[] = {
};
PyTypeObject SfMarkerLooperType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SfMarkerLooper_base", /*tp_name*/
sizeof(SfMarkerLooper), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2029,7 +1994,7 @@ PyTypeObject SfMarkerLooperType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2152,7 +2117,7 @@ SfMarkerLoop_dealloc(SfMarkerLoop* self)
{
pyo_DEALLOC
SfMarkerLoop_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2240,7 +2205,7 @@ static PyNumberMethods SfMarkerLoop_as_number = {
(binaryfunc)SfMarkerLoop_add, /*nb_add*/
(binaryfunc)SfMarkerLoop_sub, /*nb_subtract*/
(binaryfunc)SfMarkerLoop_multiply, /*nb_multiply*/
- (binaryfunc)SfMarkerLoop_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2254,16 +2219,16 @@ static PyNumberMethods SfMarkerLoop_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)SfMarkerLoop_inplace_add, /*inplace_add*/
(binaryfunc)SfMarkerLoop_inplace_sub, /*inplace_subtract*/
(binaryfunc)SfMarkerLoop_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)SfMarkerLoop_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2272,15 +2237,14 @@ static PyNumberMethods SfMarkerLoop_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)SfMarkerLoop_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)SfMarkerLoop_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SfMarkerLoopType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SfMarkerLoop_base", /*tp_name*/
sizeof(SfMarkerLoop), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2288,7 +2252,7 @@ PyTypeObject SfMarkerLoopType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&SfMarkerLoop_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/sigmodule.c b/src/objects/sigmodule.c
index 2b53071..5cf05ff 100644
--- a/src/objects/sigmodule.c
+++ b/src/objects/sigmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -121,7 +122,7 @@ Sig_dealloc(Sig* self)
{
pyo_DEALLOC
Sig_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -243,7 +244,7 @@ static PyNumberMethods Sig_as_number = {
(binaryfunc)Sig_add, /*nb_add*/
(binaryfunc)Sig_sub, /*nb_subtract*/
(binaryfunc)Sig_multiply, /*nb_multiply*/
-(binaryfunc)Sig_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -257,16 +258,16 @@ static PyNumberMethods Sig_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Sig_inplace_add, /*inplace_add*/
(binaryfunc)Sig_inplace_sub, /*inplace_subtract*/
(binaryfunc)Sig_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Sig_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -275,15 +276,14 @@ static PyNumberMethods Sig_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Sig_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Sig_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SigType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Sig_base", /*tp_name*/
sizeof(Sig), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -291,7 +291,7 @@ sizeof(Sig), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Sig_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -330,26 +330,33 @@ typedef struct {
pyo_audio_HEAD
PyObject *value;
Stream *value_stream;
+ PyObject *time;
+ Stream *time_stream;
MYFLT lastValue;
MYFLT currentValue;
- MYFLT time;
long timeStep;
MYFLT stepVal;
long timeCount;
- int modebuffer[3];
+ int modebuffer[4];
} SigTo;
static void
SigTo_generates_i(SigTo *self) {
int i;
- MYFLT value;
+ MYFLT value, time;
+
if (self->modebuffer[2] == 0) {
value = PyFloat_AS_DOUBLE(self->value);
if (value != self->lastValue) {
+ if (self->modebuffer[3] == 0)
+ time = PyFloat_AS_DOUBLE(self->time);
+ else
+ time = Stream_getData((Stream *)self->time_stream)[0];
self->timeCount = 0;
- self->timeStep = (long)(self->time * self->sr);
- self->stepVal = (value - self->currentValue) / self->timeStep;
self->lastValue = value;
+ self->timeStep = (long)(time * self->sr);
+ if (self->timeStep > 0)
+ self->stepVal = (value - self->currentValue) / self->timeStep;
}
if (self->timeStep <= 0) {
for (i=0; i<self->bufsize; i++)
@@ -369,24 +376,24 @@ SigTo_generates_i(SigTo *self) {
}
}
}
- else {
+ else {
MYFLT *vals = Stream_getData((Stream *)self->value_stream);
- if (self->timeStep <= 0) {
- for (i=0; i<self->bufsize; i++) {
- value = vals[i];
- self->data[i] = self->currentValue = self->lastValue = value;
- }
- }
- else {
- for (i=0; i<self->bufsize; i++) {
- value = vals[i];
- if (value != self->lastValue) {
- self->timeCount = 0;
- self->timeStep = (long)(self->time * self->sr);
+ for (i=0; i<self->bufsize; i++) {
+ value = vals[i];
+ if (value != self->lastValue) {
+ if (self->modebuffer[3] == 0)
+ time = PyFloat_AS_DOUBLE(self->time);
+ else
+ time = Stream_getData((Stream *)self->time_stream)[i];
+ self->timeCount = 0;
+ self->lastValue = value;
+ self->timeStep = (long)(time * self->sr);
+ if (self->timeStep > 0)
self->stepVal = (value - self->currentValue) / self->timeStep;
- self->lastValue = value;
- }
-
+ }
+ if (self->timeStep <= 0) {
+ self->data[i] = self->currentValue = self->lastValue = value;
+ } else {
if (self->timeCount == (self->timeStep - 1)) {
self->currentValue = value;
self->timeCount++;
@@ -463,6 +470,8 @@ SigTo_traverse(SigTo *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->value);
Py_VISIT(self->value_stream);
+ Py_VISIT(self->time);
+ Py_VISIT(self->time_stream);
return 0;
}
@@ -472,6 +481,8 @@ SigTo_clear(SigTo *self)
pyo_CLEAR
Py_CLEAR(self->value);
Py_CLEAR(self->value_stream);
+ Py_CLEAR(self->time);
+ Py_CLEAR(self->time_stream);
return 0;
}
@@ -480,7 +491,7 @@ SigTo_dealloc(SigTo* self)
{
pyo_DEALLOC
SigTo_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -493,12 +504,14 @@ SigTo_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self = (SigTo *)type->tp_alloc(type, 0);
self->value = PyFloat_FromDouble(0.0);
- self->time = 0.025;
+ self->time = PyFloat_FromDouble(0.025);
self->timeCount = 0;
self->stepVal = 0.0;
+ self->timeStep = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
self->modebuffer[2] = 0;
+ self->modebuffer[3] = 0;
INIT_OBJECT_COMMON
Stream_setFunctionPtr(self->stream, SigTo_compute_next_data_frame);
@@ -528,7 +541,6 @@ SigTo_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
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);
@@ -564,14 +576,13 @@ SigTo_setValue(SigTo *self, PyObject *arg)
self->modebuffer[2] = 1;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
SigTo_setTime(SigTo *self, PyObject *arg)
{
- PyObject *tmp;
+ PyObject *tmp, *streamtmp;
ASSERT_ARG_NOT_NULL
@@ -579,12 +590,21 @@ SigTo_setTime(SigTo *self, PyObject *arg)
tmp = arg;
Py_INCREF(tmp);
+ Py_DECREF(self->time);
if (isNumber == 1) {
- self->time = PyFloat_AsDouble(tmp);
- }
+ self->time = PyNumber_Float(tmp);
+ self->modebuffer[3] = 0;
+ }
+ else {
+ self->time = tmp;
+ streamtmp = PyObject_CallMethod((PyObject *)self->time, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->time_stream);
+ self->time_stream = (Stream *)streamtmp;
+ self->modebuffer[3] = 1;
+ }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject * SigTo_getServer(SigTo* self) { GET_SERVER };
@@ -610,6 +630,7 @@ static PyMemberDef SigTo_members[] = {
{"server", T_OBJECT_EX, offsetof(SigTo, server), 0, "Pyo server."},
{"stream", T_OBJECT_EX, offsetof(SigTo, stream), 0, "Stream object."},
{"value", T_OBJECT_EX, offsetof(SigTo, value), 0, "Target value."},
+{"time", T_OBJECT_EX, offsetof(SigTo, time), 0, "Ramp time."},
{"mul", T_OBJECT_EX, offsetof(SigTo, mul), 0, "Mul factor."},
{"add", T_OBJECT_EX, offsetof(SigTo, add), 0, "Add factor."},
{NULL} /* Sentinel */
@@ -633,7 +654,7 @@ static PyNumberMethods SigTo_as_number = {
(binaryfunc)SigTo_add, /*nb_add*/
(binaryfunc)SigTo_sub, /*nb_subtract*/
(binaryfunc)SigTo_multiply, /*nb_multiply*/
-(binaryfunc)SigTo_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -647,16 +668,16 @@ static PyNumberMethods SigTo_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)SigTo_inplace_add, /*inplace_add*/
(binaryfunc)SigTo_inplace_sub, /*inplace_subtract*/
(binaryfunc)SigTo_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)SigTo_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -665,15 +686,14 @@ static PyNumberMethods SigTo_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)SigTo_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)SigTo_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SigToType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SigTo_base", /*tp_name*/
sizeof(SigTo), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -681,7 +701,7 @@ sizeof(SigTo), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&SigTo_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -861,7 +881,7 @@ VarPort_dealloc(VarPort* self)
{
pyo_DEALLOC
VarPort_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1042,7 +1062,7 @@ static PyNumberMethods VarPort_as_number = {
(binaryfunc)VarPort_add, /*nb_add*/
(binaryfunc)VarPort_sub, /*nb_subtract*/
(binaryfunc)VarPort_multiply, /*nb_multiply*/
- (binaryfunc)VarPort_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1056,16 +1076,16 @@ static PyNumberMethods VarPort_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)VarPort_inplace_add, /*inplace_add*/
(binaryfunc)VarPort_inplace_sub, /*inplace_subtract*/
(binaryfunc)VarPort_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)VarPort_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1074,15 +1094,14 @@ static PyNumberMethods VarPort_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)VarPort_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)VarPort_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject VarPortType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.VarPort_base", /*tp_name*/
sizeof(VarPort), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1090,7 +1109,7 @@ PyTypeObject VarPortType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&VarPort_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/tablemodule.c b/src/objects/tablemodule.c
index 683f3f5..c8514df 100644
--- a/src/objects/tablemodule.c
+++ b/src/objects/tablemodule.c
@@ -19,6 +19,8 @@
*************************************************************************/
#include <Python.h>
+#include <object.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -27,6 +29,7 @@
#include "dummymodule.h"
#include "sndfile.h"
#include "wind.h"
+#include "fft.h"
#define __TABLE_MODULE
#include "tablemodule.h"
@@ -38,7 +41,7 @@
static void
TableStream_dealloc(TableStream* self)
{
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -85,9 +88,29 @@ TableStream_setSamplingRate(TableStream *self, double sr)
self->samplingRate = sr;
}
+#if PY_MAJOR_VERSION < 3
+static Py_ssize_t TableStream_getReadBuffer(TableStream *self, Py_ssize_t index, const void **ptr) { TABLESTREAM_READ_WRITE_BUFFER };
+static Py_ssize_t TableStream_getWriteBuffer(TableStream *self, Py_ssize_t index, const void **ptr) { TABLESTREAM_READ_WRITE_BUFFER };
+static Py_ssize_t TableStream_getSegCount(TableStream *self, Py_ssize_t *lenp) { TABLESTREAM_SEG_COUNT };
+#endif
+static int TableStream_getBuffer(PyObject *obj, Py_buffer *view, int flags) {
+ TableStream *self = (TableStream *)obj;
+ TABLESTREAM_GET_BUFFER
+};
+
+static PyBufferProcs TableStream_as_buffer = {
+#if PY_MAJOR_VERSION < 3
+ (readbufferproc)TableStream_getReadBuffer,
+ (writebufferproc)TableStream_getWriteBuffer,
+ (segcountproc)TableStream_getSegCount,
+ (charbufferproc)NULL,
+#endif
+ (getbufferproc)TableStream_getBuffer,
+ (releasebufferproc)NULL,
+};
+
PyTypeObject TableStreamType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TableStream", /*tp_name*/
sizeof(TableStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -95,7 +118,7 @@ sizeof(TableStream), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -105,8 +128,8 @@ sizeof(TableStream), /*tp_basicsize*/
0, /*tp_str*/
0, /*tp_getattro*/
0, /*tp_setattro*/
-0, /*tp_as_buffer*/
-Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
+&TableStream_as_buffer, /*tp_as_buffer*/
+Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
"TableStream objects. For internal use only. Must never be instantiated by the user.", /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
@@ -184,7 +207,7 @@ HarmTable_dealloc(HarmTable* self)
{
free(self->data);
HarmTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -239,6 +262,8 @@ static PyObject * HarmTable_fadein(HarmTable *self, PyObject *args, PyObject *kw
static PyObject * HarmTable_fadeout(HarmTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * HarmTable_pow(HarmTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * HarmTable_copy(HarmTable *self, PyObject *arg) { COPY };
+static PyObject * HarmTable_copyData(HarmTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * HarmTable_rotate(HarmTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * HarmTable_setTable(HarmTable *self, PyObject *arg) { SET_TABLE };
static PyObject * HarmTable_getTable(HarmTable *self) { GET_TABLE };
static PyObject * HarmTable_getViewTable(HarmTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -326,6 +351,8 @@ static PyMethodDef HarmTable_methods[] = {
{"fadeout", (PyCFunction)HarmTable_fadeout, METH_VARARGS|METH_KEYWORDS, "Apply a gradual decrease in the level of the table's samples."},
{"pow", (PyCFunction)HarmTable_pow, METH_VARARGS|METH_KEYWORDS, "Apply a power function on each sample in the table."},
{"copy", (PyCFunction)HarmTable_copy, METH_O, "Copy data from table given in argument."},
+{"copyData", (PyCFunction)HarmTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+{"rotate", (PyCFunction)HarmTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as argument."},
{"setData", (PyCFunction)HarmTable_setData, METH_O, "Sets the table from samples in a text file."},
{"setSize", (PyCFunction)HarmTable_setSize, METH_O, "Sets the size of the table in samples"},
{"getSize", (PyCFunction)HarmTable_getSize, METH_NOARGS, "Return the size of the table in samples"},
@@ -339,8 +366,7 @@ static PyMethodDef HarmTable_methods[] = {
};
PyTypeObject HarmTableType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.HarmTable_base", /*tp_name*/
sizeof(HarmTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -348,7 +374,7 @@ sizeof(HarmTable), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -478,7 +504,7 @@ ChebyTable_dealloc(ChebyTable* self)
{
free(self->data);
ChebyTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -533,6 +559,8 @@ static PyObject * ChebyTable_fadein(ChebyTable *self, PyObject *args, PyObject *
static PyObject * ChebyTable_fadeout(ChebyTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * ChebyTable_pow(ChebyTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * ChebyTable_copy(ChebyTable *self, PyObject *arg) { COPY };
+static PyObject * ChebyTable_copyData(ChebyTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * ChebyTable_rotate(ChebyTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * ChebyTable_setTable(ChebyTable *self, PyObject *arg) { SET_TABLE };
static PyObject * ChebyTable_getTable(ChebyTable *self) { GET_TABLE };
static PyObject * ChebyTable_getViewTable(ChebyTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -678,6 +706,8 @@ static PyMemberDef ChebyTable_members[] = {
static PyMethodDef ChebyTable_methods[] = {
{"getServer", (PyCFunction)ChebyTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)ChebyTable_copy, METH_O, "Copy data from table given in argument."},
+{"copyData", (PyCFunction)ChebyTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+{"rotate", (PyCFunction)ChebyTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -707,8 +737,7 @@ static PyMethodDef ChebyTable_methods[] = {
};
PyTypeObject ChebyTableType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.ChebyTable_base", /*tp_name*/
sizeof(ChebyTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -716,7 +745,7 @@ sizeof(ChebyTable), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -789,7 +818,7 @@ HannTable_dealloc(HannTable* self)
{
free(self->data);
HannTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -835,6 +864,8 @@ static PyObject * HannTable_fadein(HannTable *self, PyObject *args, PyObject *kw
static PyObject * HannTable_fadeout(HannTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * HannTable_pow(HannTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * HannTable_copy(HannTable *self, PyObject *arg) { COPY };
+static PyObject * HannTable_copyData(HannTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * HannTable_rotate(HannTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * HannTable_setTable(HannTable *self, PyObject *arg) { SET_TABLE };
static PyObject * HannTable_getTable(HannTable *self) { GET_TABLE };
static PyObject * HannTable_getViewTable(HannTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -883,6 +914,8 @@ static PyMemberDef HannTable_members[] = {
static PyMethodDef HannTable_methods[] = {
{"getServer", (PyCFunction)HannTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)HannTable_copy, METH_O, "Copy data from table given in argument."},
+{"copyData", (PyCFunction)HannTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+{"rotate", (PyCFunction)HannTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -910,8 +943,7 @@ static PyMethodDef HannTable_methods[] = {
};
PyTypeObject HannTableType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.HannTable_base", /*tp_name*/
sizeof(HannTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -919,7 +951,7 @@ sizeof(HannTable), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1011,7 +1043,7 @@ SincTable_dealloc(SincTable* self)
{
free(self->data);
SincTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1059,6 +1091,8 @@ static PyObject * SincTable_fadein(SincTable *self, PyObject *args, PyObject *kw
static PyObject * SincTable_fadeout(SincTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * SincTable_pow(SincTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * SincTable_copy(SincTable *self, PyObject *arg) { COPY };
+static PyObject * SincTable_copyData(SincTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * SincTable_rotate(SincTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * SincTable_setTable(SincTable *self, PyObject *arg) { SET_TABLE };
static PyObject * SincTable_getTable(SincTable *self) { GET_TABLE };
static PyObject * SincTable_getViewTable(SincTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -1141,6 +1175,8 @@ static PyMemberDef SincTable_members[] = {
static PyMethodDef SincTable_methods[] = {
{"getServer", (PyCFunction)SincTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)SincTable_copy, METH_O, "Copy data from table given in argument."},
+ {"copyData", (PyCFunction)SincTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+ {"rotate", (PyCFunction)SincTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -1170,8 +1206,7 @@ static PyMethodDef SincTable_methods[] = {
};
PyTypeObject SincTableType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SincTable_base", /*tp_name*/
sizeof(SincTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1179,7 +1214,7 @@ PyTypeObject SincTableType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1244,7 +1279,7 @@ WinTable_dealloc(WinTable* self)
{
free(self->data);
WinTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1291,6 +1326,8 @@ static PyObject * WinTable_fadein(WinTable *self, PyObject *args, PyObject *kwds
static PyObject * WinTable_fadeout(WinTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * WinTable_pow(WinTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * WinTable_copy(WinTable *self, PyObject *arg) { COPY };
+static PyObject * WinTable_copyData(WinTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * WinTable_rotate(WinTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * WinTable_setTable(WinTable *self, PyObject *arg) { SET_TABLE };
static PyObject * WinTable_getTable(WinTable *self) { GET_TABLE };
static PyObject * WinTable_getViewTable(WinTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -1360,6 +1397,8 @@ static PyMemberDef WinTable_members[] = {
static PyMethodDef WinTable_methods[] = {
{"getServer", (PyCFunction)WinTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)WinTable_copy, METH_O, "Copy data from table given in argument."},
+{"copyData", (PyCFunction)WinTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+{"rotate", (PyCFunction)WinTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -1388,8 +1427,7 @@ static PyMethodDef WinTable_methods[] = {
};
PyTypeObject WinTableType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.WinTable_base", /*tp_name*/
sizeof(WinTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1397,7 +1435,7 @@ sizeof(WinTable), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1477,7 +1515,7 @@ ParaTable_dealloc(ParaTable* self)
{
free(self->data);
ParaTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1523,6 +1561,8 @@ static PyObject * ParaTable_fadein(ParaTable *self, PyObject *args, PyObject *kw
static PyObject * ParaTable_fadeout(ParaTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * ParaTable_pow(ParaTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * ParaTable_copy(ParaTable *self, PyObject *arg) { COPY };
+static PyObject * ParaTable_copyData(ParaTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * ParaTable_rotate(ParaTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * ParaTable_setTable(ParaTable *self, PyObject *arg) { SET_TABLE };
static PyObject * ParaTable_getTable(ParaTable *self) { GET_TABLE };
static PyObject * ParaTable_getViewTable(ParaTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -1571,6 +1611,8 @@ static PyMemberDef ParaTable_members[] = {
static PyMethodDef ParaTable_methods[] = {
{"getServer", (PyCFunction)ParaTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)ParaTable_copy, METH_O, "Copy data from table given in argument."},
+ {"copyData", (PyCFunction)ParaTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+ {"rotate", (PyCFunction)ParaTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -1598,8 +1640,7 @@ static PyMethodDef ParaTable_methods[] = {
};
PyTypeObject ParaTableType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.ParaTable_base", /*tp_name*/
sizeof(ParaTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1607,7 +1648,7 @@ PyTypeObject ParaTableType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1709,7 +1750,7 @@ LinTable_dealloc(LinTable* self)
{
free(self->data);
LinTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1767,6 +1808,8 @@ static PyObject * LinTable_fadein(LinTable *self, PyObject *args, PyObject *kwds
static PyObject * LinTable_fadeout(LinTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * LinTable_pow(LinTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * LinTable_copy(LinTable *self, PyObject *arg) { COPY };
+static PyObject * LinTable_copyData(LinTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * LinTable_rotate(LinTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * LinTable_setTable(LinTable *self, PyObject *arg) { SET_TABLE };
static PyObject * LinTable_getTable(LinTable *self) { GET_TABLE };
static PyObject * LinTable_getViewTable(LinTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -1869,6 +1912,8 @@ static PyMemberDef LinTable_members[] = {
static PyMethodDef LinTable_methods[] = {
{"getServer", (PyCFunction)LinTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)LinTable_copy, METH_O, "Copy data from table given in argument."},
+{"copyData", (PyCFunction)LinTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+{"rotate", (PyCFunction)LinTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -1898,8 +1943,7 @@ static PyMethodDef LinTable_methods[] = {
};
PyTypeObject LinTableType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.LinTable_base", /*tp_name*/
sizeof(LinTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1907,7 +1951,7 @@ sizeof(LinTable), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2033,7 +2077,7 @@ LogTable_dealloc(LogTable* self)
{
free(self->data);
LogTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2091,6 +2135,8 @@ static PyObject * LogTable_fadein(LogTable *self, PyObject *args, PyObject *kwds
static PyObject * LogTable_fadeout(LogTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * LogTable_pow(LogTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * LogTable_copy(LogTable *self, PyObject *arg) { COPY };
+static PyObject * LogTable_copyData(LogTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * LogTable_rotate(LogTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * LogTable_setTable(LogTable *self, PyObject *arg) { SET_TABLE };
static PyObject * LogTable_getTable(LogTable *self) { GET_TABLE };
static PyObject * LogTable_getViewTable(LogTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -2193,6 +2239,8 @@ static PyMemberDef LogTable_members[] = {
static PyMethodDef LogTable_methods[] = {
{"getServer", (PyCFunction)LogTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)LogTable_copy, METH_O, "Copy data from table given in argument."},
+ {"copyData", (PyCFunction)LogTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+ {"rotate", (PyCFunction)LogTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -2222,8 +2270,7 @@ static PyMethodDef LogTable_methods[] = {
};
PyTypeObject LogTableType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.LogTable_base", /*tp_name*/
sizeof(LogTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2231,7 +2278,7 @@ PyTypeObject LogTableType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2335,7 +2382,7 @@ CosTable_dealloc(CosTable* self)
{
free(self->data);
CosTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2393,6 +2440,8 @@ static PyObject * CosTable_fadein(CosTable *self, PyObject *args, PyObject *kwds
static PyObject * CosTable_fadeout(CosTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * CosTable_pow(CosTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * CosTable_copy(CosTable *self, PyObject *arg) { COPY };
+static PyObject * CosTable_copyData(CosTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * CosTable_rotate(CosTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * CosTable_setTable(CosTable *self, PyObject *arg) { SET_TABLE };
static PyObject * CosTable_getTable(CosTable *self) { GET_TABLE };
static PyObject * CosTable_getViewTable(CosTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -2495,6 +2544,8 @@ static PyMemberDef CosTable_members[] = {
static PyMethodDef CosTable_methods[] = {
{"getServer", (PyCFunction)CosTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)CosTable_copy, METH_O, "Copy data from table given in argument."},
+{"copyData", (PyCFunction)CosTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+{"rotate", (PyCFunction)CosTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -2524,8 +2575,7 @@ static PyMethodDef CosTable_methods[] = {
};
PyTypeObject CosTableType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.CosTable_base", /*tp_name*/
sizeof(CosTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2533,7 +2583,7 @@ sizeof(CosTable), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2661,7 +2711,7 @@ CosLogTable_dealloc(CosLogTable* self)
{
free(self->data);
CosLogTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2719,6 +2769,8 @@ static PyObject * CosLogTable_fadein(CosLogTable *self, PyObject *args, PyObject
static PyObject * CosLogTable_fadeout(CosLogTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * CosLogTable_pow(CosLogTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * CosLogTable_copy(CosLogTable *self, PyObject *arg) { COPY };
+static PyObject * CosLogTable_copyData(CosLogTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * CosLogTable_rotate(CosLogTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * CosLogTable_setTable(CosLogTable *self, PyObject *arg) { SET_TABLE };
static PyObject * CosLogTable_getTable(CosLogTable *self) { GET_TABLE };
static PyObject * CosLogTable_getViewTable(CosLogTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -2821,6 +2873,8 @@ static PyMemberDef CosLogTable_members[] = {
static PyMethodDef CosLogTable_methods[] = {
{"getServer", (PyCFunction)CosLogTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)CosLogTable_copy, METH_O, "Copy data from table given in argument."},
+ {"copyData", (PyCFunction)CosLogTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+ {"rotate", (PyCFunction)CosLogTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -2850,8 +2904,7 @@ static PyMethodDef CosLogTable_methods[] = {
};
PyTypeObject CosLogTableType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.CosLogTable_base", /*tp_name*/
sizeof(CosLogTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2859,7 +2912,7 @@ PyTypeObject CosLogTableType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2988,7 +3041,7 @@ CurveTable_dealloc(CurveTable* self)
{
free(self->data);
CurveTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3048,6 +3101,8 @@ static PyObject * CurveTable_fadein(CurveTable *self, PyObject *args, PyObject *
static PyObject * CurveTable_fadeout(CurveTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * CurveTable_pow(CurveTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * CurveTable_copy(CurveTable *self, PyObject *arg) { COPY };
+static PyObject * CurveTable_copyData(CurveTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * CurveTable_rotate(CurveTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * CurveTable_setTable(CurveTable *self, PyObject *arg) { SET_TABLE };
static PyObject * CurveTable_getTable(CurveTable *self) { GET_TABLE };
static PyObject * CurveTable_getViewTable(CurveTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -3192,6 +3247,8 @@ static PyMemberDef CurveTable_members[] = {
static PyMethodDef CurveTable_methods[] = {
{"getServer", (PyCFunction)CurveTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)CurveTable_copy, METH_O, "Copy data from table given in argument."},
+{"copyData", (PyCFunction)CurveTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+{"rotate", (PyCFunction)CurveTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -3223,8 +3280,7 @@ static PyMethodDef CurveTable_methods[] = {
};
PyTypeObject CurveTableType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.CurveTable_base", /*tp_name*/
sizeof(CurveTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3232,7 +3288,7 @@ sizeof(CurveTable), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3358,7 +3414,7 @@ ExpTable_dealloc(ExpTable* self)
{
free(self->data);
ExpTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3418,6 +3474,8 @@ static PyObject * ExpTable_fadein(ExpTable *self, PyObject *args, PyObject *kwds
static PyObject * ExpTable_fadeout(ExpTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * ExpTable_pow(ExpTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * ExpTable_copy(ExpTable *self, PyObject *arg) { COPY };
+static PyObject * ExpTable_copyData(ExpTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * ExpTable_rotate(ExpTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * ExpTable_setTable(ExpTable *self, PyObject *arg) { SET_TABLE };
static PyObject * ExpTable_getTable(ExpTable *self) { GET_TABLE };
static PyObject * ExpTable_getViewTable(ExpTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -3561,6 +3619,8 @@ static PyMemberDef ExpTable_members[] = {
static PyMethodDef ExpTable_methods[] = {
{"getServer", (PyCFunction)ExpTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)ExpTable_copy, METH_O, "Copy data from table given in argument."},
+{"copyData", (PyCFunction)ExpTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+{"rotate", (PyCFunction)ExpTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -3592,8 +3652,7 @@ static PyMethodDef ExpTable_methods[] = {
};
PyTypeObject ExpTableType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.ExpTable_base", /*tp_name*/
sizeof(ExpTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3601,7 +3660,7 @@ sizeof(ExpTable), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3660,7 +3719,7 @@ SndTable_loadSound(SndTable *self) {
sf = sf_open(self->path, SFM_READ, &info);
if (sf == NULL)
{
- printf("SndTable failed to open the file.\n");
+ PySys_WriteStdout("SndTable failed to open the file.\n");
return;
}
snd_size = info.frames;
@@ -3684,14 +3743,14 @@ SndTable_loadSound(SndTable *self) {
self->data = (MYFLT *)realloc(self->data, (self->size + 1) * sizeof(MYFLT));
/* For sound longer than 1 minute, load 30 sec chunks. */
- if (self->size > (self->sndSr * 60 * num_chnls)) {
+ if (self->size > (int)(self->sndSr * 60 * num_chnls)) {
tmp = (MYFLT *)malloc(self->sndSr * 30 * num_chnls * sizeof(MYFLT));
sf_seek(sf, start, SEEK_SET);
num_items = self->sndSr * 30 * num_chnls;
do {
num = SF_READ(sf, tmp, num_items);
for (i=0; i<num; i++) {
- if ((i % num_chnls) == self->chnl) {
+ if ((int)(i % num_chnls) == self->chnl) {
self->data[(int)(num_count++)] = tmp[i];
}
}
@@ -3705,7 +3764,7 @@ SndTable_loadSound(SndTable *self) {
num = SF_READ(sf, tmp, num_items);
sf_close(sf);
for (i=0; i<num_items; i++) {
- if ((i % num_chnls) == self->chnl) {
+ if ((int)(i % num_chnls) == self->chnl) {
self->data[(int)(i/num_chnls)] = tmp[i];
}
}
@@ -3733,7 +3792,7 @@ SndTable_appendSound(SndTable *self) {
sf = sf_open(self->path, SFM_READ, &info);
if (sf == NULL)
{
- printf("SndTable failed to open the file.\n");
+ PySys_WriteStdout("SndTable failed to open the file.\n");
return;
}
snd_size = info.frames;
@@ -3755,7 +3814,7 @@ SndTable_appendSound(SndTable *self) {
cross_in_samps = (unsigned int)(self->crossfade * self->sr);
if (cross_in_samps >= to_load_size)
cross_in_samps = to_load_size - 1;
- if (cross_in_samps >= self->size)
+ if ((int)cross_in_samps >= self->size)
cross_in_samps = self->size - 1;
/* Allocate space for the data to be read, then read it. */
@@ -3767,7 +3826,7 @@ SndTable_appendSound(SndTable *self) {
sf_close(sf);
if (cross_in_samps != 0) {
- for (i=0; i<self->size; i++) {
+ for (i=0; i<(unsigned int)self->size; i++) {
tmp_data[i] = self->data[i];
}
}
@@ -3784,7 +3843,7 @@ SndTable_appendSound(SndTable *self) {
if (self->crossfade == 0.0) {
for (i=0; i<num_items; i++) {
- if ((i % num_chnls) == self->chnl) {
+ if ((int)(i % num_chnls) == self->chnl) {
index = (int)(i/num_chnls);
real_index = cross_point + index;
self->data[real_index] = tmp[i];
@@ -3793,7 +3852,7 @@ SndTable_appendSound(SndTable *self) {
}
else {
for (i=0; i<num_items; i++) {
- if ((i % num_chnls) == self->chnl) {
+ if ((int)(i % num_chnls) == self->chnl) {
index = (int)(i/num_chnls);
real_index = cross_point + index;
if (index < cross_in_samps) {
@@ -3830,7 +3889,7 @@ SndTable_prependSound(SndTable *self) {
sf = sf_open(self->path, SFM_READ, &info);
if (sf == NULL)
{
- printf("SndTable failed to open the file.\n");
+ PySys_WriteStdout("SndTable failed to open the file.\n");
return;
}
snd_size = info.frames;
@@ -3852,7 +3911,7 @@ SndTable_prependSound(SndTable *self) {
cross_in_samps = (unsigned int)(self->crossfade * self->sr);
if (cross_in_samps >= to_load_size)
cross_in_samps = to_load_size - 1;
- if (cross_in_samps >= self->size)
+ if ((int)cross_in_samps >= self->size)
cross_in_samps = self->size - 1;
/* Allocate space for the data to be read, then read it. */
@@ -3863,7 +3922,7 @@ SndTable_prependSound(SndTable *self) {
SF_READ(sf, tmp, num_items);
sf_close(sf);
- for (i=0; i<self->size; i++) {
+ for (i=0; i<(unsigned int)self->size; i++) {
tmp_data[i] = self->data[i];
}
@@ -3873,7 +3932,7 @@ SndTable_prependSound(SndTable *self) {
if (self->crossfade == 0.0) {
for (i=0; i<num_items; i++) {
- if ((i % num_chnls) == self->chnl) {
+ if ((int)(i % num_chnls) == self->chnl) {
index = (int)(i/num_chnls);
self->data[index] = tmp[i];
}
@@ -3882,7 +3941,7 @@ SndTable_prependSound(SndTable *self) {
}
else {
for (i=0; i<num_items; i++) {
- if ((i % num_chnls) == self->chnl) {
+ if ((int)(i % num_chnls) == self->chnl) {
index = (int)(i/num_chnls);
if (index >= cross_point) {
cross_amp = MYSQRT((index-cross_point) / (MYFLT)cross_in_samps);
@@ -3894,7 +3953,7 @@ SndTable_prependSound(SndTable *self) {
}
}
- for (i=(index+1); i<self->size; i++) {
+ for (i=(index+1); i<(unsigned int)self->size; i++) {
self->data[i] = tmp_data[i - cross_point];
}
@@ -3924,7 +3983,7 @@ SndTable_insertSound(SndTable *self) {
sf = sf_open(self->path, SFM_READ, &info);
if (sf == NULL)
{
- printf("SndTable failed to open the file.\n");
+ PySys_WriteStdout("SndTable failed to open the file.\n");
return;
}
snd_size = info.frames;
@@ -3945,7 +4004,7 @@ SndTable_insertSound(SndTable *self) {
num_items = to_load_size * num_chnls;
insert_point = (unsigned int)(self->insertPos * self->sr);
- if (insert_point >= self->size)
+ if ((int)insert_point >= self->size)
insert_point = self->size - 1;
cross_in_samps = (unsigned int)(self->crossfade * self->sr);
@@ -3964,7 +4023,7 @@ SndTable_insertSound(SndTable *self) {
SF_READ(sf, tmp, num_items);
sf_close(sf);
- for (i=0; i<self->size; i++) {
+ for (i=0; i<(unsigned int)self->size; i++) {
tmp_data[i] = self->data[i];
}
@@ -3979,7 +4038,7 @@ SndTable_insertSound(SndTable *self) {
if (self->crossfade == 0.0) {
for (i=0; i<num_items; i++) {
- if ((i % num_chnls) == self->chnl) {
+ if ((int)(i % num_chnls) == self->chnl) {
index = (int)(i/num_chnls);
self->data[index+cross_point] = tmp[i];
}
@@ -3988,7 +4047,7 @@ SndTable_insertSound(SndTable *self) {
}
else {
for (i=0; i<num_items; i++) {
- if ((i % num_chnls) == self->chnl) {
+ if ((int)(i % num_chnls) == self->chnl) {
index = (int)(i/num_chnls);
real_index = index + cross_point;
if (index <= cross_in_samps) {
@@ -4007,7 +4066,7 @@ SndTable_insertSound(SndTable *self) {
}
read_point++;
- for (i=(real_index+1); i<self->size; i++) {
+ for (i=(real_index+1); i<(unsigned int)self->size; i++) {
self->data[i] = tmp_data[read_point];
read_point++;
}
@@ -4042,7 +4101,7 @@ SndTable_dealloc(SndTable* self)
{
free(self->data);
SndTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4104,6 +4163,8 @@ static PyObject * SndTable_fadein(SndTable *self, PyObject *args, PyObject *kwds
static PyObject * SndTable_fadeout(SndTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * SndTable_pow(SndTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * SndTable_copy(SndTable *self, PyObject *arg) { COPY };
+static PyObject * SndTable_copyData(SndTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * SndTable_rotate(SndTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
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 };
@@ -4369,6 +4430,8 @@ static PyMemberDef SndTable_members[] = {
static PyMethodDef SndTable_methods[] = {
{"getServer", (PyCFunction)SndTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)SndTable_copy, METH_O, "Copy data from table given in argument."},
+{"copyData", (PyCFunction)SndTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+{"rotate", (PyCFunction)SndTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as argument."},
{"setTable", (PyCFunction)SndTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
{"getTable", (PyCFunction)SndTable_getTable, METH_NOARGS, "Returns a list of table samples."},
{"getViewTable", (PyCFunction)SndTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -4401,8 +4464,7 @@ static PyMethodDef SndTable_methods[] = {
};
PyTypeObject SndTableType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SndTable_base", /*tp_name*/
sizeof(SndTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4410,7 +4472,7 @@ sizeof(SndTable), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4461,6 +4523,10 @@ typedef struct {
int pointer;
} NewTable;
+void NewTable_resetRecordingPointer(NewTable *self) { self->pointer = 0; }
+
+MYFLT NewTable_getFeedback(NewTable *self) { return self->feedback; }
+
static PyObject *
NewTable_recordChunk(NewTable *self, MYFLT *data, int datasize)
{
@@ -4509,7 +4575,7 @@ NewTable_dealloc(NewTable* self)
{
free(self->data);
NewTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4567,6 +4633,8 @@ static PyObject * NewTable_fadein(NewTable *self, PyObject *args, PyObject *kwds
static PyObject * NewTable_fadeout(NewTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * NewTable_pow(NewTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * NewTable_copy(NewTable *self, PyObject *arg) { COPY };
+static PyObject * NewTable_copyData(NewTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * NewTable_rotate(NewTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
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 };
@@ -4728,6 +4796,8 @@ static PyMethodDef NewTable_methods[] = {
{"setFeedback", (PyCFunction)NewTable_setFeedback, METH_O, "Feedback sets the amount of old data to mix with a new recording."},
{"setData", (PyCFunction)NewTable_setData, METH_O, "Sets the table from samples in a text file."},
{"copy", (PyCFunction)NewTable_copy, METH_O, "Copy data from table given in argument."},
+{"copyData", (PyCFunction)NewTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+{"rotate", (PyCFunction)NewTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as argument."},
{"normalize", (PyCFunction)NewTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
{"reset", (PyCFunction)NewTable_reset, METH_NOARGS, "Resets table samples to 0.0"},
{"removeDC", (PyCFunction)NewTable_removeDC, METH_NOARGS, "Filter out DC offset from the table's data."},
@@ -4751,8 +4821,7 @@ static PyMethodDef NewTable_methods[] = {
};
PyTypeObject NewTableType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.NewTable_base", /*tp_name*/
sizeof(NewTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4760,7 +4829,7 @@ sizeof(NewTable), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4825,7 +4894,7 @@ DataTable_dealloc(DataTable* self)
{
free(self->data);
DataTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4882,6 +4951,8 @@ static PyObject * DataTable_fadein(DataTable *self, PyObject *args, PyObject *kw
static PyObject * DataTable_fadeout(DataTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
static PyObject * DataTable_pow(DataTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
static PyObject * DataTable_copy(DataTable *self, PyObject *arg) { COPY };
+static PyObject * DataTable_copyData(DataTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * DataTable_rotate(DataTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
static PyObject * DataTable_setTable(DataTable *self, PyObject *arg) { SET_TABLE };
static PyObject * DataTable_getTable(DataTable *self) { GET_TABLE };
static PyObject * DataTable_getViewTable(DataTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
@@ -4913,6 +4984,8 @@ static PyMemberDef DataTable_members[] = {
static PyMethodDef DataTable_methods[] = {
{"getServer", (PyCFunction)DataTable_getServer, METH_NOARGS, "Returns server object."},
{"copy", (PyCFunction)DataTable_copy, METH_O, "Copy data from table given in argument."},
+ {"copyData", (PyCFunction)DataTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+ {"rotate", (PyCFunction)DataTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
@@ -4940,8 +5013,7 @@ static PyMethodDef DataTable_methods[] = {
};
PyTypeObject DataTableType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.DataTable_base", /*tp_name*/
sizeof(DataTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4949,7 +5021,7 @@ PyTypeObject DataTableType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5029,7 +5101,7 @@ AtanTable_dealloc(AtanTable* self)
{
free(self->data);
AtanTable_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5076,6 +5148,8 @@ static PyObject * AtanTable_fadein(AtanTable *self, PyObject *args, PyObject *kw
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_copyData(AtanTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * AtanTable_rotate(AtanTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
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 };
@@ -5145,6 +5219,8 @@ static PyMemberDef AtanTable_members[] = {
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."},
+ {"copyData", (PyCFunction)AtanTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+ {"rotate", (PyCFunction)AtanTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as 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."},
@@ -5173,8 +5249,7 @@ static PyMethodDef AtanTable_methods[] = {
};
PyTypeObject AtanTableType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.AtanTable_base", /*tp_name*/
sizeof(AtanTable), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5182,7 +5257,7 @@ PyTypeObject AtanTableType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5214,6 +5289,413 @@ PyTypeObject AtanTableType = {
AtanTable_new, /* tp_new */
};
+static int
+isPowerOfTwo(int x) {
+ return (x != 0) && ((x & (x - 1)) == 0);
+}
+
+/***********************/
+/* PadSynthTable structure */
+/***********************/
+typedef struct {
+ pyo_table_HEAD
+ MYFLT **twiddle;
+ MYFLT basefreq;
+ MYFLT spread;
+ MYFLT bw;
+ MYFLT bwscl;
+ int nharms;
+ MYFLT damp;
+ double sr;
+} PadSynthTable;
+
+static void
+PadSynthTable_gen_twiddle(PadSynthTable *self) {
+ int i, n8;
+ n8 = self->size >> 3;
+ 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);
+}
+
+static void
+PadSynthTable_generate(PadSynthTable *self) {
+ int i, nh;
+ int hsize = self->size / 2;
+ MYFLT bfac, i2sr, bfonsr, nhspd, bwhz, bwi, fi, gain, absv, max, x;
+ MYFLT ifsize = 1.0 / (MYFLT)self->size;
+ MYFLT twopirndmax = TWOPI / (MYFLT)RAND_MAX;
+ MYFLT amp[hsize];
+ MYFLT phase[hsize];
+ MYFLT real[hsize];
+ MYFLT imag[hsize];
+ MYFLT inframe[self->size];
+
+ for (i=0; i<hsize; i++) {
+ amp[i] = 0.0;
+ }
+
+ bfac = (MYPOW(2.0, self->bw / 1200.0) - 1.0) * self->basefreq;
+ i2sr = 1.0 / (2.0 * self->sr);
+ bfonsr = self->basefreq / self->sr;
+ gain = self->damp;
+ for (nh=1; nh<self->nharms; nh++) {
+ nhspd = MYPOW(nh, self->spread);
+ bwhz = bfac * MYPOW(nhspd, self->bwscl);
+ bwi = 1.0 / (bwhz * i2sr);
+ fi = bfonsr * nhspd;
+ for (i=0; i<hsize; i++) {
+ // harmonic profile.
+ x = (i * ifsize - fi) * bwi;
+ x *= x;
+ if (x < 14.71280603)
+ amp[i] += MYEXP(-x) * bwi * gain;
+ }
+ gain *= self->damp;
+ }
+
+ for (i=0; i<hsize; i++) {
+ phase[i] = rand() * twopirndmax;
+ }
+
+ for (i=0; i<hsize; i++) {
+ real[i] = amp[i] * MYCOS(phase[i]);
+ imag[i] = amp[i] * MYSIN(phase[i]);
+ }
+
+ inframe[0] = real[0];
+ inframe[hsize] = 0.0;
+ for (i=1; i<hsize; i++) {
+ inframe[i] = real[i];
+ inframe[self->size - i] = imag[i];
+ }
+
+ irealfft_split(inframe, self->data, self->size, self->twiddle);
+
+ max = 0.0;
+ for (i=0; i<self->size; i++) {
+ absv = MYFABS(self->data[i]);
+ if (absv > max)
+ max = absv;
+ }
+ if (max < 1e-5)
+ max = 1e-5;
+ max = 1.0 / (max * 1.4142);
+ for (i=0; i<self->size; i++) {
+ self->data[i] *= max;
+ }
+
+ self->data[self->size] = self->data[0];
+}
+
+static int
+PadSynthTable_traverse(PadSynthTable *self, visitproc visit, void *arg)
+{
+ pyo_table_VISIT
+ return 0;
+}
+
+static int
+PadSynthTable_clear(PadSynthTable *self)
+{
+ pyo_table_CLEAR
+ return 0;
+}
+
+static void
+PadSynthTable_dealloc(PadSynthTable* self)
+{
+ int i;
+ for(i=0; i<4; i++) {
+ free(self->twiddle[i]);
+ }
+ free(self->twiddle);
+ free(self->data);
+ PadSynthTable_clear(self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
+}
+
+static PyObject *
+PadSynthTable_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ PadSynthTable *self;
+ self = (PadSynthTable *)type->tp_alloc(type, 0);
+
+ self->server = PyServer_get_server();
+
+ self->size = 262144;
+ self->basefreq = 440;
+ self->spread = 1.0;
+ self->bw = 50.0;
+ self->bwscl = 1.0;
+ self->nharms = 64;
+ self->damp = 0.7;
+
+ MAKE_NEW_TABLESTREAM(self->tablestream, &TableStreamType, NULL);
+
+ static char *kwlist[] = {"basefreq", "spread", "bw", "bwscl", "nharms", "damp", "size", NULL};
+
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE__FFFFIFI, kwlist, &self->basefreq, &self->spread, &self->bw,
+ &self->bwscl, &self->nharms, &self->damp, &self->size))
+ Py_RETURN_NONE;
+
+ if (!isPowerOfTwo(self->size)) {
+ int k = 1;
+ while (k < self->size)
+ k *= 2;
+ self->size = k;
+ PySys_WriteStdout("PadSynthTable size must be a power-of-2, using the next power-of-2 greater than size : %d\n", self->size);
+ }
+
+ self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
+ TableStream_setSize(self->tablestream, self->size);
+ TableStream_setData(self->tablestream, self->data);
+
+ self->sr = PyFloat_AsDouble(PyObject_CallMethod(self->server, "getSamplingRate", NULL));
+ TableStream_setSamplingRate(self->tablestream, self->sr);
+
+ PadSynthTable_gen_twiddle(self);
+
+ srand(time(NULL));
+ PadSynthTable_generate(self);
+
+ return (PyObject *)self;
+}
+
+static PyObject * PadSynthTable_getServer(PadSynthTable* self) { GET_SERVER };
+static PyObject * PadSynthTable_getTableStream(PadSynthTable* self) { GET_TABLE_STREAM };
+static PyObject * PadSynthTable_setData(PadSynthTable *self, PyObject *arg) { SET_TABLE_DATA };
+static PyObject * PadSynthTable_normalize(PadSynthTable *self) { NORMALIZE };
+static PyObject * PadSynthTable_reset(PadSynthTable *self) { TABLE_RESET };
+static PyObject * PadSynthTable_removeDC(PadSynthTable *self) { REMOVE_DC };
+static PyObject * PadSynthTable_reverse(PadSynthTable *self) { REVERSE };
+static PyObject * PadSynthTable_invert(PadSynthTable *self) { INVERT };
+static PyObject * PadSynthTable_rectify(PadSynthTable *self) { RECTIFY };
+static PyObject * PadSynthTable_bipolarGain(PadSynthTable *self, PyObject *args, PyObject *kwds) { TABLE_BIPOLAR_GAIN };
+static PyObject * PadSynthTable_lowpass(PadSynthTable *self, PyObject *args, PyObject *kwds) { TABLE_LOWPASS };
+static PyObject * PadSynthTable_fadein(PadSynthTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEIN };
+static PyObject * PadSynthTable_fadeout(PadSynthTable *self, PyObject *args, PyObject *kwds) { TABLE_FADEOUT };
+static PyObject * PadSynthTable_pow(PadSynthTable *self, PyObject *args, PyObject *kwds) { TABLE_POWER };
+static PyObject * PadSynthTable_copy(PadSynthTable *self, PyObject *arg) { COPY };
+static PyObject * PadSynthTable_copyData(PadSynthTable *self, PyObject *args, PyObject *kwds) { TABLE_COPYDATA };
+static PyObject * PadSynthTable_rotate(PadSynthTable *self, PyObject *args, PyObject *kwds) { TABLE_ROTATE };
+static PyObject * PadSynthTable_setTable(PadSynthTable *self, PyObject *arg) { SET_TABLE };
+static PyObject * PadSynthTable_getTable(PadSynthTable *self) { GET_TABLE };
+static PyObject * PadSynthTable_getViewTable(PadSynthTable *self, PyObject *args, PyObject *kwds) { GET_VIEW_TABLE };
+static PyObject * PadSynthTable_put(PadSynthTable *self, PyObject *args, PyObject *kwds) { TABLE_PUT };
+static PyObject * PadSynthTable_get(PadSynthTable *self, PyObject *args, PyObject *kwds) { TABLE_GET };
+static PyObject * PadSynthTable_add(PadSynthTable *self, PyObject *arg) { TABLE_ADD };
+static PyObject * PadSynthTable_sub(PadSynthTable *self, PyObject *arg) { TABLE_SUB };
+static PyObject * PadSynthTable_mul(PadSynthTable *self, PyObject *arg) { TABLE_MUL };
+
+static PyObject *
+PadSynthTable_setBaseFreq(PadSynthTable *self, PyObject *args, PyObject *kwds)
+{
+ int generate = 1;
+
+ static char *kwlist[] = {"basefreq", "generate", NULL};
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_F_I, kwlist, &self->basefreq, &generate))
+ Py_RETURN_NONE;
+
+ if (generate)
+ PadSynthTable_generate(self);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+PadSynthTable_setSpread(PadSynthTable *self, PyObject *args, PyObject *kwds)
+{
+ int generate = 1;
+
+ static char *kwlist[] = {"spread", "generate", NULL};
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_F_I, kwlist, &self->spread, &generate))
+ Py_RETURN_NONE;
+
+ if (generate)
+ PadSynthTable_generate(self);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+PadSynthTable_setBw(PadSynthTable *self, PyObject *args, PyObject *kwds)
+{
+ int generate = 1;
+
+ static char *kwlist[] = {"bw", "generate", NULL};
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_F_I, kwlist, &self->bw, &generate))
+ Py_RETURN_NONE;
+
+ if (generate)
+ PadSynthTable_generate(self);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+PadSynthTable_setBwScl(PadSynthTable *self, PyObject *args, PyObject *kwds)
+{
+ int generate = 1;
+
+ static char *kwlist[] = {"bwscl", "generate", NULL};
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_F_I, kwlist, &self->bwscl, &generate))
+ Py_RETURN_NONE;
+
+ if (generate)
+ PadSynthTable_generate(self);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+PadSynthTable_setNharms(PadSynthTable *self, PyObject *args, PyObject *kwds)
+{
+ int generate = 1;
+
+ static char *kwlist[] = {"nharms", "generate", NULL};
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwlist, &self->nharms, &generate))
+ Py_RETURN_NONE;
+
+ if (generate)
+ PadSynthTable_generate(self);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+PadSynthTable_setDamp(PadSynthTable *self, PyObject *args, PyObject *kwds)
+{
+ int generate = 1;
+
+ static char *kwlist[] = {"damp", "generate", NULL};
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, TYPE_F_I, kwlist, &self->damp, &generate))
+ Py_RETURN_NONE;
+
+ if (generate)
+ PadSynthTable_generate(self);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+PadSynthTable_setSize(PadSynthTable *self, PyObject *args, PyObject *kwds)
+{
+ int generate = 1;
+
+ static char *kwlist[] = {"size", "generate", NULL};
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwlist, &self->size, &generate))
+ Py_RETURN_NONE;
+
+ if (!isPowerOfTwo(self->size)) {
+ int k = 1;
+ while (k < self->size)
+ k *= 2;
+ self->size = k;
+ PySys_WriteStdout("PadSynthTable size must be a power-of-2, using the next power-of-2 greater than size : %d\n", self->size);
+ }
+
+ self->data = (MYFLT *)realloc(self->data, (self->size+1) * sizeof(MYFLT));
+ TableStream_setSize(self->tablestream, self->size);
+
+ if (generate)
+ PadSynthTable_generate(self);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+PadSynthTable_getSize(PadSynthTable *self)
+{
+ return PyInt_FromLong(self->size);
+};
+
+static PyMemberDef PadSynthTable_members[] = {
+ {"server", T_OBJECT_EX, offsetof(PadSynthTable, server), 0, "Pyo server."},
+ {"tablestream", T_OBJECT_EX, offsetof(PadSynthTable, tablestream), 0, "Table stream object."},
+ {NULL} /* Sentinel */
+};
+
+static PyMethodDef PadSynthTable_methods[] = {
+ {"getServer", (PyCFunction)PadSynthTable_getServer, METH_NOARGS, "Returns server object."},
+ {"copy", (PyCFunction)PadSynthTable_copy, METH_O, "Copy data from table given in argument."},
+ {"copyData", (PyCFunction)PadSynthTable_copyData, METH_VARARGS|METH_KEYWORDS, "Copy data from table given in argument."},
+ {"rotate", (PyCFunction)PadSynthTable_rotate, METH_VARARGS|METH_KEYWORDS, "Rotate table around position as argument."},
+ {"setTable", (PyCFunction)PadSynthTable_setTable, METH_O, "Sets the table content from a list of floats (must be the same size as the object size)."},
+ {"getTable", (PyCFunction)PadSynthTable_getTable, METH_NOARGS, "Returns a list of table samples."},
+ {"getViewTable", (PyCFunction)PadSynthTable_getViewTable, METH_VARARGS|METH_KEYWORDS, "Returns a list of pixel coordinates for drawing the table."},
+ {"getTableStream", (PyCFunction)PadSynthTable_getTableStream, METH_NOARGS, "Returns table stream object created by this table."},
+ {"setData", (PyCFunction)PadSynthTable_setData, METH_O, "Sets the table from samples in a text file."},
+ {"normalize", (PyCFunction)PadSynthTable_normalize, METH_NOARGS, "Normalize table samples between -1 and 1"},
+ {"reset", (PyCFunction)PadSynthTable_reset, METH_NOARGS, "Resets table samples to 0.0"},
+ {"removeDC", (PyCFunction)PadSynthTable_removeDC, METH_NOARGS, "Filter out DC offset from the table's data."},
+ {"reverse", (PyCFunction)PadSynthTable_reverse, METH_NOARGS, "Reverse the table's data."},
+ {"invert", (PyCFunction)PadSynthTable_invert, METH_NOARGS, "Reverse the table's data in amplitude."},
+ {"rectify", (PyCFunction)PadSynthTable_rectify, METH_NOARGS, "Positive rectification of the table's data."},
+ {"bipolarGain", (PyCFunction)PadSynthTable_bipolarGain, METH_VARARGS|METH_KEYWORDS, "Apply different amp values to positive and negative samples."},
+ {"lowpass", (PyCFunction)PadSynthTable_lowpass, METH_VARARGS|METH_KEYWORDS, "Apply a one-pole lowpass filter on table's samples."},
+ {"fadein", (PyCFunction)PadSynthTable_fadein, METH_VARARGS|METH_KEYWORDS, "Apply a gradual increase in the level of the table's samples."},
+ {"fadeout", (PyCFunction)PadSynthTable_fadeout, METH_VARARGS|METH_KEYWORDS, "Apply a gradual decrease in the level of the table's samples."},
+ {"pow", (PyCFunction)PadSynthTable_pow, METH_VARARGS|METH_KEYWORDS, "Apply a power function on each sample in the table."},
+ //{"setSize", (PyCFunction)PadSynthTable_setSize, METH_O, "Sets the size of the table in samples"},
+ {"getSize", (PyCFunction)PadSynthTable_getSize, METH_NOARGS, "Return the size of the table in samples"},
+ {"setBaseFreq", (PyCFunction)PadSynthTable_setBaseFreq, METH_VARARGS|METH_KEYWORDS, "Sets the base frequency in hertz."},
+ {"setSpread", (PyCFunction)PadSynthTable_setSpread, METH_VARARGS|METH_KEYWORDS, "Sets the frequency spreading factor."},
+ {"setBw", (PyCFunction)PadSynthTable_setBw, METH_VARARGS|METH_KEYWORDS, "Sets the bandwitdh of the first harmonic in cents."},
+ {"setBwScl", (PyCFunction)PadSynthTable_setBwScl, METH_VARARGS|METH_KEYWORDS, "Sets the bandwitdh scaling factor."},
+ {"setNharms", (PyCFunction)PadSynthTable_setNharms, METH_VARARGS|METH_KEYWORDS, "Sets the number of harmonics."},
+ {"setDamp", (PyCFunction)PadSynthTable_setDamp, METH_VARARGS|METH_KEYWORDS, "Sets the damping factor."},
+ {"setSize", (PyCFunction)PadSynthTable_setSize, METH_VARARGS|METH_KEYWORDS, "Sets the size of the table in samples"},
+ {"put", (PyCFunction)PadSynthTable_put, METH_VARARGS|METH_KEYWORDS, "Puts a value at specified position in the table."},
+ {"get", (PyCFunction)PadSynthTable_get, METH_VARARGS|METH_KEYWORDS, "Gets the value at specified position in the table."},
+ {"add", (PyCFunction)PadSynthTable_add, METH_O, "Performs table addition."},
+ {"sub", (PyCFunction)PadSynthTable_sub, METH_O, "Performs table substraction."},
+ {"mul", (PyCFunction)PadSynthTable_mul, METH_O, "Performs table multiplication."},
+ {NULL} /* Sentinel */
+};
+
+PyTypeObject PadSynthTableType = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "_pyo.PadSynthTable_base", /*tp_name*/
+ sizeof(PadSynthTable), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)PadSynthTable_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
+ 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*/
+ "PadSynthTable objects. Generates a table filled with a sinc function.", /* tp_doc */
+ (traverseproc)PadSynthTable_traverse, /* tp_traverse */
+ (inquiry)PadSynthTable_clear, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ PadSynthTable_methods, /* tp_methods */
+ PadSynthTable_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 */
+ PadSynthTable_new, /* tp_new */
+};
+
/******************************/
/* TableRec object definition */
/******************************/
@@ -5327,7 +5809,7 @@ TableRec_dealloc(TableRec* self)
free(self->trigsBuffer);
free(self->time_buffer_streams);
TableRec_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5392,12 +5874,23 @@ static PyObject * TableRec_getTriggerStream(TableRec* self) { GET_TRIGGER_STREAM
static PyObject * TableRec_play(TableRec *self, PyObject *args, PyObject *kwds)
{
+ int j;
+ for (j=0; j<self->bufsize; j++) {
+ self->time_buffer_streams[j] = 0;
+ }
self->pointer = 0;
self->active = 1;
+ NewTable_resetRecordingPointer((NewTable *)self->table);
PLAY
};
-static PyObject * TableRec_stop(TableRec *self) { STOP };
+static PyObject * TableRec_stop(TableRec *self) {
+ int j;
+ for (j=0; j<self->bufsize; j++) {
+ self->time_buffer_streams[j] = self->pointer;
+ }
+ STOP
+};
static PyObject *
TableRec_setTable(TableRec *self, PyObject *arg)
@@ -5435,8 +5928,7 @@ static PyMethodDef TableRec_methods[] = {
};
PyTypeObject TableRecType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TableRec_base", /*tp_name*/
sizeof(TableRec), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5444,7 +5936,7 @@ sizeof(TableRec), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5561,7 +6053,7 @@ TableRecTimeStream_dealloc(TableRecTimeStream* self)
{
pyo_DEALLOC
TableRecTimeStream_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5640,7 +6132,7 @@ static PyNumberMethods TableRecTimeStream_as_number = {
(binaryfunc)TableRecTimeStream_add, /*nb_add*/
(binaryfunc)TableRecTimeStream_sub, /*nb_subtract*/
(binaryfunc)TableRecTimeStream_multiply, /*nb_multiply*/
- (binaryfunc)TableRecTimeStream_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5654,16 +6146,16 @@ static PyNumberMethods TableRecTimeStream_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TableRecTimeStream_inplace_add, /*inplace_add*/
(binaryfunc)TableRecTimeStream_inplace_sub, /*inplace_subtract*/
(binaryfunc)TableRecTimeStream_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)TableRecTimeStream_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5672,15 +6164,14 @@ static PyNumberMethods TableRecTimeStream_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TableRecTimeStream_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TableRecTimeStream_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TableRecTimeStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TableRecTimeStream_base", /*tp_name*/
sizeof(TableRecTimeStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5688,7 +6179,7 @@ PyTypeObject TableRecTimeStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TableRecTimeStream_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5817,7 +6308,7 @@ TableMorph_dealloc(TableMorph* self)
pyo_DEALLOC
free(self->buffer);
TableMorph_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5918,8 +6409,7 @@ static PyMethodDef TableMorph_methods[] = {
};
PyTypeObject TableMorphType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TableMorph_base", /*tp_name*/
sizeof(TableMorph), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5927,7 +6417,7 @@ sizeof(TableMorph), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -6037,6 +6527,7 @@ TrigTableRec_compute_next_data_frame(TrigTableRec *self)
if (trig[j] == 1.0) {
self->active = 1;
self->pointer = 0;
+ NewTable_resetRecordingPointer((NewTable *)self->table);
if (size >= self->bufsize)
num = self->bufsize - j;
else {
@@ -6117,7 +6608,7 @@ TrigTableRec_dealloc(TrigTableRec* self)
free(self->trigsBuffer);
TrigTableRec_clear(self);
free(self->time_buffer_streams);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -6226,8 +6717,7 @@ static PyMethodDef TrigTableRec_methods[] = {
};
PyTypeObject TrigTableRecType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigTableRec_base", /*tp_name*/
sizeof(TrigTableRec), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -6235,7 +6725,7 @@ PyTypeObject TrigTableRecType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -6352,7 +6842,7 @@ TrigTableRecTimeStream_dealloc(TrigTableRecTimeStream* self)
{
pyo_DEALLOC
TrigTableRecTimeStream_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -6431,7 +6921,7 @@ static PyNumberMethods TrigTableRecTimeStream_as_number = {
(binaryfunc)TrigTableRecTimeStream_add, /*nb_add*/
(binaryfunc)TrigTableRecTimeStream_sub, /*nb_subtract*/
(binaryfunc)TrigTableRecTimeStream_multiply, /*nb_multiply*/
- (binaryfunc)TrigTableRecTimeStream_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -6445,16 +6935,16 @@ static PyNumberMethods TrigTableRecTimeStream_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TrigTableRecTimeStream_inplace_add, /*inplace_add*/
(binaryfunc)TrigTableRecTimeStream_inplace_sub, /*inplace_subtract*/
(binaryfunc)TrigTableRecTimeStream_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)TrigTableRecTimeStream_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -6463,15 +6953,14 @@ static PyNumberMethods TrigTableRecTimeStream_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TrigTableRecTimeStream_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TrigTableRecTimeStream_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigTableRecTimeStreamType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigTableRecTimeStream_base", /*tp_name*/
sizeof(TrigTableRecTimeStream), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -6479,7 +6968,7 @@ PyTypeObject TrigTableRecTimeStreamType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigTableRecTimeStream_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -6580,7 +7069,7 @@ TablePut_dealloc(TablePut* self)
pyo_DEALLOC
free(self->trigsBuffer);
TablePut_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -6678,8 +7167,7 @@ static PyMethodDef TablePut_methods[] = {
};
PyTypeObject TablePutType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TablePut_base", /*tp_name*/
sizeof(TablePut), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -6687,7 +7175,7 @@ sizeof(TablePut), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -6729,15 +7217,22 @@ typedef struct {
PyObject *pos;
Stream *pos_stream;
NewTable *table;
+ int mode;
+ int lastPos;
+ MYFLT lastValue;
+ int count;
+ MYFLT accum;
+ MYFLT valInTable;
} TableWrite;
static void
TableWrite_compute_next_data_frame(TableWrite *self)
{
- int i, ipos;
+ int i, j, ipos;
PyObject *table;
table = PyObject_CallMethod((PyObject *)self->table, "getTableStream", "");
+ MYFLT feed = NewTable_getFeedback((NewTable *)self->table);
MYFLT *tablelist = TableStream_getData((TableStream *)table);
int size = TableStream_getSize((TableStream *)table);
@@ -6745,12 +7240,49 @@ TableWrite_compute_next_data_frame(TableWrite *self)
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];
+ if (self->mode == 0)
+ ipos = (int)(pos[i] * size + 0.5);
+ else
+ ipos = (int)(pos[i] + 0.5);
+ if (ipos >= 0 && ipos < size) {
+ if (self->lastPos < 0) { /* Init case. */
+ self->valInTable = tablelist[ipos];
+ self->count = 1;
+ self->accum = in[i];
+ tablelist[ipos] = in[i] + tablelist[ipos] * feed;
+ }
+ else if (ipos == self->lastPos) { /* Same position, average inputs. */
+ self->count += 1;
+ self->accum += in[i];
+ tablelist[ipos] = self->accum / self->count + self->valInTable * feed;
+ }
+ else { /* Position changed. */
+ int steps, dir;
+ if (ipos > self->lastPos) { /* Move forward. */
+ steps = ipos - self->lastPos;
+ dir = 1;
+ }
+ else { /* Move backward. */
+ steps = self->lastPos - ipos;
+ dir = -1;
+ }
+ self->valInTable = tablelist[ipos];
+ self->count = 1;
+ self->accum = in[i];
+ if (steps < 2) { /* Moved one sample, no need to interpolate. */
+ tablelist[ipos] = in[i] + tablelist[ipos] * feed;
+ }
+ else { /* Interpolate between last pos and current pos. */
+ MYFLT inc = (in[i] - self->lastValue) / steps;
+ for (j=1; j<=steps; j++) {
+ MYFLT val = self->lastValue + inc * j;
+ tablelist[self->lastPos+j*dir] = val + tablelist[self->lastPos+j*dir] * feed;
+ }
+ }
+ }
+ self->lastPos = ipos;
+ self->lastValue = in[i];
+ }
}
}
@@ -6783,7 +7315,7 @@ TableWrite_dealloc(TableWrite* self)
{
pyo_DEALLOC
TableWrite_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -6794,14 +7326,21 @@ TableWrite_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
TableWrite *self;
self = (TableWrite *)type->tp_alloc(type, 0);
+ self->mode = 0;
+ self->lastPos = -1;
+ self->lastValue = 0.0;
+ self->count = 0;
+ self->accum = 0.0;
+ self->valInTable = 0.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};
+ static char *kwlist[] = {"input", "pos", "table", "mode", NULL};
- if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOO", kwlist, &inputtmp, &postmp, &tabletmp))
+ if (! PyArg_ParseTupleAndKeywords(args, kwds, "OOOi", kwlist, &inputtmp, &postmp, &tabletmp, &self->mode))
Py_RETURN_NONE;
INIT_INPUT_STREAM
@@ -6891,8 +7430,7 @@ static PyMethodDef TableWrite_methods[] = {
};
PyTypeObject TableWriteType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TableWrite_base", /*tp_name*/
sizeof(TableWrite), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -6900,7 +7438,7 @@ sizeof(TableWrite), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/trigmodule.c b/src/objects/trigmodule.c
index c00d825..201696a 100644
--- a/src/objects/trigmodule.c
+++ b/src/objects/trigmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include "pyomodule.h"
#include "streammodule.h"
@@ -155,7 +156,7 @@ TrigRandInt_dealloc(TrigRandInt* self)
{
pyo_DEALLOC
TrigRandInt_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -290,7 +291,7 @@ static PyNumberMethods TrigRandInt_as_number = {
(binaryfunc)TrigRandInt_add, /*nb_add*/
(binaryfunc)TrigRandInt_sub, /*nb_subtract*/
(binaryfunc)TrigRandInt_multiply, /*nb_multiply*/
- (binaryfunc)TrigRandInt_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -304,16 +305,16 @@ static PyNumberMethods TrigRandInt_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TrigRandInt_inplace_add, /*inplace_add*/
(binaryfunc)TrigRandInt_inplace_sub, /*inplace_subtract*/
(binaryfunc)TrigRandInt_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)TrigRandInt_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -322,15 +323,14 @@ static PyNumberMethods TrigRandInt_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TrigRandInt_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TrigRandInt_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigRandIntType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigRandInt_base", /*tp_name*/
sizeof(TrigRandInt), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -338,7 +338,7 @@ PyTypeObject TrigRandIntType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigRandInt_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -611,7 +611,7 @@ TrigRand_dealloc(TrigRand* self)
{
pyo_DEALLOC
TrigRand_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -806,7 +806,7 @@ static PyNumberMethods TrigRand_as_number = {
(binaryfunc)TrigRand_add, /*nb_add*/
(binaryfunc)TrigRand_sub, /*nb_subtract*/
(binaryfunc)TrigRand_multiply, /*nb_multiply*/
-(binaryfunc)TrigRand_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -820,16 +820,16 @@ static PyNumberMethods TrigRand_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TrigRand_inplace_add, /*inplace_add*/
(binaryfunc)TrigRand_inplace_sub, /*inplace_subtract*/
(binaryfunc)TrigRand_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)TrigRand_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -838,15 +838,14 @@ static PyNumberMethods TrigRand_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)TrigRand_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)TrigRand_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigRandType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigRand_base", /*tp_name*/
sizeof(TrigRand), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -854,7 +853,7 @@ sizeof(TrigRand), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigRand_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1012,7 +1011,7 @@ TrigChoice_dealloc(TrigChoice* self)
pyo_DEALLOC
free(self->choice);
TrigChoice_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1159,7 +1158,7 @@ static PyNumberMethods TrigChoice_as_number = {
(binaryfunc)TrigChoice_add, /*nb_add*/
(binaryfunc)TrigChoice_sub, /*nb_subtract*/
(binaryfunc)TrigChoice_multiply, /*nb_multiply*/
-(binaryfunc)TrigChoice_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1173,16 +1172,16 @@ static PyNumberMethods TrigChoice_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TrigChoice_inplace_add, /*inplace_add*/
(binaryfunc)TrigChoice_inplace_sub, /*inplace_subtract*/
(binaryfunc)TrigChoice_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)TrigChoice_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1191,15 +1190,14 @@ static PyNumberMethods TrigChoice_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)TrigChoice_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)TrigChoice_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigChoiceType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigChoice_base", /*tp_name*/
sizeof(TrigChoice), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1207,7 +1205,7 @@ sizeof(TrigChoice), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigChoice_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1311,7 +1309,7 @@ TrigFunc_dealloc(TrigFunc* self)
{
pyo_DEALLOC
TrigFunc_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1405,8 +1403,7 @@ static PyMethodDef TrigFunc_methods[] = {
};
PyTypeObject TrigFuncType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigFunc_base", /*tp_name*/
sizeof(TrigFunc), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1414,7 +1411,7 @@ sizeof(TrigFunc), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1643,7 +1640,7 @@ TrigEnv_dealloc(TrigEnv* self)
pyo_DEALLOC
free(self->trigsBuffer);
TrigEnv_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1837,7 +1834,7 @@ static PyNumberMethods TrigEnv_as_number = {
(binaryfunc)TrigEnv_add, /*nb_add*/
(binaryfunc)TrigEnv_sub, /*nb_subtract*/
(binaryfunc)TrigEnv_multiply, /*nb_multiply*/
-(binaryfunc)TrigEnv_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1851,16 +1848,16 @@ static PyNumberMethods TrigEnv_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TrigEnv_inplace_add, /*inplace_add*/
(binaryfunc)TrigEnv_inplace_sub, /*inplace_subtract*/
(binaryfunc)TrigEnv_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)TrigEnv_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1869,15 +1866,14 @@ static PyNumberMethods TrigEnv_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)TrigEnv_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)TrigEnv_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigEnvType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigEnv_base", /*tp_name*/
sizeof(TrigEnv), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1885,7 +1881,7 @@ sizeof(TrigEnv), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigEnv_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2087,7 +2083,7 @@ TrigLinseg_dealloc(TrigLinseg* self)
free(self->times);
free(self->trigsBuffer);
TrigLinseg_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2215,7 +2211,7 @@ static PyNumberMethods TrigLinseg_as_number = {
(binaryfunc)TrigLinseg_add, /*nb_add*/
(binaryfunc)TrigLinseg_sub, /*nb_subtract*/
(binaryfunc)TrigLinseg_multiply, /*nb_multiply*/
-(binaryfunc)TrigLinseg_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2229,16 +2225,16 @@ static PyNumberMethods TrigLinseg_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TrigLinseg_inplace_add, /*inplace_add*/
(binaryfunc)TrigLinseg_inplace_sub, /*inplace_subtract*/
(binaryfunc)TrigLinseg_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)TrigLinseg_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2247,15 +2243,14 @@ static PyNumberMethods TrigLinseg_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)TrigLinseg_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)TrigLinseg_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigLinsegType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigLinseg_base", /*tp_name*/
sizeof(TrigLinseg), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2263,7 +2258,7 @@ sizeof(TrigLinseg), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigLinseg_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2488,7 +2483,7 @@ TrigExpseg_dealloc(TrigExpseg* self)
free(self->times);
free(self->trigsBuffer);
TrigExpseg_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2643,7 +2638,7 @@ static PyNumberMethods TrigExpseg_as_number = {
(binaryfunc)TrigExpseg_add, /*nb_add*/
(binaryfunc)TrigExpseg_sub, /*nb_subtract*/
(binaryfunc)TrigExpseg_multiply, /*nb_multiply*/
-(binaryfunc)TrigExpseg_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2657,16 +2652,16 @@ static PyNumberMethods TrigExpseg_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TrigExpseg_inplace_add, /*inplace_add*/
(binaryfunc)TrigExpseg_inplace_sub, /*inplace_subtract*/
(binaryfunc)TrigExpseg_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)TrigExpseg_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2675,15 +2670,14 @@ static PyNumberMethods TrigExpseg_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)TrigExpseg_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)TrigExpseg_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigExpsegType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigExpseg_base", /*tp_name*/
sizeof(TrigExpseg), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2691,7 +2685,7 @@ sizeof(TrigExpseg), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigExpseg_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2901,21 +2895,21 @@ TrigXnoise_poisson(TrigXnoise *self) {
// x1 = max value, x2 = max step
static MYFLT
TrigXnoise_walker(TrigXnoise *self) {
- int modulo, dir;
+ unsigned int modulo, dir;
if (self->xx2 < 0.002) self->xx2 = 0.002;
- modulo = (int)(self->xx2 * 1000.0);
- dir = pyorand() % 2;
+ modulo = (unsigned int)(self->xx2 * 1000.0);
+ dir = pyorand() % 100;
- if (dir == 0)
- self->walkerValue = self->walkerValue + (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ if (dir < 50)
+ self->walkerValue += ((MYFLT)(pyorand() % modulo) * 0.001);
else
- self->walkerValue = self->walkerValue - (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ self->walkerValue -= ((MYFLT)(pyorand() % modulo) * 0.001);
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
- if (self->walkerValue < 0.0)
+ else if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
return self->walkerValue;
@@ -2924,7 +2918,7 @@ TrigXnoise_walker(TrigXnoise *self) {
// x1 = max value, x2 = max step
static MYFLT
TrigXnoise_loopseg(TrigXnoise *self) {
- int modulo, dir;
+ unsigned int modulo, dir;
if (self->loopChoice == 0) {
@@ -2932,17 +2926,17 @@ TrigXnoise_loopseg(TrigXnoise *self) {
if (self->xx2 < 0.002) self->xx2 = 0.002;
- modulo = (int)(self->xx2 * 1000.0);
- dir = pyorand() % 2;
+ modulo = (unsigned int)(self->xx2 * 1000.0);
+ dir = pyorand() % 100;
- if (dir == 0)
- self->walkerValue = self->walkerValue + (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ if (dir < 50)
+ self->walkerValue += ((MYFLT)(pyorand() % modulo) * 0.001);
else
- self->walkerValue = self->walkerValue - (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ self->walkerValue -= ((MYFLT)(pyorand() % modulo) * 0.001);
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
- if (self->walkerValue < 0.0)
+ else if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
self->loop_buffer[self->loopCountRec++] = self->walkerValue;
@@ -3185,7 +3179,7 @@ TrigXnoise_dealloc(TrigXnoise* self)
{
pyo_DEALLOC
TrigXnoise_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3384,7 +3378,7 @@ static PyNumberMethods TrigXnoise_as_number = {
(binaryfunc)TrigXnoise_add, /*nb_add*/
(binaryfunc)TrigXnoise_sub, /*nb_subtract*/
(binaryfunc)TrigXnoise_multiply, /*nb_multiply*/
- (binaryfunc)TrigXnoise_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3398,16 +3392,16 @@ static PyNumberMethods TrigXnoise_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TrigXnoise_inplace_add, /*inplace_add*/
(binaryfunc)TrigXnoise_inplace_sub, /*inplace_subtract*/
(binaryfunc)TrigXnoise_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)TrigXnoise_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3416,15 +3410,14 @@ static PyNumberMethods TrigXnoise_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TrigXnoise_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TrigXnoise_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigXnoiseType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigXnoise_base", /*tp_name*/
sizeof(TrigXnoise), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3432,7 +3425,7 @@ PyTypeObject TrigXnoiseType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigXnoise_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3671,21 +3664,21 @@ TrigXnoiseMidi_poisson(TrigXnoiseMidi *self) {
// x1 = max value, x2 = max step
static MYFLT
TrigXnoiseMidi_walker(TrigXnoiseMidi *self) {
- int modulo, dir;
+ unsigned int modulo, dir;
if (self->xx2 < 0.002) self->xx2 = 0.002;
- modulo = (int)(self->xx2 * 1000.0);
- dir = pyorand() % 2;
+ modulo = (unsigned int)(self->xx2 * 1000.0);
+ dir = pyorand() % 100;
- if (dir == 0)
- self->walkerValue = self->walkerValue + (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ if (dir < 50)
+ self->walkerValue += ((MYFLT)(pyorand() % modulo) * 0.001);
else
- self->walkerValue = self->walkerValue - (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ self->walkerValue -= ((MYFLT)(pyorand() % modulo) * 0.001);
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
- if (self->walkerValue < 0.0)
+ else if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
return self->walkerValue;
@@ -3694,7 +3687,7 @@ TrigXnoiseMidi_walker(TrigXnoiseMidi *self) {
// x1 = max value, x2 = max step
static MYFLT
TrigXnoiseMidi_loopseg(TrigXnoiseMidi *self) {
- int modulo, dir;
+ unsigned int modulo, dir;
if (self->loopChoice == 0) {
@@ -3702,17 +3695,17 @@ TrigXnoiseMidi_loopseg(TrigXnoiseMidi *self) {
if (self->xx2 < 0.002) self->xx2 = 0.002;
- modulo = (int)(self->xx2 * 1000.0);
- dir = pyorand() % 2;
+ modulo = (unsigned int)(self->xx2 * 1000.0);
+ dir = pyorand() % 100;
- if (dir == 0)
- self->walkerValue = self->walkerValue + (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ if (dir < 50)
+ self->walkerValue += ((MYFLT)(pyorand() % modulo) * 0.001);
else
- self->walkerValue = self->walkerValue - (((pyorand() % modulo) - (modulo / 2)) * 0.001);
+ self->walkerValue -= ((MYFLT)(pyorand() % modulo) * 0.001);
if (self->walkerValue > self->xx1)
self->walkerValue = self->xx1;
- if (self->walkerValue < 0.0)
+ else if (self->walkerValue < 0.0)
self->walkerValue = 0.0;
self->loop_buffer[self->loopCountRec++] = self->walkerValue;
@@ -3960,7 +3953,7 @@ TrigXnoiseMidi_dealloc(TrigXnoiseMidi* self)
{
pyo_DEALLOC
TrigXnoiseMidi_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4088,7 +4081,7 @@ TrigXnoiseMidi_setScale(TrigXnoiseMidi *self, PyObject *arg)
if (tmp >= 0 && tmp <= 2)
self->scale = tmp;
else
- printf("scale attribute must be an integer {0, 1, 2}\n");
+ PySys_WriteStdout("TrigXnoiseMidi: scale attribute must be an integer {0, 1, 2}\n");
}
Py_INCREF(Py_None);
@@ -4210,7 +4203,7 @@ static PyNumberMethods TrigXnoiseMidi_as_number = {
(binaryfunc)TrigXnoiseMidi_add, /*nb_add*/
(binaryfunc)TrigXnoiseMidi_sub, /*nb_subtract*/
(binaryfunc)TrigXnoiseMidi_multiply, /*nb_multiply*/
- (binaryfunc)TrigXnoiseMidi_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4224,16 +4217,16 @@ static PyNumberMethods TrigXnoiseMidi_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TrigXnoiseMidi_inplace_add, /*inplace_add*/
(binaryfunc)TrigXnoiseMidi_inplace_sub, /*inplace_subtract*/
(binaryfunc)TrigXnoiseMidi_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)TrigXnoiseMidi_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4242,15 +4235,14 @@ static PyNumberMethods TrigXnoiseMidi_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TrigXnoiseMidi_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TrigXnoiseMidi_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigXnoiseMidiType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigXnoiseMidi_base", /*tp_name*/
sizeof(TrigXnoiseMidi), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4258,7 +4250,7 @@ PyTypeObject TrigXnoiseMidiType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigXnoiseMidi_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4419,7 +4411,7 @@ Counter_dealloc(Counter* self)
{
pyo_DEALLOC
Counter_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4577,7 +4569,7 @@ static PyNumberMethods Counter_as_number = {
(binaryfunc)Counter_add, /*nb_add*/
(binaryfunc)Counter_sub, /*nb_subtract*/
(binaryfunc)Counter_multiply, /*nb_multiply*/
-(binaryfunc)Counter_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4591,16 +4583,16 @@ static PyNumberMethods Counter_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Counter_inplace_add, /*inplace_add*/
(binaryfunc)Counter_inplace_sub, /*inplace_subtract*/
(binaryfunc)Counter_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Counter_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4609,15 +4601,14 @@ static PyNumberMethods Counter_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Counter_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Counter_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject CounterType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Counter_base", /*tp_name*/
sizeof(Counter), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4625,7 +4616,7 @@ sizeof(Counter), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Counter_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4849,7 +4840,7 @@ Thresh_dealloc(Thresh* self)
{
pyo_DEALLOC
Thresh_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4987,7 +4978,7 @@ static PyNumberMethods Thresh_as_number = {
(binaryfunc)Thresh_add, /*nb_add*/
(binaryfunc)Thresh_sub, /*nb_subtract*/
(binaryfunc)Thresh_multiply, /*nb_multiply*/
- (binaryfunc)Thresh_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5001,16 +4992,16 @@ static PyNumberMethods Thresh_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Thresh_inplace_add, /*inplace_add*/
(binaryfunc)Thresh_inplace_sub, /*inplace_subtract*/
(binaryfunc)Thresh_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Thresh_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5019,15 +5010,14 @@ static PyNumberMethods Thresh_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Thresh_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Thresh_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ThreshType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Thresh_base", /*tp_name*/
sizeof(Thresh), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5035,7 +5025,7 @@ sizeof(Thresh), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Thresh_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5202,7 +5192,7 @@ Percent_dealloc(Percent* self)
{
pyo_DEALLOC
Percent_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5326,7 +5316,7 @@ static PyNumberMethods Percent_as_number = {
(binaryfunc)Percent_add, /*nb_add*/
(binaryfunc)Percent_sub, /*nb_subtract*/
(binaryfunc)Percent_multiply, /*nb_multiply*/
- (binaryfunc)Percent_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5340,16 +5330,16 @@ static PyNumberMethods Percent_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Percent_inplace_add, /*inplace_add*/
(binaryfunc)Percent_inplace_sub, /*inplace_subtract*/
(binaryfunc)Percent_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Percent_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5358,15 +5348,14 @@ static PyNumberMethods Percent_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Percent_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Percent_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject PercentType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Percent_base", /*tp_name*/
sizeof(Percent), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5374,7 +5363,7 @@ PyTypeObject PercentType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Percent_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5527,7 +5516,7 @@ Timer_dealloc(Timer* self)
{
pyo_DEALLOC
Timer_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5622,7 +5611,7 @@ static PyNumberMethods Timer_as_number = {
(binaryfunc)Timer_add, /*nb_add*/
(binaryfunc)Timer_sub, /*nb_subtract*/
(binaryfunc)Timer_multiply, /*nb_multiply*/
- (binaryfunc)Timer_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5636,16 +5625,16 @@ static PyNumberMethods Timer_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Timer_inplace_add, /*inplace_add*/
(binaryfunc)Timer_inplace_sub, /*inplace_subtract*/
(binaryfunc)Timer_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Timer_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5654,15 +5643,14 @@ static PyNumberMethods Timer_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Timer_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Timer_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TimerType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Timer_base", /*tp_name*/
sizeof(Timer), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5670,7 +5658,7 @@ PyTypeObject TimerType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Timer_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5709,26 +5697,57 @@ typedef struct {
pyo_audio_HEAD
PyObject *input;
Stream *input_stream;
+ PyObject *choice;
+ Stream *audioval;
int chSize;
int chCount;
- MYFLT *choice;
+ int curIsAudio;
MYFLT value;
+ MYFLT *trigsBuffer;
+ TriggerStream *trig_stream;
int modebuffer[2]; // need at least 2 slots for mul & add
} Iter;
static void
+Iter_get_stream(Iter *self, PyObject *obj) {
+ PyObject *streamtmp;
+ streamtmp = PyObject_CallMethod((PyObject *)obj, "_getStream", NULL);
+ Py_INCREF(streamtmp);
+ Py_XDECREF(self->audioval);
+ self->audioval = (Stream *)streamtmp;
+}
+
+static void
Iter_generate(Iter *self) {
int i;
+ PyObject *obj;
MYFLT *in = Stream_getData((Stream *)self->input_stream);
for (i=0; i<self->bufsize; i++) {
+ self->trigsBuffer[i] = 0.0;
if (in[i] == 1) {
if (self->chCount >= self->chSize)
self->chCount = 0;
- self->value = self->choice[self->chCount];
+ obj = PyList_GetItem(self->choice, self->chCount);
+ if (PyNumber_Check(obj)) {
+ self->value = PyFloat_AsDouble(obj);
+ self->curIsAudio = 0;
+ }
+ else {
+ self->curIsAudio = 1;
+ Iter_get_stream(self, obj);
+ }
self->chCount++;
+ if (self->chCount == self->chSize)
+ self->trigsBuffer[i] = 1.0;
+ }
+ if (self->curIsAudio) {
+ MYFLT *val = Stream_getData((Stream *)self->audioval);
+ self->data[i] = val[i];
+ }
+ else {
+ self->data[i] = self->value;
}
- self->data[i] = self->value;
}
}
@@ -5794,6 +5813,9 @@ Iter_traverse(Iter *self, visitproc visit, void *arg)
pyo_VISIT
Py_VISIT(self->input);
Py_VISIT(self->input_stream);
+ Py_VISIT(self->choice);
+ Py_VISIT(self->audioval);
+ Py_VISIT(self->trig_stream);
return 0;
}
@@ -5803,6 +5825,9 @@ Iter_clear(Iter *self)
pyo_CLEAR
Py_CLEAR(self->input);
Py_CLEAR(self->input_stream);
+ Py_CLEAR(self->choice);
+ Py_CLEAR(self->audioval);
+ Py_CLEAR(self->trig_stream);
return 0;
}
@@ -5810,9 +5835,9 @@ static void
Iter_dealloc(Iter* self)
{
pyo_DEALLOC
- free(self->choice);
+ free(self->trigsBuffer);
Iter_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5826,6 +5851,7 @@ Iter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->value = 0.;
self->chCount = 0;
+ self->curIsAudio = 0;
self->modebuffer[0] = 0;
self->modebuffer[1] = 0;
@@ -5856,6 +5882,15 @@ Iter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->value = inittmp;
+ 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;
@@ -5863,6 +5898,7 @@ 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_getTriggerStream(Iter* self) { GET_TRIGGER_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 };
@@ -5884,26 +5920,20 @@ static PyObject * Iter_inplace_div(Iter *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
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;
+ Py_RETURN_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_AsDouble(PyList_GET_ITEM(tmp, i));
- }
-
- (*self->mode_func_ptr)(self);
+ Py_INCREF(tmp);
+ Py_XDECREF(self->choice);
+ self->choice = tmp;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -5917,13 +5947,13 @@ Iter_reset(Iter *self, PyObject *arg)
else
self->chCount = 0;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyMemberDef Iter_members[] = {
{"server", T_OBJECT_EX, offsetof(Iter, server), 0, "Pyo server."},
{"stream", T_OBJECT_EX, offsetof(Iter, stream), 0, "Stream object."},
+ {"trig_stream", T_OBJECT_EX, offsetof(Iter, trig_stream), 0, "Trigger Stream object."},
{"input", T_OBJECT_EX, offsetof(Iter, input), 0, "Input sound object."},
{"mul", T_OBJECT_EX, offsetof(Iter, mul), 0, "Mul factor."},
{"add", T_OBJECT_EX, offsetof(Iter, add), 0, "Add factor."},
@@ -5933,6 +5963,7 @@ static PyMemberDef Iter_members[] = {
static PyMethodDef Iter_methods[] = {
{"getServer", (PyCFunction)Iter_getServer, METH_NOARGS, "Returns server object."},
{"_getStream", (PyCFunction)Iter_getStream, METH_NOARGS, "Returns stream object."},
+ {"_getTriggerStream", (PyCFunction)Iter_getTriggerStream, METH_NOARGS, "Returns trigger stream object."},
{"play", (PyCFunction)Iter_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"out", (PyCFunction)Iter_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
{"stop", (PyCFunction)Iter_stop, METH_NOARGS, "Stops computing."},
@@ -5949,7 +5980,7 @@ static PyNumberMethods Iter_as_number = {
(binaryfunc)Iter_add, /*nb_add*/
(binaryfunc)Iter_sub, /*nb_subtract*/
(binaryfunc)Iter_multiply, /*nb_multiply*/
- (binaryfunc)Iter_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5963,16 +5994,16 @@ static PyNumberMethods Iter_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Iter_inplace_add, /*inplace_add*/
(binaryfunc)Iter_inplace_sub, /*inplace_subtract*/
(binaryfunc)Iter_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Iter_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5981,15 +6012,14 @@ static PyNumberMethods Iter_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Iter_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Iter_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject IterType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Iter_base", /*tp_name*/
sizeof(Iter), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5997,7 +6027,7 @@ PyTypeObject IterType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Iter_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -6142,7 +6172,7 @@ Count_dealloc(Count* self)
{
pyo_DEALLOC
Count_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -6254,7 +6284,7 @@ static PyNumberMethods Count_as_number = {
(binaryfunc)Count_add, /*nb_add*/
(binaryfunc)Count_sub, /*nb_subtract*/
(binaryfunc)Count_multiply, /*nb_multiply*/
- (binaryfunc)Count_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -6268,16 +6298,16 @@ static PyNumberMethods Count_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Count_inplace_add, /*inplace_add*/
(binaryfunc)Count_inplace_sub, /*inplace_subtract*/
(binaryfunc)Count_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Count_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -6286,15 +6316,14 @@ static PyNumberMethods Count_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Count_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Count_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject CountType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Count_base", /*tp_name*/
sizeof(Count), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -6302,7 +6331,7 @@ PyTypeObject CountType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Count_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -6447,7 +6476,7 @@ NextTrig_dealloc(NextTrig* self)
{
pyo_DEALLOC
NextTrig_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -6540,7 +6569,7 @@ static PyNumberMethods NextTrig_as_number = {
(binaryfunc)NextTrig_add, /*nb_add*/
(binaryfunc)NextTrig_sub, /*nb_subtract*/
(binaryfunc)NextTrig_multiply, /*nb_multiply*/
- (binaryfunc)NextTrig_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -6554,16 +6583,16 @@ static PyNumberMethods NextTrig_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)NextTrig_inplace_add, /*inplace_add*/
(binaryfunc)NextTrig_inplace_sub, /*inplace_subtract*/
(binaryfunc)NextTrig_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)NextTrig_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -6572,15 +6601,14 @@ static PyNumberMethods NextTrig_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)NextTrig_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)NextTrig_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject NextTrigType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.NextTrig_base", /*tp_name*/
sizeof(NextTrig), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -6588,7 +6616,7 @@ PyTypeObject NextTrigType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&NextTrig_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -6748,7 +6776,7 @@ TrigVal_dealloc(TrigVal* self)
{
pyo_DEALLOC
TrigVal_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -6874,7 +6902,7 @@ static PyNumberMethods TrigVal_as_number = {
(binaryfunc)TrigVal_add, /*nb_add*/
(binaryfunc)TrigVal_sub, /*nb_subtract*/
(binaryfunc)TrigVal_multiply, /*nb_multiply*/
- (binaryfunc)TrigVal_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -6888,16 +6916,16 @@ static PyNumberMethods TrigVal_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TrigVal_inplace_add, /*inplace_add*/
(binaryfunc)TrigVal_inplace_sub, /*inplace_subtract*/
(binaryfunc)TrigVal_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)TrigVal_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -6906,15 +6934,14 @@ static PyNumberMethods TrigVal_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TrigVal_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TrigVal_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrigValType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrigVal_base", /*tp_name*/
sizeof(TrigVal), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -6922,7 +6949,7 @@ PyTypeObject TrigValType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrigVal_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/utilsmodule.c b/src/objects/utilsmodule.c
index 6442876..662fc09 100644
--- a/src/objects/utilsmodule.c
+++ b/src/objects/utilsmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -51,9 +52,9 @@ Print_process_time(Print *self) {
if (self->currentTime >= self->time) {
self->currentTime = 0.0;
if (self->message == NULL || self->message[0] == '\0')
- printf("%f\n", in[i]);
+ PySys_WriteStdout("%f\n", in[i]);
else
- printf("%s : %f\n", self->message, in[i]);
+ PySys_WriteStdout("%s : %f\n", self->message, in[i]);
}
self->currentTime += self->sampleToSec;
}
@@ -69,9 +70,9 @@ Print_process_change(Print *self) {
inval = in[i];
if (inval < (self->lastValue-0.00001) || inval > (self->lastValue+0.00001)) {
if (self->message == NULL || self->message[0] == '\0')
- printf("%f\n", inval);
+ PySys_WriteStdout("%f\n", inval);
else
- printf("%s : %f\n", self->message, inval);
+ PySys_WriteStdout("%s : %f\n", self->message, inval);
self->lastValue = inval;
}
}
@@ -122,7 +123,7 @@ Print_dealloc(Print* self)
{
pyo_DEALLOC
Print_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -169,15 +170,12 @@ Print_setMethod(Print *self, PyObject *arg)
{
ASSERT_ARG_NOT_NULL
- int isNumber = PyNumber_Check(arg);
-
- if (isNumber == 1) {
+ if (PyNumber_Check(arg) == 1) {
self->method = PyInt_AsLong(arg);
(*self->mode_func_ptr)(self);
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -185,14 +183,10 @@ Print_setInterval(Print *self, PyObject *arg)
{
ASSERT_ARG_NOT_NULL
- int isNumber = PyNumber_Check(arg);
-
- if (isNumber == 1) {
+ if (PyNumber_Check(arg) == 1)
self->time = PyFloat_AsDouble(arg);
- }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyObject *
@@ -200,14 +194,10 @@ Print_setMessage(Print *self, PyObject *arg)
{
ASSERT_ARG_NOT_NULL
- int isString = PyString_Check(arg);
+ if (PY_STRING_CHECK(arg))
+ self->message = PY_STRING_AS_STRING(arg);
- if (isString == 1) {
- self->message = PyString_AsString(arg);
- }
-
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static PyMemberDef Print_members[] = {
@@ -229,8 +219,7 @@ static PyMethodDef Print_methods[] = {
};
PyTypeObject PrintType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Print_base", /*tp_name*/
sizeof(Print), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -238,7 +227,7 @@ sizeof(Print), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -414,7 +403,7 @@ Snap_dealloc(Snap* self)
pyo_DEALLOC
free(self->choice);
Snap_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -531,7 +520,7 @@ Snap_setScale(Snap *self, PyObject *arg)
if (tmp >= 0 && tmp <= 2)
self->scale = tmp;
else
- printf("scale attribute must be an integer {0, 1, 2}\n");
+ PySys_WriteStdout("Snap: scale attribute must be an integer {0, 1, 2}\n");
}
Py_INCREF(Py_None);
@@ -566,7 +555,7 @@ static PyNumberMethods Snap_as_number = {
(binaryfunc)Snap_add, /*nb_add*/
(binaryfunc)Snap_sub, /*nb_subtract*/
(binaryfunc)Snap_multiply, /*nb_multiply*/
- (binaryfunc)Snap_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -580,16 +569,16 @@ static PyNumberMethods Snap_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Snap_inplace_add, /*inplace_add*/
(binaryfunc)Snap_inplace_sub, /*inplace_subtract*/
(binaryfunc)Snap_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Snap_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -598,15 +587,14 @@ static PyNumberMethods Snap_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Snap_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Snap_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SnapType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Snap_base", /*tp_name*/
sizeof(Snap), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -614,7 +602,7 @@ PyTypeObject SnapType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Snap_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -793,7 +781,7 @@ Interp_dealloc(Interp* self)
{
pyo_DEALLOC
Interp_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -926,7 +914,7 @@ static PyNumberMethods Interp_as_number = {
(binaryfunc)Interp_add, /*nb_add*/
(binaryfunc)Interp_sub, /*nb_subtract*/
(binaryfunc)Interp_multiply, /*nb_multiply*/
-(binaryfunc)Interp_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -940,16 +928,16 @@ static PyNumberMethods Interp_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Interp_inplace_add, /*inplace_add*/
(binaryfunc)Interp_inplace_sub, /*inplace_subtract*/
(binaryfunc)Interp_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Interp_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -958,15 +946,14 @@ static PyNumberMethods Interp_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Interp_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Interp_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject InterpType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Interp_base", /*tp_name*/
sizeof(Interp), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -974,7 +961,7 @@ sizeof(Interp), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Interp_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1161,7 +1148,7 @@ SampHold_dealloc(SampHold* self)
{
pyo_DEALLOC
SampHold_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1296,7 +1283,7 @@ static PyNumberMethods SampHold_as_number = {
(binaryfunc)SampHold_add, /*nb_add*/
(binaryfunc)SampHold_sub, /*nb_subtract*/
(binaryfunc)SampHold_multiply, /*nb_multiply*/
-(binaryfunc)SampHold_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1310,16 +1297,16 @@ static PyNumberMethods SampHold_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)SampHold_inplace_add, /*inplace_add*/
(binaryfunc)SampHold_inplace_sub, /*inplace_subtract*/
(binaryfunc)SampHold_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)SampHold_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1328,15 +1315,14 @@ static PyNumberMethods SampHold_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)SampHold_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)SampHold_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject SampHoldType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.SampHold_base", /*tp_name*/
sizeof(SampHold), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1344,7 +1330,7 @@ sizeof(SampHold), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&SampHold_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1535,7 +1521,7 @@ TrackHold_dealloc(TrackHold* self)
{
pyo_DEALLOC
TrackHold_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1670,7 +1656,7 @@ static PyNumberMethods TrackHold_as_number = {
(binaryfunc)TrackHold_add, /*nb_add*/
(binaryfunc)TrackHold_sub, /*nb_subtract*/
(binaryfunc)TrackHold_multiply, /*nb_multiply*/
-(binaryfunc)TrackHold_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1684,16 +1670,16 @@ static PyNumberMethods TrackHold_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TrackHold_inplace_add, /*inplace_add*/
(binaryfunc)TrackHold_inplace_sub, /*inplace_subtract*/
(binaryfunc)TrackHold_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)TrackHold_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -1702,15 +1688,14 @@ static PyNumberMethods TrackHold_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)TrackHold_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)TrackHold_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TrackHoldType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TrackHold_base", /*tp_name*/
sizeof(TrackHold), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1718,7 +1703,7 @@ sizeof(TrackHold), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TrackHold_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1911,7 +1896,7 @@ Compare_dealloc(Compare* self)
{
pyo_DEALLOC
Compare_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2018,7 +2003,7 @@ Compare_setMode(Compare *self, PyObject *arg)
ASSERT_ARG_NOT_NULL
if (! PyInt_Check(arg)) {
- printf("mode should be a comparison operator as a string\n");
+ PySys_WriteStdout("Compare: mode attribute should be a comparison operator as a string\n");
Py_RETURN_NONE;
}
@@ -2068,7 +2053,7 @@ static PyNumberMethods Compare_as_number = {
(binaryfunc)Compare_add, /*nb_add*/
(binaryfunc)Compare_sub, /*nb_subtract*/
(binaryfunc)Compare_multiply, /*nb_multiply*/
-(binaryfunc)Compare_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2082,16 +2067,16 @@ static PyNumberMethods Compare_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Compare_inplace_add, /*inplace_add*/
(binaryfunc)Compare_inplace_sub, /*inplace_subtract*/
(binaryfunc)Compare_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Compare_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2100,15 +2085,14 @@ static PyNumberMethods Compare_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Compare_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Compare_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject CompareType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Compare_base", /*tp_name*/
sizeof(Compare), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2116,7 +2100,7 @@ sizeof(Compare), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Compare_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2331,7 +2315,7 @@ Between_dealloc(Between* self)
{
pyo_DEALLOC
Between_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2495,7 +2479,7 @@ static PyNumberMethods Between_as_number = {
(binaryfunc)Between_add, /*nb_add*/
(binaryfunc)Between_sub, /*nb_subtract*/
(binaryfunc)Between_multiply, /*nb_multiply*/
- (binaryfunc)Between_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2509,16 +2493,16 @@ static PyNumberMethods Between_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Between_inplace_add, /*inplace_add*/
(binaryfunc)Between_inplace_sub, /*inplace_subtract*/
(binaryfunc)Between_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Between_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2527,15 +2511,14 @@ static PyNumberMethods Between_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Between_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Between_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject BetweenType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Between_base", /*tp_name*/
sizeof(Between), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2543,7 +2526,7 @@ PyTypeObject BetweenType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Between_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2681,7 +2664,7 @@ Denorm_dealloc(Denorm* self)
{
pyo_DEALLOC
Denorm_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2769,7 +2752,7 @@ static PyNumberMethods Denorm_as_number = {
(binaryfunc)Denorm_add, /*nb_add*/
(binaryfunc)Denorm_sub, /*nb_subtract*/
(binaryfunc)Denorm_multiply, /*nb_multiply*/
- (binaryfunc)Denorm_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2783,16 +2766,16 @@ static PyNumberMethods Denorm_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Denorm_inplace_add, /*inplace_add*/
(binaryfunc)Denorm_inplace_sub, /*inplace_subtract*/
(binaryfunc)Denorm_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Denorm_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2801,15 +2784,14 @@ static PyNumberMethods Denorm_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Denorm_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Denorm_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject DenormType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Denorm_base", /*tp_name*/
sizeof(Denorm), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2817,7 +2799,7 @@ PyTypeObject DenormType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Denorm_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -2961,7 +2943,7 @@ DBToA_dealloc(DBToA* self)
{
pyo_DEALLOC
DBToA_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3049,7 +3031,7 @@ static PyNumberMethods DBToA_as_number = {
(binaryfunc)DBToA_add, /*nb_add*/
(binaryfunc)DBToA_sub, /*nb_subtract*/
(binaryfunc)DBToA_multiply, /*nb_multiply*/
- (binaryfunc)DBToA_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3063,16 +3045,16 @@ static PyNumberMethods DBToA_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)DBToA_inplace_add, /*inplace_add*/
(binaryfunc)DBToA_inplace_sub, /*inplace_subtract*/
(binaryfunc)DBToA_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)DBToA_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3081,15 +3063,14 @@ static PyNumberMethods DBToA_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)DBToA_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)DBToA_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject DBToAType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.DBToA_base", /*tp_name*/
sizeof(DBToA), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3097,7 +3078,7 @@ PyTypeObject DBToAType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&DBToA_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3241,7 +3222,7 @@ AToDB_dealloc(AToDB* self)
{
pyo_DEALLOC
AToDB_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3329,7 +3310,7 @@ static PyNumberMethods AToDB_as_number = {
(binaryfunc)AToDB_add, /*nb_add*/
(binaryfunc)AToDB_sub, /*nb_subtract*/
(binaryfunc)AToDB_multiply, /*nb_multiply*/
- (binaryfunc)AToDB_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3343,16 +3324,16 @@ static PyNumberMethods AToDB_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)AToDB_inplace_add, /*inplace_add*/
(binaryfunc)AToDB_inplace_sub, /*inplace_subtract*/
(binaryfunc)AToDB_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)AToDB_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3361,15 +3342,14 @@ static PyNumberMethods AToDB_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)AToDB_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)AToDB_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject AToDBType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.AToDB_base", /*tp_name*/
sizeof(AToDB), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3377,7 +3357,7 @@ PyTypeObject AToDBType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&AToDB_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -3654,7 +3634,7 @@ Scale_dealloc(Scale* self)
{
pyo_DEALLOC
Scale_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -3930,7 +3910,7 @@ static PyNumberMethods Scale_as_number = {
(binaryfunc)Scale_add, /*nb_add*/
(binaryfunc)Scale_sub, /*nb_subtract*/
(binaryfunc)Scale_multiply, /*nb_multiply*/
- (binaryfunc)Scale_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -3944,16 +3924,16 @@ static PyNumberMethods Scale_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Scale_inplace_add, /*inplace_add*/
(binaryfunc)Scale_inplace_sub, /*inplace_subtract*/
(binaryfunc)Scale_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)Scale_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -3962,15 +3942,14 @@ static PyNumberMethods Scale_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)Scale_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)Scale_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ScaleType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Scale_base", /*tp_name*/
sizeof(Scale), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -3978,7 +3957,7 @@ PyTypeObject ScaleType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Scale_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4118,7 +4097,7 @@ CentsToTranspo_dealloc(CentsToTranspo* self)
{
pyo_DEALLOC
CentsToTranspo_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4206,7 +4185,7 @@ static PyNumberMethods CentsToTranspo_as_number = {
(binaryfunc)CentsToTranspo_add, /*nb_add*/
(binaryfunc)CentsToTranspo_sub, /*nb_subtract*/
(binaryfunc)CentsToTranspo_multiply, /*nb_multiply*/
- (binaryfunc)CentsToTranspo_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4220,16 +4199,16 @@ static PyNumberMethods CentsToTranspo_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)CentsToTranspo_inplace_add, /*inplace_add*/
(binaryfunc)CentsToTranspo_inplace_sub, /*inplace_subtract*/
(binaryfunc)CentsToTranspo_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)CentsToTranspo_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4238,15 +4217,14 @@ static PyNumberMethods CentsToTranspo_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)CentsToTranspo_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)CentsToTranspo_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject CentsToTranspoType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.CentsToTranspo_base", /*tp_name*/
sizeof(CentsToTranspo), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4254,7 +4232,7 @@ PyTypeObject CentsToTranspoType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&CentsToTranspo_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4394,7 +4372,7 @@ TranspoToCents_dealloc(TranspoToCents* self)
{
pyo_DEALLOC
TranspoToCents_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4482,7 +4460,7 @@ static PyNumberMethods TranspoToCents_as_number = {
(binaryfunc)TranspoToCents_add, /*nb_add*/
(binaryfunc)TranspoToCents_sub, /*nb_subtract*/
(binaryfunc)TranspoToCents_multiply, /*nb_multiply*/
- (binaryfunc)TranspoToCents_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4496,16 +4474,16 @@ static PyNumberMethods TranspoToCents_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)TranspoToCents_inplace_add, /*inplace_add*/
(binaryfunc)TranspoToCents_inplace_sub, /*inplace_subtract*/
(binaryfunc)TranspoToCents_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)TranspoToCents_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4514,15 +4492,14 @@ static PyNumberMethods TranspoToCents_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)TranspoToCents_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)TranspoToCents_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject TranspoToCentsType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.TranspoToCents_base", /*tp_name*/
sizeof(TranspoToCents), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4530,7 +4507,7 @@ PyTypeObject TranspoToCentsType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&TranspoToCents_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4670,7 +4647,7 @@ MToF_dealloc(MToF* self)
{
pyo_DEALLOC
MToF_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -4758,7 +4735,7 @@ static PyNumberMethods MToF_as_number = {
(binaryfunc)MToF_add, /*nb_add*/
(binaryfunc)MToF_sub, /*nb_subtract*/
(binaryfunc)MToF_multiply, /*nb_multiply*/
- (binaryfunc)MToF_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -4772,16 +4749,16 @@ static PyNumberMethods MToF_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)MToF_inplace_add, /*inplace_add*/
(binaryfunc)MToF_inplace_sub, /*inplace_subtract*/
(binaryfunc)MToF_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)MToF_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -4790,15 +4767,14 @@ static PyNumberMethods MToF_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)MToF_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)MToF_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject MToFType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MToF_base", /*tp_name*/
sizeof(MToF), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -4806,7 +4782,7 @@ PyTypeObject MToFType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&MToF_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -4948,7 +4924,7 @@ FToM_dealloc(FToM* self)
{
pyo_DEALLOC
FToM_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5036,7 +5012,7 @@ 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*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5050,16 +5026,16 @@ static PyNumberMethods FToM_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*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*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5068,15 +5044,14 @@ static PyNumberMethods FToM_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)FToM_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)FToM_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject FToMType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.FToM_base", /*tp_name*/
sizeof(FToM), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5084,7 +5059,7 @@ PyTypeObject FToMType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&FToM_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5225,7 +5200,7 @@ MToT_dealloc(MToT* self)
{
pyo_DEALLOC
MToT_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5330,7 +5305,7 @@ static PyNumberMethods MToT_as_number = {
(binaryfunc)MToT_add, /*nb_add*/
(binaryfunc)MToT_sub, /*nb_subtract*/
(binaryfunc)MToT_multiply, /*nb_multiply*/
- (binaryfunc)MToT_div, /*nb_divide*/
+ INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5344,16 +5319,16 @@ static PyNumberMethods MToT_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- 0, /*nb_coerce*/
+ INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
- 0, /*nb_oct*/
- 0, /*nb_hex*/
+ INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+ INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)MToT_inplace_add, /*inplace_add*/
(binaryfunc)MToT_inplace_sub, /*inplace_subtract*/
(binaryfunc)MToT_inplace_multiply, /*inplace_multiply*/
- (binaryfunc)MToT_inplace_div, /*inplace_divide*/
+ INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5362,15 +5337,14 @@ static PyNumberMethods MToT_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
- 0, /*nb_true_divide*/
+ (binaryfunc)MToT_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
- 0, /*nb_inplace_true_divide*/
+ (binaryfunc)MToT_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject MToTType = {
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.MToT_base", /*tp_name*/
sizeof(MToT), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5378,7 +5352,7 @@ PyTypeObject MToTType = {
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- 0, /*tp_compare*/
+ 0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&MToT_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -5640,7 +5614,7 @@ Resample_dealloc(Resample* self)
free(self->pinput);
}
Resample_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -5767,7 +5741,7 @@ static PyNumberMethods Resample_as_number = {
(binaryfunc)Resample_add, /*nb_add*/
(binaryfunc)Resample_sub, /*nb_subtract*/
(binaryfunc)Resample_multiply, /*nb_multiply*/
-(binaryfunc)Resample_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -5781,16 +5755,16 @@ static PyNumberMethods Resample_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)Resample_inplace_add, /*inplace_add*/
(binaryfunc)Resample_inplace_sub, /*inplace_subtract*/
(binaryfunc)Resample_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)Resample_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -5799,15 +5773,14 @@ static PyNumberMethods Resample_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)Resample_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)Resample_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject ResampleType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.Resample_base", /*tp_name*/
sizeof(Resample), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -5815,7 +5788,7 @@ sizeof(Resample), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&Resample_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/src/objects/wgverbmodule.c b/src/objects/wgverbmodule.c
index ba280e4..5af9328 100644
--- a/src/objects/wgverbmodule.c
+++ b/src/objects/wgverbmodule.c
@@ -19,6 +19,7 @@
*************************************************************************/
#include <Python.h>
+#include "py2to3.h"
#include "structmember.h"
#include <math.h>
#include "pyomodule.h"
@@ -472,7 +473,7 @@ WGVerb_dealloc(WGVerb* self)
free(self->buffer[i]);
}
WGVerb_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -573,6 +574,22 @@ static PyObject * WGVerb_div(WGVerb *self, PyObject *arg) { DIV };
static PyObject * WGVerb_inplace_div(WGVerb *self, PyObject *arg) { INPLACE_DIV };
static PyObject *
+WGVerb_reset(WGVerb *self)
+{
+ int i, j;
+ for (i=0; i<8; i++) {
+ self->in_count[i] = 0;
+ self->lastSamples[i] = 0.0;
+ for (j=0; j<(self->size[i]+1); j++) {
+ self->buffer[i][j] = 0.;
+ }
+ }
+ self->total_signal = 0.0;
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
WGVerb_setFeedback(WGVerb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -683,6 +700,7 @@ static PyMethodDef WGVerb_methods[] = {
{"play", (PyCFunction)WGVerb_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"out", (PyCFunction)WGVerb_out, METH_VARARGS|METH_KEYWORDS, "Starts computing and sends sound to soundcard channel speficied by argument."},
{"stop", (PyCFunction)WGVerb_stop, METH_NOARGS, "Stops computing."},
+{"reset", (PyCFunction)WGVerb_reset, METH_NOARGS, "Reset the delay line."},
{"setFeedback", (PyCFunction)WGVerb_setFeedback, METH_O, "Sets feedback value between 0 -> 1."},
{"setCutoff", (PyCFunction)WGVerb_setCutoff, METH_O, "Sets lowpass filter cutoff."},
{"setMix", (PyCFunction)WGVerb_setMix, METH_O, "Sets balance between dry and wet signals."},
@@ -697,7 +715,7 @@ static PyNumberMethods WGVerb_as_number = {
(binaryfunc)WGVerb_add, /*nb_add*/
(binaryfunc)WGVerb_sub, /*nb_subtract*/
(binaryfunc)WGVerb_multiply, /*nb_multiply*/
-(binaryfunc)WGVerb_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -711,16 +729,16 @@ static PyNumberMethods WGVerb_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)WGVerb_inplace_add, /*inplace_add*/
(binaryfunc)WGVerb_inplace_sub, /*inplace_subtract*/
(binaryfunc)WGVerb_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)WGVerb_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -729,15 +747,14 @@ static PyNumberMethods WGVerb_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)WGVerb_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)WGVerb_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject WGVerbType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.WGVerb_base", /*tp_name*/
sizeof(WGVerb), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -745,7 +762,7 @@ sizeof(WGVerb), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&WGVerb_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1446,7 +1463,7 @@ STReverb_dealloc(STReverb* self)
}
free(self->buffer_streams);
STReverb_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -1566,6 +1583,42 @@ static PyObject * STReverb_play(STReverb *self, PyObject *args, PyObject *kwds)
static PyObject * STReverb_stop(STReverb *self) { STOP };
static PyObject *
+STReverb_reset(STReverb *self)
+{
+ int i, j, k, maxsize;
+
+ for (k=0; k<2; k++) {
+ for (i=0; i<8; i++) {
+ self->in_count[k][i] = 0;
+ self->lastSamples[k][i] = 0.0;
+ for (j=0; j<self->size[k][i]; j++) {
+ self->buffer[k][i][j] = 0.;
+ }
+ }
+ }
+ for (k=0; k<NUM_REFS; k++) {
+ self->ref_in_count[k] = 0;
+ maxsize = (int)(first_ref_delays[k] * self->srfac * 4.0 + 0.5);
+ for (i=0; i<(maxsize+1); i++) {
+ self->ref_buffer[k][i] = 0.0;
+ }
+ }
+ for (k=0; k<2; k++) {
+ for (i=0; i<self->bufsize; i++) {
+ self->input_buffer[k][i] = 0.0;
+ }
+ }
+
+ for (i=0; i<(2 * self->bufsize); i++) {
+ self->buffer_streams[i] = 0.0;
+ }
+
+ self->total_signal[0] = self->total_signal[1] = 0.0;
+
+ Py_RETURN_NONE;
+}
+
+static PyObject *
STReverb_setInpos(STReverb *self, PyObject *arg)
{
PyObject *tmp, *streamtmp;
@@ -1774,6 +1827,7 @@ static PyMethodDef STReverb_methods[] = {
{"_getStream", (PyCFunction)STReverb_getStream, METH_NOARGS, "Returns stream object."},
{"play", (PyCFunction)STReverb_play, METH_VARARGS|METH_KEYWORDS, "Starts computing without sending sound to soundcard."},
{"stop", (PyCFunction)STReverb_stop, METH_NOARGS, "Stops computing."},
+{"reset", (PyCFunction)STReverb_reset, METH_NOARGS, "Reset the delay line."},
{"setInpos", (PyCFunction)STReverb_setInpos, METH_O, "Sets position of the source between 0 -> 1."},
{"setRevtime", (PyCFunction)STReverb_setRevtime, METH_O, "Sets reverb duration in seconds."},
{"setCutoff", (PyCFunction)STReverb_setCutoff, METH_O, "Sets lowpass filter cutoff."},
@@ -1784,8 +1838,7 @@ static PyMethodDef STReverb_methods[] = {
};
PyTypeObject STReverbType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.STReverb_base", /*tp_name*/
sizeof(STReverb), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1793,7 +1846,7 @@ sizeof(STReverb), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
@@ -1916,7 +1969,7 @@ STRev_dealloc(STRev* self)
{
pyo_DEALLOC
STRev_clear(self);
- self->ob_type->tp_free((PyObject*)self);
+ Py_TYPE(self)->tp_free((PyObject*)self);
}
static PyObject *
@@ -2003,7 +2056,7 @@ static PyNumberMethods STRev_as_number = {
(binaryfunc)STRev_add, /*nb_add*/
(binaryfunc)STRev_sub, /*nb_subtract*/
(binaryfunc)STRev_multiply, /*nb_multiply*/
-(binaryfunc)STRev_div, /*nb_divide*/
+INITIALIZE_NB_DIVIDE_ZERO /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -2017,16 +2070,16 @@ static PyNumberMethods STRev_as_number = {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
-0, /*nb_coerce*/
+INITIALIZE_NB_COERCE_ZERO /*nb_coerce*/
0, /*nb_int*/
0, /*nb_long*/
0, /*nb_float*/
-0, /*nb_oct*/
-0, /*nb_hex*/
+INITIALIZE_NB_OCT_ZERO /*nb_oct*/
+INITIALIZE_NB_HEX_ZERO /*nb_hex*/
(binaryfunc)STRev_inplace_add, /*inplace_add*/
(binaryfunc)STRev_inplace_sub, /*inplace_subtract*/
(binaryfunc)STRev_inplace_multiply, /*inplace_multiply*/
-(binaryfunc)STRev_inplace_div, /*inplace_divide*/
+INITIALIZE_NB_IN_PLACE_DIVIDE_ZERO /*inplace_divide*/
0, /*inplace_remainder*/
0, /*inplace_power*/
0, /*inplace_lshift*/
@@ -2035,15 +2088,14 @@ static PyNumberMethods STRev_as_number = {
0, /*inplace_xor*/
0, /*inplace_or*/
0, /*nb_floor_divide*/
-0, /*nb_true_divide*/
+(binaryfunc)STRev_div, /*nb_true_divide*/
0, /*nb_inplace_floor_divide*/
-0, /*nb_inplace_true_divide*/
+(binaryfunc)STRev_inplace_div, /*nb_inplace_true_divide*/
0, /* nb_index */
};
PyTypeObject STRevType = {
-PyObject_HEAD_INIT(NULL)
-0, /*ob_size*/
+PyVarObject_HEAD_INIT(NULL, 0)
"_pyo.STRev_base", /*tp_name*/
sizeof(STRev), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -2051,7 +2103,7 @@ sizeof(STRev), /*tp_basicsize*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
-0, /*tp_compare*/
+0, /*tp_as_async (tp_compare in Python 2)*/
0, /*tp_repr*/
&STRev_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
diff --git a/utils/E-Pyo.py b/utils/E-Pyo.py
index 203c256..b7c05b9 100755
--- a/utils/E-Pyo.py
+++ b/utils/E-Pyo.py
@@ -5,52 +5,70 @@ E-Pyo is a simple text editor especially configured to edit pyo audio programs.
You can do absolutely everything you want with this piece of software.
-Olivier Belanger - 2012
+Olivier Belanger - 2016
TODO:
- - Fix printing to pdf
- - Output panel close button on OSX (display only)
+ - Fix printing to pdf.
+
"""
+from __future__ import division
from __future__ import with_statement
+from __future__ import print_function
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
+
+import os, inspect, keyword, wx, codecs, subprocess, unicodedata
+import contextlib, shutil, copy, pprint, random, time, threading
+from types import MethodType
from wx.lib.wordwrap import wordwrap
from wx.lib.embeddedimage import PyEmbeddedImage
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 wx.stc as stc
import wx.lib.agw.flatnotebook as FNB
-from pyo import *
+from pyo import * # what do we really need? OBJECTS_TREE, PYO_VERSION
from PyoDoc import ManualFrame
-reload(sys)
-sys.setdefaultencoding("utf-8")
+if sys.version_info[0] < 3:
+ from StringIO import StringIO
+ unicode_t = unicode
+ reload(sys)
+ sys.setdefaultencoding("utf-8")
+else:
+ from io import StringIO as StringIO
+ unicode_t = str
+
+if "phoenix" in wx.version():
+ from wx.adv import AboutDialogInfo, AboutBox
+ from wx import ComboCtrl
+ from wx import ComboPopup
+ def packItemData(obj):
+ return obj
+ def unpackItemData(obj):
+ return obj
+else:
+ from wx import AboutDialogInfo, AboutBox
+ from wx.combo import ComboCtrl
+ from wx.combo import ComboPopup
+ def packItemData(obj):
+ return wx.TreeItemData(obj)
+ def unpackItemData(obj):
+ return obj.GetData()
+ wx.QueueEvent = wx.PostEvent
################## SETUP ##################
PLATFORM = sys.platform
+
+# Not sure if ENCODING stuff is needed anymore with python3/wxpython phoenix.
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',
+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'
@@ -63,26 +81,13 @@ WIN_APP_BUNDLED = False
def stdoutIO(stdout=None):
old = sys.stdout
if stdout is None:
- stdout = StringIO.StringIO()
+ stdout = StringIO()
sys.stdout = stdout
yield stdout
sys.stdout = old
-def convert_line_endings(temp, mode):
- #modes: 0 - Unix, 1 - Mac, 2 - DOS
- if mode == 0:
- temp = string.replace(temp, '\r\n', '\n')
- temp = string.replace(temp, '\r', '\n')
- elif mode == 1:
- temp = string.replace(temp, '\r\n', '\r')
- temp = string.replace(temp, '\n', '\r')
- elif mode == 2:
- import re
- temp = re.sub("\r(?!\n)|(?<!\r)\n", "\r\n", temp)
- return temp
-
def ensureNFD(unistr):
- if PLATFORM in ['linux2', 'win32']:
+ if PLATFORM == 'win32' or PLATFORM.startswith('linux'):
encodings = [DEFAULT_ENCODING, ENCODING,
'cp1252', 'iso-8859-1', 'utf-16']
format = 'NFC'
@@ -91,7 +96,7 @@ def ensureNFD(unistr):
'macroman', 'iso-8859-1', 'utf-16']
format = 'NFC'
decstr = unistr
- if type(decstr) != UnicodeType:
+ if type(decstr) != unicode_t:
for encoding in encodings:
try:
decstr = decstr.decode(encoding)
@@ -100,7 +105,7 @@ def ensureNFD(unistr):
continue
except:
decstr = "UnableToDecodeString"
- print "Unicode encoding not in a recognized format..."
+ print("Unicode encoding not in a recognized format...")
break
if decstr == "UnableToDecodeString":
return unistr
@@ -120,7 +125,10 @@ def toSysEncoding(unistr):
def hex_to_rgb(value):
value = value.lstrip('#')
lv = len(value)
- return tuple(int(value[i:i+lv/3], 16) for i in range(0, lv, lv/3))
+ return tuple(int(value[i:i+lv // 3], 16) for i in range(0, lv, lv // 3))
+
+LOWERCASE = 'abcdefghijklmnopqrstuvwxyz'
+UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
################## Paths ##################
TEMP_PATH = os.path.join(os.path.expanduser('~'), '.epyo')
@@ -135,13 +143,15 @@ if not os.path.isfile(PREFERENCES_PATH):
epyo_prefs = {}
with open(PREFERENCES_PATH, "r") as f:
text = f.read()
-exec text in locals()
+spos = text.find("=")
+dictext = text[spos+1:]
+epyo_prefs = eval(dictext)
PREFERENCES = copy.deepcopy(epyo_prefs)
tmp_version = PREFERENCES.get("version", "no_version_pref")
if tmp_version != APP_VERSION:
tmp_version = APP_VERSION
- print "Erasing preferences..."
+ print("Erasing preferences...")
shutil.rmtree(os.path.join(TEMP_PATH, "doc"), True)
PREFERENCES = {}
PREFERENCES["version"] = tmp_version
@@ -156,11 +166,14 @@ if PLATFORM == "win32" and sys.executable.endswith("E-Pyo.exe"):
if PLATFORM == "darwin" and '/%s.app' % APP_NAME in os.getcwd():
OSX_APP_BUNDLED = True
-
+
# 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", sys.executable)
+ # This way of finding the python executable assume that python is in the PATH variable.
+ proc = subprocess.Popen('python -c "import sys; print(sys.executable)"', shell=False,
+ universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ WHICH_PYTHON = proc.communicate()[0][:-1]
else:
WHICH_PYTHON = PREFERENCES.get("which_python", "")
INSTALLATION_ERROR_MESSAGE = ""
@@ -168,15 +181,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, universal_newlines=True, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
WHICH_PYTHON = proc.communicate()[0][:-1]
elif PLATFORM == "darwin":
- proc = subprocess.Popen(["which python"], shell=True,
+ proc = subprocess.Popen(["which python"], shell=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
WHICH_PYTHON = proc.communicate()[0][:-1]
- elif PLATFORM == "linux2":
- proc = subprocess.Popen(["which python"], shell=True,
+ elif PLATFORM.startswith("linux"):
+ proc = subprocess.Popen(["which python"], shell=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
WHICH_PYTHON = proc.communicate()[0][:-1]
else:
@@ -190,8 +204,11 @@ if WHICH_PYTHON == "":
if os.path.isfile("C:\Python2%d\python.exe" % i):
WHICH_PYTHON = "C:\Python2%d\python.exe" % i
break
+ ########################
if WHICH_PYTHON == "":
- INSTALLATION_ERROR_MESSAGE = "Python 2.x doesn't seem to be installed on this computer. Check your Python installation and try again."
+ INSTALLATION_ERROR_MESSAGE = ("Python 2.x doesn't seem to be installed "
+ "on this computer. Check your Python "
+ "installation and try again.")
# Check for WxPython / Pyo installation and architecture #
if OSX_APP_BUNDLED:
@@ -200,35 +217,57 @@ if OSX_APP_BUNDLED:
tmpexecpath = os.environ["EXECUTABLEPATH"]
tmprscpath = os.environ["RESOURCEPATH"]
tmpargv0 = os.environ["ARGVZERO"]
- cmd = 'export -n PYTHONHOME PYTHONPATH EXECUTABLEPATH RESOURCEPATH ARGVZERO;env;%s -c "import pyo";export PYTHONHOME=%s;export PYTHONPATH=%s;export EXECUTABLEPATH=%s;export RESOURCEPATH=%s;export ARGVZERO=%s' % (WHICH_PYTHON, tmphome, tmppath, tmpexecpath, tmprscpath, tmpargv0)
- cmd2 = 'export -n PYTHONHOME PYTHONPATH EXECUTABLEPATH RESOURCEPATH ARGVZERO;env;%s -c "import wx";export PYTHONHOME=%s;export PYTHONPATH=%s;export EXECUTABLEPATH=%s;export RESOURCEPATH=%s;export ARGVZERO=%s' % (WHICH_PYTHON, tmphome, tmppath, tmpexecpath, tmprscpath, tmpargv0)
+ cmd = ('export -n PYTHONHOME PYTHONPATH EXECUTABLEPATH RESOURCEPATH ARGVZERO;'
+ 'env;%s -c "import pyo";export PYTHONHOME=%s;export PYTHONPATH=%s;'
+ 'export EXECUTABLEPATH=%s;export RESOURCEPATH=%s;export ARGVZERO=%s' %
+ (WHICH_PYTHON, tmphome, tmppath, tmpexecpath, tmprscpath, tmpargv0))
+ cmd2 = ('export -n PYTHONHOME PYTHONPATH EXECUTABLEPATH RESOURCEPATH ARGVZERO;'
+ 'env;%s -c "import wx";export PYTHONHOME=%s;export PYTHONPATH=%s;'
+ 'export EXECUTABLEPATH=%s;export RESOURCEPATH=%s;export ARGVZERO=%s' %
+ (WHICH_PYTHON, tmphome, tmppath, tmpexecpath, tmprscpath, tmpargv0))
else:
cmd = '%s -c "import pyo"' % WHICH_PYTHON
cmd2 = '%s -c "import wx"' % WHICH_PYTHON
proc = subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
IMPORT_PYO_STDOUT, IMPORT_PYO_STDERR = proc.communicate()
+IMPORT_PYO_STDOUT = ensureNFD(IMPORT_PYO_STDOUT)
+IMPORT_PYO_STDERR = ensureNFD(IMPORT_PYO_STDERR)
if "ImportError" in IMPORT_PYO_STDERR:
if "No module named" in IMPORT_PYO_STDERR:
- INSTALLATION_ERROR_MESSAGE = "Pyo is not installed in the current Python installation. Audio programs won't run.\n\nCurrent Python path: %s\n" % WHICH_PYTHON
- elif "no appropriate 64-bit architecture" in IMPORT_PYO_STDERR or "but wrong architecture" in IMPORT_PYO_STDERR:
+ INSTALLATION_ERROR_MESSAGE = ("Pyo is not installed in the current Python "
+ "installation. Audio programs won't run.\n\n"
+ "Current Python path: %s\n" % WHICH_PYTHON)
+ elif ("no appropriate 64-bit architecture" in IMPORT_PYO_STDERR
+ or "but wrong architecture" in IMPORT_PYO_STDERR):
CALLER_NEED_TO_INVOKE_32_BIT = True
- INSTALLATION_ERROR_MESSAGE = "The current Python installation is running in 64-bit mode but pyo installation is 32-bit.\n\n"
+ INSTALLATION_ERROR_MESSAGE = ("The current Python installation is running "
+ "in 64-bit mode but pyo installation is 32-bit.\n\n")
if PLATFORM == "darwin":
- INSTALLATION_ERROR_MESSAGE += "'VERSIONER_PYTHON_PREFER_32_BIT=yes' will be invoked before calling python executable.\n\n"
+ INSTALLATION_ERROR_MESSAGE += ("'VERSIONER_PYTHON_PREFER_32_BIT=yes' "
+ "will be invoked before calling python "
+ "executable.\n\n")
INSTALLATION_ERROR_MESSAGE += "Current Python path: %s\n" % WHICH_PYTHON
else:
proc = subprocess.Popen([cmd2], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
IMPORT_WX_STDOUT, IMPORT_WX_STDERR = proc.communicate()
+ IMPORT_WX_STDOUT = ensureNFD(IMPORT_WX_STDOUT)
+ IMPORT_WX_STDERR = ensureNFD(IMPORT_WX_STDERR)
if "ImportError" in IMPORT_WX_STDERR:
if "No module named" in IMPORT_WX_STDERR:
- INSTALLATION_ERROR_MESSAGE = "WxPython is not installed in the current Python installation. It is needed by pyo to show graphical display.\n\nCurrent Python path: %s\n" % WHICH_PYTHON
+ INSTALLATION_ERROR_MESSAGE = ("WxPython is not installed in the current "
+ "Python installation. It is needed by pyo "
+ "to show graphical display.\n\nCurrent "
+ "Python path: %s\n" % WHICH_PYTHON)
elif "no appropriate 64-bit architecture" in IMPORT_WX_STDERR:
CALLER_NEED_TO_INVOKE_32_BIT = True
- INSTALLATION_ERROR_MESSAGE = "The current Python installation is running in 64-bit mode but WxPython installation is 32-bit.\n\n"
+ INSTALLATION_ERROR_MESSAGE = ("The current Python installation is running in "
+ "64-bit mode but WxPython installation is 32-bit.\n\n")
if PLATFORM == "darwin":
- INSTALLATION_ERROR_MESSAGE += "'VERSIONER_PYTHON_PREFER_32_BIT=yes' will be invoked before calling python executable.\n\n"
+ INSTALLATION_ERROR_MESSAGE += ("'VERSIONER_PYTHON_PREFER_32_BIT=yes' "
+ "will be invoked before calling python "
+ "executable.\n\n")
INSTALLATION_ERROR_MESSAGE += "Current Python path: %s\n" % WHICH_PYTHON
-
+
if OSX_APP_BUNDLED:
EXAMPLE_PATH = os.path.join(os.getcwd(), "examples")
elif WIN_APP_BUNDLED:
@@ -288,7 +327,7 @@ if not os.path.isdir(STYLES_PATH):
DEFAULT_STYLE = os.path.join(STYLES_PATH, "Default")
if not os.path.isfile(os.path.join(STYLES_PATH, "Default")):
shutil.copy(os.path.join(os.getcwd(), "styles", "Default"), DEFAULT_STYLE)
-if PREFERENCES.has_key("pref_style"):
+if "pref_style" in PREFERENCES:
PREF_STYLE = os.path.join(ensureNFD(STYLES_PATH), PREFERENCES["pref_style"])
else:
PREF_STYLE = DEFAULT_STYLE
@@ -324,7 +363,7 @@ s.gui(locals())
CECILIA5_TEMPLATE = '''class Module(BaseModule):
"""
Module's documentation
-
+
"""
def __init__(self):
BaseModule.__init__(self)
@@ -355,7 +394,7 @@ ZYNE_TEMPLATE = '''class MySynth(BaseSynth):
MODULES = {
- "MySynth": { "title": "- Generic module -", "synth": MySynth,
+ "MySynth": { "title": "- Generic module -", "synth": MySynth,
"p1": ["Ratio", 0.5, 0, 10, False, False],
"p2": ["Index", 5, 0, 20, False, False],
"p3": ["LP cutoff", 4000, 100, 15000, False, True]
@@ -379,18 +418,18 @@ class MyFrame(wx.Frame):
self.freqPort = SigTo(value=250, time=0.05, init=250)
self.sine = Sine(freq=self.freqPort, mul=0.3).mix(2).out()
- self.onOffText = wx.StaticText(self.panel, id=-1, label="Audio",
+ self.onOffText = wx.StaticText(self.panel, id=-1, label="Audio",
pos=(28,10), size=wx.DefaultSize)
- self.onOff = wx.ToggleButton(self.panel, id=-1, label="on / off",
+ self.onOff = wx.ToggleButton(self.panel, id=-1, label="on / off",
pos=(10,28), size=wx.DefaultSize)
self.onOff.Bind(wx.EVT_TOGGLEBUTTON, self.handleAudio)
- self.frTxt = wx.StaticText(self.panel, id=-1, label="Freq: 250.00",
+ self.frTxt = wx.StaticText(self.panel, id=-1, label="Freq: 250.00",
pos=(140,60), size=(250,50))
- self.freq = wx.Slider(self.panel, id=-1, value=25000, minValue=5000,
+ self.freq = wx.Slider(self.panel, id=-1, value=25000, minValue=5000,
maxValue=1000000, pos=(140,82), size=(250,50))
self.freq.Bind(wx.EVT_SLIDER, self.changeFreq)
-
+
def handleAudio(self, evt):
if evt.GetInt() == 1:
s.start()
@@ -401,7 +440,7 @@ class MyFrame(wx.Frame):
x = evt.GetInt() * 0.01
self.frTxt.SetLabel("Freq: %.2f" % x)
self.freqPort.value = x
-
+
app = wx.App(False)
mainFrame = MyFrame(None, title='Simple App', pos=(100,100), size=(500,300))
mainFrame.Show()
@@ -431,14 +470,14 @@ RADIOPYO_TEMPLATE = '''#!/usr/bin/env python
"""
Template for a RadioPyo song (version 1.0).
-A RadioPyo song is a musical python script using the python-pyo
+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/
+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
+ 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
@@ -485,10 +524,10 @@ if not READY:
s.gui(locals())
'''
-TEMPLATE_NAMES = {98: "Header", 97: "Pyo", 96: "WxPython", 95: "Cecilia5",
+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,
+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")
@@ -496,7 +535,7 @@ 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")])
+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:
@@ -517,7 +556,7 @@ RAISE_COMP = ''' Exception("`An exception occurred...`")
TRY_COMP = ''':
`expression`
except:
- `print "Ouch!"`
+ `print("Ouch!")`
'''
IF_COMP = ''' `expression1`:
`pass`
@@ -537,17 +576,19 @@ CLASS_COMP = ''' `Cname`:
`pass`
'''
FOR_COMP = """ i in range(`10`):
- `print i`
+ `print(i)`
"""
WHILE_COMP = """ `i` `>` `0`:
`i -= 1`
- `print i`
+ `print(i)`
"""
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,
+
+# TODO: Python 3 syntax (if possible, compatible with python 2)
+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 ##################
@@ -785,8 +826,8 @@ KEY_COMMANDS = {
}
############## Allowed Extensions ##############
-ALLOWED_EXT = PREFERENCES.get("allowed_ext",
- ["py", "c5", "txt", "", "c", "h", "cpp", "hpp", "zy",
+ALLOWED_EXT = PREFERENCES.get("allowed_ext",
+ ["py", "c5", "txt", "", "c", "h", "cpp", "hpp", "zy", "bat",
"sh", "rst", "iss", "sg", "md", "jsfx-inc", "lua", "css"])
############## Pyo keywords ##############
@@ -827,27 +868,29 @@ else:
STYLES_GENERALS = ['default', 'background', 'selback', 'caret']
-STYLES_TEXT_COMP = ['comment', 'commentblock', 'number', 'operator', 'string',
- 'triple', 'keyword', 'pyokeyword', 'class', 'function',
+STYLES_TEXT_COMP = ['comment', 'commentblock', 'number', 'operator', 'string',
+ 'triple', 'keyword', 'pyokeyword', 'class', 'function',
'linenumber']
-STYLES_INTER_COMP = ['marginback', 'foldmarginback', 'markerfg', 'markerbg',
+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',
+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',
+ '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()
-exec text in locals()
+spos = text.find("=")
+dictext = text[spos+1:]
+style = eval(dictext)
try:
STYLES = copy.deepcopy(style)
except:
@@ -873,11 +916,11 @@ except:
'selback': {'colour': '#C0DFFF'},
'string': {'bold': 0, 'colour': '#036A07', 'italic': 0, 'underline': 0},
'triple': {'bold': 0, 'colour': '#03BA07', 'italic': 0, 'underline': 0}}
-if not STYLES.has_key('face'):
+if 'face' not in STYLES:
STYLES['face'] = DEFAULT_FONT_FACE
-if not STYLES.has_key('size'):
+if 'size' not in STYLES:
STYLES['size'] = FONT_SIZE
-if not STYLES.has_key('size2'):
+if 'size2' not in STYLES:
STYLES['size2'] = FONT_SIZE2
STYLES_PREVIEW_TEXT = '''# Comment
@@ -906,7 +949,7 @@ class DataEvent(wx.PyEvent):
self.SetEventType(wxDATA_EVENT)
self.data = data
- def Clone (self):
+ def Clone (self):
self.__class__ (self.GetId())
class RunningThread(threading.Thread):
@@ -917,7 +960,7 @@ class RunningThread(threading.Thread):
self.event_receiver = event_receiver
self.terminated = False
self.pid = None
-
+
def setFileName(self, filename):
self.filename = filename
@@ -930,7 +973,7 @@ class RunningThread(threading.Thread):
try:
os.system("Taskkill /PID %d /F" % self.proc.pid)
except:
- print '"Taskkill" does not succeed to kill the process %d.' % self.proc.pid
+ print('"Taskkill" does not succeed to kill the process %d.' % self.proc.pid)
else:
self.proc.terminate()
if self.proc.poll() == None:
@@ -942,42 +985,48 @@ class RunningThread(threading.Thread):
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 -u "%s"' % (prelude, SET_32_BIT_ARCH, WHICH_PYTHON, self.path)],
- shell=True, cwd=self.cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ universal_newlines=True, shell=True, cwd=self.cwd,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
else:
- self.proc = subprocess.Popen(['%s%s -u "%s"' % (prelude, WHICH_PYTHON, self.path)], cwd=self.cwd,
- shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ self.proc = subprocess.Popen(['%s%s -u "%s"' % (prelude, WHICH_PYTHON, self.path)],
+ cwd=self.cwd, universal_newlines=True, shell=True,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
elif PLATFORM == "darwin":
if CALLER_NEED_TO_INVOKE_32_BIT:
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)
+ universal_newlines=True, shell=True, cwd=self.cwd,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
else:
self.proc = subprocess.Popen(['%s -u "%s"' % (WHICH_PYTHON, self.path)], cwd=self.cwd,
- shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ universal_newlines=True, shell=True, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
elif PLATFORM == "win32":
- self.proc = subprocess.Popen([WHICH_PYTHON, "-u", self.path], cwd=self.cwd, shell=False, # TODO: shell=True ?
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ self.proc = subprocess.Popen([WHICH_PYTHON, "-u", self.path], cwd=ensureNFD(self.cwd),
+ universal_newlines=True, shell=False, stdout=subprocess.PIPE,
+ stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
else:
- self.proc = subprocess.Popen([WHICH_PYTHON, "-u", self.path], cwd=self.cwd,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ self.proc = subprocess.Popen([WHICH_PYTHON, "-u", self.path], cwd=self.cwd, universal_newlines=True,
+ 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()))
+ ltime = time.strftime('"%d %b %Y %H:%M:%S"', time.localtime())
+ header = '=== Output log of process "%s", launched: %s ===\n' % (self.filename, ltime)
data_event = DataEvent({"log": header, "pid": self.pid, "filename": self.filename, "active": True})
- wx.PostEvent(self.event_receiver, data_event)
+ wx.QueueEvent(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 + str(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)
+ wx.QueueEvent(self.event_receiver, data_event)
sys.stdout.flush()
- time.sleep(.025)
+ time.sleep(.01)
stdout, stderr = self.proc.communicate()
output = ""
if stdout is not None:
- output = output + stdout
+ output = output + str(stdout)
if stderr is not None:
- output = output + stderr
+ output = output + str(stderr)
output = output.replace(">>> ", "").replace("... ", "")
if "StartNotification name = default" in output:
output = output.replace("StartNotification name = default", "")
@@ -1005,9 +1054,9 @@ class RunningThread(threading.Thread):
pass
if self.terminated:
output = output + "\n=== Process killed. ==="
- data_event = DataEvent({"log": output, "pid": self.pid,
+ data_event = DataEvent({"log": output, "pid": self.pid,
"filename": self.filename, "active": False})
- wx.PostEvent(self.event_receiver, data_event)
+ wx.QueueEvent(self.event_receiver, data_event)
class BackgroundServerThread(threading.Thread):
def __init__(self, cwd, event_receiver):
@@ -1033,38 +1082,37 @@ class BackgroundServerThread(threading.Thread):
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)
+ self.proc = subprocess.Popen([WHICH_PYTHON, '-i', '-u', os.path.join(TEMP_PATH, "background_server.py")],
+ shell=True, cwd=ensureNFD(self.cwd), stdout=subprocess.PIPE, bufsize=0,
+ universal_newlines=True, 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',
+ self.proc = subprocess.Popen(["%s -i -u %s" % (WHICH_PYTHON, os.path.join(TEMP_PATH, "background_server.py"))],
+ bufsize=0, cwd=self.cwd, shell=True, stdout=subprocess.PIPE, universal_newlines=True,
+ stderr=subprocess.STDOUT, stdin=subprocess.PIPE)
+
+ ltime = time.strftime('"%d %b %Y %H:%M:%S"', time.localtime())
+ header = '=== Output log of background server, launched: %s ===\n' % ltime
+ data_event = DataEvent({"log": header, "pid": self.pid,
+ "filename": 'background_server.py',
"active": True})
- wx.PostEvent(self.event_receiver, data_event)
+ wx.QueueEvent(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 + str(line)
log = log.replace(">>> ", "").replace("... ", "")
- data_event = DataEvent({"log": log, "pid": self.pid,
- "filename": 'background_server.py',
+ data_event = DataEvent({"log": log, "pid": self.pid,
+ "filename": 'background_server.py',
"active": True})
- wx.PostEvent(self.event_receiver, data_event)
+ wx.QueueEvent(self.event_receiver, data_event)
sys.stdout.flush()
- time.sleep(.025)
+ time.sleep(.01)
stdout, stderr = self.proc.communicate()
output = ""
if stdout is not None:
- output = output + stdout
+ output = output + str(stdout)
if stderr is not None:
- output = output + stderr
+ output = output + str(stderr)
output = output.replace(">>> ", "").replace("... ", "")
if "StartNotification name = default" in output:
output = output.replace("StartNotification name = default", "")
@@ -1092,14 +1140,14 @@ class BackgroundServerThread(threading.Thread):
pass
if self.terminated:
output = output + "\n=== Process killed. ==="
- data_event = DataEvent({"log": output, "pid": self.pid,
- "filename": 'background_server.py',
+ data_event = DataEvent({"log": output, "pid": self.pid,
+ "filename": 'background_server.py',
"active": False})
- wx.PostEvent(self.event_receiver, data_event)
+ wx.QueueEvent(self.event_receiver, data_event)
class KeyCommandsFrame(wx.Frame):
def __init__(self, parent):
- wx.Frame.__init__(self, parent, wx.ID_ANY,
+ wx.Frame.__init__(self, parent, wx.ID_ANY,
title="Editor Key Commands List", size=(650,550))
self.menuBar = wx.MenuBar()
menu1 = wx.Menu()
@@ -1130,7 +1178,7 @@ class KeyCommandsFrame(wx.Frame):
self.Hide()
class EditorPreview(stc.StyledTextCtrl):
- def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize,
+ 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)
@@ -1153,7 +1201,6 @@ class EditorPreview(stc.StyledTextCtrl):
self.SetProperty("fold", "1")
self.SetProperty("tab.timmy.whinge.level", "1")
self.SetMargins(5,5)
- self.SetUseAntiAliasing(True)
self.SetEdgeColour(STYLES["lineedge"]['colour'])
self.SetEdgeMode(stc.STC_EDGE_LINE)
self.SetEdgeColumn(60)
@@ -1161,12 +1208,12 @@ class EditorPreview(stc.StyledTextCtrl):
self.SetMarginWidth(0, 12)
self.SetMarginMask(0, ~wx.stc.STC_MASK_FOLDERS)
self.SetMarginSensitive(0, True)
-
+
self.SetMarginType(1, stc.STC_MARGIN_NUMBER)
self.SetMarginWidth(1, 28)
self.SetMarginMask(1, 0)
self.SetMarginSensitive(1, False)
-
+
self.SetMarginType(2, stc.STC_MARGIN_SYMBOL)
self.SetMarginWidth(2, 12)
self.SetMarginMask(2, stc.STC_MASK_FOLDERS)
@@ -1187,7 +1234,7 @@ class EditorPreview(stc.StyledTextCtrl):
st = "face:%s,fore:%s,size:%s" % (STYLES['face'], STYLES[forekey]['colour'], STYLES['size'])
if backkey:
st += ",back:%s" % STYLES[backkey]['colour']
- if STYLES[forekey].has_key('bold'):
+ if 'bold' in STYLES[forekey]:
if STYLES[forekey]['bold']:
st += ",bold"
if STYLES[forekey]['italic']:
@@ -1197,7 +1244,7 @@ class EditorPreview(stc.StyledTextCtrl):
return st
self.StyleSetSpec(stc.STC_STYLE_DEFAULT, buildStyle('default', 'background'))
- self.StyleClearAll() # Reset all to be like the default
+ self.StyleClearAll() # Reset all to be like the default
self.MarkerDefine(0, stc.STC_MARK_SHORTARROW, STYLES['markerbg']['colour'], STYLES['markerbg']['colour'])
self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_BOXMINUS, STYLES['markerfg']['colour'], STYLES['markerbg']['colour'])
self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_BOXPLUS, STYLES['markerfg']['colour'], STYLES['markerbg']['colour'])
@@ -1255,18 +1302,18 @@ class ComponentPanel(scrolled.ScrolledPanel):
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
+ self.bTogRefs[btog] = component
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)
+ box.Add(itog, 0, wx.TOP|wx.ALIGN_RIGHT, 1)
itog.Bind(wx.EVT_TOGGLEBUTTON, self.OnIToggleButton)
- self.iTogRefs[itog] = component
+ self.iTogRefs[itog] = component
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)
+ box.Add(utog, 0, wx.TOP|wx.ALIGN_RIGHT, 1)
utog.Bind(wx.EVT_TOGGLEBUTTON, self.OnUToggleButton)
- self.uTogRefs[utog] = component
- box.AddSpacer(20)
+ self.uTogRefs[utog] = component
+ box.AddSpacer(20)
selector = csel.ColourSelect(self, -1, "", hex_to_rgb(STYLES[component]['colour']), size=(20,20))
box.Add(selector, 0, wx.TOP|wx.ALIGN_RIGHT, 1)
selector.Bind(csel.EVT_COLOURSELECT, self.OnSelectColour)
@@ -1374,10 +1421,10 @@ class ColourEditor(wx.Frame):
facelist = enum.GetFacenames()
facelist.sort()
- 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']) ]
+ 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 = {}
@@ -1405,7 +1452,7 @@ class ColourEditor(wx.Frame):
mainSizer.Add(self.components, 1, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)
mainSizer.Add(wx.StaticLine(self.panel), 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 10)
-
+
faceBox = wx.BoxSizer(wx.HORIZONTAL)
faceLabel = wx.StaticText(self.panel, wx.ID_ANY, "Font Face:")
faceBox.Add(faceLabel, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
@@ -1470,13 +1517,15 @@ class ColourEditor(wx.Frame):
self.cur_style = stl
with open(os.path.join(ensureNFD(STYLES_PATH), stl)) as f:
text = f.read()
- exec text in locals()
+ spos = text.find("=")
+ dictext = text[spos+1:]
+ style = eval(dictext)
STYLES = copy.deepcopy(style)
- if not STYLES.has_key('face'):
+ if 'face' not in STYLES:
STYLES['face'] = DEFAULT_FONT_FACE
- if not STYLES.has_key('size'):
+ if 'size' not in STYLES:
STYLES['size'] = FONT_SIZE
- if not STYLES.has_key('size2'):
+ if 'size2' not in STYLES:
STYLES['size2'] = FONT_SIZE2
self.editorPreview.setStyle()
for but, name in self.buttonRefs.items():
@@ -1520,7 +1569,7 @@ class SearchProjectPanel(scrolled.ScrolledPanel):
self.Bind(wx.EVT_BUTTON, self.onOpenFile, id=BUTID)
BUTID += 1
fileText = wx.StaticText(self, wx.ID_ANY, label="File : %s" % file)
- off = (but.GetSize()[1] - textY) / 2
+ off = (but.GetSize()[1] - textY) // 2
box.Add(fileText, 1, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, off)
mainSizer.Add(box, 1, wx.LEFT|wx.RIGHT|wx.EXPAND, 10)
for i in range(len(self.dict[file][0])):
@@ -1539,7 +1588,7 @@ class SearchProjectPanel(scrolled.ScrolledPanel):
for f in self.files:
num_rows += len(self.dict[f][0])
self.SetMaxSize((-1, max(h*num_rows, self.GetSize()[1])))
-
+
def onOpenFile(self, evt):
filename = self.root + self.files[evt.GetId() - 25000]
self.GetParent().GetParent().panel.addPage(filename)
@@ -1576,35 +1625,40 @@ class SnippetTree(wx.Panel):
toolbarbox = wx.BoxSizer(wx.HORIZONTAL)
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")
+
+ if "phoenix" not in wx.version():
+ 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")
+ else:
+ self.toolbar.AddTool(SNIPPET_ADD_FOLDER_ID, "Add Category", folder_add_bmp, shortHelp="Add a New Category")
+ self.toolbar.AddTool(SNIPPET_DEL_FILE_ID, "Delete", file_add_bmp, shortHelp="Delete Snippet or Category")
+
self.toolbar.EnableTool(SNIPPET_DEL_FILE_ID, False)
self.toolbar.Realize()
toolbarbox.Add(self.toolbar, 1, wx.ALIGN_LEFT | wx.EXPAND, 0)
- wx.EVT_TOOL(self, SNIPPET_ADD_FOLDER_ID, self.onAdd)
- wx.EVT_TOOL(self, SNIPPET_DEL_FILE_ID, self.onDelete)
+ self.Bind(wx.EVT_TOOL, self.onAdd, id=SNIPPET_ADD_FOLDER_ID)
+ self.Bind(wx.EVT_TOOL, self.onDelete, id=SNIPPET_DEL_FILE_ID)
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)
if wx.Platform == '__WXMAC__':
- self.tree.SetFont(wx.Font(11, wx.ROMAN, wx.NORMAL, wx.NORMAL, face=snip_faces['face']))
+ self.tree.SetFont(wx.Font(11, wx.ROMAN, wx.NORMAL, wx.NORMAL, False, snip_faces['face']))
else:
- self.tree.SetFont(wx.Font(8, wx.ROMAN, wx.NORMAL, wx.NORMAL, face=snip_faces['face']))
+ self.tree.SetFont(wx.Font(8, wx.ROMAN, wx.NORMAL, wx.NORMAL, False, snip_faces['face']))
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))
+ 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))
self.tree.SetImageList(self.il)
- self.tree.SetSpacing(12)
self.tree.SetIndent(6)
self.root = self.tree.AddRoot("EPyo_Snippet_tree", self.fldridx, self.fldropenidx, None)
@@ -1788,7 +1842,7 @@ class SnippetFrame(wx.Frame):
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)
@@ -1834,11 +1888,10 @@ class SnippetFrame(wx.Frame):
self.category_name = category
with codecs.open(os.path.join(ensureNFD(SNIPPETS_PATH), self.category_name, self.snippet_name), "r", encoding="utf-8") as f:
text = f.read()
- exec text in locals()
- try:
- self.entry.SetTextUTF8(snippet["value"])
- except:
- self.entry.SetText(snippet["value"])
+ spos = text.find("=")
+ dictext = text[spos+1:]
+ snippet = eval(dictext)
+ self.entry.SetText(snippet["value"])
if snippet["shortcut"]:
self.short.SetValue(snippet["shortcut"])
self.short.SetForegroundColour("#000000")
@@ -1847,7 +1900,7 @@ class SnippetFrame(wx.Frame):
self.short.SetForegroundColour("#AAAAAA")
def onSave(self, evt):
- dlg = wx.SingleChoiceDialog(self, 'Choose the Snippet Category',
+ dlg = wx.SingleChoiceDialog(self, 'Choose the Snippet Category',
'Snippet Category', SNIPPETS_CATEGORIES, wx.OK)
dlg.SetSize((250,300))
dlg.CenterOnParent()
@@ -1865,7 +1918,7 @@ class SnippetFrame(wx.Frame):
short = self.short.GetValue()
if short == "Type your shortcut...":
short = ""
- dic = {'shortcut': short, 'value': self.entry.GetTextUTF8()}
+ dic = {'shortcut': short, 'value': self.entry.GetText()}
with codecs.open(os.path.join(SNIPPETS_PATH, category, name), "w", encoding="utf-8") as f:
f.write("snippet = %s" % pprint.pformat(dic))
self.snippet_tree.addItem(name, category)
@@ -1901,7 +1954,7 @@ class SnippetFrame(wx.Frame):
if txt == "":
return
ch = chr(key)
- if ch in string.lowercase:
+ if ch in LOWERCASE:
ch = ch.upper()
txt += ch
self.short.SetValue(txt)
@@ -1910,9 +1963,9 @@ class SnippetFrame(wx.Frame):
else:
evt.Skip()
-class FileSelectorCombo(wx.combo.ComboCtrl):
+class FileSelectorCombo(ComboCtrl):
def __init__(self, *args, **kw):
- wx.combo.ComboCtrl.__init__(self, *args, **kw)
+ ComboCtrl.__init__(self, *args, **kw)
w, h = 12, 14
bmp = wx.EmptyBitmap(w,h)
dc = wx.MemoryDC(bmp)
@@ -1923,14 +1976,18 @@ class FileSelectorCombo(wx.combo.ComboCtrl):
dc.SetBrush(wx.Brush("#444444"))
dc.SetPen(wx.Pen("#444444"))
- dc.DrawPolygon([wx.Point(4,h/2-2), wx.Point(w/2,2), wx.Point(w-4,h/2-2)])
- dc.DrawPolygon([wx.Point(4,h/2+2), wx.Point(w/2,h-2), wx.Point(w-4,h/2+2)])
+ dc.DrawPolygon([wx.Point(4, h // 2 - 2), wx.Point(w // 2, 2), wx.Point(w - 4, h // 2 - 2)])
+ dc.DrawPolygon([wx.Point(4, h // 2 + 2), wx.Point(w // 2, h - 2), wx.Point(w - 4, h // 2 + 2)])
del dc
bmp.SetMaskColour(bgcolor)
self.SetButtonBitmaps(bmp, True)
-class TreeCtrlComboPopup(wx.combo.ComboPopup):
+class TreeCtrlComboPopup(ComboPopup):
+ def __init__(self):
+ ComboPopup.__init__(self)
+ self.tree = None
+
def Init(self):
self.value = None
self.curitem = None
@@ -1949,63 +2006,55 @@ class TreeCtrlComboPopup(wx.combo.ComboPopup):
self.tree.SetFont(font)
self.tree.Bind(wx.EVT_MOTION, self.OnMotion)
self.tree.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
+ return True
def GetControl(self):
return self.tree
- def GetStringValue(self):
- if self.value:
- return self.tree.GetItemText(self.value)
- return ""
-
def OnPopup(self):
self.tree.DeleteAllItems()
- editor = self.GetCombo().GetParent().GetParent().panel.editor
+ if "phoenix" in wx.version():
+ editor = self.GetComboCtrl().GetParent().GetParent().panel.editor
+ else:
+ editor = self.GetCombo().GetParent().GetParent().panel.editor
count = editor.GetLineCount()
for i in range(count):
- text = editor.GetLineUTF8(i)
+ text = editor.GetLine(i)
if text.startswith("class "):
text = text.replace("class ", "")
text = text[0:text.find(":")]
if len(text) > 50:
text = text[:50] + "...)"
- item = self.AddItem(text, None, wx.TreeItemData(i))
+ item = self.AddItem(text, None, packItemData(i))
elif text.startswith("def "):
text = text.replace("def ", "")
text = text[0:text.find(":")]
if len(text) > 50:
text = text[:50] + "...)"
- item = self.AddItem(text, None, wx.TreeItemData(i))
+ item = self.AddItem(text, None, packItemData(i))
elif text.lstrip().startswith("def "):
indent = editor.GetLineIndentation(i)
text = text.lstrip().replace("def ", "")
text = " "*indent + text[0:text.find(":")]
if len(text) > 50:
text = text[:50] + "...)"
- item = self.AddItem(text, None, wx.TreeItemData(i))
+ item = self.AddItem(text, None, packItemData(i))
self.tree.SetSize((400, 500))
def SetStringValue(self, value):
- root = self.tree.GetRootItem()
- if not root:
- return
- found = self.FindItem(root, value)
- if found:
- self.value = found
- self.tree.SelectItem(found)
+ if self.curitem is not None:
+ self.tree.SelectItem(self.curitem)
def GetAdjustedSize(self, minWidth, prefHeight, maxHeight):
return wx.Size(minWidth, min(200, maxHeight))
- def FindItem(self, parentItem, text):
- item, cookie = self.tree.GetFirstChild(parentItem)
- while item:
- if self.tree.GetItemText(item) == text:
- return item
- if self.tree.ItemHasChildren(item):
- item = self.FindItem(item, text)
- item, cookie = self.tree.GetNextChild(parentItem, cookie)
- return wx.TreeItemId();
+ def FindItem(self, *args):
+ "Dummy with variable size args needed to avoid error on both classic and phoenix."
+ return True
+
+ def GetStringValue(self):
+ if self.curitem is not None:
+ return self.tree.GetItemText(self.curitem)
def AddItem(self, value, parent=None, data=None):
if not parent:
@@ -2020,22 +2069,22 @@ class TreeCtrlComboPopup(wx.combo.ComboPopup):
item, flags = self.tree.HitTest(evt.GetPosition())
if item and flags & wx.TREE_HITTEST_ONITEMLABEL:
self.tree.SelectItem(item)
- self.curitem = item
evt.Skip()
def OnLeftDown(self, evt):
item, flags = self.tree.HitTest(evt.GetPosition())
if item and flags & wx.TREE_HITTEST_ONITEMLABEL:
self.curitem = item
- self.value = item
self.Dismiss()
- editor = self.GetCombo().GetParent().GetParent().panel.editor
- line = self.tree.GetPyData(item)
+ if "phoenix" in wx.version():
+ editor = self.GetComboCtrl().GetParent().GetParent().panel.editor
+ else:
+ editor = self.GetCombo().GetParent().GetParent().panel.editor
+ line = unpackItemData(self.tree.GetItemData(item))
editor.GotoLine(line)
- halfNumLinesOnScreen = editor.LinesOnScreen() / 2
+ halfNumLinesOnScreen = editor.LinesOnScreen() // 2
editor.ScrollToLine(line - halfNumLinesOnScreen)
wx.CallAfter(editor.SetFocus)
- evt.Skip()
class MainFrame(wx.Frame):
def __init__(self, parent, ID, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):
@@ -2080,7 +2129,7 @@ class MainFrame(wx.Frame):
self.submenu1 = wx.Menu()
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)
+ menu1.AppendSubMenu(self.submenu1, "New From Template")
self.Bind(wx.EVT_MENU, self.newFromTemplate, id=min(TEMPLATE_NAMES.keys()), id2=max(TEMPLATE_NAMES.keys()))
menu1.Append(wx.ID_OPEN, "Open\tCtrl+O")
self.Bind(wx.EVT_MENU, self.open, id=wx.ID_OPEN)
@@ -2104,7 +2153,7 @@ class MainFrame(wx.Frame):
if ID_OPEN_RECENT > 2000:
for i in range(2000, ID_OPEN_RECENT):
self.Bind(wx.EVT_MENU, self.openRecent, id=i)
- menu1.AppendMenu(1999, "Open Recent...", self.submenu2)
+ menu1.AppendSubMenu(self.submenu2, "Open Recent...")
menu1.AppendSeparator()
menu1.Append(wx.ID_CLOSE, "Close\tCtrl+W")
self.Bind(wx.EVT_MENU, self.close, id=wx.ID_CLOSE)
@@ -2176,7 +2225,7 @@ class MainFrame(wx.Frame):
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.AppendSubMenu(submenublk, "Code Blocks")
menu2.AppendSeparator()
menu2.Append(114, "Auto Complete container syntax", kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_MENU, self.autoCompContainer, id=114)
@@ -2188,7 +2237,7 @@ class MainFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.upperLower, id=170, id2=171)
submenu2.Append(172, "Convert Tabs to Spaces")
self.Bind(wx.EVT_MENU, self.tabsToSpaces, id=172)
- menu2.AppendMenu(-1, "Text Converters", submenu2)
+ menu2.AppendSubMenu(submenu2, "Text Converters")
menu2.AppendSeparator()
menu2.Append(140, "Goto line...\tCtrl+L")
self.Bind(wx.EVT_MENU, self.gotoLine, id=140)
@@ -2297,7 +2346,7 @@ class MainFrame(wx.Frame):
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
- self.menu6.AppendMenu(-1, folder, exmenu)
+ self.menu6.AppendSubMenu(exmenu, folder)
ID_EXAMPLE += 1
self.Bind(wx.EVT_MENU, self.openExample, id=1000, id2=ID_EXAMPLE)
self.menuBar.Append(self.menu6, "Pyo Examples")
@@ -2308,10 +2357,10 @@ class MainFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.openFilters, id=11998)
self.filters_menu.Append(11999, "Rebuild Filters Menu")
self.Bind(wx.EVT_MENU, self.buildFilterMenu, id=11999)
- self.filters_menu.AppendSeparator()
+ self.filters_menu.AppendSeparator()
self.buildFilterMenu()
self.menuBar.Append(self.filters_menu, "Filters")
-
+
windowMenu = wx.Menu()
aEntry = wx.AcceleratorEntry(wx.ACCEL_CTRL, wx.WXK_TAB, 10001)
windowMenu.Append(10001, 'Navigate Tabs Forward\t%s' % aEntry.ToString())
@@ -2338,12 +2387,12 @@ class MainFrame(wx.Frame):
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 = self.status.GetSize()[1] #16
cch = -1
- elif PLATFORM == "linux2":
+ elif PLATFORM.startswith("linux"):
ststyle = wx.TE_PROCESS_ENTER|wx.SIMPLE_BORDER
sth = self.status.GetSize()[1]+1 #20
cch = self.status.GetSize()[1] #21
@@ -2387,7 +2436,7 @@ class MainFrame(wx.Frame):
if PLATFORM == "darwin":
yoff1 = -1
yoff2 = -5
- elif PLATFORM == "linux2":
+ elif PLATFORM.startswith("linux"):
yoff1 = -2
yoff2 = -1
elif PLATFORM == "win32":
@@ -2415,7 +2464,7 @@ class MainFrame(wx.Frame):
self.menu3.SetLabel(299, "Revert Master Document to None")
else:
self.master_document = None
- self.menu3.SetLabel(299, "Set Current Document as Master")
+ self.menu3.SetLabel(299, "Set Current Document as Master")
def StatusOnSize(self, evt):
self.Reposition()
@@ -2423,7 +2472,7 @@ class MainFrame(wx.Frame):
def rebuildStyleMenu(self):
items = self.menu5.GetMenuItems()
for item in items:
- self.menu5.DeleteItem(item)
+ self.menu5.Delete(item.GetId())
ID_STYLE = 500
for st in [f for f in os.listdir(STYLES_PATH) if f[0] != "."]:
self.menu5.Append(ID_STYLE, st, "", wx.ITEM_RADIO)
@@ -2437,7 +2486,7 @@ class MainFrame(wx.Frame):
def reloadSnippetMenu(self):
items = self.menu7.GetMenuItems()
for item in items:
- self.menu7.DeleteItem(item)
+ self.menu7.Delete(item.GetId())
self.makeSnippetMenu()
def makeSnippetMenu(self):
@@ -2449,7 +2498,9 @@ class MainFrame(wx.Frame):
for file in files:
with open(os.path.join(SNIPPETS_PATH, cat, file), "r") as f:
text = f.read()
- exec text in locals()
+ spos = text.find("=")
+ dictext = text[spos+1:]
+ snippet = eval(dictext)
short = snippet["shortcut"]
accel = 0
if "Shift" in short:
@@ -2479,12 +2530,11 @@ class MainFrame(wx.Frame):
submenu.Append(itemId, file)
self.Bind(wx.EVT_MENU, self.insertSnippet, id=itemId)
itemId += 1
- self.menu7.AppendMenu(itemId, cat, submenu)
- itemId += 1
- if accel_entries != []:
- accel_table = wx.AcceleratorTable(accel_entries)
+ self.menu7.AppendSubMenu(submenu, cat)
+ 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)
@@ -2497,7 +2547,7 @@ class MainFrame(wx.Frame):
self.panel.editor.Copy()
def listCopy(self, evt):
- text = self.panel.editor.GetSelectedTextUTF8()
+ text = self.panel.editor.GetSelectedText()
self.pastingList.append(toSysEncoding(text))
def paste(self, evt):
@@ -2511,23 +2561,25 @@ class MainFrame(wx.Frame):
def saveListPaste(self, evt):
if self.pastingList != []:
- dlg = wx.FileDialog(self, message="Save file as ...",
- defaultDir=os.path.expanduser('~'), style=wx.SAVE)
+ dlg = wx.FileDialog(self, message="Save file as ...",
+ defaultDir=os.path.expanduser('~'),
+ style=wx.FD_SAVE)
if dlg.ShowModal() == wx.ID_OK:
path = ensureNFD(dlg.GetPath())
with open(path, "w") as f:
f.write(str(self.pastingList))
def loadListPaste(self, evt):
- dlg = wx.FileDialog(self, message="Choose a file",
- defaultDir=os.path.expanduser("~"), style=wx.OPEN)
+ dlg = wx.FileDialog(self, message="Choose a file",
+ defaultDir=os.path.expanduser("~"),
+ style=wx.FD_OPEN)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
self.pastingList = []
with open(path, "r") as f:
try:
pastingList = eval(f.read())
- if type(pastingList) == ListType:
+ if type(pastingList) == list:
self.pastingList = pastingList
except:
f.seek(0)
@@ -2555,7 +2607,7 @@ class MainFrame(wx.Frame):
if self.ID_FILTERS != 12000:
for i in range(12000, self.ID_FILTERS):
self.filters_menu.Delete(i)
- ID_FILTERS = 12000
+ ID_FILTERS = 12000
with open(FILTERS_FILE, "r") as f:
for line in f.readlines():
if line.startswith("def "):
@@ -2571,19 +2623,22 @@ class MainFrame(wx.Frame):
self.panel.addPage(FILTERS_FILE)
def applyFilter(self, evt):
- execfile(FILTERS_FILE, {}, locals())
+ with open(FILTERS_FILE, "r") as f:
+ text = f.read()
+ functions = {}
+ exec(text, functions)
filter = self.filters[evt.GetId()]
- try:
- text = self.panel.editor.GetSelectedTextUTF8()
- except:
- text = self.panel.editor.GetSelectedText()
+ text = self.panel.editor.GetSelectedText()
if text == "":
- dlg = wx.MessageDialog(self, "You must select some text to apply a filter...", "No selected text!", style=wx.OK|wx.STAY_ON_TOP)
+ dlg = wx.MessageDialog(self,
+ "You must select some text to apply a filter...",
+ "No selected text!",
+ style=wx.OK | wx.STAY_ON_TOP)
dlg.ShowModal()
dlg.Destroy()
else:
- self.panel.editor.ReplaceSelection(locals()[filter](text))
-
+ self.panel.editor.ReplaceSelection(functions[filter](text))
+
def undo(self, evt):
if evt.GetId() == wx.ID_UNDO:
self.panel.editor.Undo()
@@ -2653,9 +2708,9 @@ class MainFrame(wx.Frame):
self.panel.editor.GotoLine(val)
first = self.panel.editor.GetFirstVisibleLine()
if val == first:
- self.panel.editor.LineScroll(0, -self.panel.editor.LinesOnScreen()/2)
+ self.panel.editor.LineScroll(0, -self.panel.editor.LinesOnScreen() // 2)
else:
- self.panel.editor.LineScroll(0, self.panel.editor.LinesOnScreen()/2)
+ self.panel.editor.LineScroll(0, self.panel.editor.LinesOnScreen() // 2)
#self.panel.editor.SetCurrentPos(pos)
#self.panel.editor.EnsureVisible(val)
#self.panel.editor.EnsureCaretVisible()
@@ -2691,7 +2746,7 @@ class MainFrame(wx.Frame):
word = self.panel.editor.getWordUnderCaret()
self.status_search.SetValue(word)
self.onQuickSearchEnter(None)
-
+
def onQuickSearchEnter(self, evt):
str = self.status_search.GetValue()
self.panel.editor.SetFocus()
@@ -2708,7 +2763,7 @@ class MainFrame(wx.Frame):
def searchInProject(self, evt):
ok = False
search = ""
- choices = self.panel.project.projectDict.keys()
+ choices = list(self.panel.project.projectDict.keys())
if len(choices) == 0:
dlg = wx.MessageDialog(self, 'You must load at least one folder to use the "Search in Project Files" option.',
'No project folder', wx.OK | wx.ICON_INFORMATION)
@@ -2730,11 +2785,12 @@ class MainFrame(wx.Frame):
search = dlg.GetValue()
dlg.Destroy()
if search:
- wx.CallAfter(self.doSearchInProject, rootdir, search)
-
+ wx.CallAfter(self.doSearchInProject, rootdir, ensureNFD(search))
+
def doSearchInProject(self, rootdir, search):
result = {}
filters = ["build"]
+ busy = wx.BusyCursor()
for root, dirs, files in os.walk(rootdir):
if os.path.split(root)[1].startswith("."):
filters.append(os.path.split(root)[1])
@@ -2750,37 +2806,41 @@ class MainFrame(wx.Frame):
filepath = os.path.join(root, file).replace(rootdir, "")
if filepath.endswith("~"):
continue
- with open(os.path.join(root, file), "r") as f:
- for i, line in enumerate(f.readlines()):
- if "\0" in line:
- # binary file detected
- break
- if search.encode("utf-8").lower() in line.lower():
- if not result.has_key(filepath):
- result[filepath] = ([], [])
- result[filepath][0].append(i+1)
- if len(line) < 50:
- result[filepath][1].append(line.strip().replace("\n", ""))
- else:
- pos = line.lower().find(search.encode("utf-8").lower())
- p1 = pos - 25
- if p1 < 0:
- p1, pre = 0, ""
- else:
- pre = "... "
- p2 = pos + 25
- if p2 >= len(line):
- p2, post = len(line), ""
+ try:
+ with open(os.path.join(root, file), "r") as f:
+ for i, line in enumerate(f.readlines()):
+ if "\0" in line:
+ # binary file detected
+ break
+ if search.lower() in line.lower():
+ if filepath not in result:
+ result[filepath] = ([], [])
+ result[filepath][0].append(i+1)
+ if len(line) < 50:
+ result[filepath][1].append(line.strip().replace("\n", ""))
else:
- post = " ..."
- result[filepath][1].append(pre + line[p1:p2].strip().replace("\n", "") + post)
+ pos = line.lower().find(search.lower())
+ p1 = pos - 25
+ if p1 < 0:
+ p1, pre = 0, ""
+ else:
+ pre = "... "
+ p2 = pos + 25
+ if p2 >= len(line):
+ p2, post = len(line), ""
+ else:
+ post = " ..."
+ result[filepath][1].append(pre + line[p1:p2].strip().replace("\n", "") + post)
+ except:
+ pass
+ del busy
if result:
f = SearchProjectFrame(self, rootdir, result)
def insertPath(self, evt):
- dlg = wx.FileDialog(self, message="Choose a file",
+ dlg = wx.FileDialog(self, message="Choose a file",
defaultDir=PREFERENCES.get("insert_path", os.path.expanduser("~")),
- defaultFile="", style=wx.OPEN | wx.MULTIPLE)
+ defaultFile="", style=wx.FD_OPEN | wx.FD_MULTIPLE)
if dlg.ShowModal() == wx.ID_OK:
paths = dlg.GetPaths()
if len(paths) == 1:
@@ -2804,7 +2864,9 @@ class MainFrame(wx.Frame):
category = item.GetMenu().GetTitle()
with codecs.open(os.path.join(ensureNFD(SNIPPETS_PATH), category, name), "r", encoding="utf-8") as f:
text = f.read()
- exec text in locals()
+ spos = text.find("=")
+ dictext = text[spos+1:]
+ snippet = eval(dictext)
self.panel.editor.insertSnippet(snippet["value"])
def openStyleEditor(self, evt):
@@ -2816,18 +2878,20 @@ class MainFrame(wx.Frame):
st = menu.FindItemById(id).GetLabel()
self.setStyle(st, fromMenu=True)
self.style_frame.setCurrentStyle(st)
-
+
def setStyle(self, st, fromMenu=False):
global STYLES
with open(os.path.join(ensureNFD(STYLES_PATH), st)) as f:
text = f.read()
- exec text in locals()
+ spos = text.find("=")
+ dictext = text[spos+1:]
+ style = eval(dictext)
STYLES = copy.deepcopy(style)
- if not STYLES.has_key('face'):
+ if 'face' not in STYLES:
STYLES['face'] = DEFAULT_FONT_FACE
- if not STYLES.has_key('size'):
+ if 'size' not in STYLES:
STYLES['size'] = FONT_SIZE
- if not STYLES.has_key('size2'):
+ if 'size2' not in STYLES:
STYLES['size2'] = FONT_SIZE2
for i in range(self.panel.notebook.GetPageCount()):
@@ -2884,11 +2948,11 @@ class MainFrame(wx.Frame):
if not self.panel.splitter.IsSplit():
self.panel.splitter.SplitVertically(self.panel.left_splitter, self.panel.right_splitter, 175)
h = self.panel.GetSize()[1]
- self.panel.left_splitter.SplitHorizontally(self.panel.project, self.panel.markers, h*3/4)
+ self.panel.left_splitter.SplitHorizontally(self.panel.project, self.panel.markers, h * 3 // 4)
self.panel.left_splitter.Unsplit(self.panel.markers)
else:
h = self.panel.GetSize()[1]
- self.panel.left_splitter.SplitHorizontally(self.panel.project, self.panel.markers, h*3/4)
+ self.panel.left_splitter.SplitHorizontally(self.panel.project, self.panel.markers, h * 3 // 4)
else:
if self.panel.markers.IsShown():
self.panel.left_splitter.Unsplit(self.panel.project)
@@ -2904,11 +2968,11 @@ class MainFrame(wx.Frame):
if not self.panel.splitter.IsSplit():
self.panel.splitter.SplitVertically(self.panel.left_splitter, self.panel.right_splitter, 175)
h = self.panel.GetSize()[1]
- self.panel.left_splitter.SplitHorizontally(self.panel.project, self.panel.markers, h*3/4)
+ self.panel.left_splitter.SplitHorizontally(self.panel.project, self.panel.markers, h * 3 // 4)
self.panel.left_splitter.Unsplit(self.panel.project)
else:
h = self.panel.GetSize()[1]
- self.panel.left_splitter.SplitHorizontally(self.panel.project, self.panel.markers, h*3/4)
+ self.panel.left_splitter.SplitHorizontally(self.panel.project, self.panel.markers, h * 3 // 4)
else:
if self.panel.project.IsShown():
self.panel.left_splitter.Unsplit(self.panel.markers)
@@ -2922,7 +2986,7 @@ class MainFrame(wx.Frame):
if self.panel.outputlog.IsShownOnScreen():
return
h = self.panel.GetSize()[1]
- self.panel.right_splitter.SplitHorizontally(self.panel.notebook, self.panel.outputlog, h*4/5 - h)
+ self.panel.right_splitter.SplitHorizontally(self.panel.notebook, self.panel.outputlog, h * 4 // 5 - h)
else:
if not self.panel.outputlog.IsShownOnScreen():
return
@@ -2956,7 +3020,7 @@ class MainFrame(wx.Frame):
subId2 = 2000
if lines != []:
for item in self.submenu2.GetMenuItems():
- self.submenu2.DeleteItem(item)
+ self.submenu2.Delete(item.GetId())
for file in lines:
self.submenu2.Append(subId2, toSysEncoding(file))
subId2 += 1
@@ -2971,9 +3035,9 @@ class MainFrame(wx.Frame):
self.panel.addPage(ensureNFD(file))
def open(self, event, encoding=None):
- dlg = wx.FileDialog(self, message="Choose a file",
+ dlg = wx.FileDialog(self, message="Choose a file",
defaultDir=PREFERENCES.get("open_file_path", os.path.expanduser("~")),
- defaultFile="", style=wx.OPEN | wx.MULTIPLE)
+ defaultFile="", style=wx.FD_OPEN | wx.FD_MULTIPLE)
if dlg.ShowModal() == wx.ID_OK:
paths = dlg.GetPaths()
for path in paths:
@@ -3011,9 +3075,9 @@ class MainFrame(wx.Frame):
self.panel.addPage(os.path.join(os.getcwd(), "Resources", filename))
else:
self.panel.addPage(os.path.join(os.getcwd(), filename))
-
+
def openFolder(self, event):
- dlg = wx.DirDialog(self, message="Choose a folder",
+ dlg = wx.DirDialog(self, message="Choose a folder",
defaultPath=PREFERENCES.get("open_folder_path", os.path.expanduser("~")),
style=wx.DD_DEFAULT_STYLE)
if dlg.ShowModal() == wx.ID_OK:
@@ -3036,9 +3100,11 @@ class MainFrame(wx.Frame):
def saveas(self, event):
deffile = os.path.split(self.panel.editor.path)[1]
- dlg = wx.FileDialog(self, message="Save file as ...",
- defaultDir=PREFERENCES.get("save_file_path", os.path.expanduser("~")),
- defaultFile=deffile, style=wx.SAVE)
+ dlg = wx.FileDialog(self, message="Save file as ...",
+ defaultDir=PREFERENCES.get("save_file_path",
+ os.path.expanduser("~")),
+ defaultFile=deffile,
+ style=wx.FD_SAVE)
dlg.SetFilterIndex(0)
if dlg.ShowModal() == wx.ID_OK:
path = ensureNFD(dlg.GetPath())
@@ -3061,10 +3127,7 @@ class MainFrame(wx.Frame):
fname = dlg.GetValue()
if not fname.endswith(".py"):
fname = fname + ".py"
- try:
- text = self.panel.editor.GetTextUTF8()
- except:
- text = self.panel.editor.GetText()
+ text = self.panel.editor.GetText()
with open(os.path.join(TEMPLATE_PATH, fname), "w") as f:
f.write(text)
dlg.Destroy()
@@ -3097,16 +3160,37 @@ class MainFrame(wx.Frame):
cwd = toSysEncoding(os.path.split(path)[0])
except:
pass
- return cwd
+ return ensureNFD(cwd)
def addCwdToSysPath(self, text):
cwd = self.getCurrentWorkingDirectory()
- check = True
+ if sys.platform == "win32":
+ cwd = cwd.replace("/", "\\")
+ cwd = cwd.replace("\\", "\\\\")
+ check1 = check2 = True
+ is_future = '__future__' in text
+ future_found = not is_future
+ is_sys_import = 'import sys' in text
+ sys_found = not is_sys_import
newtext = ""
for line in text.splitlines():
- if check and not line.startswith("#"):
- newtext += '# encoding: utf-8\nimport sys\nsys.path.append("%s")\n' % cwd
- check = False
+ if check1:
+ if not line.startswith("#"):
+ if not '# encoding: utf-8' in text:
+ newtext += '# encoding: utf-8\n'
+ check1 = False
+ if not check1 and check2:
+ if is_future and '__future__' in line:
+ future_found = True
+ if future_found and not '__future__' in line:
+ if not is_sys_import:
+ newtext += 'import sys\nsys.path.append("%s")\n' % cwd
+ check2 = False
+ elif is_sys_import and 'import sys' in line:
+ sys_found = True
+ elif sys_found:
+ newtext += 'sys.path.append("%s")\n' % cwd
+ check2 = False
newtext += line + "\n"
return newtext
@@ -3137,7 +3221,7 @@ class MainFrame(wx.Frame):
with open(self.master_document, "r") as f:
text = f.read()
else:
- text = self.panel.editor.GetTextUTF8()
+ text = self.panel.editor.GetText()
if text != "":
text = self.addCwdToSysPath(text)
with open(TEMP_FILE, "w") as f:
@@ -3145,7 +3229,7 @@ class MainFrame(wx.Frame):
self.run(TEMP_FILE)
def runSelection(self, event):
- text = self.panel.editor.GetSelectedTextUTF8()
+ text = self.panel.editor.GetSelectedText()
if text != "":
text = self.addCwdToSysPath(text)
with open(TEMP_FILE, "w") as f:
@@ -3153,11 +3237,11 @@ class MainFrame(wx.Frame):
self.run(TEMP_FILE)
def runSelectionAsPyo(self, event):
- text = self.panel.editor.GetSelectedTextUTF8()
+ text = self.panel.editor.GetSelectedText()
if text == "":
pos = self.panel.editor.GetCurrentPos()
line = self.panel.editor.LineFromPosition(pos)
- text = self.panel.editor.GetLineUTF8(line)
+ text = self.panel.editor.GetLine(line)
text = self.addCwdToSysPath(text)
with open(TEMP_FILE, "w") as f:
f.write("from pyo import *\ns = Server().boot()\n")
@@ -3166,13 +3250,13 @@ class MainFrame(wx.Frame):
self.run(TEMP_FILE)
def execSelection(self, event):
- text = self.panel.editor.GetSelectedTextUTF8()
+ text = self.panel.editor.GetSelectedText()
if text == "":
pos = self.panel.editor.GetCurrentPos()
line = self.panel.editor.LineFromPosition(pos)
- text = self.panel.editor.GetLineUTF8(line)
- if not text.startswith("print"):
- text = "print " + text
+ text = self.panel.editor.GetLine(line)
+ if not text.startswith("print("):
+ text = "print(" + text + ")"
else:
pos = self.panel.editor.GetSelectionEnd()
line = self.panel.editor.LineFromPosition(pos)
@@ -3180,7 +3264,7 @@ class MainFrame(wx.Frame):
self.panel.editor.SetCurrentPos(pos)
self.panel.editor.addText("\n", False)
with stdoutIO() as s:
- exec text
+ exec(text)
self.panel.editor.addText(s.getvalue())
def prepareBackgroundServer(self):
@@ -3217,7 +3301,7 @@ class MainFrame(wx.Frame):
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, sys, os\nsys.path.append(os.getcwd())\nfrom pyo import *\n")
+ f.write("print('Starting background server...')\nimport time, sys, os\nsys.path.append(os.getcwd())\nfrom pyo import *\n")
f.write("s = Server(%s)\n" % BACKGROUND_SERVER_ARGS)
if outDriverIndex != -1:
f.write("s.setOutputDevice(%d)\n" % outDriverIndex)
@@ -3234,7 +3318,7 @@ class MainFrame(wx.Frame):
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:
self.prepareBackgroundServer()
@@ -3255,11 +3339,11 @@ class MainFrame(wx.Frame):
def sendSelectionToBackgroundServer(self, evt):
end = None
- text = self.panel.editor.GetSelectedTextUTF8()
+ text = self.panel.editor.GetSelectedText()
if text == "":
pos = self.panel.editor.GetCurrentPos()
line = self.panel.editor.LineFromPosition(pos)
- text = self.panel.editor.GetLineUTF8(line)
+ text = self.panel.editor.GetLine(line)
else:
end = self.panel.editor.GetSelectionEnd()
if self.back_server_started:
@@ -3301,26 +3385,26 @@ class MainFrame(wx.Frame):
def showDocString(self, evt):
self.panel.editor.onShowDocString()
-
+
def onShowEditorKeyCommands(self, evt):
if not self.keyCommandsFrame.IsShown():
self.keyCommandsFrame.CenterOnParent()
self.keyCommandsFrame.Show()
def onHelpAbout(self, evt):
- info = wx.AboutDialogInfo()
+ info = AboutDialogInfo()
info.Name = APP_NAME
info.Version = APP_VERSION
- info.Copyright = u"(C) 2012 Olivier Belanger"
+ info.Copyright = u"(C) 2016 Olivier Belanger"
info.Description = "E-Pyo is a text editor especially configured to edit pyo audio programs.\n\n"
- wx.AboutBox(info)
+ AboutBox(info)
def OnClose(self, event):
- msg = "You are about to leave E-Pyo. Is this really what you want to do?"
- dlg = wx.MessageDialog(self, msg, "Warning!", wx.YES_NO|wx.ICON_QUESTION)
- if dlg.ShowModal() != wx.ID_YES:
- event.StopPropagation()
- return
+ msg = "You are about to leave E-Pyo. Is this really what you want to do?"
+ dlg = wx.MessageDialog(self, msg, "Warning!", wx.YES_NO|wx.ICON_QUESTION)
+ if dlg.ShowModal() != wx.ID_YES:
+ event.StopPropagation()
+ return
if self.back_server_started == True:
try:
self.startStopBackgroundServer(None)
@@ -3401,11 +3485,11 @@ class MainPanel(wx.Panel):
self.markers = MarkersPanel(self.left_splitter, self, (-1, -1))
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.notebook.SetAGWWindowStyleFlag(FNB.FNB_FANCY_TABS|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))
- self.right_splitter.SplitHorizontally(self.notebook, self.outputlog, (self.GetSize()[1]*4/5) - self.GetSize()[1])
+ self.right_splitter.SplitHorizontally(self.notebook, self.outputlog, (self.GetSize()[1] * 4 // 5) - self.GetSize()[1])
self.splitter.SplitVertically(self.left_splitter, self.right_splitter, 175)
self.splitter.Unsplit(self.left_splitter)
@@ -3465,7 +3549,9 @@ class MainPanel(wx.Panel):
if founded:
with open(os.path.join(MARKERS_PATH, marker_file), "r") as f:
text = f.read()
- exec text in locals()
+ spos = text.find("=")
+ dictext = text[spos+1:]
+ markers = eval(dictext)
self.editor.setMarkers(copy.deepcopy(markers))
def onClosingPage(self, evt):
@@ -3514,7 +3600,7 @@ class MainPanel(wx.Panel):
#######################################################
### The idea of EditorPanel is to allow multiple views
-### at the same time in a single notebook page.
+### at the same time in a single notebook page.
### Also: A tree view of classes and functions of the file
### Not yet implemented... ( TODO )
#######################################################
@@ -3529,7 +3615,7 @@ class EditorPanel(wx.Panel):
self.SetSizerAndFit(box)
class Editor(stc.StyledTextCtrl):
- def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize,
+ 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)
@@ -3556,7 +3642,7 @@ class Editor(stc.StyledTextCtrl):
self.auto_comp_container = PREFERENCES.get("auto_comp_container", 0)
- self.alphaStr = string.lowercase + string.uppercase + '0123456789'
+ self.alphaStr = LOWERCASE + UPPERCASE + '0123456789'
self.Colourise(0, -1)
self.SetCurrentPos(0)
@@ -3581,9 +3667,8 @@ class Editor(stc.StyledTextCtrl):
self.SetProperty("fold", "1")
self.SetProperty("tab.timmy.whinge.level", "1")
self.SetMargins(5, 5)
- self.SetUseAntiAliasing(True)
self.SetEdgeColour(STYLES["lineedge"]['colour'])
- self.SetEdgeColumn(78)
+ self.SetEdgeColumn(80)
self.SetMarginType(0, stc.STC_MARGIN_SYMBOL)
self.SetMarginWidth(0, 12)
@@ -3655,7 +3740,7 @@ class Editor(stc.StyledTextCtrl):
st = "face:%s,fore:%s,size:%s" % (STYLES['face'], STYLES[forekey]['colour'], STYLES['size'])
if backkey:
st += ",back:%s" % STYLES[backkey]['colour']
- if STYLES[forekey].has_key('bold'):
+ if 'bold' in STYLES[forekey]:
if STYLES[forekey]['bold']:
st += ",bold"
if STYLES[forekey]['italic']:
@@ -3665,7 +3750,7 @@ class Editor(stc.StyledTextCtrl):
return st
self.StyleSetSpec(stc.STC_STYLE_DEFAULT, buildStyle('default', 'background'))
- self.StyleClearAll() # Reset all to be like the default
+ self.StyleClearAll() # Reset all to be like the default
self.MarkerDefine(0, stc.STC_MARK_SHORTARROW, STYLES['markerbg']['colour'], STYLES['markerbg']['colour'])
self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_BOXMINUS, STYLES['markerfg']['colour'], STYLES['markerbg']['colour'])
@@ -3882,7 +3967,7 @@ class Editor(stc.StyledTextCtrl):
last = self.GetCurrentLine() - 1
break
self.LineDown()
- self.SetSelection(self.GetLineEndPosition(first)+1,
+ self.SetSelection(self.GetLineEndPosition(first)+1,
self.GetLineEndPosition(last)+1)
if evt is not None:
evt.StopPropagation()
@@ -3895,7 +3980,7 @@ class Editor(stc.StyledTextCtrl):
first = self.GetCurrentLine()
break
self.LineUp()
- self.SetSelection(self.GetLineEndPosition(first)+1,
+ self.SetSelection(self.GetLineEndPosition(first)+1,
self.GetLineEndPosition(last)+1)
if evt is not None:
evt.StopPropagation()
@@ -3924,7 +4009,7 @@ class Editor(stc.StyledTextCtrl):
self.SearchAnchor()
res = self.SearchPrev(stc.STC_FIND_MATCHCASE, str)
line = self.GetCurrentLine()
- halfNumLinesOnScreen = self.LinesOnScreen() / 2
+ halfNumLinesOnScreen = self.LinesOnScreen() // 2
self.ScrollToLine(line - halfNumLinesOnScreen)
def OnShowFindReplace(self):
@@ -3985,7 +4070,7 @@ class Editor(stc.StyledTextCtrl):
self.anchor1 = startpos + newStrLen + 1
self.anchor2 += diffLen
line = self.GetCurrentLine()
- halfNumLinesOnScreen = self.LinesOnScreen() / 2
+ halfNumLinesOnScreen = self.LinesOnScreen() // 2
self.ScrollToLine(line - halfNumLinesOnScreen)
def OnFindClose(self, evt):
@@ -4000,22 +4085,20 @@ class Editor(stc.StyledTextCtrl):
self.SetEdgeMode(stc.STC_EDGE_LINE)
else:
self.SetEdgeMode(stc.STC_EDGE_NONE)
-
+
def removeTrailingWhiteSpace(self):
- text = self.GetTextUTF8()
+ text = self.GetText()
lines = [line.rstrip() for line in text.splitlines(False)]
text= "\n".join(lines)
self.setText(text, False)
def tabsToSpaces(self):
- text = self.GetTextUTF8()
+ text = self.GetText()
text = text.replace("\t", " ")
self.setText(text, False)
### Save and Close file ###
def saveMyFile(self, file):
- #with codecs.open(file, "w", encoding="utf-8") as f:
- # f.write(self.GetTextUTF8())
self.SaveFile(file)
self.path = file
self.saveMark = False
@@ -4049,14 +4132,14 @@ class Editor(stc.StyledTextCtrl):
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?',
+ dlg = wx.MessageDialog(None, 'file ' + f + ' has been modified. Do you want to save?',
'Warning!', wx.YES | wx.NO | wx.CANCEL)
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 ...", defaultDir=os.getcwd(),
- defaultFile="", style=wx.SAVE|wx.FD_OVERWRITE_PROMPT)
+ dlg2 = wx.FileDialog(None, message="Save file as ...", defaultDir=os.getcwd(),
+ defaultFile="", style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
dlg2.SetFilterIndex(0)
if dlg2.ShowModal() == wx.ID_OK:
path = dlg2.GetPath()
@@ -4081,13 +4164,13 @@ class Editor(stc.StyledTextCtrl):
if self.GetModify():
if not self.path: f = "Untitled"
else: f = os.path.split(self.path)[1]
- dlg = wx.MessageDialog(None, 'file ' + f + ' has been modified. Do you want to save?',
+ dlg = wx.MessageDialog(None, 'file ' + f + ' has been modified. Do you want to save?',
'Warning!', wx.YES | wx.NO)
if dlg.ShowModal() == wx.ID_YES:
dlg.Destroy()
if not self.path or "Untitled-" in self.path:
dlg2 = wx.FileDialog(None, message="Save file as ...", defaultDir=os.getcwd(),
- defaultFile="", style=wx.SAVE|wx.FD_OVERWRITE_PROMPT)
+ defaultFile="", style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
dlg2.SetFilterIndex(0)
if dlg2.ShowModal() == wx.ID_OK:
@@ -4111,30 +4194,21 @@ class Editor(stc.StyledTextCtrl):
### Text Methods ###
def addText(self, text, update=True):
- try:
- self.AddTextUTF8(text)
- except:
- self.AddText(text)
+ self.AddText(text)
if update:
count = self.GetLineCount()
for i in range(count):
self.updateVariableDict(i)
def insertText(self, pos, text, update=True):
- try:
- self.InsertTextUTF8(pos, text)
- except:
- self.InsertText(pos, text)
+ self.InsertText(pos, text)
if update:
count = self.GetLineCount()
for i in range(count):
self.updateVariableDict(i)
def setText(self, text, update=True):
- try:
- self.SetTextUTF8(text)
- except:
- self.SetText(text)
+ self.SetText(text)
if update:
count = self.GetLineCount()
for i in range(count):
@@ -4161,18 +4235,18 @@ class Editor(stc.StyledTextCtrl):
caretPos = self.GetCurrentPos()
startpos = self.WordStartPosition(caretPos, True)
endpos = self.WordEndPosition(caretPos, True)
- currentword = self.GetTextRangeUTF8(startpos, endpos)
+ currentword = self.GetTextRange(startpos, endpos)
return currentword
def showAutoCompContainer(self, state):
self.auto_comp_container = state
-
+
def showAutoComp(self):
propagate = True
charBefore = " "
caretPos = self.GetCurrentPos()
if caretPos > 0:
- charBefore = self.GetTextRangeUTF8(caretPos - 1, caretPos)
+ charBefore = self.GetTextRange(caretPos - 1, caretPos)
currentword = self.getWordUnderCaret()
if charBefore in self.alphaStr:
list = ''
@@ -4194,7 +4268,7 @@ class Editor(stc.StyledTextCtrl):
braceend = False
startpos = self.WordStartPosition(pos-2, True)
endpos = self.WordEndPosition(pos-2, True)
- currentword = self.GetTextRangeUTF8(startpos, endpos)
+ currentword = self.GetTextRange(startpos, endpos)
for word in PYO_WORDLIST:
if word == currentword:
text = class_args(eval(word)).replace(word, "")
@@ -4273,7 +4347,7 @@ class Editor(stc.StyledTextCtrl):
self.SetCurrentPos(pos)
wx.CallAfter(self.SetAnchor, self.GetCurrentPos())
else:
- self.selection = self.GetSelectedTextUTF8()
+ self.selection = self.GetSelectedText()
pos = self.GetSelectionStart()
wx.CallAfter(self.navigateSnips, pos)
@@ -4297,7 +4371,7 @@ class Editor(stc.StyledTextCtrl):
while charat == ord("."):
startpos = self.WordStartPosition(pos-2, True)
endpos = self.WordEndPosition(pos-2, True)
- currentword = "%s.%s" % (self.GetTextRangeUTF8(startpos, endpos), currentword)
+ currentword = "%s.%s" % (self.GetTextRange(startpos, endpos), currentword)
pos = startpos - 1
charat = self.GetCharAt(pos)
if currentword != "":
@@ -4321,7 +4395,7 @@ class Editor(stc.StyledTextCtrl):
return propagate
def updateVariableDict(self, line):
- text = self.GetLineUTF8(line).replace(" ", "")
+ text = self.GetLine(line).replace(" ", "")
egpos = text.find("=")
brpos = text.find("(")
if egpos != -1 and brpos != -1:
@@ -4334,10 +4408,10 @@ class Editor(stc.StyledTextCtrl):
def processReturn(self):
prevline = self.GetCurrentLine() - 1
self.updateVariableDict(prevline)
- if self.GetLineUTF8(prevline).strip().endswith(":"):
+ if self.GetLine(prevline).strip().endswith(":"):
indent = self.GetLineIndentation(prevline)
self.addText(" "*(indent+4), False)
- elif self.GetLineIndentation(prevline) != 0 and self.GetLineUTF8(prevline).strip() != "":
+ elif self.GetLineIndentation(prevline) != 0 and self.GetLine(prevline).strip() != "":
indent = self.GetLineIndentation(prevline)
self.addText(" "*indent, False)
@@ -4381,7 +4455,7 @@ class Editor(stc.StyledTextCtrl):
if "import " in line:
text = text + line
try:
- exec text in locals()
+ exec(text, locals())
docstr = eval(currentword).__doc__
dlg = wx.lib.dialogs.ScrolledMessageDialog(self, docstr, "__doc__ string for %s" % currentword, size=(700,500))
dlg.CenterOnParent()
@@ -4392,31 +4466,32 @@ class Editor(stc.StyledTextCtrl):
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 self.auto_comp_container:
+ if chr(evt.GetKeyCode()) in ['[', '{', '(', '"', '`']:
+ 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():
@@ -4504,7 +4579,7 @@ class Editor(stc.StyledTextCtrl):
wx.CallAfter(self.processReturn)
# Process Tab key --- AutoCompletion, Insert object's args, snippet for builtin keywords
elif evt.GetKeyCode() == wx.WXK_TAB:
- autoCompActive = self.AutoCompActive()
+ autoCompActive = self.AutoCompActive()
currentword = self.getWordUnderCaret()
currentline = self.GetCurrentLine()
charat = self.GetCharAt(self.GetCurrentPos()-1)
@@ -4564,7 +4639,7 @@ class Editor(stc.StyledTextCtrl):
if braceAtCaret >= 0:
braceOpposite = self.BraceMatch(braceAtCaret)
- if braceAtCaret != -1 and braceOpposite == -1:
+ if braceAtCaret != -1 and braceOpposite == -1:
self.BraceBadLight(braceAtCaret)
else:
self.BraceHighlight(braceAtCaret, braceOpposite)
@@ -4574,11 +4649,6 @@ class Editor(stc.StyledTextCtrl):
self.args_buffer = []
self.quit_navigate_args = False
- # if self.endOfLine:
- # for i in range(self.GetLineCount()):
- # pos = self.GetLineEndPosition(i)
- # if self.GetCharAt(pos-1) != 172:
- # self.InsertTextUTF8(pos, "¬")
self.moveMarkers()
self.checkScrollbar()
self.OnModified()
@@ -4601,9 +4671,9 @@ class Editor(stc.StyledTextCtrl):
for i in range(self.firstLine, self.endLine+1):
lineLen = len(self.GetLine(i))
pos = self.PositionFromLine(i)
- if self.GetTextRangeUTF8(pos,pos+1) != '#' and lineLen > 2:
+ if self.GetTextRange(pos,pos+1) != '#' and lineLen > 2:
self.insertText(pos, '#', False)
- elif self.GetTextRangeUTF8(pos,pos+1) == '#':
+ elif self.GetTextRange(pos,pos+1) == '#':
self.GotoPos(pos+1)
self.DelWordLeft()
@@ -4623,16 +4693,16 @@ class Editor(stc.StyledTextCtrl):
handle = handles[self.current_marker]
line = self.markers_dict[handle][0]
self.GotoLine(line)
- halfNumLinesOnScreen = self.LinesOnScreen() / 2
+ 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]
+ key = list(dic.keys())[0]
except:
return
- if type(dic[key]) != ListType:
+ if type(dic[key]) != list:
return
self.markers_dict = dic
for handle in self.markers_dict.keys():
@@ -4649,11 +4719,11 @@ class Editor(stc.StyledTextCtrl):
if dict != self.markers_dict:
self.markers_dict = dict
self.GetParent().GetParent().GetParent().GetParent().markers.setDict(self.markers_dict)
-
+
def addMarker(self, line):
if not self.MarkerGet(line):
handle = self.MarkerAdd(line, 0)
- self.markers_dict[handle] = [line, ""]
+ self.markers_dict[handle] = [line, ""]
comment = ""
dlg = wx.TextEntryDialog(self, 'Enter a comment for that marker:', 'Marker Comment')
if dlg.ShowModal() == wx.ID_OK:
@@ -4790,7 +4860,7 @@ class SimpleEditor(stc.StyledTextCtrl):
self.panel = parent
- self.alphaStr = string.lowercase + string.uppercase + '0123456789'
+ self.alphaStr = LOWERCASE + UPPERCASE + '0123456789'
self.Colourise(0, -1)
self.SetCurrentPos(0)
@@ -4809,7 +4879,6 @@ class SimpleEditor(stc.StyledTextCtrl):
self.SetEdgeMode(0)
self.SetWrapMode(stc.STC_WRAP_WORD)
- self.SetUseAntiAliasing(True)
self.SetEdgeColour(STYLES["lineedge"]['colour'])
self.SetEdgeColumn(78)
self.SetReadOnly(True)
@@ -4823,7 +4892,7 @@ class SimpleEditor(stc.StyledTextCtrl):
st = "face:%s,fore:%s,size:%s" % (STYLES['face'], STYLES[forekey]['colour'], STYLES['size'])
if backkey:
st += ",back:%s" % STYLES[backkey]['colour']
- if STYLES[forekey].has_key('bold'):
+ if 'bold' in STYLES[forekey]:
if STYLES[forekey]['bold']:
st += ",bold"
if STYLES[forekey]['italic']:
@@ -4832,7 +4901,7 @@ class SimpleEditor(stc.StyledTextCtrl):
st += ",underline"
return st
self.StyleSetSpec(stc.STC_STYLE_DEFAULT, buildStyle('default', 'background'))
- self.StyleClearAll() # Reset all to be like the default
+ self.StyleClearAll() # Reset all to be like the default
self.StyleSetSpec(stc.STC_STYLE_DEFAULT, buildStyle('default', 'background'))
self.StyleSetSpec(stc.STC_STYLE_LINENUMBER, buildStyle('linenumber', 'marginback', True))
@@ -4876,7 +4945,7 @@ class OutputLogPanel(wx.Panel):
if PLATFORM == "darwin":
font.SetPointSize(psize-1)
self.toolbar.SetToolBitmapSize(tsize)
-
+
if PLATFORM == "win32":
self.toolbar.AddSeparator()
title = wx.StaticText(self.toolbar, -1, " Output panel")
@@ -4885,13 +4954,13 @@ class OutputLogPanel(wx.Panel):
self.toolbar.AddSeparator()
if PLATFORM == "win32":
self.toolbar.AddSeparator()
- self.processPopup = wx.Choice(self.toolbar, -1, choices=[])
+ self.processPopup = wx.Choice(self.toolbar, -1, choices=[], size=(150, -1))
self.processPopup.SetFont(font)
self.toolbar.AddControl(self.processPopup)
if PLATFORM == "win32":
self.toolbar.AddSeparator()
- self.processKill = wx.Button(self.toolbar, -1, label="Kill", size=(40,self.processPopup.GetSize()[1]))
- self.processKill.SetFont(font)
+ 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":
@@ -4921,11 +4990,14 @@ class OutputLogPanel(wx.Panel):
if PLATFORM == "darwin":
tb2.SetToolBitmapSize(tsize)
tb2.AddSeparator()
- tb2.AddLabelTool(17, "Close Panel", close_panel_bmp, shortHelp="Close Panel")
+ if "phoenix" not in wx.version():
+ tb2.AddLabelTool(17, "Close Panel", close_panel_bmp, shortHelp="Close Panel")
+ else:
+ tb2.AddTool(17, "Close Panel", close_panel_bmp, shortHelp="Close Panel")
tb2.Realize()
toolbarbox.Add(tb2, 0, wx.ALIGN_RIGHT, 0)
- wx.EVT_TOOL(self, 17, self.onCloseOutputPanel)
+ self.Bind(wx.EVT_TOOL, self.onCloseOutputPanel, id=17)
self.sizer.Add(toolbarbox, 0, wx.EXPAND)
@@ -5006,10 +5078,7 @@ class PastingListEditorFrame(wx.Frame):
self.editors.append(editor)
if not line.endswith("\n"):
line = line + "\n"
- try:
- editor.AddTextUTF8(line)
- except:
- editor.AddText(line)
+ editor.AddText(line)
Y = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
if heightSum > Y - 100:
@@ -5023,19 +5092,19 @@ class PastingListEditorFrame(wx.Frame):
def close(self, evt):
pastingList = []
for editor in self.editors:
- text = editor.GetTextUTF8()
+ text = editor.GetText()
if text.replace("\n", "").strip() != "":
pastingList.append(text)
self.parent.pastingList = pastingList
self.Destroy()
-
+
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,
+ wx.Panel.__init__(self, parent, -1, size=size,
style=wx.WANTS_CHARS|wx.SUNKEN_BORDER|wx.EXPAND)
self.SetMinSize((150, -1))
self.mainPanel = mainPanel
@@ -5055,27 +5124,41 @@ class ProjectTree(wx.Panel):
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_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")
+
+ if "phoenix" not in wx.version():
+ 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")
+ else:
+ self.toolbar.AddTool(TOOL_ADD_FILE_ID, "Add File",
+ file_add_bmp, shortHelp="Add File")
+ self.toolbar.AddTool(TOOL_ADD_FOLDER_ID, "Add Folder",
+ folder_add_bmp, shortHelp="Add Folder")
+ self.toolbar.AddTool(TOOL_REFRESH_TREE_ID, "Refresh Tree",
+ refresh_tree_bmp, shortHelp="Refresh Tree")
+
self.toolbar.EnableTool(TOOL_ADD_FILE_ID, False)
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")
+
+ if "phoenix" not in wx.version():
+ tb2.AddLabelTool(15, "Close Panel", close_panel_bmp, shortHelp="Close Panel")
+ else:
+ tb2.AddTool(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.Bind(wx.EVT_TOOL, self.onAdd, id=TOOL_ADD_FILE_ID)
+ self.Bind(wx.EVT_TOOL, self.onAdd, id=TOOL_ADD_FOLDER_ID)
+ self.Bind(wx.EVT_TOOL, self.onRefresh, id=TOOL_REFRESH_TREE_ID)
+ self.Bind(wx.EVT_TOOL, self.onCloseProjectPanel, id=15)
self.sizer.Add(toolbarbox, 0, wx.EXPAND)
@@ -5087,7 +5170,7 @@ class ProjectTree(wx.Panel):
pt = 11
else:
pt = 8
- fnt = wx.Font(pt, wx.ROMAN, wx.NORMAL, wx.NORMAL, face=STYLES['face'])
+ fnt = wx.Font(pt, wx.ROMAN, wx.NORMAL, wx.NORMAL, False, STYLES['face'])
self.tree.SetFont(fnt)
self.sizer.Add(self.tree, 1, wx.EXPAND)
@@ -5095,18 +5178,17 @@ class ProjectTree(wx.Panel):
isz = (12,12)
self.il = wx.ImageList(isz[0], isz[1])
- bmp = wx.ArtProvider_GetBitmap(wx.ART_FOLDER, 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)
+ 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)
+ 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.root = self.tree.AddRoot("EPyo_Project_tree", self.fldridx,
self.fldropenidx, None)
self.tree.SetItemTextColour(self.root, STYLES['default']['colour'])
@@ -5140,7 +5222,7 @@ class ProjectTree(wx.Panel):
expanded = []
self._tree_analyze(self.root, expanded)
self.tree.DeleteAllItems()
- self.root = self.tree.AddRoot("EPyo_Project_tree", self.fldridx,
+ self.root = self.tree.AddRoot("EPyo_Project_tree", self.fldridx,
self.fldropenidx, None)
for folder, path in self.projectDict.items():
self.loadFolder(path)
@@ -5150,9 +5232,9 @@ class ProjectTree(wx.Panel):
folderName = os.path.split(dirPath)[1]
self.projectDict[folderName] = dirPath
self.mainPanel.mainFrame.showProjectTree(True)
- item = self.tree.AppendItem(self.root, folderName, self.fldridx,
+ item = self.tree.AppendItem(self.root, folderName, self.fldridx,
self.fldropenidx, None)
- self.tree.SetPyData(item, dirPath)
+ self.tree.SetItemData(item, packItemData(dirPath))
self.tree.SetItemTextColour(item, STYLES['default']['colour'])
self.buildRecursiveTree(dirPath, item)
@@ -5164,14 +5246,14 @@ class ProjectTree(wx.Panel):
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,
+ child = self.tree.AppendItem(item, elem, self.fileidx,
self.fileidx)
- self.tree.SetPyData(child, os.path.join(dir, path))
+ self.tree.SetItemData(child, packItemData(os.path.join(dir, path)))
elif os.path.isdir(path):
if elem != "build":
- child = self.tree.AppendItem(item, elem, self.fldridx,
+ child = self.tree.AppendItem(item, elem, self.fldridx,
self.fldropenidx)
- self.tree.SetPyData(child, os.path.join(dir, path))
+ self.tree.SetItemData(child, packItemData(os.path.join(dir, path)))
self.buildRecursiveTree(path, child)
if child is not None:
self.tree.SetItemTextColour(child, STYLES['default']['colour'])
@@ -5180,16 +5262,16 @@ class ProjectTree(wx.Panel):
id = evt.GetId()
treeItemId = self.tree.GetSelection()
if self.selectedItem != None:
- selPath = self.tree.GetPyData(self.selectedItem)
+ selPath = unpackItemData(self.tree.GetItemData(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)
+ self.scope = unpackItemData(self.tree.GetItemData(treeItemId))
elif self.selectedItem == None and id == TOOL_ADD_FOLDER_ID:
- dlg = wx.DirDialog(self,
+ dlg = wx.DirDialog(self,
"Choose directory where to save your folder:",
- defaultPath=os.path.expanduser("~"),
+ defaultPath=os.path.expanduser("~"),
style=wx.DD_DEFAULT_STYLE)
if dlg.ShowModal() == wx.ID_OK:
self.scope = dlg.GetPath()
@@ -5199,14 +5281,14 @@ class ProjectTree(wx.Panel):
return
treeItemId = self.tree.GetRootItem()
if id == TOOL_ADD_FILE_ID:
- item = self.tree.AppendItem(treeItemId, "Untitled", self.fileidx,
+ item = self.tree.AppendItem(treeItemId, "Untitled", self.fileidx,
self.fileidx, None)
self.edititem = item
else:
- item = self.tree.AppendItem(treeItemId, "Untitled", self.fldridx,
+ 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.SetItemData(item, packItemData(os.path.join(self.scope, "Untitled")))
self.tree.SetItemTextColour(item, STYLES['default']['colour'])
self.tree.EnsureVisible(item)
if PLATFORM == "darwin":
@@ -5236,7 +5318,7 @@ class ProjectTree(wx.Panel):
pt = event.GetPosition();
self.edititem, flags = self.tree.HitTest(pt)
if self.edititem:
- self.itempath = self.tree.GetPyData(self.edititem)
+ self.itempath = unpackItemData(self.tree.GetItemData(self.edititem))
self.select(self.edititem)
self.tree.EditLabel(self.edititem)
else:
@@ -5250,14 +5332,14 @@ class ProjectTree(wx.Panel):
if newlabel != "":
newpath = os.path.join(head, event.GetLabel())
os.rename(self.itempath, newpath)
- self.tree.SetPyData(self.edititem, newpath)
+ self.tree.SetItemData(self.edititem, packItemData(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)
+ self.tree.SetItemData(self.edititem, packItemData(newpath))
f = open(newpath, "w")
f.close()
self.mainPanel.addPage(newpath)
@@ -5267,7 +5349,7 @@ 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)
+ self.tree.SetItemData(self.editfolder, packItemData(newpath))
os.mkdir(newpath)
if self.selectedItem == None:
self.projectDict[newitem] = self.scope
@@ -5295,7 +5377,7 @@ class ProjectTree(wx.Panel):
def openPage(self, item):
hasChild = self.tree.ItemHasChildren(item)
if not hasChild:
- path = self.tree.GetPyData(item)
+ path = unpackItemData(self.tree.GetItemData(item))
self.mainPanel.addPage(path)
def select(self, item):
@@ -5313,7 +5395,7 @@ 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),
+ 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'])
@@ -5327,9 +5409,9 @@ class MarkersListScroll(scrolled.ScrolledPanel):
self.selected2 = None
if wx.Platform == '__WXMAC__':
- self.font = wx.Font(11, wx.ROMAN, wx.NORMAL, wx.NORMAL, face=STYLES['face'])
+ self.font = wx.Font(11, wx.ROMAN, wx.NORMAL, wx.NORMAL, False, STYLES['face'])
else:
- self.font = wx.Font(8, wx.ROMAN, wx.NORMAL, wx.NORMAL, face=STYLES['face'])
+ self.font = wx.Font(8, wx.ROMAN, wx.NORMAL, wx.NORMAL, False, STYLES['face'])
self.SetSizer(self.box)
self.SetAutoLayout(1)
@@ -5369,7 +5451,7 @@ class MarkersListScroll(scrolled.ScrolledPanel):
self.selected = item.GetUserData()[0]
line = item.GetUserData()[1]
editor.GotoLine(line)
- halfNumLinesOnScreen = editor.LinesOnScreen() / 2
+ halfNumLinesOnScreen = editor.LinesOnScreen() // 2
editor.ScrollToLine(line - halfNumLinesOnScreen)
else:
line = self.row_dict[self.selected][0]
@@ -5377,7 +5459,7 @@ class MarkersListScroll(scrolled.ScrolledPanel):
line2 = item.GetUserData()[1]
l1, l2 = min(line, line2), max(line, line2)
editor.GotoLine(l1)
- halfNumLinesOnScreen = editor.LinesOnScreen() / 2
+ halfNumLinesOnScreen = editor.LinesOnScreen() // 2
editor.ScrollToLine(l1 - halfNumLinesOnScreen)
editor.SetSelection(editor.PositionFromLine(l1), editor.PositionFromLine(l2+1))
break
@@ -5417,18 +5499,28 @@ class MarkersPanel(wx.Panel):
toolbarbox = wx.BoxSizer(wx.HORIZONTAL)
self.toolbar = wx.ToolBar(self, -1, size=(-1,36))
self.toolbar.SetToolBitmapSize(tsize)
- self.toolbar.AddLabelTool(TOOL_DELETE_ALL_MARKERS_ID, "Delete All Markers", delete_all_markers, shortHelp="Delete All Markers")
+
+ if "phoenix" not in wx.version():
+ self.toolbar.AddLabelTool(TOOL_DELETE_ALL_MARKERS_ID, "Delete All Markers", delete_all_markers, shortHelp="Delete All Markers")
+ else:
+ self.toolbar.AddTool(TOOL_DELETE_ALL_MARKERS_ID, "Delete All Markers", delete_all_markers, shortHelp="Delete All Markers")
+
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(16, "Close Panel", close_panel_bmp, shortHelp="Close Panel")
+
+ if "phoenix" not in wx.version():
+ tb2.AddLabelTool(16, "Close Panel", close_panel_bmp, shortHelp="Close Panel")
+ else:
+ tb2.AddTool(16, "Close Panel", close_panel_bmp, shortHelp="Close Panel")
+
tb2.Realize()
toolbarbox.Add(tb2, 0, wx.ALIGN_RIGHT, 0)
- wx.EVT_TOOL(self, TOOL_DELETE_ALL_MARKERS_ID, self.onDeleteAll)
- wx.EVT_TOOL(self, 16, self.onCloseMarkersPanel)
+ self.Bind(wx.EVT_TOOL, self.onDeleteAll, id=TOOL_DELETE_ALL_MARKERS_ID)
+ self.Bind(wx.EVT_TOOL, self.onCloseMarkersPanel, id=16)
self.sizer.Add(toolbarbox, 0, wx.EXPAND)
@@ -5454,11 +5546,11 @@ class PreferencesDialog(wx.Dialog):
def __init__(self):
wx.Dialog.__init__(self, None, wx.ID_ANY, 'E-Pyo Preferences')
mainSizer = wx.BoxSizer(wx.VERTICAL)
- mainSizer.AddSpacer((-1,10))
+ mainSizer.AddSpacer(10)
font, entryfont, pointsize = self.GetFont(), self.GetFont(), self.GetFont().GetPointSize()
-
+
font.SetWeight(wx.BOLD)
- if PLATFORM == "linux2":
+ if PLATFORM.startswith("linux"):
entryfont.SetPointSize(pointsize)
elif PLATFORM == "win32":
entryfont.SetPointSize(pointsize)
@@ -5477,7 +5569,7 @@ class PreferencesDialog(wx.Dialog):
ctrlSizer.Add(self.entry_exe, 0, wx.ALL|wx.EXPAND, 5)
but = wx.Button(self, id=wx.ID_ANY, label="Choose...")
but.Bind(wx.EVT_BUTTON, self.setExecutable)
- ctrlSizer.Add(but, 0, wx.ALL, 5)
+ ctrlSizer.Add(but, 0, wx.ALL, 5)
but2 = wx.Button(self, id=wx.ID_ANY, label="Revert")
but2.Bind(wx.EVT_BUTTON, self.revertExecutable)
ctrlSizer.Add(but2, 0, wx.ALL, 5)
@@ -5495,10 +5587,10 @@ class PreferencesDialog(wx.Dialog):
ctrlSizer.Add(self.entry_res, 0, wx.ALL|wx.EXPAND, 5)
but = wx.Button(self, id=wx.ID_ANY, label="Choose...")
but.Bind(wx.EVT_BUTTON, self.setResourcesFolder)
- ctrlSizer.Add(but, 0, wx.ALL, 5)
+ ctrlSizer.Add(but, 0, wx.ALL, 5)
but2 = wx.Button(self, id=wx.ID_ANY, label="Revert")
but2.Bind(wx.EVT_BUTTON, self.revertResourcesFolder)
- ctrlSizer.Add(but2, 0, wx.ALL, 5)
+ ctrlSizer.Add(but2, 0, wx.ALL, 5)
mainSizer.Add(ctrlSizer, 0, wx.BOTTOM|wx.LEFT|wx.RIGHT, 5)
mainSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, 5)
@@ -5516,7 +5608,7 @@ class PreferencesDialog(wx.Dialog):
ctrlSizer.Add(self.server_args, 0, wx.ALL|wx.EXPAND, 5)
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)
+ ctrlSizer.Add(but, 0, wx.ALL, 5)
mainSizer.Add(ctrlSizer, 0, wx.BOTTOM|wx.LEFT|wx.RIGHT, 5)
popupSizer = wx.FlexGridSizer(2, 4, 5, 10)
@@ -5535,7 +5627,7 @@ class PreferencesDialog(wx.Dialog):
if preferedDriver and preferedDriver in driverList:
driverIndex = driverIndexes[driverList.index(preferedDriver)]
self.popupInDriver.SetStringSelection(preferedDriver)
- elif defaultDriver:
+ elif defaultDriver >= 0:
self.popupInDriver.SetSelection(driverIndexes.index(defaultDriver))
preferedDriver = PREFERENCES.get("background_server_out_device", "")
@@ -5547,7 +5639,7 @@ class PreferencesDialog(wx.Dialog):
if preferedDriver and preferedDriver in driverList:
driverIndex = driverIndexes[driverList.index(preferedDriver)]
self.popupOutDriver.SetStringSelection(preferedDriver)
- elif defaultDriver:
+ elif defaultDriver >= 0:
self.popupOutDriver.SetSelection(driverIndexes.index(defaultDriver))
# TODO: Added "all" interfaces option in input and output
@@ -5597,8 +5689,8 @@ class PreferencesDialog(wx.Dialog):
mainSizer.Add(ctrlSizer, 0, wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, 5)
btnSizer = self.CreateButtonSizer(wx.CANCEL|wx.OK)
-
- mainSizer.AddSpacer((-1,5))
+
+ mainSizer.AddSpacer(5)
mainSizer.Add(wx.StaticLine(self), 1, wx.EXPAND|wx.ALL, 2)
mainSizer.Add(btnSizer, 0, wx.ALL | wx.ALIGN_RIGHT, 5)
self.SetSizer(mainSizer)
@@ -5626,7 +5718,7 @@ class PreferencesDialog(wx.Dialog):
def setServerDefaultArgs(self, evt):
self.server_args.SetValue(BACKGROUND_SERVER_DEFAULT_ARGS)
-
+
def writePrefs(self):
global ALLOWED_EXT, WHICH_PYTHON, RESOURCES_PATH, SNIPPETS_PATH, STYLES_PATH, BACKGROUND_SERVER_ARGS
@@ -5666,10 +5758,10 @@ class PreferencesDialog(wx.Dialog):
extensions = [ext.strip() for ext in self.entry_ext.GetValue().split(",")]
ALLOWED_EXT = PREFERENCES["allowed_ext"] = extensions
-
+
server_args = self.server_args.GetValue()
BACKGROUND_SERVER_ARGS = PREFERENCES["background_server_args"] = server_args
-
+
PREFERENCES["background_server_out_device"] = self.popupOutDriver.GetStringSelection()
PREFERENCES["background_server_in_device"] = self.popupInDriver.GetStringSelection()
midiDevice = self.popupMidiInDriver.GetStringSelection()
@@ -5684,22 +5776,22 @@ class STCPrintout(wx.Printout):
framework
This class can be used for both printing to a printer and for print preview
- functions. Unless otherwise specified, the print is scaled based on the
+ functions. Unless otherwise specified, the print is scaled based on the
size of the current font used in the STC so that specifying a larger font
produces a larger font in the printed output (and correspondingly fewer
- lines per page). Alternatively, you can eihdec specify the number of
+ lines per page). Alternatively, you can eihdec specify the number of
lines per page, or you can specify the print font size in points which
produces a constant number of lines per inch regardless of the paper size.
Note that line wrapping in the source STC is currently ignored and lines
- will be truncated at the right margin instead of wrapping. The STC doesn't
+ will be truncated at the right margin instead of wrapping. The STC doesn't
provide a convenient method for determining where line breaks occur within
a wrapped line, so it may be a difficult task to ever implement printing
with line wrapping using the wx.StyledTextCtrl.FormatRange method.
"""
debuglevel = 1
- def __init__(self, stc, page_setup_data=None, print_mode=None, title=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.
@@ -5709,7 +5801,7 @@ class STCPrintout(wx.Printout):
is used to determine the margins of the page.
@kwarg print_mode: optional; of the wx.stc.STC_PRINT_*
- flags indicating how to render color text. Defaults to
+ flags indicating how to render color text. Defaults to
wx.stc.STC_PRINT_COLOURONWHITEDEFAULTBG
@kwarg title: optional text string to use as the title which will be
@@ -5719,14 +5811,14 @@ class STCPrintout(wx.Printout):
border around the text on each page
@kwarg lines_per_page: optional integer that will force the page to
- contain the specified number of lines. Either of C{output_point_size}
+ contain the specified number of lines. Either of C{output_point_size}
and C{lines_per_page} fully specifies the page, so if both are
specified, C{lines_per_page} will be used.
@kwarg output_point_size: optional integer that will force the output
- text to be drawn in the specified point size. (Note that there are
+ text to be drawn in the specified point size. (Note that there are
72 points per inch.) If not specified, the point size of the text in
- the STC will be used unless C{lines_per_page} is specified. Either of
+ the STC will be used unless C{lines_per_page} is specified. Either of
C{output_point_size} and C{lines_per_page} fully specifies the page,
so if both are specified, C{lines_per_page} will be used.
"""
@@ -5783,11 +5875,11 @@ class STCPrintout(wx.Printout):
logical coordinates.
"""
if self.debuglevel > 0:
- print
+ print()
dc.SetFont(self.stc.GetFont())
- # Calculate pixels per inch of the various devices. The dc_ppi will be
+ # Calculate pixels per inch of the various devices. The dc_ppi will be
# equivalent to the page or screen PPI if the target is the printer or
# a print preview, respectively.
page_ppi_x, page_ppi_y = self.GetPPIPrinter()
@@ -5798,10 +5890,10 @@ class STCPrintout(wx.Printout):
print("screen ppi: %dx%d" % (screen_ppi_x, screen_ppi_y))
print("dc ppi: %dx%d" % (dc_ppi_x, dc_ppi_y))
- # Calculate paper size. Note that this is the size in pixels of the
+ # Calculate paper size. Note that this is the size in pixels of the
# entire paper, which may be larger than the printable range of the
- # printer. We need to use the entire paper size because we calculate
- # margins ourselves. Note that GetPageSizePixels returns the
+ # printer. We need to use the entire paper size because we calculate
+ # margins ourselves. Note that GetPageSizePixels returns the
# dimensions of the printable area.
px, py, pw, ph = self.GetPaperRectPixels()
page_width_inch = float(pw) / page_ppi_x
@@ -5858,7 +5950,7 @@ class STCPrintout(wx.Printout):
@param dc: the Device Context
@param usable_page_height_mm: height in mm of the printable part of the
- page (i.e. with the border height removed)
+ page (i.e. with the border height removed)
@returns: the number of lines on the page
"""
@@ -5871,7 +5963,7 @@ class STCPrintout(wx.Printout):
else:
points_per_line = font.GetPointSize()
- # desired lines per mm based on point size. Note: printer points are
+ # desired lines per mm based on point size. Note: printer points are
# defined as 72 points per inch
lines_per_inch = 72.0 / float(points_per_line)
@@ -5899,7 +5991,7 @@ class STCPrintout(wx.Printout):
# actual line height in pixels according to the DC
dc_pixels_per_line = dc.GetCharHeight()
- # actual line height in pixels according to the STC. This can be
+ # actual line height in pixels according to the STC. This can be
# different from dc_pixels_per_line even though it is the same font.
# Don't know why this is the case; maybe because the STC takes into
# account additional spacing?
@@ -6043,7 +6135,7 @@ class STCPrintout(wx.Printout):
dc.SetFont(self.getHeaderFont())
dc.SetTextForeground ("black")
dum, yoffset = dc.GetTextExtent(".")
- yoffset /= 2
+ yoffset = yoffset // 2
if self.title:
title_w, title_h = dc.GetTextExtent(self.title)
dc.DrawText(self.title, self.x1, self.y1 - title_h - yoffset)
@@ -6091,7 +6183,7 @@ 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,
+ dc.DrawRectangle(self.x1, self.y1, self.x2 - self.x1 + 1,
self.y2 - self.y1 + 1)
class MyFileDropTarget(wx.FileDropTarget):
@@ -6108,6 +6200,7 @@ class MyFileDropTarget(wx.FileDropTarget):
self.window.GetTopLevelParent().panel.addPage(file)
else:
pass
+ return True
class EPyoApp(wx.App):
def __init__(self, *args, **kwargs):
@@ -6120,13 +6213,13 @@ class EPyoApp(wx.App):
else: X = 850
if Y < 750: Y -= 50
else: Y = 750
- self.frame = MainFrame(None, -1, title='E-Pyo Editor',
+ 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:
+ if type(filenames) != list:
filenames = [filenames]
for filename in filenames:
if os.path.isdir(filename):
@@ -6155,4 +6248,4 @@ if __name__ == '__main__':
pass
app = EPyoApp(redirect=False)
- app.MainLoop()
+ app.MainLoop()
\ No newline at end of file
diff --git a/utils/PyoDoc.py b/utils/PyoDoc.py
index 262891d..b88322b 100644
--- a/utils/PyoDoc.py
+++ b/utils/PyoDoc.py
@@ -1,12 +1,17 @@
#!/usr/bin/env python
# encoding: utf-8
-from __future__ import with_statement
+from __future__ import print_function
import subprocess, threading, os, sys, unicodedata
import wx
-import wx.stc as stc
+import wx.stc as stc
from wx.lib.embeddedimage import PyEmbeddedImage
from pyo import *
+if sys.version_info[0] < 3:
+ unicode_t = unicode
+else:
+ unicode_t = str
+
DOC_AS_SINGLE_APP = False
PLATFORM = sys.platform
@@ -181,25 +186,25 @@ up_24_png = PyEmbeddedImage(
"3Aey0QOcASDAAN0xfmdOgZiqAAAAAElFTkSuQmCC")
catalog['up_24.png'] = up_24_png
-_INTRO_TEXT = """
+_INTRO_TEXT = """
pyo manual version %s
pyo is a Python module written in C to help digital signal processing script creation.
-pyo is a Python module containing classes for a wide variety of audio signal processing types.
-With pyo, user will be able to include signal processing chains directly in Python scripts or
-projects, and to manipulate them in real-time through the interpreter. Tools in pyo module
-offer primitives, like mathematical operations on audio signal, basic signal processing
-(filters, delays, synthesis generators, etc.) together with complex algorithms to create
-granulation and others creative sound manipulations. pyo supports OSC protocol (Open Sound
-Control), to ease communications between softwares, and MIDI protocol, for generating sound
-events and controlling process parameters. pyo allows creation of sophisticated signal
-processing chains with all the benefits of a mature, and wild used, general programming
+pyo is a Python module containing classes for a wide variety of audio signal processing types.
+With pyo, user will be able to include signal processing chains directly in Python scripts or
+projects, and to manipulate them in real-time through the interpreter. Tools in pyo module
+offer primitives, like mathematical operations on audio signal, basic signal processing
+(filters, delays, synthesis generators, etc.) together with complex algorithms to create
+granulation and others creative sound manipulations. pyo supports OSC protocol (Open Sound
+Control), to ease communications between softwares, and MIDI protocol, for generating sound
+events and controlling process parameters. pyo allows creation of sophisticated signal
+processing chains with all the benefits of a mature, and wild used, general programming
language.
Overview:
-Server : Main processing audio loop callback handler.
+Server : Main processing audio loop callback handler.
PyoObjectBase : Base class for all pyo objects.
PyoObject : Base class for all pyo objects that manipulate vectors of samples.
PyoTableObject : Base class for all pyo table objects.
@@ -210,16 +215,17 @@ functions : Miscellaneous functions.
""" % PYO_VERSION
PYOGUI_DOC = """
-The classes in this module are based on internal classes that where
+The classes in this module are based on internal classes that where
originally designed to help the creation of graphical tools for the
control and the visualization of audio signals. WxPython must be installed
under the current Python distribution to access these classes.
"""
-_DOC_KEYWORDS = ['Attributes', 'Examples', 'Methods', 'Notes', 'Methods details',
+_DOC_KEYWORDS = ['Attributes', 'Examples', 'Methods', 'Notes', 'Methods details',
'Parentclass', 'Overview', 'Initline', 'Description', 'Parameters']
-_HEADERS = ["Server", "PyoObjectBase", "Map", "Stream", "TableStream", "functions", "PyoGui"]
+_HEADERS = ["Server", "PyoObjectBase", "Map", "Stream", "TableStream", "functions",
+ "MidiListener", "OscListener", "PyoGui"]
_KEYWORDS_LIST = ['SLMap']
_KEYWORDS_LIST.extend(_HEADERS)
_NUM_PAGES = 1
@@ -240,7 +246,7 @@ for k1 in _HEADERS:
else:
_KEYWORDS_LIST.extend(OBJECTS_TREE[k1])
_NUM_PAGES += len(OBJECTS_TREE[k1])
-
+
PYOOBJECTBASE_METHODS_FILTER = [x[0] for x in inspect.getmembers(PyoObjectBase, inspect.ismethod)]
PYOOBJECT_METHODS_FILTER = [x[0] for x in inspect.getmembers(PyoObject, inspect.ismethod)]
PYOMATRIXOBJECT_METHODS_FILTER = [x[0] for x in inspect.getmembers(PyoMatrixObject, inspect.ismethod)]
@@ -265,10 +271,10 @@ def _ed_set_style(editor, searchKey=None):
editor.SetTabWidth(4)
editor.SetUseTabs(False)
- editor.StyleSetSpec(stc.STC_STYLE_DEFAULT, "fore:%(default)s,face:%(face)s,size:%(size)d,back:%(background)s" % DOC_FACES)
+ editor.StyleSetSpec(stc.STC_STYLE_DEFAULT, "fore:%(default)s,face:%(face)s,size:%(size)d,back:%(background)s" % DOC_FACES)
editor.StyleClearAll()
- editor.StyleSetSpec(stc.STC_STYLE_DEFAULT, "fore:%(default)s,face:%(face)s,size:%(size)d" % DOC_FACES)
- editor.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "fore:%(linenumber)s,back:%(marginback)s,face:%(face)s,size:%(size2)d" % DOC_FACES)
+ editor.StyleSetSpec(stc.STC_STYLE_DEFAULT, "fore:%(default)s,face:%(face)s,size:%(size)d" % DOC_FACES)
+ editor.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "fore:%(linenumber)s,back:%(marginback)s,face:%(face)s,size:%(size2)d" % DOC_FACES)
editor.StyleSetSpec(stc.STC_STYLE_CONTROLCHAR, "fore:%(default)s,face:%(face)s" % DOC_FACES)
editor.StyleSetSpec(stc.STC_P_DEFAULT, "fore:%(default)s,face:%(face)s,size:%(size)d" % DOC_FACES)
editor.StyleSetSpec(stc.STC_P_COMMENTLINE, "fore:%(comment)s,face:%(face)s,size:%(size)d" % DOC_FACES)
@@ -304,20 +310,32 @@ class ManualPanel(wx.Treebook):
wx.Treebook.__init__(self, parent, -1, style=wx.BK_DEFAULT | wx.SUNKEN_BORDER)
self.parent = parent
self.searchKey = None
+ self.needToParse = True
self.Bind(wx.EVT_TREEBOOK_PAGE_CHANGED, self.OnPageChanged)
self.parse()
-
+
def reset_history(self):
self.fromToolbar = False
self.oldPage = ""
self.sequence = []
self.seq_index = 0
+ def deleteAllPagesButOne(self):
+ c = self.GetPageCount()
+ c-= 1
+ while c != 0:
+ self.DeletePage(c)
+ c -= 1
+
def parse(self):
self.searchKey = None
- self.DeleteAllPages()
self.reset_history()
+ makeIntro = True
+ if self.GetPageCount() > 0:
+ self.deleteAllPagesButOne()
+ makeIntro = False
+
self.needToParse = False
if not os.path.isdir(DOC_PATH):
os.mkdir(DOC_PATH)
@@ -332,8 +350,9 @@ class ManualPanel(wx.Treebook):
dlg.SetSize((300, 100))
keepGoing = True
count = 1
- win = self.makePanel("Intro")
- self.AddPage(win, "Intro")
+ if makeIntro:
+ win = self.makePanel("Intro")
+ self.AddPage(win, "Intro")
for key in _HEADERS:
if type(OBJECTS_TREE[key]) == type([]):
count += 1
@@ -393,11 +412,11 @@ class ManualPanel(wx.Treebook):
dlg.Destroy()
self.setStyle()
self.getPage("Intro")
- wx.FutureCall(100, self.AdjustSize)
+ wx.CallLater(100, self.AdjustSize)
def parseOnSearchName(self, keyword):
self.searchKey = None
- self.DeleteAllPages()
+ self.deleteAllPagesButOne()
self.reset_history()
keyword = keyword.lower()
@@ -474,7 +493,7 @@ class ManualPanel(wx.Treebook):
def parseOnSearchPage(self, keyword):
self.searchKey = keyword
- self.DeleteAllPages()
+ self.deleteAllPagesButOne()
self.reset_history()
keyword = keyword.lower()
@@ -559,7 +578,6 @@ class ManualPanel(wx.Treebook):
wx.CallAfter(self.AdjustSize)
def AdjustSize(self):
- self.GetTreeCtrl().InvalidateBestSize()
self.SendSizeEvent()
def copy(self):
@@ -823,42 +841,6 @@ class ManualPanel(wx.Treebook):
self.fromToolbar = False
return
- def getMethodsDoc2(self, text, obj):
- if obj == "Clean_objects":
- return "Methods details:\n\nClean_objects.start():\n\n Starts the thread. The timer begins on this call."
- lines = text.splitlines(True)
- flag = False
- methods = ''
- for line in lines:
- if flag:
- if line.strip() == '': continue
- else:
- l = line.lstrip()
- ppos = l.find('(')
- if ppos != -1:
- meth = l[0:ppos]
- args, varargs, varkw, defaults = inspect.getargspec(getattr(eval(obj), meth))
- args = inspect.formatargspec(args, varargs, varkw, defaults, formatvalue=removeExtraDecimals)
- args = args.replace('self, ', '')
- methods += obj + '.' + meth + args + ':\n'
- docstr = getattr(eval(obj), meth).__doc__.rstrip()
- methods += docstr + '\n\n '
-
- if 'Methods:' in line:
- flag = True
- methods += ' Methods details:\n\n '
-
- for key in _DOC_KEYWORDS:
- if key != 'Methods':
- if key in line:
- flag = False
-
- methods_form = ''
- if methods != '':
- for line in methods.splitlines():
- methods_form += line[4:] + '\n'
- return methods_form
-
def getExampleScript(self):
stc = self.GetPage(self.GetSelection()).win
start = stc.LineFromPosition(stc.FindText(0, stc.GetLength(), "Examples:")) + 1
@@ -869,6 +851,7 @@ class ManualPanel(wx.Treebook):
return text
def setStyle(self):
+ return # TreeBook has no more a GetTreeCtrl method. Don't know how to retrieve it...
tree = self.GetTreeCtrl()
tree.SetBackgroundColour(DOC_STYLES['Default']['background'])
root = tree.GetRootItem()
@@ -884,7 +867,7 @@ class ManualPanel(wx.Treebook):
(child, cookie) = tree.GetNextChild(root, cookie)
class ManualFrame(wx.Frame):
- def __init__(self, parent=None, id=-1, title='Pyo Documentation', size=(940, 700),
+ def __init__(self, parent=None, id=-1, title='Pyo Documentation', size=(940, 700),
osx_app_bundled=False, which_python="python",
caller_need_to_invoke_32_bit=False,
set_32_bit_arch="export VERSIONER_PYTHON_PREFER_32_BIT=yes;"):
@@ -903,32 +886,44 @@ class ManualFrame(wx.Frame):
tb_size = 24
self.toolbar = self.CreateToolBar()
- self.toolbar.SetToolBitmapSize((tb_size, tb_size)) # sets icon size
+ self.toolbar.SetToolBitmapSize((tb_size, tb_size)) # sets icon size
back_ico = catalog["previous_%d.png" % tb_size]
forward_ico = catalog["next_%d.png" % tb_size]
home_ico = catalog["up_%d.png" % tb_size]
exec_ico = catalog["play_%d.png" % tb_size]
- backTool = self.toolbar.AddSimpleTool(wx.ID_BACKWARD, back_ico.GetBitmap(), "Back")
+ if sys.version_info[0] < 3:
+ backTool = self.toolbar.AddSimpleTool(wx.ID_BACKWARD, back_ico.GetBitmap(), "Back")
+ else:
+ backTool = self.toolbar.AddTool(wx.ID_BACKWARD, "", back_ico.GetBitmap(), "Back")
self.toolbar.EnableTool(wx.ID_BACKWARD, False)
self.Bind(wx.EVT_MENU, self.onBack, backTool)
self.toolbar.AddSeparator()
- forwardTool = self.toolbar.AddSimpleTool(wx.ID_FORWARD, forward_ico.GetBitmap(), "Forward")
+ if sys.version_info[0] < 3:
+ forwardTool = self.toolbar.AddSimpleTool(wx.ID_FORWARD, forward_ico.GetBitmap(), "Forward")
+ else:
+ forwardTool = self.toolbar.AddTool(wx.ID_FORWARD, "", forward_ico.GetBitmap(), "Forward")
self.toolbar.EnableTool(wx.ID_FORWARD, False)
self.Bind(wx.EVT_MENU, self.onForward, forwardTool)
self.toolbar.AddSeparator()
- homeTool = self.toolbar.AddSimpleTool(wx.ID_HOME, home_ico.GetBitmap(), "Go Home")
+ if sys.version_info[0] < 3:
+ homeTool = self.toolbar.AddSimpleTool(wx.ID_HOME, home_ico.GetBitmap(), "Go Home")
+ else:
+ homeTool = self.toolbar.AddTool(wx.ID_HOME, "", home_ico.GetBitmap(), "Go Home")
self.toolbar.EnableTool(wx.ID_HOME, True)
self.Bind(wx.EVT_MENU, self.onHome, homeTool)
self.toolbar.AddSeparator()
- execTool = self.toolbar.AddSimpleTool(wx.ID_PREVIEW, exec_ico.GetBitmap(), "Run Example")
+ if sys.version_info[0] < 3:
+ execTool = self.toolbar.AddSimpleTool(wx.ID_PREVIEW, exec_ico.GetBitmap(), "Run Example")
+ else:
+ execTool = self.toolbar.AddTool(wx.ID_PREVIEW, "", exec_ico.GetBitmap(), "Run Example")
self.toolbar.EnableTool(wx.ID_PREVIEW, True)
self.Bind(wx.EVT_MENU, self.onRun, execTool)
@@ -990,7 +985,7 @@ class ManualFrame(wx.Frame):
self.search.SetFocus()
def onSearchEnter(self, evt):
- self.doc_panel.GetTreeCtrl().SetFocus()
+ self.doc_panel.SetFocus()
def onSearch(self, evt):
if self.searchTimer != None:
@@ -1055,7 +1050,7 @@ class ManualFrame(wx.Frame):
f.write(text)
th = RunningThread(DOC_EXAMPLE_PATH, TEMP_PATH, self.which_python, self.osx_app_bundled, self.caller_need_to_invoke_32_bit, self.set_32_bit_arch)
th.start()
- wx.FutureCall(8000, self.status.SetStatusText, "", 0)
+ wx.CallLater(8000, self.status.SetStatusText, "", 0)
class RunningThread(threading.Thread):
def __init__(self, path, cwd, which_python, osx_app_bundled, caller_need_to_invoke_32_bit, set_32_bit_arch):
@@ -1077,23 +1072,23 @@ 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;env;" % vars_to_remove
if self.caller_need_to_invoke_32_bit:
- self.proc = subprocess.Popen(["%s%s%s %s" % (prelude, self.set_32_bit_arch, self.which_python, self.path)],
+ self.proc = subprocess.Popen(["%s%s%s %s" % (prelude, self.set_32_bit_arch, self.which_python, self.path)],
shell=True, cwd=self.cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
- self.proc = subprocess.Popen(["%s%s %s" % (prelude, self.which_python, self.path)], cwd=self.cwd,
+ self.proc = subprocess.Popen(["%s%s %s" % (prelude, self.which_python, self.path)], cwd=self.cwd,
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
elif wx.Platform == '__WXMAC__':
if self.caller_need_to_invoke_32_bit:
- self.proc = subprocess.Popen(["%s%s %s" % (self.set_32_bit_arch, self.which_python, self.path)],
+ self.proc = subprocess.Popen(["%s%s %s" % (self.set_32_bit_arch, self.which_python, self.path)],
shell=True, cwd=self.cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
- self.proc = subprocess.Popen(["%s %s" % (self.which_python, self.path)], cwd=self.cwd,
+ self.proc = subprocess.Popen(["%s %s" % (self.which_python, self.path)], cwd=self.cwd,
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
elif wx.Platform == "__WXMSW__":
- self.proc = subprocess.Popen([self.which_python, self.path], cwd=self.cwd,
+ self.proc = subprocess.Popen([self.which_python, self.path], cwd=self.cwd,
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
- self.proc = subprocess.Popen([self.which_python, self.path], cwd=self.cwd,
+ self.proc = subprocess.Popen([self.which_python, self.path], cwd=self.cwd,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -1101,7 +1096,7 @@ class RunningThread(threading.Thread):
time.sleep(.25)
def ensureNFD(unistr):
- if PLATFORM in ['linux2', 'win32']:
+ if PLATFORM == 'win32' or PLATFORM.startswith('linux'):
encodings = [DEFAULT_ENCODING, ENCODING,
'cp1252', 'iso-8859-1', 'utf-16']
format = 'NFC'
@@ -1110,7 +1105,7 @@ def ensureNFD(unistr):
'macroman', 'iso-8859-1', 'utf-16']
format = 'NFC'
decstr = unistr
- if type(decstr) != UnicodeType:
+ if type(decstr) != unicode_t:
for encoding in encodings:
try:
decstr = decstr.decode(encoding)
@@ -1119,7 +1114,7 @@ def ensureNFD(unistr):
continue
except:
decstr = "UnableToDecodeString"
- print "Unicode encoding not in a recognized format..."
+ print("Unicode encoding not in a recognized format...")
break
if decstr == "UnableToDecodeString":
return unistr
@@ -1138,7 +1133,7 @@ def toSysEncoding(unistr):
if __name__ == "__main__":
DOC_AS_SINGLE_APP = True
- app = wx.PySimpleApp()
+ app = wx.App()
doc_frame = ManualFrame()
doc_frame.Show()
- app.MainLoop()
+ app.MainLoop()
\ No newline at end of file
diff --git a/utils/epyo_builder_OSX.sh b/utils/epyo_builder_OSX.sh
deleted file mode 100755
index 74cfebf..0000000
--- a/utils/epyo_builder_OSX.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-mkdir Resources
-cp PyoDoc.py Resources/
-cp Tutorial_01_RingMod.py Resources/
-cp Tutorial_02_Flanger.py Resources/
-cp Tutorial_03_TriTable.py Resources/
-cp *.icns Resources/
-cp -R ../examples Resources/
-cp -R snippets Resources/
-cp -R styles Resources/
-
-rm -rf build dist
-py2applet --make-setup --argv-emulation=0 E-Pyo.py Resources/*
-python setup.py py2app --plist=info.plist
-rm -f setup.py
-rm -rf build
-mv dist E-Pyo_OSX
-
-if cd E-Pyo_OSX;
-then
- find . -name .git -depth -exec rm -rf {} \
- find . -name *.pyc -depth -exec rm -f {} \
- find . -name .* -depth -exec rm -f {} \;
-else
- echo "Something wrong. E-Pyo_OSX not created"
- exit;
-fi
-
-# 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-x86_64.app E-Pyo.app
-
-cd ..
-cp -R E-Pyo_OSX/E-Pyo.app .
-
-# 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 ../..
-
-rm -rf E-Pyo_OSX
-rm -rf Resources
diff --git a/utils/epyo_builder_win32.py b/utils/epyo_builder_win32.py
index eeb85e7..70fd483 100644
--- a/utils/epyo_builder_win32.py
+++ b/utils/epyo_builder_win32.py
@@ -13,8 +13,11 @@ shutil.copytree("../examples", "Resources/examples")
shutil.copytree("snippets", "Resources/snippets")
shutil.copytree("styles", "Resources/styles")
-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)
+if version[0] < 3:
+ 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)
+else:
+ os.system('pyinstaller --clean -F -c --icon=Resources\E-PyoIcon.ico "E-Pyo.py"')
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
deleted file mode 100644
index fd258f1..0000000
--- a/utils/info.plist
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleDisplayName</key>
- <string>E-Pyo</string>
- <key>CFBundleDocumentTypes</key>
- <array>
- <dict>
- <key>CFBundleTypeOSTypes</key>
- <array>
- <string>TEXT</string>
- </array>
- <key>CFBundleTypeExtensions</key>
- <array>
- <string>py</string>
- </array>
- <key>CFBundleTypeRole</key>
- <string>Editor</string>
- <key>CFBundleTypeIconFile</key>
- <string>E-PyoIconDoc.icns</string>
- <key>LSIsAppleDefaultForType</key>
- <false/>
- </dict>
- </array>
- <key>CFBundleExecutable</key>
- <string>E-Pyo</string>
- <key>CFBundleIconFile</key>
- <string>E-PyoIcon.icns</string>
- <key>CFBundleIdentifier</key>
- <string>org.pythonmac.unspecified.E-Pyo</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>0.7.9</string>
- <key>CFBundleName</key>
- <string>E-Pyo</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>0.7.9</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>0.7.9</string>
- <key>LSHasLocalizedDisplayName</key>
- <false/>
- <key>NSAppleScriptEnabled</key>
- <false/>
- <key>NSHumanReadableCopyright</key>
- <string>Copyright not specified</string>
- <key>NSMainNibFile</key>
- <string>MainMenu</string>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
- <key>PyMainFileNames</key>
- <array>
- <string>__boot__</string>
- </array>
- <key>PyOptions</key>
- <dict>
- <key>alias</key>
- <false/>
- <key>argv_emulation</key>
- <true/>
- <key>no_chdir</key>
- <false/>
- <key>optimize</key>
- <integer>0</integer>
- <key>prefer_ppc</key>
- <false/>
- <key>site_packages</key>
- <false/>
- <key>use_pythonpath</key>
- <false/>
- </dict>
- <key>PyResourcePackages</key>
- <array/>
- <key>PyRuntimeLocations</key>
- <array>
- <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.7/Python</string>
- <key>PythonLongVersion</key>
- <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.7</string>
- <key>py2app</key>
- <dict>
- <key>alias</key>
- <false/>
- <key>template</key>
- <string>app</string>
- <key>version</key>
- <string>0.9</string>
- </dict>
- </dict>
-</dict>
-</plist>
--
python-pyo packaging
More information about the pkg-multimedia-commits
mailing list