install ardour.menus and bindings file (elthariel) ; initial, basic MIDI gain (fader) working

git-svn-id: svn://localhost/ardour2/branches/3.0@5416 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2009-07-23 03:01:31 +00:00
parent 3804e3bc49
commit 38510cb19e
5 changed files with 101 additions and 22 deletions

View File

@ -77,12 +77,13 @@ GainMeter::setup_slider_pix ()
GainMeterBase::GainMeterBase (Session& s,
const Glib::RefPtr<Gdk::Pixbuf>& pix,
bool horizontal)
: _session (s),
: _session (s)
// 0.781787 is the value needed for gain to be set to 0.
gain_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1),
gain_automation_style_button (""),
gain_automation_state_button (""),
dpi_changed (false)
, gain_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1)
, gain_automation_style_button ("")
, gain_automation_state_button ("")
, dpi_changed (false)
, _is_midi (false)
{
using namespace Menu_Helpers;
@ -183,6 +184,20 @@ GainMeterBase::set_controls (boost::shared_ptr<Route> r,
level_meter->set_meter (pm.get());
gain_slider->set_controllable (amp->gain_control());
if (!_route || _route->output()->n_ports().n_midi() == 0) {
_is_midi = false;
gain_adjustment.set_lower (0.0);
gain_adjustment.set_upper (1.0);
gain_adjustment.set_step_increment (0.01);
gain_adjustment.set_page_increment (0.1);
} else {
_is_midi = true;
gain_adjustment.set_lower (0.0);
gain_adjustment.set_upper (2.0);
gain_adjustment.set_step_increment (0.05);
gain_adjustment.set_page_increment (0.1);
}
if (!_route || !_route->is_hidden()) {
using namespace Menu_Helpers;
@ -361,10 +376,14 @@ GainMeterBase::show_gain ()
float v = gain_adjustment.get_value();
if (v == 0.0) {
strcpy (buf, _("-inf"));
if (!_is_midi) {
if (v == 0.0) {
strcpy (buf, _("-inf"));
} else {
snprintf (buf, sizeof (buf), "%.1f", coefficient_to_dB (slider_position_to_gain (v)));
}
} else {
snprintf (buf, 32, "%.1f", coefficient_to_dB (slider_position_to_gain (v)));
snprintf (buf, sizeof (buf), "%.1f", v);
}
gain_display.set_text (buf);
@ -376,7 +395,11 @@ GainMeterBase::gain_adjusted ()
if (!ignore_toggle) {
if (_route) {
if (_route->amp() == _amp) {
_route->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this);
if (_is_midi) {
_route->set_gain (gain_adjustment.get_value(), this);
} else {
_route->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this);
}
} else {
_amp->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this);
}
@ -389,7 +412,13 @@ GainMeterBase::gain_adjusted ()
void
GainMeterBase::effective_gain_display ()
{
gfloat value = gain_to_slider_position (_amp->gain());
gfloat value;
if (!_route || _route->output()->n_ports().n_midi() == 0) {
value = gain_to_slider_position (_amp->gain());
} else {
value = _amp->gain ();
}
//cerr << this << " for " << _io->name() << " EGAIN = " << value
// << " AGAIN = " << gain_adjustment.get_value () << endl;

View File

@ -174,6 +174,7 @@ class GainMeterBase : virtual public sigc::trackable
bool dpi_changed;
bool color_changed;
void color_handler(bool);
bool _is_midi;
};
class GainMeter : public GainMeterBase, public Gtk::VBox

View File

@ -258,12 +258,12 @@ def build(bld):
obj.source += [ 'cocoacarbon.mm' ]
obj.cxxflags += [ '-DTOP_MENUBAR', '-DGTKOSX' ]
obj.linkflags += [ '-framework', 'AppKit', '-framework', 'CoreAudioKit' ]
if bld.env['AUDIOUNITS']:
obj.source += [ 'au_pluginui.mm' ]
obj.cxxflags += [ '-DHAVE_AUDIOUNITS' ]
obj.uselib_local += ' libappleutility '
else:
obj.source += [ 'x11.cc' ]
@ -377,7 +377,7 @@ def build(bld):
obj.argv = menus_argv
obj.stdin = 'ardour.menus.in'
obj.stdout = 'ardour.menus'
obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
bld.install_files(os.path.join(bld.env['CONFIGDIR'], 'ardour3'), 'ardour.menus')
# Keybindings
keybindings_dict = {}
@ -397,9 +397,10 @@ def build(bld):
for b in [ 'SAE-de-keypad', 'SAE-de-nokeypad', 'SAE-us-keypad', 'SAE-us-nokeypad',
'mnemonic-us', 'ergonomic-us' ]:
obj = bld.new_task_gen('subst')
obj.target = b + '.bindings'
obj.source = obj.target + '.in'
obj.dict = keybindings_dict
obj.target = b + '.bindings'
obj.source = obj.target + '.in'
obj.dict = keybindings_dict
obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
# Icons/Images
bld.install_files('${DATADIR}/ardour3/icons', 'icons/*.png')
@ -415,3 +416,4 @@ def build(bld):
def i18n(bld):
build_i18n (bld, 'gtk2_ardour', APPNAME, gtk2_ardour_sources)

View File

@ -154,6 +154,18 @@ Amp::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, n
/* gain has not changed, but its non-unity
*/
for (BufferSet::midi_iterator i = bufs.midi_begin(); i != bufs.midi_end(); ++i) {
MidiBuffer& mb (*i);
for (MidiBuffer::iterator m = mb.begin(); m != mb.end(); ++m) {
Evoral::MIDIEvent<MidiBuffer::TimeType> ev = *m;
if (ev.is_note_on()) {
ev.scale_velocity (_current_gain);
}
}
}
for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
apply_gain_to_buffer (i->data(), nframes, _current_gain);
}
@ -197,16 +209,19 @@ Amp::apply_gain (BufferSet& bufs, nframes_t nframes, gain_t initial, gain_t targ
/* MIDI Gain */
for (BufferSet::midi_iterator i = bufs.midi_begin(); i != bufs.midi_end(); ++i) {
#if 0
MidiBuffer& mb (*i);
MidiBuffer& mb (*i);
for (MidiBuffer::iterator m = mb.begin(); m != mb.end(); ++m) {
Evoral::MIDIEvent<MidiBuffer::TimeType> ev (*m);
if (ev.buffer()[0] == MIDI_CMD_NOTE_ON) {
ev.buffer()[2] = (uint8_t) rint (ev.buffer()[2] * 1.0);
Evoral::MIDIEvent<MidiBuffer::TimeType> ev = *m;
if (ev.is_note_on()) {
gain_t scale = delta * (ev.time()/nframes);
std::cerr << "scale by " << scale << " for " << ev.time() << " of " << nframes << std::endl;
ev.scale_velocity (scale);
}
}
#endif
}
/* Audio Gain */
@ -238,10 +253,35 @@ void
Amp::apply_simple_gain (BufferSet& bufs, nframes_t nframes, gain_t target)
{
if (target == 0.0) {
for (BufferSet::midi_iterator i = bufs.midi_begin(); i != bufs.midi_end(); ++i) {
MidiBuffer& mb (*i);
for (MidiBuffer::iterator m = mb.begin(); m != mb.end(); ++m) {
Evoral::MIDIEvent<MidiBuffer::TimeType> ev = *m;
if (ev.is_note_on()) {
ev.set_velocity (0);
}
}
}
for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
memset (i->data(), 0, sizeof (Sample) * nframes);
}
} else if (target != 1.0) {
for (BufferSet::midi_iterator i = bufs.midi_begin(); i != bufs.midi_end(); ++i) {
MidiBuffer& mb (*i);
for (MidiBuffer::iterator m = mb.begin(); m != mb.end(); ++m) {
Evoral::MIDIEvent<MidiBuffer::TimeType> ev = *m;
if (ev.is_note_on()) {
ev.scale_velocity (target);
}
}
}
for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
apply_gain_to_buffer (i->data(), nframes, target);
}

View File

@ -19,6 +19,7 @@
#ifndef EVORAL_MIDI_EVENT_HPP
#define EVORAL_MIDI_EVENT_HPP
#include <cmath>
#include <boost/shared_ptr.hpp>
#include "evoral/Event.hpp"
#include "evoral/midi_events.h"
@ -68,6 +69,12 @@ struct MIDIEvent : public Event<Time> {
inline bool is_channel_pressure() const { return (type() == MIDI_CMD_CHANNEL_PRESSURE); }
inline uint8_t note() const { return (this->_buf[1]); }
inline uint8_t velocity() const { return (this->_buf[2]); }
inline void set_velocity(uint8_t value) { this->_buf[2] = value; }
inline void scale_velocity(float factor) {
if (factor < 0) factor = 0;
this->_buf[2] = (uint8_t) lrintf (this->_buf[2]*factor);
if (this->_buf[2] > 127) this->_buf[2] = 127;
}
inline uint8_t cc_number() const { return (this->_buf[1]); }
inline void set_cc_number(uint8_t number) { this->_buf[1] = number; }
inline uint8_t cc_value() const { return (this->_buf[2]); }