Moved DataType into it's own class (resolved a name clash on ARDOUR::MIDI

which was a show stopper for gcc 3.3)
Also fixed a few warnings in fft_graph.cc


git-svn-id: svn://localhost/ardour2/trunk@739 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2006-08-01 21:33:25 +00:00
parent 14f4612181
commit 959438031c
13 changed files with 27 additions and 67 deletions

View File

@ -234,11 +234,11 @@ FFTGraph::draw_scales(Glib::RefPtr<Gdk::Window> window)
while (_logScale[logscale_pos] < position_on_scale)
logscale_pos++;
int coord = v_margin + 1.0 + position_on_scale;
int coord = (int)(v_margin + 1.0 + position_on_scale);
int SR = 44100;
int rate_at_pos = (double)(SR/2) * (double)logscale_pos / (double)_dataSize;
int rate_at_pos = (int)((double)(SR/2) * (double)logscale_pos / (double)_dataSize);
char buf[32];
snprintf(buf,32,"%dhz",rate_at_pos);

View File

@ -105,7 +105,7 @@ void
PanAutomationTimeAxisView::add_line (AutomationLine& line)
{
char buf[32];
snprintf(buf,32,"Line %d",lines.size()+1);
snprintf(buf,32,"Line %ld",lines.size()+1);
multiline_selector.append_text(buf);
if (lines.empty()) {

View File

@ -35,6 +35,7 @@
#include <jack/jack.h>
#include <jack/transport.h>
#include <ardour/types.h>
#include <ardour/data_type.h>
namespace ARDOUR {

View File

@ -1,6 +1,5 @@
/*
Copyright (C) 2006 Paul Davis
Written by Dave Robillard, 2006
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
@ -24,7 +23,7 @@
#include <cstdlib> // for posix_memalign
#include <cassert>
#include <ardour/types.h>
#include <jack/jack.h>
#include <ardour/data_type.h>
namespace ARDOUR {
@ -60,44 +59,7 @@ public:
/** Type of this buffer.
* Based on this you can static cast a Buffer* to the desired type. */
virtual DataType type() const { return _type; }
/** Jack type (eg JACK_DEFAULT_AUDIO_TYPE) */
const char* jack_type() const { return type_to_jack_type(type()); }
/** String type as saved in session XML files (eg "audio" or "midi") */
const char* type_string() const { return type_to_string(type()); }
/* The below static methods need to be separate from the above methods
* because the conversion is needed in places where there's no Buffer.
* These should probably live somewhere else...
*/
static const char* type_to_jack_type(DataType t) {
switch (t) {
case AUDIO: return JACK_DEFAULT_AUDIO_TYPE;
//case MIDI: return JACK_DEFAULT_MIDI_TYPE;
default: return "";
}
}
static const char* type_to_string(DataType t) {
switch (t) {
case AUDIO: return "audio";
case MIDI: return "midi";
default: return "unknown"; // reeeally shouldn't ever happen
}
}
/** Used for loading from XML (route default types etc) */
static DataType type_from_string(const string& str) {
if (str == "audio")
return AUDIO;
else if (str == "midi")
return MIDI;
else
return NIL;
}
DataType type() const { return _type; }
protected:
DataType _type;
@ -114,7 +76,7 @@ class AudioBuffer : public Buffer
{
public:
AudioBuffer(size_t capacity)
: Buffer(AUDIO, capacity)
: Buffer(DataType::AUDIO, capacity)
, _data(NULL)
{
_size = capacity; // For audio buffers, size = capacity (always)

View File

@ -39,6 +39,7 @@
#include <ardour/state_manager.h>
#include <ardour/curve.h>
#include <ardour/types.h>
#include <ardour/data_type.h>
using std::string;
using std::vector;
@ -67,7 +68,7 @@ class IO : public Stateful, public ARDOUR::StateManager
IO (Session&, string name,
int input_min = -1, int input_max = -1,
int output_min = -1, int output_max = -1,
DataType default_type = AUDIO);
DataType default_type = DataType::AUDIO);
virtual ~IO();
@ -116,8 +117,8 @@ class IO : public Stateful, public ARDOUR::StateManager
Connection *input_connection() const { return _input_connection; }
Connection *output_connection() const { return _output_connection; }
int add_input_port (string source, void *src, DataType type = NIL);
int add_output_port (string destination, void *src, DataType type = NIL);
int add_input_port (string source, void *src, DataType type = DataType::NIL);
int add_output_port (string destination, void *src, DataType type = DataType::NIL);
int remove_input_port (Port *, void *src);
int remove_output_port (Port *, void *src);

View File

@ -70,7 +70,7 @@ class Route : public IO
Route (Session&, std::string name, int input_min, int input_max, int output_min, int output_max,
Flag flags = Flag(0), DataType default_type = AUDIO);
Flag flags = Flag(0), DataType default_type = DataType::AUDIO);
Route (Session&, const XMLNode&);
virtual ~Route();

View File

@ -31,7 +31,7 @@ class RouteGroup;
class Track : public Route
{
public:
Track (Session&, string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal, DataType default_type = AUDIO);
Track (Session&, string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO);
virtual ~Track ();
@ -91,7 +91,7 @@ class Track : public Route
sigc::signal<void> FreezeChange;
protected:
Track (Session& sess, const XMLNode& node, DataType default_type = AUDIO);
Track (Session& sess, const XMLNode& node, DataType default_type = DataType::AUDIO);
virtual XMLNode& state (bool full) = 0;

View File

@ -193,7 +193,7 @@ namespace ARDOUR {
Splice
};
enum RegionPoint {
enum RegionPoint {
Start,
End,
SyncPoint
@ -243,12 +243,6 @@ namespace ARDOUR {
PeakDatum min;
PeakDatum max;
};
enum DataType {
NIL = 0,
AUDIO,
MIDI
};
}
std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf);

View File

@ -401,7 +401,7 @@ AudioEngine::register_input_port (DataType type, const string& portname)
}
jack_port_t *p = jack_port_register (_jack, portname.c_str(),
Buffer::type_to_jack_type(type), JackPortIsInput, 0);
type.to_jack_type(), JackPortIsInput, 0);
if (p) {
@ -435,7 +435,7 @@ AudioEngine::register_output_port (DataType type, const string& portname)
jack_port_t *p;
if ((p = jack_port_register (_jack, portname.c_str(),
Buffer::type_to_jack_type(type), JackPortIsOutput, 0)) != 0) {
type.to_jack_type(), JackPortIsOutput, 0)) != 0) {
Port *newport = new Port (p);
ports.insert (ports.begin(), newport);
return newport;

View File

@ -27,6 +27,7 @@
#include <ardour/auditioner.h>
#include <ardour/audioplaylist.h>
#include <ardour/panner.h>
#include <ardour/data_type.h>
using namespace std;
using namespace ARDOUR;
@ -44,12 +45,12 @@ Auditioner::Auditioner (Session& s)
defer_pan_reset ();
if (left.length()) {
add_output_port (left, this, AUDIO);
add_output_port (left, this, DataType::AUDIO);
}
if (right.length()) {
audio_diskstream().add_channel();
add_output_port (right, this, AUDIO);
add_output_port (right, this, DataType::AUDIO);
}
allow_pan_reset ();

View File

@ -797,7 +797,7 @@ IO::add_output_port (string destination, void* src, DataType type)
Port* our_port;
char name[64];
if (type == NIL)
if (type == DataType::NIL)
type = _default_type;
{
@ -909,7 +909,7 @@ IO::add_input_port (string source, void* src, DataType type)
Port* our_port;
char name[64];
if (type == NIL)
if (type == DataType::NIL)
type = _default_type;
{

View File

@ -1333,7 +1333,7 @@ Route::state(bool full_state)
node->add_property("flags", buf);
}
node->add_property("default-type", Buffer::type_to_string(_default_type));
node->add_property("default-type", _default_type.to_string());
node->add_property("active", _active?"yes":"no");
node->add_property("muted", _muted?"yes":"no");
@ -1510,8 +1510,8 @@ Route::set_state (const XMLNode& node)
}
if ((prop = node.property ("default-type")) != 0) {
_default_type = Buffer::type_from_string(prop->value());
assert(_default_type != NIL);
_default_type = DataType(prop->value());
assert(_default_type != DataType::NIL);
}
if ((prop = node.property ("phase-invert")) != 0) {

View File

@ -64,6 +64,7 @@
#include <ardour/crossfade.h>
#include <ardour/playlist.h>
#include <ardour/click.h>
#include <ardour/data_type.h>
#ifdef HAVE_LIBLO
#include <ardour/osc.h>
@ -1807,7 +1808,7 @@ Session::new_audio_route (int input_channels, int output_channels)
} while (n < (UINT_MAX-1));
try {
shared_ptr<Route> bus (new Route (*this, bus_name, -1, -1, -1, -1, Route::Flag(0), AUDIO));
shared_ptr<Route> bus (new Route (*this, bus_name, -1, -1, -1, -1, Route::Flag(0), DataType::AUDIO));
if (bus->ensure_io (input_channels, output_channels, false, this)) {
error << string_compose (_("cannot configure %1 in/%2 out configuration for new audio track"),