Rev 1723 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include "state_button.h"
#include "capturer.h"
#include "binaural_drones.h"
#include "console.h"
#include "din.h"
#include "ui_list.h"
#include "fractaliser.h"
#include "keyboard_keyboard.h"
#include "main.h"
#include "mondrian.h"
#include "oscilloscope.h"
state_button* capturer_t::add () {
#ifdef __EVALUATION__
if (ncaps == 1) {
cons << RED << "Can add more mouse captures in the Licensed Version of DIN Is Noise" << eol;
return 0;
}
#endif
state_button* sb = new state_button;
sb->set_pos (sbx, sby);
sbx += state_button::SIZE2;
title.add_child (sb);
caps.push_back (sb);
++ncaps;
return sb;
}
i_binaural_drones::i_binaural_drones () : wav ("binaural-drones-waveform.crv"), waved ("binaural-drones-waveform.ed"), fdrcrv ("fader.crv"), hlp ("binaural-drones.hlp") {
#ifdef __EVALUATION__
name = "binaural-drones [Evaluation Version]";
#else
name = "binaural-drones";
#endif
wavlis.sb = this;
waved.add (&wav, &wavlis);
extern curve_library wav_lib;
waved.attach_library (&wav_lib);
prev_mousex = prev_mousey = 0;
vol_fader.sol (&fdrcrv);
pitch_fader.sol (&fdrcrv);
abort = 0;
inst = 1;
}
din::din (cmdlist& cl) :
wave ("microtonal-keyboard-waveform.crv"),
waved ("microtonal-keyboard-waveform.ed"),
wavlis (wave_listener::MICROTONAL_KEYBOARD),
win (0, 0, view.xmax, view.ymax),
drone_wave ("drone.crv"),
droneed ("drone.ed"),
dronelis (wave_listener::DRONE),
fm ("fm", "fm.crv"),
am ("am", "am.crv"),
moded ("modulation.ed"),
am_delta (0.01f, 1),
gatr ("gr", "gater.crv"),
gated ("gater.ed"),
gatlib ("gater-patterns.lib"),
helptext ("din.hlp")
{
#ifdef __EVALUATION__
name = "microtonal-keyboard [Evaluation Version]";
#else
name = "microtonal-keyboard";
#endif
prev_mousex = prev_mousey = delta_mousex = delta_mousey = 0;
win_mousex = win_mousey = prev_win_mousex = prev_win_mousey = 0;
tonex = toney = 0;
current_range = 0;
adding = 0;
wanding = 0;
moving_drones = 0;
rising = falling = 0;
n_dvap = 0;
dvap = 0;
dap = 0;
n_dap = 0;
num_drones = 0;
create_drone_pend = 0;
static const int cap = 1024;
selected_drones.reserve (cap);
scaleinfo.scl = this;
fdr_gater_prev_amount = 0;
p_am_delta = &am_delta;
am_delta.depth = 0.01f;
rvec.reserve (cap);
svec.reserve (cap);
xforming = NONE;
num_selected_drones = num_browsed_drones = 0;
ptr_scaleinfo = &all_notes;
nstepz = 0;
con_pts = 0;
con_clr = 0;
con_size = 0;
totcon = 0;
_2totcon = 0;
ec = 0;
inst = 1;
dinfo.cen.lis = this;
/*butt = 50;
inter_butt = butt / 4.0;
ring.x = win_mousex;
ring.y = win_mousey;
ring.r = 5 * butt;
butting = 0;*/
}
void din::chuck () {
if (num_selected_drones > 1) {
#ifdef __EVALUATION__
if (num_selected_drones > 3) {
cons << RED << "Chuck with more than 3 drones possible in the Licensed Version of DIN Is Noise" << eol;
return;
}
#endif
int yes = 1;
drone* sun = selected_drones[0];
sun->chuck.set (yes, 0);
for (int i = 1; i < num_selected_drones; ++i) {
drone* planet = selected_drones[i];
planet->chuck.set (yes, sun);
sun->chuck.sat = planet;
planet->chuck.sat = 0;
planet->chuck.calc (planet);
sun = planet;
}
cons << GREEN << "Chucked " << num_selected_drones << " drones" << eol;
} else {
cons << RED_A2D << eol;
}
}
void din::create_drone_pendulum () {
int o = dinfo.drone_pend.orient;
double along[] = {rgn.width, rgn.height};
int num_drones = dinfo.drone_pend.n;
#ifdef __EVALUATION__
cons << RED << "Can create drone pendulums only in the Licensed Version of DIN Is Noise" << eol;
return;
#endif
CLEAR_SELECTED_DRONES
double xl [] = {double(rgn.left), double(rgn.midx)};
double yl [] = {double((rgn.bottom + rgn.top) / 2.0), double(rgn.bottom)};
double x = xl [o], y = yl [o];
double* xy [] = {&x, &y};
double& xyo = *xy[o];
double depths [] = {double(rgn.top - rgn.midy), double(rgn.right - rgn.midx)};
double depth = depths[o];
int nd1 = num_drones - 1;
double spacing = along[o] * 1.0 / nd1;
double _1bylast = 1.0 / nd1;
double a = 0.0f, da = _1bylast;
for (int i = 0, spc = aout.samples_per_channel; i < num_drones; ++i) {
get_color::data.p = i * _1bylast;
drone* pd = add_drone (x, y);
drone& d = *pd;
d.sel = 1;
selected_drones.push_back (pd);
d.mod.active = 1;
mod_params* mods [] = {&d.mod.am, &d.mod.fm};
mod_params& mod = *mods[o];
mod.depth = warp_depth (a) * depth;
mod.bv.set_bpm (warp_bpm (a)* dinfo.drone_pend.bpm, spc);
a += da;
xyo += spacing;
}
print_selected_drones ();
drone_pendulum_group* grp = new drone_pendulum_group (o, depth, selected_drones, num_selected_drones);
drone_pendulums.push_back (grp);
uis.dpeu.bpm.set_value (dinfo.drone_pend.bpm);
uis.dpeu.depth.set_value (depth);
cons << GREEN << "Created a drone pendulum of " << num_drones << " drones." << eol;
}
void din::create_drone_mesh () {
mkb_selector.mesh = 0;
#ifdef __EVALUATION__
if (mkb_selector.rowcol > 4) {
cons << RED << "Can only create a 2 x 2 drone mesh with the Evaluation Version oF DIN Is Noise" << eol;
return;
}
#endif
mkb_selector.orderer = mkb_selector.orderers [dinfo.mesh_vars.order];
mkb_selector.order_order ();
amd.triggert = dinfo.mesh_vars.duration * 1.0f / mkb_selector.rowcol;
amd.i = 0;
amd.j = mkb_selector.cols;
CLEAR_SELECTED_DRONES
amd.start ();
}
void din::change_range_note (int i, int d) {
#ifdef __EVALUATION__
cons << RED << "Change Left/Right Note/Octave is available in the Licensed Version of DIN Is Noise" << eol;
return;
#endif
int cn = dinfo.change_note;
scale_info& si = *ptr_scaleinfo;
range& sr = ranges [dinfo.sel_range];
if (cn)
sr.change_note (i, d, si);
else
sr.change_octave (i, d, si);
int ri, rj;
ri = rj = dinfo.sel_range;
if (i) {
int srr = dinfo.sel_range + 1;
if (srr < num_ranges) {
range& rsrr = ranges [srr];
if (cn)
rsrr.change_note (0, d, si);
else
rsrr.change_octave (0, d, si);
ri = dinfo.sel_range; rj = srr;
}
} else {
int srl = dinfo.sel_range - 1;
if (srl > -1) {
range& rsrl = ranges [srl];
if (cn)
rsrl.change_note (1, d, si);
else
rsrl.change_octave (1, d, si);
ri = srl; rj = dinfo.sel_range;
}
}
if (ri == rj)
refresh_drones (ri);
else
refresh_drones (ri, rj);
note& L = sr.notes[0];
note& R = sr.notes[1];
sprintf (BUFFER, "Left Note = %s @ %0.3f Hz, Right Note = %s @ %0.3f Hz, Hz/pixel = %0.3f", L.name.c_str(), L.hz, R.name.c_str(), R.hz, sr.hz_per_pix ());
cons << YELLOW << BUFFER << eol;
}
int din::connect_drones () {
if (num_selected_drones < 2) {
cons << RED_A2D << eol;
return 0;
}
#ifdef __EVALUATION__
#define MAX_CONN 4
if (num_selected_drones > MAX_CONN) {
cons << RED << "Can only connect upto " << MAX_CONN << " drones in the Evaluation Version of DIN Is Noise" << eol;
return 0;
}
#endif
if (nstepz == 0) {
cons << RED << "Bad Steps value, please check Menu > Drone Tools > Steps" << eol;
return 0;
}
for (int s = 0; s < nstepz; ++s) {
int ds = stepz[s];
for (int i = 0, j = 0; i < num_selected_drones; ++i) {
j = i + ds;
if (MENU.cb_conn_wrap.state) j %= num_selected_drones;
if (j < num_selected_drones) {
drone* pdi = selected_drones[i];
drone& di = *pdi;
drone* pdj = selected_drones[j];
drone& dj = *pdj;
if (can_connect (pdi, pdj)) {
double m = magnitude (pdi->cx, pdi->cy, pdj->cx, pdj->cy);
di.connections.push_back (pdj);
dj.connections.push_back (pdi);
di.mags.push_back (m);
dj.mags.push_back (m);
++di.nconn;
++dj.nconn;
totcon += 2;
}
}
}
}
_2totcon = 2 * totcon;
alloc_conns ();
int last = num_selected_drones - 1;
drone* pld = selected_drones [last];
drone *pdi = 0, *pdj = 0;
for (int i = 0, j = 1; i < last; ++i, ++j) {
pdi = selected_drones [i];
pdj = selected_drones [j];
push_back (trackers, pdi);
pdi->tracking = drone::POINT;
pdi->tracked_drone = pdj;
}
pld->tracking = drone::USE;
pld->tracked_drone = pdi;
push_back (trackers, pld);
return 1;
}
int fractaliser::apply (multi_curve& crv) {
#ifdef __EVALUATION__
cons << RED << "Can apply plugins only in the Licensed Version of DIN Is Noise" << eol;
return 0;
#endif
render ();
int npts = points.size ();
if (npts == 0) return 0;
crv.clear (0);
if (change_curve_name) crv.set_name (ss.str());
typedef std::list< point<float> >::iterator points_list_iterator;
points_list_iterator lti = left_tangents.begin (), rti = right_tangents.begin ();
for (int i = 0; i < npts; ++i) {
point<float>& p = points[i];
point<float>& lt = *lti++;
point<float>& rt = *rti++;
crv.add_vertex (p.x, p.y);
crv.add_left_tangent (lt.x, lt.y);
crv.add_right_tangent (rt.x, rt.y);
}
if (shapeform) crv.shapeform = 1;
crv.evaluate ();
return 1;
}
keyboard_keyboard::keyboard_keyboard () :
wave ("keyboard-keyboard-waveform.crv"), waved ("keyboard-keyboard-waveform.ed"), wavlis (wave_listener::KEYBOARD_KEYBOARD),
attackcrv ("attack.crv"), decaycrv ("decay.crv"),
attacked ("attack.ed"), decayed ("decay.ed"),
helptext ("keyboard-keyboard.hlp"), velcrv ("velocity.crv"),
veled ("velocity.ed"), vellib ("velocity.lib")
{
#ifdef __EVALUATION__
name = "keyboard-keyboard [Evaluation Version]";
#else
name = "keyboard-keyboard";
#endif
last_mousex = last_mousey = -1;
num_triggered_notes = 0;
scaleinfo.scl = this;
show_nearby_notes = 0;
fname = "keyboard-keyboard.settings";
ifstream file ((user_data_dir + fname).c_str (), ios::in);
if (!file) {
dlog << "!!! couldnt load: " << fname << endl;
} else {
string ignore;
file >> ignore >> show_nearby_notes;
file >> ignore >> ATTACK_TIME;
file >> ignore >> DECAY_TIME;
file >> ignore >> NOTE_VOLUME;
file >> ignore >> PITCH_BEND;
file >> ignore >> trig_what;
PITCH_BEND_PER_PIXEL = 0.01f * PITCH_BEND;
}
inst = 1;
}
extern const char* INSTRUMENTS [];
extern const char* INSTRUMENTS_SHORT [];
extern const int NUM_INSTRUMENTS, LAST_INSTRUMENT;
extern int CURRENT_INSTRUMENT;
extern string INSTRUMENT;
extern instrument* INSTRUMENT_PTR [];
extern checkbutton* LAST_TABS [];
extern oscilloscope scope;
void load_instrument (instrument* inst) {
if (inst == 0) inst = get_current_instrument ();
MENU.b_microtonal_keyboard.turn_off (DONT_CALL_LISTENER);
MENU.b_keyboard_keyboard.turn_off (DONT_CALL_LISTENER);
MENU.b_mondrian.turn_off (DONT_CALL_LISTENER);
MENU.b_binaural_drones.turn_off (DONT_CALL_LISTENER);
if (inst == &keybd2) {
MENU.b_keyboard_keyboard.turn_on ();
MENU.next_tab = MENUP.cb_instrument;
CURRENT_INSTRUMENT = 0;
} else if (inst == &din0) {
CURRENT_INSTRUMENT = 1;
MENU.b_microtonal_keyboard.turn_on ();
checkbutton* pcb = LAST_TABS [CURRENT_INSTRUMENT];
if (pcb) {
MENU.next_tab = pcb;
} else {
if (din0.num_selected_drones)
MENU.next_tab = MENUP.cb_mkb_drone_params;
else
MENU.next_tab = MENUP.cb_mkb_voice;
}
} else if (inst == &mondrian0) {
CURRENT_INSTRUMENT = 2;
MENU.b_mondrian.turn_on ();
MENU.cb_instrument.turn_on ();
checkbutton* pcb = LAST_TABS [CURRENT_INSTRUMENT];
if (pcb) MENU.next_tab = pcb; else MENU.next_tab = MENUP.cb_mon_tools;
} else /*if (inst == &binaural_drones0)*/ {
CURRENT_INSTRUMENT = 3;
MENU.b_binaural_drones.turn_on ();
MENU.cb_instrument.turn_on ();
checkbutton* pcb = LAST_TABS [CURRENT_INSTRUMENT];
if (pcb) MENU.next_tab = pcb; else MENU.next_tab = MENUP.cb_binaural_drones_tools;
}
scope.load_current_instrument ();
MENU.scol.setup ();
MENU.next_tab_instr = inst;
uis.set_current (inst);
MENU.hide_editors ();
MENU.show_editors (inst);
#ifdef __EVALUATION__
if (dynamic_cast<ui*>(inst) != &anote)
#endif
MENU.setup_tabs (inst);
setup_plugin_labels ();
cons ("setup-editors");
uis.update_bottom_line ();
}
extern string VERSION_NUMBER;
extern string LOCATION;
extern string APP_NAME;
void make_app_name () {
#ifdef __EVALUATION__
APP_NAME = "DIN Is Noise " + VERSION_NUMBER + " | EVALUATION VERSION";
#elif defined __LICENSED__
APP_NAME = "DIN Is Noise " + VERSION_NUMBER + " | LICENSED VERSION";
#endif
}