mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Use compiler provided __BIG_ENDIAN__ instead of WORD_BIGENDIAN
Auditioning in sfdb_ui works. CoreAudioSource updates. git-svn-id: svn://localhost/trunk/ardour2@263 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
b5dd613a0c
commit
9a951bcd20
5 changed files with 107 additions and 29 deletions
11
SConstruct
11
SConstruct
|
|
@ -349,7 +349,7 @@ env.Append (BUILDERS = {'Tarball' : tarball_bld})
|
||||||
|
|
||||||
libraries = { }
|
libraries = { }
|
||||||
|
|
||||||
libraries['core'] = LibraryInfo (CPPPATH = [ '#libs'])
|
libraries['core'] = LibraryInfo (CCFLAGS = '-Ilibs')
|
||||||
|
|
||||||
libraries['sndfile'] = LibraryInfo()
|
libraries['sndfile'] = LibraryInfo()
|
||||||
libraries['sndfile'].ParseConfig('pkg-config --cflags --libs sndfile')
|
libraries['sndfile'].ParseConfig('pkg-config --cflags --libs sndfile')
|
||||||
|
|
@ -663,15 +663,6 @@ env.Append(CCFLAGS="-Wall")
|
||||||
if env['VST']:
|
if env['VST']:
|
||||||
env.Append(CCFLAGS="-DVST_SUPPORT")
|
env.Append(CCFLAGS="-DVST_SUPPORT")
|
||||||
|
|
||||||
|
|
||||||
# check endianness
|
|
||||||
if sys.byteorder == "big":
|
|
||||||
print "Host is big endian"
|
|
||||||
env.Append(CCFLAGS="-DWORDS_BIGENDIAN")
|
|
||||||
else:
|
|
||||||
print "Host is little endian"
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# everybody needs this
|
# everybody needs this
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -19,18 +19,27 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
|
|
||||||
|
#include <pbd/basename.h>
|
||||||
|
|
||||||
#include <gtkmm/box.h>
|
#include <gtkmm/box.h>
|
||||||
#include <gtkmm/stock.h>
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
#include <ardour/audio_library.h>
|
#include <ardour/audio_library.h>
|
||||||
|
#include <ardour/audioregion.h>
|
||||||
#include <ardour/sndfile_helpers.h>
|
#include <ardour/sndfile_helpers.h>
|
||||||
|
#include <ardour/sndfilesource.h>
|
||||||
|
|
||||||
#include "sfdb_ui.h"
|
#include "sfdb_ui.h"
|
||||||
|
#include "gui_thread.h"
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
|
using namespace ARDOUR;
|
||||||
|
|
||||||
std::string length2string (const int32_t frames, const int32_t sample_rate);
|
std::string length2string (const int32_t frames, const int32_t sample_rate);
|
||||||
|
|
||||||
SoundFileBox::SoundFileBox ()
|
SoundFileBox::SoundFileBox ()
|
||||||
|
|
@ -64,6 +73,9 @@ SoundFileBox::SoundFileBox ()
|
||||||
main_box.pack_start(bottom_box, false, false);
|
main_box.pack_start(bottom_box, false, false);
|
||||||
|
|
||||||
field_view.set_size_request(200, 150);
|
field_view.set_size_request(200, 150);
|
||||||
|
field_view.append_column (_("Field"), label_columns.field);
|
||||||
|
field_view.append_column_editable (_("Value"), label_columns.data);
|
||||||
|
|
||||||
top_box.set_homogeneous(true);
|
top_box.set_homogeneous(true);
|
||||||
top_box.pack_start(add_field_btn);
|
top_box.pack_start(add_field_btn);
|
||||||
top_box.pack_start(remove_field_btn);
|
top_box.pack_start(remove_field_btn);
|
||||||
|
|
@ -83,14 +95,14 @@ SoundFileBox::SoundFileBox ()
|
||||||
(mem_fun (*this, &SoundFileBox::remove_field_clicked));
|
(mem_fun (*this, &SoundFileBox::remove_field_clicked));
|
||||||
|
|
||||||
field_view.get_selection()->signal_changed().connect (mem_fun (*this, &SoundFileBox::field_selected));
|
field_view.get_selection()->signal_changed().connect (mem_fun (*this, &SoundFileBox::field_selected));
|
||||||
ARDOUR::Library->fields_changed.connect (mem_fun (*this, &SoundFileBox::setup_fields));
|
Library->fields_changed.connect (mem_fun (*this, &SoundFileBox::setup_fields));
|
||||||
|
|
||||||
show_all();
|
show_all();
|
||||||
stop_btn.hide();
|
stop_btn.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SoundFileBox::set_session(ARDOUR::Session* s)
|
SoundFileBox::set_session(Session* s)
|
||||||
{
|
{
|
||||||
_session = s;
|
_session = s;
|
||||||
|
|
||||||
|
|
@ -104,6 +116,8 @@ SoundFileBox::set_session(ARDOUR::Session* s)
|
||||||
bool
|
bool
|
||||||
SoundFileBox::setup_labels (string filename)
|
SoundFileBox::setup_labels (string filename)
|
||||||
{
|
{
|
||||||
|
path = filename;
|
||||||
|
|
||||||
SNDFILE *sf;
|
SNDFILE *sf;
|
||||||
|
|
||||||
sf_info.format = 0; // libsndfile says to clear this before sf_open().
|
sf_info.format = 0; // libsndfile says to clear this before sf_open().
|
||||||
|
|
@ -117,7 +131,7 @@ SoundFileBox::setup_labels (string filename)
|
||||||
if (sf_info.frames == 0 && sf_info.channels == 0 &&
|
if (sf_info.frames == 0 && sf_info.channels == 0 &&
|
||||||
sf_info.samplerate == 0 && sf_info.format == 0 &&
|
sf_info.samplerate == 0 && sf_info.format == 0 &&
|
||||||
sf_info.sections == 0) {
|
sf_info.sections == 0) {
|
||||||
/* .. ok, its not a sound file */
|
/* .. ok, it's not a sound file */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,20 +149,88 @@ SoundFileBox::setup_labels (string filename)
|
||||||
samplerate.set_alignment (0.0f, 0.0f);
|
samplerate.set_alignment (0.0f, 0.0f);
|
||||||
samplerate.set_text (string_compose("Samplerate: %1", sf_info.samplerate));
|
samplerate.set_text (string_compose("Samplerate: %1", sf_info.samplerate));
|
||||||
|
|
||||||
|
setup_fields ();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SoundFileBox::setup_fields ()
|
SoundFileBox::setup_fields ()
|
||||||
{}
|
{
|
||||||
|
ENSURE_GUI_THREAD(mem_fun (*this, &SoundFileBox::setup_fields));
|
||||||
|
|
||||||
|
vector<string> field_list;
|
||||||
|
Library->get_fields(field_list);
|
||||||
|
|
||||||
|
vector<string>::iterator i;
|
||||||
|
Gtk::TreeModel::iterator iter;
|
||||||
|
Gtk::TreeModel::Row row;
|
||||||
|
for (i = field_list.begin(); i != field_list.end(); ++i) {
|
||||||
|
string value = Library->get_field(path, *i);
|
||||||
|
iter = fields->append();
|
||||||
|
row = *iter;
|
||||||
|
|
||||||
|
row[label_columns.field] = *i;
|
||||||
|
row[label_columns.data] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SoundFileBox::play_btn_clicked ()
|
SoundFileBox::play_btn_clicked ()
|
||||||
{}
|
{
|
||||||
|
if (!_session) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_session->cancel_audition();
|
||||||
|
|
||||||
|
if (access(path.c_str(), R_OK)) {
|
||||||
|
warning << string_compose(_("Could not read file: %1 (%2)."), path, strerror(errno)) << endmsg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::map<string, AudioRegion*> region_cache;
|
||||||
|
|
||||||
|
if (region_cache.find (path) == region_cache.end()) {
|
||||||
|
AudioRegion::SourceList srclist;
|
||||||
|
SndFileSource* sfs;
|
||||||
|
|
||||||
|
for (int n = 0; n < sf_info.channels; ++n) {
|
||||||
|
try {
|
||||||
|
sfs = new SndFileSource(path+":"+string_compose("%1", n), false);
|
||||||
|
srclist.push_back(sfs);
|
||||||
|
|
||||||
|
} catch (failed_constructor& err) {
|
||||||
|
error << _("Could not access soundfile: ") << path << endmsg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (srclist.empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string result;
|
||||||
|
_session->region_name (result, PBD::basename(srclist[0]->name()), false);
|
||||||
|
AudioRegion* a_region = new AudioRegion(srclist, 0, srclist[0]->length(), result, 0, Region::DefaultFlags, false);
|
||||||
|
region_cache[path] = a_region;
|
||||||
|
}
|
||||||
|
|
||||||
|
play_btn.hide();
|
||||||
|
stop_btn.show();
|
||||||
|
|
||||||
|
_session->audition_region(*region_cache[path]);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SoundFileBox::stop_btn_clicked ()
|
SoundFileBox::stop_btn_clicked ()
|
||||||
{}
|
{
|
||||||
|
if (_session) {
|
||||||
|
_session->cancel_audition();
|
||||||
|
play_btn.show();
|
||||||
|
stop_btn.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SoundFileBox::add_field_clicked ()
|
SoundFileBox::add_field_clicked ()
|
||||||
|
|
@ -159,8 +241,14 @@ SoundFileBox::remove_field_clicked ()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void
|
void
|
||||||
SoundFileBox::audition_status_changed (bool state)
|
SoundFileBox::audition_status_changed (bool active)
|
||||||
{}
|
{
|
||||||
|
ENSURE_GUI_THREAD(bind (mem_fun (*this, &SoundFileBox::audition_status_changed), active));
|
||||||
|
|
||||||
|
if (!active) {
|
||||||
|
stop_btn_clicked ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SoundFileBox::field_selected ()
|
SoundFileBox::field_selected ()
|
||||||
|
|
@ -178,7 +266,7 @@ SoundFileBrowser::SoundFileBrowser (std::string title)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SoundFileBrowser::set_session (ARDOUR::Session* s)
|
SoundFileBrowser::set_session (Session* s)
|
||||||
{
|
{
|
||||||
preview.set_session(s);
|
preview.set_session(s);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ class SoundFileBox : public Gtk::VBox
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ARDOUR::Session* _session;
|
ARDOUR::Session* _session;
|
||||||
|
std::string path;
|
||||||
|
|
||||||
struct LabelModelColumns : public Gtk::TreeModel::ColumnRecord
|
struct LabelModelColumns : public Gtk::TreeModel::ColumnRecord
|
||||||
{
|
{
|
||||||
|
|
@ -92,7 +93,6 @@ class SoundFileBox : public Gtk::VBox
|
||||||
Gtk::Button add_field_btn;
|
Gtk::Button add_field_btn;
|
||||||
Gtk::Button remove_field_btn;
|
Gtk::Button remove_field_btn;
|
||||||
|
|
||||||
// void fields_refiller (Gtk::CList &clist);
|
|
||||||
void setup_fields ();
|
void setup_fields ();
|
||||||
|
|
||||||
void play_btn_clicked ();
|
void play_btn_clicked ();
|
||||||
|
|
|
||||||
|
|
@ -86,15 +86,14 @@ CoreAudioSource::init (const string& idstr, bool build_peak)
|
||||||
|
|
||||||
if (channel >= n_channels) {
|
if (channel >= n_channels) {
|
||||||
error << string_compose(_("CoreAudioSource: file only contains %1 channels; %2 is invalid as a channel number"), n_channels, channel) << endmsg;
|
error << string_compose(_("CoreAudioSource: file only contains %1 channels; %2 is invalid as a channel number"), n_channels, channel) << endmsg;
|
||||||
ExtAudioFileDispose(af_ref);
|
ExtAudioFileDispose(*af_ref);
|
||||||
throw failed_constructor();
|
throw failed_constructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t ca_frames;
|
int64_t ca_frames;
|
||||||
size_t prop_size = sizeof(ca_frames);
|
size_t prop_size = sizeof(ca_frames);
|
||||||
|
|
||||||
err = ExtAudioFileGetProperty(af_ref, kExtAudioFileProperty_FileLengthFrames,
|
err = ExtAudioFileGetProperty(*af_ref, kExtAudioFileProperty_FileLengthFrames, prop_size, &ca_frames);
|
||||||
sizeof(ca_frames), &ca_frames);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
throw failed_constructor();
|
throw failed_constructor();
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +103,7 @@ CoreAudioSource::init (const string& idstr, bool build_peak)
|
||||||
|
|
||||||
if (build_peak) {
|
if (build_peak) {
|
||||||
if (initialize_peakfile (false, file)) {
|
if (initialize_peakfile (false, file)) {
|
||||||
ExtAudioFileDispose(af_ref);
|
ExtAudioFileDispose(*af_ref);
|
||||||
throw failed_constructor ();
|
throw failed_constructor ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,7 +115,7 @@ CoreAudioSource::~CoreAudioSource ()
|
||||||
GoingAway (this); /* EMIT SIGNAL */
|
GoingAway (this); /* EMIT SIGNAL */
|
||||||
|
|
||||||
if (af_ref) {
|
if (af_ref) {
|
||||||
ExtAudioFileDispose(af_ref);
|
ExtAudioFileDispose(*af_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmpbuf) {
|
if (tmpbuf) {
|
||||||
|
|
@ -137,7 +136,7 @@ CoreAudioSource::read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt) co
|
||||||
float *ptr;
|
float *ptr;
|
||||||
uint32_t real_cnt;
|
uint32_t real_cnt;
|
||||||
|
|
||||||
OSStatus err = ExtAudioFileSeek(af_ref, start);
|
OSStatus err = ExtAudioFileSeek(*af_ref, start);
|
||||||
if (err) {
|
if (err) {
|
||||||
error << string_compose(_("CoreAudioSource: could not seek to frame %1 within %2"), start, _name.substr (1)) << endmsg;
|
error << string_compose(_("CoreAudioSource: could not seek to frame %1 within %2"), start, _name.substr (1)) << endmsg;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -145,7 +144,7 @@ CoreAudioSource::read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt) co
|
||||||
|
|
||||||
if (n_channels == 1) {
|
if (n_channels == 1) {
|
||||||
uint32_t ioNumber = cnt;
|
uint32_t ioNumber = cnt;
|
||||||
err = ExtAudioFileRead(af_ref, &ioNumber, dst);
|
err = ExtAudioFileRead(*af_ref, &ioNumber, dst);
|
||||||
_read_data_count = cnt * sizeof(float);
|
_read_data_count = cnt * sizeof(float);
|
||||||
return ioNumber;
|
return ioNumber;
|
||||||
}
|
}
|
||||||
|
|
@ -165,7 +164,7 @@ CoreAudioSource::read (Sample *dst, jack_nframes_t start, jack_nframes_t cnt) co
|
||||||
}
|
}
|
||||||
|
|
||||||
nread = real_cnt;
|
nread = real_cnt;
|
||||||
err = ExtAudioFileRead(af_ext, &nread, tmpbuf);
|
err = ExtAudioFileRead(*af_ref, &nread, tmpbuf);
|
||||||
ptr = tmpbuf + channel;
|
ptr = tmpbuf + channel;
|
||||||
nread /= n_channels;
|
nread /= n_channels;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ char FileSource::bwf_serial_number[13] = "000000000000";
|
||||||
string FileSource::search_path;
|
string FileSource::search_path;
|
||||||
|
|
||||||
#undef WE_ARE_BIGENDIAN
|
#undef WE_ARE_BIGENDIAN
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef __BIG_ENDIAN__
|
||||||
#define WE_ARE_BIGENDIAN true
|
#define WE_ARE_BIGENDIAN true
|
||||||
#else
|
#else
|
||||||
#define WE_ARE_BIGENDIAN false
|
#define WE_ARE_BIGENDIAN false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue