#include "timecode/time.h"
#include "timecode/bbt_time.h"
+#include "ardour/amp.h"
#include "ardour/async_midi_port.h"
#include "ardour/audioengine.h"
#include "ardour/debug.h"
#include "pbd/i18n.h"
+#ifdef PLATFORM_WINDOWS
+#define random() rand()
+#endif
+
using namespace ARDOUR;
using namespace std;
using namespace PBD;
#define ABLETON 0x2982
#define PUSH2 0x1967
-__attribute__((constructor)) static void
-register_enums ()
-{
- EnumWriter& enum_writer (EnumWriter::instance());
- vector<int> i;
- vector<string> s;
-
- MusicalMode::Type mode;
-
-#define REGISTER(e) enum_writer.register_distinct (typeid(e).name(), i, s); i.clear(); s.clear()
-#define REGISTER_CLASS_ENUM(t,e) i.push_back (t::e); s.push_back (#e)
-
- REGISTER_CLASS_ENUM (MusicalMode,Dorian);
- REGISTER_CLASS_ENUM (MusicalMode, IonianMajor);
- REGISTER_CLASS_ENUM (MusicalMode, Minor);
- REGISTER_CLASS_ENUM (MusicalMode, HarmonicMinor);
- REGISTER_CLASS_ENUM (MusicalMode, MelodicMinorAscending);
- REGISTER_CLASS_ENUM (MusicalMode, MelodicMinorDescending);
- REGISTER_CLASS_ENUM (MusicalMode, Phrygian);
- REGISTER_CLASS_ENUM (MusicalMode, Lydian);
- REGISTER_CLASS_ENUM (MusicalMode, Mixolydian);
- REGISTER_CLASS_ENUM (MusicalMode, Aeolian);
- REGISTER_CLASS_ENUM (MusicalMode, Locrian);
- REGISTER_CLASS_ENUM (MusicalMode, PentatonicMajor);
- REGISTER_CLASS_ENUM (MusicalMode, PentatonicMinor);
- REGISTER_CLASS_ENUM (MusicalMode, Chromatic);
- REGISTER_CLASS_ENUM (MusicalMode, BluesScale);
- REGISTER_CLASS_ENUM (MusicalMode, NeapolitanMinor);
- REGISTER_CLASS_ENUM (MusicalMode, NeapolitanMajor);
- REGISTER_CLASS_ENUM (MusicalMode, Oriental);
- REGISTER_CLASS_ENUM (MusicalMode, DoubleHarmonic);
- REGISTER_CLASS_ENUM (MusicalMode, Enigmatic);
- REGISTER_CLASS_ENUM (MusicalMode, Hirajoshi);
- REGISTER_CLASS_ENUM (MusicalMode, HungarianMinor);
- REGISTER_CLASS_ENUM (MusicalMode, HungarianMajor);
- REGISTER_CLASS_ENUM (MusicalMode, Kumoi);
- REGISTER_CLASS_ENUM (MusicalMode, Iwato);
- REGISTER_CLASS_ENUM (MusicalMode, Hindu);
- REGISTER_CLASS_ENUM (MusicalMode, Spanish8Tone);
- REGISTER_CLASS_ENUM (MusicalMode, Pelog);
- REGISTER_CLASS_ENUM (MusicalMode, HungarianGypsy);
- REGISTER_CLASS_ENUM (MusicalMode, Overtone);
- REGISTER_CLASS_ENUM (MusicalMode, LeadingWholeTone);
- REGISTER_CLASS_ENUM (MusicalMode, Arabian);
- REGISTER_CLASS_ENUM (MusicalMode, Balinese);
- REGISTER_CLASS_ENUM (MusicalMode, Gypsy);
- REGISTER_CLASS_ENUM (MusicalMode, Mohammedan);
- REGISTER_CLASS_ENUM (MusicalMode, Javanese);
- REGISTER_CLASS_ENUM (MusicalMode, Persian);
- REGISTER_CLASS_ENUM (MusicalMode, Algerian);
- REGISTER (mode);
-}
-
Push2::Push2 (ARDOUR::Session& s)
: ControlProtocol (s, string (X_("Ableton Push 2")))
, AbstractUI<Push2Request> (name())
, _pressure_mode (AfterTouch)
, selection_color (LED::Green)
, contrast_color (LED::Green)
+ , in_range_select (false)
{
build_maps ();
try {
_canvas = new Push2Canvas (*this, 960, 160);
- mix_layout = new MixLayout (*this, *session);
- scale_layout = new ScaleLayout (*this, *session);
- track_mix_layout = new TrackMixLayout (*this, *session);
- splash_layout = new SplashLayout (*this, *session);
+ mix_layout = new MixLayout (*this, *session, "globalmix");
+ scale_layout = new ScaleLayout (*this, *session, "scale");
+ track_mix_layout = new TrackMixLayout (*this, *session, "trackmix");
+ splash_layout = new SplashLayout (*this, *session, "splash");
} catch (...) {
error << _("Cannot construct Canvas for display") << endmsg;
libusb_release_interface (handle, 0x00);
libusb_close (handle);
+ handle = 0;
return -1;
}
*/
ButtonID buttons[] = { Mute, Solo, Master, Up, Right, Left, Down, Note, Session, Mix, AddTrack, Delete, Undo,
- Metronome, Shift, Select, Play, RecordEnable, Automate, Repeat, Note, Session, DoubleLoop,
+ Metronome, Shift, Select, Play, RecordEnable, Automate, Repeat, Note, Session,
Quantize, Duplicate, Browse, PageRight, PageLeft, OctaveUp, OctaveDown, Layout, Scale
};
}
}
+ if (_current_layout) {
+ _current_layout->update_meters ();
+ _current_layout->update_clocks ();
+ }
+
_canvas->vblank();
return true;
void
Push2::other_vpot (int n, int delta)
{
+ boost::shared_ptr<Amp> click_gain;
switch (n) {
case 0:
+ /* tempo control */
break;
case 1:
+ /* metronome gain control */
+ click_gain = session->click_gain();
+ if (click_gain) {
+ boost::shared_ptr<AutomationControl> ac = click_gain->gain_control();
+ if (ac) {
+ ac->set_value (ac->interface_to_internal (
+ min (ac->upper(), max (ac->lower(), ac->internal_to_interface (ac->get_value()) + (delta/256.0)))),
+ PBD::Controllable::UseGroup);
+ }
+ }
break;
case 2:
/* master gain control */
if (master) {
boost::shared_ptr<AutomationControl> ac = master->gain_control();
if (ac) {
- ac->set_value (ac->get_value() + ((2.0/64.0) * delta), PBD::Controllable::UseGroup);
+ ac->set_value (ac->interface_to_internal (
+ min (ac->upper(), max (ac->lower(), ac->internal_to_interface (ac->get_value()) + (delta/256.0)))),
+ PBD::Controllable::UseGroup);
}
}
break;
/* disconnect from pad port, if appropriate */
if (current_midi_track && pad_port) {
+
+ /* XXX this could possibly leave dangling MIDI notes.
+ *
+ * A general libardour fix is required. It isn't obvious
+ * how note resolution can be done unless disconnecting
+ * becomes "slow" (i.e. deferred for as long as it takes
+ * to resolve notes).
+ */
current_midi_track->input()->disconnect (current_midi_track->input()->nth(0), pad_port->name(), this);
}
void
Push2::set_current_layout (Push2Layout* layout)
{
- if (_current_layout) {
- _current_layout->hide ();
- _canvas->root()->remove (_current_layout);
- _previous_layout = _current_layout;
- }
+ if (layout && layout == _current_layout) {
+ _current_layout->show ();
+ } else {
- _current_layout = layout;
+ if (_current_layout) {
+ _current_layout->hide ();
+ _canvas->root()->remove (_current_layout);
+ _previous_layout = _current_layout;
+ }
+
+ _current_layout = layout;
+
+ if (_current_layout) {
+ _canvas->root()->add (_current_layout);
+ _current_layout->show ();
+ }
- if (_current_layout) {
- _canvas->root()->add (_current_layout);
- _current_layout->show ();
- }
- _canvas->request_redraw ();
+ _canvas->request_redraw ();
+ }
}
void