-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added draw wavetable example, minor changes
- Loading branch information
1 parent
f0d3478
commit 2161ae7
Showing
34 changed files
with
757 additions
and
168 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
processing-library/wellen/examples/DSP/ExampleDSP25VocoderSAM/ExampleDSP25VocoderSAM.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import wellen.*; | ||
import wellen.dsp.*; | ||
|
||
/* | ||
* this example demonstrate how to use a vocoder with SAM. see the vocoder example for further explanation. | ||
*/ | ||
|
||
Vocoder mVocoder; | ||
|
||
Wavetable mVocoderCarrierOsc; | ||
|
||
SAM mSAM; | ||
|
||
void settings() { | ||
size(640, 480); | ||
} | ||
|
||
void setup() { | ||
Wellen.dumpAudioInputAndOutputDevices(); | ||
mVocoderCarrierOsc = new Wavetable(); | ||
Wavetable.fill(mVocoderCarrierOsc.get_wavetable(), Wellen.WAVEFORM_SAWTOOTH); | ||
mVocoderCarrierOsc.set_frequency(55); | ||
mVocoderCarrierOsc.set_amplitude(1.0f); | ||
mVocoder = new Vocoder(24, 4, Wellen.DEFAULT_SAMPLING_RATE, 1); | ||
mVocoder.set_volume(8); | ||
mSAM = new SAM(); | ||
DSP.start(this, 1); | ||
Beat.start(this, 140); | ||
} | ||
|
||
void draw() { | ||
background(255); | ||
stroke(0); | ||
final int mBufferSize = DSP.get_buffer_size(); | ||
DSP.draw_buffers(g, width, height); | ||
} | ||
|
||
void beat(int beatCount) { | ||
mSAM.say("hello"); | ||
} | ||
|
||
void mouseMoved() { | ||
mVocoder.set_formant_shift(map(mouseX, 0, width, 0.25f, 2.5f)); | ||
mVocoder.set_reaction_time(map(mouseY, 0, height, 0.002f, 0.1f)); | ||
} | ||
|
||
void keyPressed() { | ||
if (key == '1') { | ||
mVocoderCarrierOsc.set_frequency(27.5f); | ||
} | ||
if (key == '2') { | ||
mVocoderCarrierOsc.set_frequency(55.0f); | ||
} | ||
if (key == '3') { | ||
mVocoderCarrierOsc.set_frequency(110.0f); | ||
} | ||
if (key == '4') { | ||
mVocoderCarrierOsc.set_frequency(220.0f); | ||
} | ||
} | ||
|
||
void audioblock(float[] output_signal) { | ||
for (int i = 0; i < output_signal.length; i++) { | ||
float mCarrier = mVocoderCarrierOsc.output(); | ||
float mModulator = mSAM.output() * 0.5f; | ||
output_signal[i] = mVocoder.process(mCarrier, mModulator); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...ssing-library/wellen/examples/DSP/ExampleDSP26DrawWavetable/ExampleDSP26DrawWavetable.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import wellen.*; | ||
import wellen.dsp.*; | ||
|
||
/* | ||
* this example demonstrates how to draw data directly into a *wavetable* buffer. it is a nice way to explore how | ||
* slight changes in the wavetable can change the characterics of the sound ( e.g create a race engine sound ). | ||
* | ||
* move mouse to change amplitude and frequency. press and move mouse to draw into wavetable. press `1` to set | ||
* wavetable to sine shape, `2` to reset wavetable, `3` to disable interpolation and `4` to enable linear | ||
* interpolation. | ||
*/ | ||
|
||
Wavetable fWavetable; | ||
|
||
final int fWavetableSize = 128; | ||
|
||
void settings() { | ||
size(640, 480); | ||
} | ||
|
||
void setup() { | ||
fWavetable = new Wavetable(fWavetableSize); | ||
fWavetable.set_interpolation(Wellen.WAVESHAPE_INTERPOLATE_LINEAR); | ||
/* similar to `Wavetable.sine(fWavetable.get_wavetable())` */ | ||
for (int i = 0; i < fWavetable.get_wavetable().length; i++) { | ||
final float r = TWO_PI * (float) i / fWavetable.get_wavetable().length; | ||
fWavetable.get_wavetable()[i] = sin(r); | ||
} | ||
DSP.start(this); | ||
} | ||
|
||
void draw() { | ||
background(255); | ||
noStroke(); | ||
fill(32); | ||
for (int i = 0; i < fWavetable.get_wavetable().length; i++) { | ||
float x0 = map(i, 0, fWavetable.get_wavetable().length, 0, width); | ||
float y0 = map(fWavetable.get_wavetable()[i], -1, 1, 0, height); | ||
float x1 = map(i + 1, 0, fWavetable.get_wavetable().length, 0, width); | ||
float y1 = height * 0.5f; | ||
rectMode(CORNERS); | ||
rect(x0, y0, x1, y1); | ||
} | ||
stroke(0); | ||
DSP.draw_buffers(g, width, height); | ||
} | ||
|
||
void mouseMoved() { | ||
final float mNewFrequency = map(mouseX, 0, width, 1, 110); | ||
final float mNewAmplitude = map(mouseY, 0, height, 0, 1); | ||
fWavetable.set_frequency(mNewFrequency, Wellen.millis_to_samples(100)); | ||
fWavetable.set_amplitude(mNewAmplitude, Wellen.millis_to_samples(10)); | ||
} | ||
|
||
void mouseDragged() { | ||
int i = (int) map(mouseX, 0, width, 0, fWavetable.get_wavetable().length); | ||
i = constrain(i, 0, fWavetable.get_wavetable().length - 1); | ||
fWavetable.get_wavetable()[i] = map(mouseY, 0, height, -1, 1); | ||
} | ||
|
||
void keyPressed() { | ||
switch (key) { | ||
case '1': | ||
Wavetable.sine(fWavetable.get_wavetable()); | ||
break; | ||
case '2': | ||
Arrays.fill(fWavetable.get_wavetable(), 0.0f); | ||
break; | ||
case '3': | ||
fWavetable.set_interpolation(Wellen.WAVESHAPE_INTERPOLATE_NONE); | ||
break; | ||
case '4': | ||
fWavetable.set_interpolation(Wellen.WAVESHAPE_INTERPOLATE_LINEAR); | ||
break; | ||
} | ||
} | ||
|
||
void audioblock(float[] output_signal) { | ||
for (int i = 0; i < output_signal.length; i++) { | ||
output_signal[i] = fWavetable.output(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...n/examples/external/ExampleExternal11MIDIInputOutput/ExampleExternal11MIDIInputOutput.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import wellen.*; | ||
import wellen.dsp.*; | ||
|
||
/* | ||
* this example demonstrates how to send + receive MIDI events. | ||
*/ | ||
|
||
MidiOut mMidiOut; | ||
|
||
MidiIn mMidiIn; | ||
|
||
int mNote = 0; | ||
|
||
int mVelocity = 0; | ||
|
||
void settings() { | ||
size(640, 480); | ||
} | ||
|
||
void setup() { | ||
Wellen.dumpMidiInputDevices(); | ||
mMidiIn = new MidiIn("Arturia KeyStep 37"); | ||
mMidiIn.addListener(new MIDIInput()); | ||
mMidiOut = new MidiOut("Arturia KeyStep 37"); | ||
} | ||
|
||
void draw() { | ||
background(255); | ||
noStroke(); | ||
fill(map(mVelocity, 0, 127, 255, 0)); | ||
float mScale = Tone.is_playing() ? map(mNote, 24, 96, 5, height * 0.8f) : 5; | ||
ellipse(width * 0.5f, height * 0.5f, mScale, mScale); | ||
} | ||
|
||
void mousePressed() { | ||
mMidiOut.sendNoteOn(10, 48, 100); | ||
} | ||
|
||
class MIDIInput implements MidiInListener { | ||
|
||
void receiveProgramChange(int channel, int number, int value) { | ||
} | ||
|
||
void receiveControlChange(int channel, int number, int value) { | ||
} | ||
|
||
void clock_tick() { | ||
} | ||
|
||
void clock_start() { | ||
} | ||
|
||
void clock_continue() { | ||
} | ||
|
||
void clock_stop() { | ||
} | ||
|
||
void clock_song_position_pointer(int pOffset16th) { | ||
} | ||
|
||
void receiveNoteOff(int channel, int pitch) { | ||
Tone.instrument(channel); | ||
mNote = pitch; | ||
mVelocity = 0; | ||
Tone.note_off(mNote); | ||
} | ||
|
||
void receiveNoteOn(int channel, int pitch, int velocity) { | ||
Tone.instrument(channel); | ||
mNote = pitch; | ||
mVelocity = velocity; | ||
Tone.note_on(mNote, mVelocity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.