Skip to content

Commit

Permalink
Removed drum overlap ; Added SOLO button
Browse files Browse the repository at this point in the history
  • Loading branch information
vlcoo authored May 7, 2022
1 parent 123226b commit 6edda0a
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 42 deletions.
19 changes: 10 additions & 9 deletions Channel.pde
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ChannelOsc {
boolean sostenuto_pedal = false;
boolean soft_pedal = false;
ArrayList<Integer> curr_holding;
ArrayList<Integer> curr_sustaining;
ArrayList<Integer> curr_sostenuting;
float curr_freqDetune = 0.0;
float curr_noteDetune = 0.0;
String please_how_many_midi_params_are_there = "dw, around 100+"; // darn.
Expand All @@ -36,14 +36,14 @@ public class ChannelOsc {
ChannelOsc() {
current_notes = new HashMap<Integer, SoundObject>();
curr_holding = new ArrayList();
curr_sustaining = new ArrayList();
curr_sostenuting = new ArrayList();
}


ChannelOsc(int osc_type) {
current_notes = new HashMap<Integer, SoundObject>();
curr_holding = new ArrayList();
curr_sustaining = new ArrayList();
curr_sostenuting = new ArrayList();
set_osc_type(osc_type);
}

Expand Down Expand Up @@ -104,7 +104,8 @@ public class ChannelOsc {

int sample_code = note_code_to_percussion(note_code);
SoundFile s = (SoundFile) samples[sample_code-1];
if (s == null || s.isPlaying()) return;
if (s == null) return;
if (s.isPlaying()) stop_note(note_code);

s.amp(amp * 0.32 * curr_global_amp * amp_multiplier * (soft_pedal ? 0.5 : 1));
s.play();
Expand All @@ -120,7 +121,7 @@ public class ChannelOsc {
curr_holding.add(note_code);
return;
}
if (sostenuto_pedal && curr_sustaining.contains(note_code)) {
if (sostenuto_pedal && curr_sostenuting.contains(note_code)) {
return;
}

Expand Down Expand Up @@ -154,15 +155,15 @@ public class ChannelOsc {
if (sostenuto_pedal) {
for (Entry<Integer, SoundObject> s : this.current_notes.entrySet()) {
if (((Oscillator) s.getValue()).isPlaying()) {
curr_sustaining.add(s.getKey());
curr_sostenuting.add(s.getKey());
}
}
}
else {
for (int note_code : curr_sustaining) {
for (int note_code : curr_sostenuting) {
stop_note(note_code);
}
curr_sustaining.clear();
curr_sostenuting.clear();
}
}

Expand Down Expand Up @@ -259,7 +260,7 @@ public class ChannelOsc {
void reset_params() {
current_notes.clear();
curr_holding.clear();
curr_sustaining.clear();
curr_sostenuting.clear();
last_amp = 0.0;
last_freq = 0;
last_notecode = -1;
Expand Down
44 changes: 32 additions & 12 deletions P3synth.pde
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import processing.awt.PSurfaceAWT;
final processing.core.PApplet PARENT = this;
final float VERCODE = 23.11;
final float OVERALL_VOL = 0.7;
final float HIRES_MULT = 2;

Frame frame;
String osname;
Expand All @@ -27,11 +28,23 @@ Button b_loop;
Button b_labs;
WaitingDialog dialog_meta_msgs;
HashMap<String, String> config_map;
boolean hi_res = false;

float _mouseX = 0;
float _mouseY = 0;

void settings() {
osname = System.getProperty("os.name");
if (osname.contains("Windows")) size(724, 460);
else size(724, 430);
int sizeX = 724;
int sizeY = 430;
if (osname.contains("Windows")) sizeY = 460;

if (hi_res) {
sizeX *= HIRES_MULT;
sizeY *= HIRES_MULT;
noSmooth();
}
size(sizeX, sizeY);
}


Expand All @@ -41,9 +54,9 @@ void setup() {
SinOsc warmup = new SinOsc(PARENT);
warmup.freq(100);
warmup.amp(0.1);
warmup.play(); // has to be done so the audio driver is prepared for what we're about to do to 'em...
Env warmup_env = new Env(PARENT);
warmup_env.play(warmup, 0.01, 0.08, 0.1, 0.04);

//size(724, 460);
surface.setTitle("vlco_o P3synth");
frame = ( (PSurfaceAWT.SmoothCanvas)surface.getNative() ).getFrame();

Expand All @@ -61,15 +74,26 @@ void setup() {
dnd_listener = new DnDListener();
drop.addDropListener(dnd_listener);

warmup.stop();
warmup_env = null;
warmup = null;
redraw_all();
}



void draw() {
if (hi_res) {
scale(HIRES_MULT);
_mouseX = mouseX / HIRES_MULT;
_mouseY = mouseY / HIRES_MULT;
}
else {
_mouseX = mouseX;
_mouseY = mouseY;
}

redraw_all();

if (player.playing_state == 1) {
int n = (int) (player.seq.getTickPosition() / (player.midi_resolution/4)) % 8;
image(logo_anim[abs(n)], 311, 10);
Expand Down Expand Up @@ -346,14 +370,10 @@ void mouseClicked() {
b_labs.set_pressed(!b_labs.pressed);
win_labs.reposition();
}

else {
player.disp.check_buttons(); // check for any presses on the player controls
player.check_chan_disp_buttons(); // check for any presses on the channel display
}

}

player.check_chan_disp_buttons(mouseButton); // check for any presses on the channel display

media_buttons.redraw();
setting_buttons.redraw();
b_meta_msgs.redraw();
Expand All @@ -363,7 +383,7 @@ void mouseClicked() {

void mouseDragged() {
if (mouseButton == LEFT) {
player.disp.check_buttons();
player.disp.check_buttons(mouseButton);
}
}

Expand Down
19 changes: 17 additions & 2 deletions Player.pde
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,23 @@ class Player {
}


void check_chan_disp_buttons() {
for (ChannelOsc c : channels) c.disp.check_buttons();
void set_channel_solo(boolean how, int chan) {
if (how) {
for (ChannelOsc c : channels) {
if (c.id == chan) c.set_muted(false);
else c.set_muted(true);
}
}
else {
for (ChannelOsc c : channels) {
c.set_muted(!c.silenced);
}
}
}


void check_chan_disp_buttons(int mButton) {
for (ChannelOsc c : channels) c.disp.check_buttons(mButton);
}


Expand Down
41 changes: 22 additions & 19 deletions UIServer.pde
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ class ChannelDisplay {
}


void check_buttons() {
void check_buttons(int mButton) {
if (button_mute.collided()) {
parent.set_muted(!button_mute.pressed);
if (mButton == LEFT) parent.set_muted(!button_mute.pressed);
else if (mButton == RIGHT) player.set_channel_solo(!button_mute.pressed, parent.id);
}
}

Expand Down Expand Up @@ -282,29 +283,31 @@ class PlayerDisplay {
}


void check_buttons() {
if (parent.playing_state == -1) return;

if (collided_posbar()) {
void check_buttons(int mButton) {
if (mButton == LEFT) {
if (parent.playing_state == -1) return;
int new_pos = int( map(_mouseX, x + POS_X_POSBAR, x + POS_X_POSBAR + WIDTH_POSBAR, 0, parent.seq.getTickLength()) );
parent.setTicks(new_pos);
return;
}

int handle_no = collided_loopset_bar();
try {
if (handle_no == -1) {

if (collided_posbar()) {
if (parent.playing_state == -1) return;
int new_pos = int( map(_mouseX, x + POS_X_POSBAR, x + POS_X_POSBAR + WIDTH_POSBAR, 0, parent.seq.getTickLength()) );
parent.seq.setLoopStartPoint(new_pos);
parent.setTicks(new_pos);
return;
}

else if (handle_no == 1) {
int new_pos = int( map(_mouseX, x + POS_X_POSBAR, x + POS_X_POSBAR + WIDTH_POSBAR, 0, parent.seq.getTickLength()) );
parent.seq.setLoopEndPoint(new_pos);
int handle_no = collided_loopset_bar();
try {
if (handle_no == -1) {
int new_pos = int( map(_mouseX, x + POS_X_POSBAR, x + POS_X_POSBAR + WIDTH_POSBAR, 0, parent.seq.getTickLength()) );
parent.seq.setLoopStartPoint(new_pos);
}

else if (handle_no == 1) {
int new_pos = int( map(_mouseX, x + POS_X_POSBAR, x + POS_X_POSBAR + WIDTH_POSBAR, 0, parent.seq.getTickLength()) );
parent.seq.setLoopEndPoint(new_pos);
}
}
catch (IllegalArgumentException iae) { }
}
catch (IllegalArgumentException iae) { }
}


Expand Down

0 comments on commit 6edda0a

Please sign in to comment.