add GUI support to create tape/destructive tracks

git-svn-id: svn://localhost/trunk/ardour2@278 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2006-01-19 05:01:43 +00:00
parent cd87dceb0f
commit 6ef5c8da56
12 changed files with 141 additions and 60 deletions

View file

@ -22,7 +22,8 @@
#include <cmath>
#include <sigc++/bind.h>
#include <gtkmm/stock.h>
#include <pbd/error.h>
#include <gtkmm2ext/utils.h>
#include "utils.h"
@ -34,7 +35,26 @@ using namespace Gtkmm2ext;
using namespace sigc;
using namespace std;
extern std::vector<string> channel_combo_strings;
static const char* channel_setup_names[] = {
"mono",
"stereo",
"3 channels",
"4 channels",
"5 channels",
"8 channels",
"manual setup",
0
};
static const char* track_mode_names[] = {
"normal",
"tape",
0
};
static vector<string> channel_combo_strings;
static vector<string> track_mode_strings;
AddRouteDialog::AddRouteDialog ()
: Dialog (_("ardour: add track/bus")),
@ -43,6 +63,15 @@ AddRouteDialog::AddRouteDialog ()
routes_adjustment (1, 1, 32, 1, 4),
routes_spinner (routes_adjustment)
{
if (channel_combo_strings.empty()) {
channel_combo_strings = internationalize (channel_setup_names);
}
if (track_mode_strings.empty()) {
track_mode_strings = internationalize (track_mode_names);
}
set_name ("AddRouteDialog");
set_wmclass (X_("ardour_add_track_bus"), "Ardour");
set_position (Gtk::WIN_POS_MOUSE);
@ -65,9 +94,16 @@ AddRouteDialog::AddRouteDialog ()
hbrb->pack_start (bus_button, false, false);
set_popdown_strings (channel_combo, channel_combo_strings);
set_popdown_strings (track_mode_combo, track_mode_strings);
channel_combo.set_active_text (channel_combo_strings.front());
channel_combo.set_name (X_("ChannelCountSelector"));
track_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
bus_button.signal_clicked().connect (mem_fun (*this, &AddRouteDialog::track_type_chosen));
track_mode_combo.set_active_text (track_mode_strings.front());
track_mode_combo.set_name (X_("ChannelCountSelector"));
#if NOT_USEFUL_YET
HBox *hbnt = manage (new HBox);
@ -78,6 +114,7 @@ AddRouteDialog::AddRouteDialog ()
get_vbox()->pack_start (*hbrb, false, false);
get_vbox()->pack_start (*(manage (new Label ("Channel configuration"))), false, false);
get_vbox()->pack_start (channel_combo, false, false);
get_vbox()->pack_start (track_mode_combo, false, false, 10);
#if NOT_USEFUL_YET
get_vbox()->pack_start (*hbnt, false, false);
#endif
@ -92,6 +129,16 @@ AddRouteDialog::~AddRouteDialog ()
{
}
void
AddRouteDialog::track_type_chosen ()
{
if (track_button.get_active()) {
track_mode_combo.set_sensitive (true);
} else {
track_mode_combo.set_sensitive (true);
}
}
bool
AddRouteDialog::track ()
{
@ -110,8 +157,37 @@ AddRouteDialog::count ()
return (int) floor (routes_adjustment.get_value ());
}
ARDOUR::TrackMode
AddRouteDialog::mode ()
{
Glib::ustring str = track_mode_combo.get_active_text();
if (str == _("normal")) {
return ARDOUR::Normal;
} else if (str == _("tape")) {
return ARDOUR::Destructive;
} else {
fatal << string_compose (X_("programming error: unknown track mode in add route dialog combo = %1"), str)
<< endmsg;
/*NOTREACHED*/
}
/* keep gcc happy */
return ARDOUR::Normal;
}
int
AddRouteDialog::channels ()
{
return channel_combo_get_channel_count (channel_combo);
string str = channel_combo.get_active_text();
int chns;
if (str == _("mono")) {
return 1;
} else if (str == _("stereo")) {
return 2;
} else if ((chns = atoi (str)) != 0) {
return chns;
} else {
return 0;
}
}

View file

@ -11,7 +11,7 @@
#include <gtkmm/button.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm2ext/click_box.h>
#include <ardour/types.h>
class AddRouteDialog : public Gtk::Dialog
{
@ -23,6 +23,7 @@ class AddRouteDialog : public Gtk::Dialog
std::string name_template ();
int channels ();
int count ();
ARDOUR::TrackMode mode();
private:
Gtk::Entry name_template_entry;
@ -31,6 +32,9 @@ class AddRouteDialog : public Gtk::Dialog
Gtk::Adjustment routes_adjustment;
Gtk::SpinButton routes_spinner;
Gtk::ComboBoxText channel_combo;
Gtk::ComboBoxText track_mode_combo;
void track_type_chosen ();
};
#endif /* __gtk_ardour_add_route_dialog_h__ */

View file

@ -87,19 +87,6 @@ sigc::signal<void> ARDOUR_UI::RapidScreenUpdate;
sigc::signal<void> ARDOUR_UI::SuperRapidScreenUpdate;
sigc::signal<void,jack_nframes_t> ARDOUR_UI::Clock;
static const char* channel_setup_names[] = {
"mono",
"stereo",
"3 channels",
"4 channels",
"5 channels",
"8 channels",
"manual setup",
0
};
vector<string> channel_combo_strings;
ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
: Gtkmm2ext::UI ("ardour", argcp, argvp, rcfile),
@ -203,8 +190,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
ARDOUR::Session::AskAboutPendingState.connect (mem_fun(*this, &ARDOUR_UI::pending_state_dialog));
channel_combo_strings = internationalize (channel_setup_names);
/* have to wait for AudioEngine and Configuration before proceeding */
}
@ -903,7 +888,7 @@ ARDOUR_UI::session_add_midi_track ()
}
void
ARDOUR_UI::session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels)
ARDOUR_UI::session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode)
{
Route* route;
@ -914,7 +899,7 @@ ARDOUR_UI::session_add_audio_route (bool disk, int32_t input_channels, int32_t o
try {
if (disk) {
if ((route = session->new_audio_track (input_channels, output_channels)) == 0) {
if ((route = session->new_audio_track (input_channels, output_channels, mode)) == 0) {
error << _("could not create new audio track") << endmsg;
}
} else {
@ -2086,7 +2071,7 @@ ARDOUR_UI::add_route ()
while (count) {
if (track) {
session_add_audio_track (input_chan, output_chan);
session_add_audio_track (input_chan, output_chan, add_route_dialog->mode());
} else {
session_add_audio_bus (input_chan, output_chan);
}

View file

@ -188,12 +188,12 @@ class ARDOUR_UI : public Gtkmm2ext::UI
void add_route ();
void session_add_audio_track (int input_channels, int32_t output_channels) {
session_add_audio_route (true, input_channels, output_channels);
void session_add_audio_track (int input_channels, int32_t output_channels, ARDOUR::TrackMode mode) {
session_add_audio_route (true, input_channels, output_channels, mode);
}
void session_add_audio_bus (int input_channels, int32_t output_channels) {
session_add_audio_route (false, input_channels, output_channels);
session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal);
}
void session_add_midi_track ();
@ -523,7 +523,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
void save_template ();
void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels);
void session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode);
void add_diskstream_to_menu (ARDOUR::DiskStream&);
void diskstream_selected (gint32);

View file

@ -176,7 +176,7 @@ ARDOUR_UI::install_actions ()
ActionManager::session_sensitive_actions.push_back (act);
ActionManager::register_action (common_actions, X_("About"), _("About"), mem_fun(*this, &ARDOUR_UI::show_splash));
act = ActionManager::register_action (common_actions, X_("AddAudioTrack"), _("add audio track"), bind (mem_fun(*this, &ARDOUR_UI::session_add_audio_track), 1, 1));
act = ActionManager::register_action (common_actions, X_("AddAudioTrack"), _("add audio track"), bind (mem_fun(*this, &ARDOUR_UI::session_add_audio_track), 1, 1, ARDOUR::Normal));
ActionManager::session_sensitive_actions.push_back (act);
act = ActionManager::register_action (common_actions, X_("AddAudioBus"), _("add audio bus"), bind (mem_fun(*this, &ARDOUR_UI::session_add_audio_bus), 1, 1));
ActionManager::session_sensitive_actions.push_back (act);

View file

@ -291,23 +291,6 @@ get_canvas_points (string who, uint32_t npoints)
return new ArdourCanvas::Points (npoints);
}
int
channel_combo_get_channel_count (Gtk::ComboBoxText& combo)
{
string str = combo.get_active_text();
int chns;
if (str == _("mono")) {
return 1;
} else if (str == _("stereo")) {
return 2;
} else if ((chns = atoi (str)) != 0) {
return chns;
} else {
return 0;
}
}
static int32_t
int_from_hex (char hic, char loc)
{

View file

@ -64,7 +64,6 @@ unsigned char* xpm2rgba (const char** xpm, uint32_t& w, uint32_t& h);
ArdourCanvas::Points* get_canvas_points (std::string who, uint32_t npoints);
int channel_combo_get_channel_count (Gtk::ComboBoxText& combo);
Pango::FontDescription get_font_for_style (std::string widgetname);
gint pane_handler (GdkEventButton*, Gtk::Paned*);

View file

@ -32,7 +32,7 @@ class AudioPlaylist;
class AudioTrack : public Route
{
public:
AudioTrack (Session&, string name, Route::Flag f = Route::Flag (0));
AudioTrack (Session&, string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal);
AudioTrack (Session&, const XMLNode&);
~AudioTrack ();
@ -56,9 +56,9 @@ class AudioTrack : public Route
int use_diskstream (string name);
int use_diskstream (id_t id);
bool destructive() const { return _destructive; }
void set_destructive (bool yn);
sigc::signal<void> DestructiveChanged;
TrackMode mode() const { return _mode; }
void set_mode (TrackMode m);
sigc::signal<void> ModeChanged;
jack_nframes_t update_total_latency();
void set_latency_delay (jack_nframes_t);
@ -99,6 +99,7 @@ class AudioTrack : public Route
protected:
DiskStream *diskstream;
MeterPoint _saved_meter_point;
TrackMode _mode;
void passthru_silence (jack_nframes_t start_frame, jack_nframes_t end_frame,
jack_nframes_t nframes, jack_nframes_t offset, int declick,

View file

@ -526,7 +526,7 @@ class Session : public sigc::trackable, public Stateful
/* fundamental operations. duh. */
AudioTrack *new_audio_track (int input_channels, int output_channels);
AudioTrack *new_audio_track (int input_channels, int output_channels, TrackMode mode = Normal);
Route *new_audio_route (int input_channels, int output_channels);

View file

@ -92,6 +92,11 @@ namespace ARDOUR {
MeterPostFader
};
enum TrackMode {
Normal,
Destructive
};
enum smpte_wrap_t {
smpte_wrap_none = 0,
smpte_wrap_frames,

View file

@ -41,7 +41,7 @@ using namespace std;
//using namespace sigc;
using namespace ARDOUR;
AudioTrack::AudioTrack (Session& sess, string name, Route::Flag flag)
AudioTrack::AudioTrack (Session& sess, string name, Route::Flag flag, TrackMode mode)
: Route (sess, name, 1, -1, -1, -1, flag),
diskstream (0),
_midi_rec_enable_control (*this, _session.midi_port())
@ -54,13 +54,18 @@ AudioTrack::AudioTrack (Session& sess, string name, Route::Flag flag)
dflags = DiskStream::Flag (dflags | DiskStream::Recordable);
}
DiskStream* ds = new DiskStream (_session, name, dflags);
if (mode == Destructive) {
dflags = DiskStream::Flag (dflags | DiskStream::Destructive);
}
set_diskstream (*ds, this);
DiskStream* ds = new DiskStream (_session, name, dflags);
_declickable = true;
_freeze_record.state = NoFreeze;
_saved_meter_point = _meter_point;
_mode = mode;
set_diskstream (*ds, this);
// we do this even though Route already did it in it's init
reset_midi_control (_session.midi_port(), _session.get_midi_control());
@ -149,6 +154,7 @@ AudioTrack::set_diskstream (DiskStream& ds, void *src)
diskstream = &ds.ref();
diskstream->set_io (*this);
diskstream->set_destructive (_mode == Destructive);
if (diskstream->deprecated_io_node) {
@ -269,6 +275,19 @@ AudioTrack::set_state (const XMLNode& node)
return -1;
}
if ((prop = node.property (X_("mode"))) != 0) {
if (prop->value() == X_("normal")) {
_mode = Normal;
} else if (prop->value() == X_("destructive")) {
_mode = Destructive;
} else {
warning << string_compose ("unknown audio track mode \"%1\" seen and ignored", prop->value()) << endmsg;
_mode = Normal;
}
} else {
_mode = Normal;
}
midi_kids = node.children ("MIDI");
for (iter = midi_kids.begin(); iter != midi_kids.end(); ++iter) {
@ -416,6 +435,15 @@ AudioTrack::get_state()
remote_control_node->add_property (X_("id"), buf);
root.add_child_nocopy (*remote_control_node);
switch (_mode) {
case Normal:
root.add_property (X_("mode"), X_("normal"));
break;
case Destructive:
root.add_property (X_("mode"), X_("destructive"));
break;
}
return root;
}
@ -1098,13 +1126,13 @@ AudioTrack::MIDIRecEnableControl::write_feedback (MIDI::byte* buf, int32_t& bufs
}
void
AudioTrack::set_destructive (bool yn)
AudioTrack::set_mode (TrackMode m)
{
if (diskstream) {
if (_destructive != yn) {
diskstream->set_destructive (yn);
_destructive = yn;
DestructiveChanged();
if (_mode != m) {
_mode = m;
diskstream->set_destructive (m == Destructive);
ModeChanged();
}
}
}

View file

@ -1623,7 +1623,7 @@ Session::resort_routes (void* src)
}
AudioTrack*
Session::new_audio_track (int input_channels, int output_channels)
Session::new_audio_track (int input_channels, int output_channels, TrackMode mode)
{
AudioTrack *track;
char track_name[32];
@ -1675,7 +1675,7 @@ Session::new_audio_track (int input_channels, int output_channels)
}
try {
track = new AudioTrack (*this, track_name);
track = new AudioTrack (*this, track_name, Route::Flag (0), mode);
if (track->ensure_io (input_channels, output_channels, false, this)) {
error << string_compose (_("cannot configure %1 in/%2 out configuration for new audio track"),