/* This is the third part of building a 4-step Sequencer Synthesizer modeling the one found at : http://www.handmadeelectronicinstruments.com/store/product/four-step-sequencer-synthesizer/ We start having some fun here. In this step, we add link all of the controls to a few sound synthesizers. We will need the external java library beads for all of the sound synthesis. There are 7 knobs on the device. The bottom four knobs each control the frequency of a square wave oscillator. The top left knob. controls the rate of the sequence. It essentially controls the speed of a clock. Each time the clock ticks, the next oscillator is turned on and the remaining three are turned off. The second knob on the top controls the cutoff frequency for a low-pass filter. In theory, you should be able to "turn off"an oscillator by raising its frequency above the cut-off frequency of the filter. In practice this doesn't work so well do to the quality of the filter, the qualities of the oscillators, aliasing, and other reasons. The right-most knob on the top controls the overall volume. Some minor modifications have been made to the Control class and a new class called Trigger has been added. Andy Sarroff, 2/2014 */ // Download the following from http://www.beadsproject.net/ import beads.*; PImage bgimg; PImage ledOn; PImage ledOff; PImage swOn; PImage swOff; int zone; // We will have an array of controls and and array of switches Control[] controls = new Control[7]; Switch[] switches = new Switch[5]; // The Clock instance will control the timing of the sequencer Clock cl; // create our AudioContext, which will oversee audio input/output AudioContext ac; // The Glide class interpolates smoothly (over time from a current value // to a target value. This makes value changes (e.g. for oscillator frequencies // smooth and pleasing sounding. Each control knob will be associated with a // Glide instance Glide[] glides = new Glide[7]; BiquadFilter lpf; WavePlayer[] wp = new WavePlayer[4]; ScalingMixer sc; Gain g; /* The audio chain will look like this: cl | --- wp ---\ | --- wp ---\ [ --- sc --- lpf --- g --- ac.out | --- wp ---/ | --- wp ---/ That is, the Clock triggers each individual WavePlayer, the sum of which feed the ScalingMixer. The mixer output goes through a low pass filter, a gain stage, and finally to the output. These connections are made in the function initializeAudio(). */ void setup() { size(692, 346); // http://img.ehowcdn.com/default/ehow/images/a07/fd/m6/types-brushed-aluminum-sheets-1.1-800x800.jpg bgimg = loadImage("aluminum.jpg"); bgimg.resize(bgimg.width*2, bgimg.height); imageMode(CENTER); // Load images // http://openclipart.org/image/300px/svg_to_png/88123/led_red_black.png ledOn = loadImage("led.png"); ledOn.resize(ledOn.width/10, 0); ledOff = loadImage("ledOff.png"); ledOff.resize(ledOff.width/10, 0); // http://www.yourpowercentre.com.au/wp-content/uploads/2013/10/switch.jpg swOn = loadImage("swOn.png"); swOn.resize(swOn.width/3, 0); swOff = loadImage("swOff.png"); swOff.resize(swOff.width/3, 0); // http://578e7a9bafc08e847f59-b21544d490ba797ec9de9d17e947de3d.r81.cf1.rackcdn.com/lrs-18519e_7379.jpg PImage img = loadImage("knob_t.png"); img.resize(img.width/4, 0); // Set size of window to match background image background(bgimg); // Inititalize controls for (int i=0; i= 2 && zone <=3) { controls[zone-1].update(); } else if (zone >=8 && zone <= 11) { controls[zone-5].update(); } } void mousePressed() { getZone(); if (zone == 1) { switches[4].on = !switches[4].on; if (switches[4].on) { ac.start(); } else { for (int i=0; i<4; i++) { switches[i].on = false; } ac.stop(); } } } // START NO NOTES // code used to capture screenshots void keyReleased() { boolean online = true; if (key == '`' && !online) save("sketch.png"); }