mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 20:26:30 +01:00
Use the channel selector to decide which channel to add program changes to.
git-svn-id: svn://localhost/ardour2/branches/3.0@8343 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
bc29adf054
commit
fd0c45ec97
5 changed files with 39 additions and 45 deletions
|
|
@ -4724,7 +4724,7 @@ Editor::insert_program_change ()
|
||||||
MidiRegionView* const mrv = dynamic_cast<MidiRegionView*> (*i);
|
MidiRegionView* const mrv = dynamic_cast<MidiRegionView*> (*i);
|
||||||
if (mrv) {
|
if (mrv) {
|
||||||
if (p >= mrv->region()->first_frame() && p <= mrv->region()->last_frame()) {
|
if (p >= mrv->region()->first_frame() && p <= mrv->region()->last_frame()) {
|
||||||
mrv->add_program_change (p - mrv->region()->position(), d.channel (), d.program ());
|
mrv->add_program_change (p - mrv->region()->position(), d.program ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@
|
||||||
#include "midi_region_view.h"
|
#include "midi_region_view.h"
|
||||||
#include "midi_streamview.h"
|
#include "midi_streamview.h"
|
||||||
#include "midi_time_axis.h"
|
#include "midi_time_axis.h"
|
||||||
#include "midi_time_axis.h"
|
|
||||||
#include "midi_util.h"
|
#include "midi_util.h"
|
||||||
#include "note_player.h"
|
#include "note_player.h"
|
||||||
#include "public_editor.h"
|
#include "public_editor.h"
|
||||||
|
|
@ -726,7 +725,7 @@ MidiRegionView::create_note_at(double x, double y, double length, bool sh)
|
||||||
MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
|
MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
|
||||||
MidiStreamView* const view = mtv->midi_view();
|
MidiStreamView* const view = mtv->midi_view();
|
||||||
|
|
||||||
double note = midi_stream_view()->y_to_note(y);
|
double note = view->y_to_note(y);
|
||||||
|
|
||||||
assert(note >= 0.0);
|
assert(note >= 0.0);
|
||||||
assert(note <= 127.0);
|
assert(note <= 127.0);
|
||||||
|
|
@ -745,26 +744,7 @@ MidiRegionView::create_note_at(double x, double y, double length, bool sh)
|
||||||
length = frames_to_beats (beats_to_frames (length) - 1);
|
length = frames_to_beats (beats_to_frames (length) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t chn_mask = mtv->channel_selector().get_selected_channels();
|
const boost::shared_ptr<NoteType> new_note (new NoteType (get_channel_for_add (),
|
||||||
int chn_cnt = 0;
|
|
||||||
uint8_t channel = 0;
|
|
||||||
|
|
||||||
/* pick the highest selected channel, unless all channels are selected,
|
|
||||||
which is interpreted to mean channel 1 (zero)
|
|
||||||
*/
|
|
||||||
|
|
||||||
for (uint16_t i = 0; i < 16; ++i) {
|
|
||||||
if (chn_mask & (1<<i)) {
|
|
||||||
channel = i;
|
|
||||||
chn_cnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chn_cnt == 16) {
|
|
||||||
channel = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const boost::shared_ptr<NoteType> new_note (new NoteType (channel,
|
|
||||||
frames_to_beats(start_frames + _region->start()), length,
|
frames_to_beats(start_frames + _region->start()), length,
|
||||||
(uint8_t)note, 0x40));
|
(uint8_t)note, 0x40));
|
||||||
|
|
||||||
|
|
@ -1670,10 +1650,10 @@ MidiRegionView::alter_program_change(PCEvent& old_program, const MIDI::Name::Pat
|
||||||
|
|
||||||
/** @param t Time in frames relative to region position */
|
/** @param t Time in frames relative to region position */
|
||||||
void
|
void
|
||||||
MidiRegionView::add_program_change (framecnt_t t, uint8_t channel, uint8_t value)
|
MidiRegionView::add_program_change (framecnt_t t, uint8_t value)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Evoral::Control> control = midi_region()->model()->control (
|
boost::shared_ptr<Evoral::Control> control = midi_region()->model()->control (
|
||||||
Evoral::Parameter (MidiPgmChangeAutomation, channel, 0), true
|
Evoral::Parameter (MidiPgmChangeAutomation, get_channel_for_add (), 0), true
|
||||||
);
|
);
|
||||||
|
|
||||||
assert (control);
|
assert (control);
|
||||||
|
|
@ -3294,3 +3274,32 @@ MidiRegionView::trim_front_ending ()
|
||||||
midi_region()->fix_negative_start ();
|
midi_region()->fix_negative_start ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return channel (counted from 0) to add an event to, based on the current setting
|
||||||
|
* of the channel selector.
|
||||||
|
*/
|
||||||
|
uint8_t
|
||||||
|
MidiRegionView::get_channel_for_add () const
|
||||||
|
{
|
||||||
|
MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
|
||||||
|
uint16_t const chn_mask = mtv->channel_selector().get_selected_channels();
|
||||||
|
int chn_cnt = 0;
|
||||||
|
uint8_t channel = 0;
|
||||||
|
|
||||||
|
/* pick the highest selected channel, unless all channels are selected,
|
||||||
|
which is interpreted to mean channel 1 (zero)
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (uint16_t i = 0; i < 16; ++i) {
|
||||||
|
if (chn_mask & (1<<i)) {
|
||||||
|
channel = i;
|
||||||
|
chn_cnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chn_cnt == 16) {
|
||||||
|
channel = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ class MidiRegionView : public RegionView
|
||||||
*/
|
*/
|
||||||
void alter_program_change(PCEvent& old_program, const MIDI::Name::PatchPrimaryKey& new_patch);
|
void alter_program_change(PCEvent& old_program, const MIDI::Name::PatchPrimaryKey& new_patch);
|
||||||
|
|
||||||
void add_program_change (framecnt_t, uint8_t, uint8_t);
|
void add_program_change (framecnt_t, uint8_t);
|
||||||
void move_program_change (PCEvent, Evoral::MusicalTime);
|
void move_program_change (PCEvent, Evoral::MusicalTime);
|
||||||
void delete_program_change (ArdourCanvas::CanvasProgramChange *);
|
void delete_program_change (ArdourCanvas::CanvasProgramChange *);
|
||||||
|
|
||||||
|
|
@ -346,6 +346,8 @@ class MidiRegionView : public RegionView
|
||||||
void add_to_selection (ArdourCanvas::CanvasNoteEvent*);
|
void add_to_selection (ArdourCanvas::CanvasNoteEvent*);
|
||||||
void remove_from_selection (ArdourCanvas::CanvasNoteEvent*);
|
void remove_from_selection (ArdourCanvas::CanvasNoteEvent*);
|
||||||
|
|
||||||
|
uint8_t get_channel_for_add () const;
|
||||||
|
|
||||||
int8_t _force_channel;
|
int8_t _force_channel;
|
||||||
uint16_t _last_channel_selection;
|
uint16_t _last_channel_selection;
|
||||||
uint8_t _current_range_min;
|
uint8_t _current_range_min;
|
||||||
|
|
|
||||||
|
|
@ -26,19 +26,11 @@ using namespace Gtk;
|
||||||
|
|
||||||
ProgramChangeDialog::ProgramChangeDialog ()
|
ProgramChangeDialog::ProgramChangeDialog ()
|
||||||
: ArdourDialog (_("Add Program Change"), true)
|
: ArdourDialog (_("Add Program Change"), true)
|
||||||
, _channel (*manage (new Adjustment (1, 1, 16, 1, 2)))
|
|
||||||
, _program (*manage (new Adjustment (1, 1, 128, 1, 16)))
|
, _program (*manage (new Adjustment (1, 1, 128, 1, 16)))
|
||||||
{
|
{
|
||||||
Table* t = manage (new Table (2, 2));
|
Table* t = manage (new Table (1, 2));
|
||||||
t->set_spacings (6);
|
|
||||||
|
|
||||||
Label* l = manage (new Label (_("Channel")));
|
Label* l = manage (new Label (_("Program")));
|
||||||
l->set_alignment (0, 0.5);
|
|
||||||
t->attach (*l, 0, 1, 0, 1);
|
|
||||||
|
|
||||||
t->attach (_channel, 1, 2, 0, 1);
|
|
||||||
|
|
||||||
l = manage (new Label (_("Program")));
|
|
||||||
l->set_alignment (0, 0.5);
|
l->set_alignment (0, 0.5);
|
||||||
t->attach (*l, 0, 1, 1, 2);
|
t->attach (*l, 0, 1, 1, 2);
|
||||||
t->attach (_program, 1, 2, 1, 2);
|
t->attach (_program, 1, 2, 1, 2);
|
||||||
|
|
@ -52,13 +44,6 @@ ProgramChangeDialog::ProgramChangeDialog ()
|
||||||
show_all ();
|
show_all ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return Channel, counted from 0 */
|
|
||||||
uint8_t
|
|
||||||
ProgramChangeDialog::channel () const
|
|
||||||
{
|
|
||||||
return _channel.get_value_as_int () - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @return Program change number, counted from 0 */
|
/** @return Program change number, counted from 0 */
|
||||||
uint8_t
|
uint8_t
|
||||||
ProgramChangeDialog::program () const
|
ProgramChangeDialog::program () const
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,8 @@ class ProgramChangeDialog : public ArdourDialog
|
||||||
public:
|
public:
|
||||||
ProgramChangeDialog ();
|
ProgramChangeDialog ();
|
||||||
|
|
||||||
uint8_t channel () const;
|
|
||||||
uint8_t program () const;
|
uint8_t program () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Gtk::SpinButton _channel;
|
|
||||||
Gtk::SpinButton _program;
|
Gtk::SpinButton _program;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue