Complex Waveforms
With sawtooth and square wave, the amplitudes are 1/(harmonic number). So, with a sawtooth:
1st 2nd 3rd 4th
1/1 1/2 1/3 1/4 etc.
Remember, the first is also the fundamental.
Square waves, of course, are only the odd harmonics.
Triangle waves are trickier. The amplitudes are 1/((harmonic number)^2). And, to make matters worse, all the even harmonics are 180 degrees out of phase. But you can simulate this by giving it a negative amplitude. So the harmonics are like this:
1st 2nd 3rd 4th 5th
1/1 -1/4 1/9 -1/16 1/25 etc.
Does that make sense?
If you're only using multiple [osc~], make sure you synchronize their phases by sending a [0( to the right inlets.
Bandlimited oscillators
This is a collection of abstractions that generate bandlimited oscillators. They include:
[bl-saw.mmb~] - bandlimited sawtooth waveform
[bl-pulse.mmb~] - bandlimited pulse wave with PWM
[bl-tri.mmb~] - bandlimited triangle wave
[bl-asymtri.mmb~] - bandlimited asymmetrical triangle wave (sort of...see below)
There is also an object called [bl-init.mmb]. This is the object that initializes all the waveforms and at least one instance MUST be included in order for the others to work.
There are also help patches included. 
IMPORTANT!
Before you can use these, you must do the following steps.
1. Open [bl-init.mmb]
2. There is a message box that says [44100(. This is the maximum sampling rate that these will work at (running at lower sampling rates will be fine). If you plan on using higher sampling rates, change this message box and click it. Technically, it will still work at a higher sampling rate, but it won't generate harmonics above the sampling rate in this box.
3. Click the [bang( to fill the wave tables. This patch actually creates a wavetable for EVERY harmonic between 30Hz and the Nyquist frequency. So it will take a few minutes. Be patient! You will get a message in the Pd window when it is done.
4. Save the patch.
Once you do this, [bl-init.mmb] will simply load with the tables already generated, so you don't have to wait every time you instantiate it. I didn't have this already done for you in order to keep the upload small, and so you can see how to adjust it if you need to.
So, I guess I'll go ahead and try to explain how these work. As stated above, every harmonic is generated in [bl-init.mmb] for the oscillators. It doesn't create a table for each set of harmonics however (e.g., there isn't a saw table with two harmonics, a saw table with three harmonics, etc.). Instead, each of these individual tables are tacked on to the end of each other to create one long wave table. So, for each set of 1027 samples in the sawtooth wavetable, there is one cycle with a set amount of harmonics.
When the oscillators read the frequency input, it is divided into the Nyquist frequency to determine how many harmonics are needed. It then uses this (* 1027) as the offset for the table. This is how I got around the problem of table switching at block boundaries. By doing this way, the "switching" is done at audio rate.
There are actually two [tabread4~]s. One has one less harmonic than the other. As the frequency changes it crossfades between these tables. When one table goes completely silent, that's when it "switches." Below 30Hz, they switch to geometrically perfect waveforms.
[bl-saw.mmb~] and [bl-tri.mmb~] just read through the tables. Nothing really interesting about them.
[bl-pulse.mmb~] is actually the difference between to sawtooths. In other words, there are two bandlimited sawtooth oscillators inside of it. Adjusting the pulse width cause the phase of one of the sawtooths to shift. When you subtract this phase-shifted sawtooth from the other, it creates a bandlimited pulse wave...without oversampling! This is the same Phase Offset Modulation method used in Reason's SubTractor.
[bl-asymtri.mmb~] uses the same technique as [bl-pulse.mmb~], except it uses bandlimited parabola waves instead of sawtooths. Adjust the phase offset sets where the top vertex is. This doesn't really generate true triangle or saw waves, though. They still have the parabolic curve in them, so the harmonics seem to come out a little more. It's more of a "reasonable approximation." But, it is bandlimited, and it does sound pretty cool to modulate the shape. I don't have the scaling quite right yet, but I'll get to it later...maybe. 
I should also mention that these use my [vphasor.mmb~] abstraction, so the phase reset is sample accurate.
I'll eventually set these up to allow frequency and pulse-width arguments, but I'm currently in the process of moving to another country, so it may be a little bit before I get around to it.
Didn't any of that make any sense?
Bandlimited~ - bandlimited signal generator (square, triangle, saw)
IMPLEMENTATION DETAILS:
adding up harmonics for each phase can use a lot of CPU power, especially for lower frequency. Even in the current optimized state if you try playing a low frequency such as 2 or 3 hz it'll probably go above 100% usage.
So I decide to trade memory for cpu. Once you create the first instance of bandlimited~ it'll create 138 wavetables of size 2051 for each waveform type (square, triangle, saw, saw-triangle; rsaw is just saw inverted). In each table there will be a waveform generated with a different amount of harmonics, it iterates by 8.
So the tables will look like this:
8, 16, 24, 32, 40 ... 1104 harmonics
In the perform loop what it does is calculate the number of harmonics needed for the specified frequency: cutoff / frequency (cutoff is the nyquist limite), rounds down to the nearest integer.
It then checks to see which wave table is closest the this number and then calculates the missing component, ex:
44.1Kzh, nyquist = 22050
generated frequency = 330hz
number of harmonics = 66
the closest wave table has 64 harmonics
It'll then use 4 point interpolation (borrowed from tabread4~) to generate a signal from this wave table and add the harmonics 65-66.
This way the calculation loop is guaranteed to never be greater than 4 iterations.
The sin function itself is also placed in a wavetable of size 2051 (3 guard points). But when creating the waveform wavetables it'll use the real function.
Because the wavetables represent waveforms up to 1104 harmonics any frequency that requires more will start to eat up the CPU. These frequencies would be the frequencies below the nyquist limite divided by 1104.
That would be about 20hz at 44.1Kzh, 30hz at 88.2kz ...
EDIT: grammar
Hard-syncing phasors
Hello,
I'm trying to make something that sounds like C64 SID chip. One particular property of that chip is that, it is possible to hard-sync two oscillators, so that the slave oscillators phase is reset to zero every time master oscillators phase returns to zero. I couldn't find a a way to implement this in pd.
Trying to capture the zero crossings on the master oscillator seems to be a dead end, because i'll have to turn it into a control signal somewhere to connect it to the phase input on slave phasor. And control signals are much too slow to catch every zero crossing.
Any ideas?
MIDI NOTE OFF velocity question
stripnote filters out zero velocity bangs, not note off bangs unfortunately. Pd doesn't recognize note off it appears, it only recognizes zero velocity note events and assumes that they're note offs. if your master keyboard transmits note off velocity (which is MIDI standard btw) the note offs pass because they're not non-zero.
In my patches I use stripnote to take off the zero velocity note offs as my cheapo plastic keyboard at home doesn't transmit note off velocity (it sets it uniformly to zero), but it doesn't work with a 'better' master keyboard because note its note off is not zero velocity (when I lift my fingers off the keys in slow motion I still get values of ~20).
I should write to Miller...
)
\[zerox~\]
If you plan on using [xerox~] to phase sync two oscillators, it probably won't cut it. Generally, you want those things to be sample accurate. [xerox~] will give you a click corresponding to zero crossings out its right outlet, but, as far as I know at least, Pd's oscillators can't really use that for phase syncing ([xerox~] is actually based on a Max object, yet strangely Max's oscillators can't use it either). It would require a conversion to message rate to reset the phase, which kills sample accuracy, not to mention the fact that the phase input of [phasor~] quantizes to block boundaries (default 64 samples in Pd), which also kills sample accuracy.
However, if you know the ratio between your two oscillators, phase syncing can be achieved using a master [phasor~] to run both oscillators. Use the master sync frequency to drive the [phasor~], then multiply the output of the [phasor~] by the ratio between the synced (slave) oscillator and the master one. In other words, it should be multiplied by:
slave frequency / master frequency
Then, you just [wrap~] the signal and viola, you have a new synced phasor signal to drive the slave oscillator. The attached patch should hopefully clarify.
\[zerox~\]
Howdy.
I'm very new to pd, having just installed it to see if I could use it to create a synth I have already designed.
At the heart of the synth is a pair of sync oscillators. So, to recreate it, I'll need to be able to reset an oscillator to the beginning of its cycle every time a master oscillator crosses zero.
After searching, I read a couple old posts dealing with generally ineffective ways to detect zero crossings, and then chanced upon a post that mentions [zerox~]. Apparently, it detects all zero crossings (2 per cycle of a sine wave) and there is no help file to speak of.
Does anyone have any experience with this object? I'm interested in knowing if it is practical for audio-rate detection.
I'll be doing some experiments of my own, which will progress slowly as I familiarize myself with pd.
Thanks
Zero.pd
This is a question in the form of an answer;
A: a patch which loads a soundfile and stores all "zeroes" to a table. Then randomly scans the soundfile from zero to zero.
Q: Is there a tilde object which detects zero-crossings, and can it be used to 'shuffle' samples with no clicking?
Le Centre de Ressources Art Sensitif - Journées de formation Pure Data
Le Centre de Ressources Art Sensitif à Mains d'Oeuvres organise des ateliers et des journées de formation aux logiciels et matériels de gestion d'événements interactifs temps réel. Pour être tenu informé, inscrivez-vous à notre lettre d'information via le site Internet http://www.craslab.org
CALENDRIER
Journée Pure Data & Vidéo - Samedi 28 octobre 2006
11H00/13h puis 14H/18H
Tarif plein 20 euros // Tarif réduit 15 euros, sur présentation de justificatifs (chômeurs, étudiants, adhérents Art Sensitif, Audoniens)
Formateurs : Benjamin Cadon (Labomedia, Orléans), avec l'aide de Jean-Noël Montagné.
Atelier Arduino et Interfaces libres - Samedi 4 novembre 2006
11H00/13h puis 14H/18H
Tarif unique : 50€ (formation + matériels : interface Arduino, 1 capteur, 1 actionneur)
Formateurs : Maurin Donneaud et Vincent Roudault, avec l'aide de Jean-Noël Montagné.
Journée Pure Data & Audio - Samedi 18 novembre 2006
11H00/13h puis 14H/18H
Tarif plein 20 euros // Tarif réduit 15 euros, sur présentation de justificatifs (chômeurs, étudiants, adhérents Art Sensitif, Audoniens)
Formateurs : Cédric Buron, avec l'aide de Jean-Noël Montagné.
Stage Initiation à Processing - Samedi 2 & le dimanche 3 décembre 2006
Chaque journée : de 11H00 à 13h puis de 14H à 18H
Tarif plein 20 euros /par jour // Tarif réduit 15 euros / par jour, sur présentation de justificatifs (chômeurs, étudiants, adhérents Art Sensitif, Audoniens)
Formateurs : Julien Gachadoat, avec l'aide de Jean-Noël Montagné.
Réservations à : formations (àà ) craslab. org
Le détail des formations et des modalités d'inscription sont visibles sur le site Internet http://www.craslab.org
PROSPECTIVE
Le Centre de Ressources Art Sensitif prépare sa programmation de formations 2007 (événements en perspective, sous réserve) :
- 2 journées d'initiation à Pure Data
- Pure Data + capteurs & actionneurs
- Pure Data & 3D
- Atelier de pratique Processing + Wiring - interfaces en matériel libre
- Atelier de pratique CUI (Create Usb Interface) et fabrication d'interfaces simples
- Atelier de pratique fabrication de capteurs simples
- Journée thématique interaction temps réel & pédagogie
Centre de ressources Art Sensitif à Mains d'Œuvres
http://www.craslab.org
01.77.60.28.00.
Le C.R.A.S. est ouvert sur rendez-vous pour des prestations personnalisées (démos, conseils, etc.) et l'accompagnement de projet. Modalités, contact : info (àà ) craslab. org
Le C.R.A.S. est une réalisation des associations
Art Sensitif http://www.artsens.org
Mains d'œuvres http://www.mainsdoeuvres.org
Ce projet est co-financé par l'Union Européenne -FEDER- Actions innovatrices.
Avec le soutien du Conseil régional d'Ile-de-france.
*MAINS D'OEUVRES RECOIT LE SOUTIEN DE : Ville de Saint-Ouen, Conseil général de la Seine-Saint-Denis, Conseil régional d'Ile-de-france, DRAC Ile-de-France / Ministère de la Culture et de la Communication, Caisse des dépôts et consignations, Fondation France Active, Mairie de Paris, Direction départementale de la jeunesse et des sports de la Seine-Saint-Denis.
*MAINS D'OEUVRES EST MEMBRE DE : actes if (http://www.actesif.com), Artfactories (http://www.artfactories.net), Autre(s)pARTs
(http://autresparts.free.fr), TransEuropeHalles (http://www.teh.net), Médias-cité (http://www.medias-cite.org)
Mains d'Œuvres
1, rue Charles Garnier, 93 400 Saint-Ouen
Tel : 01 40 11 25 25 / Fax : 01 40 11 25 24
info@mainsdoeuvres.org
plan d'acces sur http://www.mainsdoeuvres.org • http://www.myspace.com/mainsdoeuvres.org
Métro Porte de Clignancourt (l.4) ou Garibaldi (l.13) / Bus 85 (Luxembourg -> Mairie de St-Ouen) : arrêt Paul Bert

