mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
Removed direct libsndfile usage.
git-svn-id: svn://localhost/trunk/ardour2@362 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
e057db8057
commit
123ec9cb30
4 changed files with 21 additions and 63 deletions
|
|
@ -33,8 +33,6 @@
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <sndfile.h>
|
|
||||||
|
|
||||||
#include <gtkmm/layout.h>
|
#include <gtkmm/layout.h>
|
||||||
#include <gtkmm/comboboxtext.h>
|
#include <gtkmm/comboboxtext.h>
|
||||||
|
|
||||||
|
|
@ -47,6 +45,7 @@
|
||||||
#include <ardour/tempo.h>
|
#include <ardour/tempo.h>
|
||||||
#include <ardour/location.h>
|
#include <ardour/location.h>
|
||||||
#include <ardour/region.h>
|
#include <ardour/region.h>
|
||||||
|
#include <ardour/sndfile_helpers.h>
|
||||||
|
|
||||||
#include "audio_clock.h"
|
#include "audio_clock.h"
|
||||||
#include "gtk-custom-ruler.h"
|
#include "gtk-custom-ruler.h"
|
||||||
|
|
@ -955,7 +954,7 @@ class Editor : public PublicEditor
|
||||||
|
|
||||||
void insert_sndfile (bool as_tracks);
|
void insert_sndfile (bool as_tracks);
|
||||||
void embed_audio (); // inserts into region list
|
void embed_audio (); // inserts into region list
|
||||||
int reject_because_rate_differs (const string & path, SF_INFO& finfo, const string & action, bool multiple_pending);
|
int reject_because_rate_differs (const string & path, SoundFileInfo& finfo, const string & action, bool multiple_pending);
|
||||||
|
|
||||||
void do_embed_sndfiles (vector<string> paths, bool split);
|
void do_embed_sndfiles (vector<string> paths, bool split);
|
||||||
void embed_sndfile (string path, bool split, bool multiple_files, bool& check_sr);
|
void embed_sndfile (string path, bool split, bool multiple_files, bool& check_sr);
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <sndfile.h>
|
|
||||||
|
|
||||||
#include <pbd/error.h>
|
#include <pbd/error.h>
|
||||||
#include <pbd/basename.h>
|
#include <pbd/basename.h>
|
||||||
#include <pbd/pthread_utils.h>
|
#include <pbd/pthread_utils.h>
|
||||||
|
|
@ -2104,7 +2102,7 @@ Editor::do_import (vector<string> paths, bool split, bool as_tracks)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Editor::reject_because_rate_differs (const string & path, SF_INFO& finfo, const string & action, bool multiple_pending)
|
Editor::reject_because_rate_differs (const string & path, SoundFileInfo& finfo, const string & action, bool multiple_pending)
|
||||||
{
|
{
|
||||||
if (!session) {
|
if (!session) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -2185,8 +2183,7 @@ Editor::embed_sndfile (string path, bool split, bool multiple_files, bool& check
|
||||||
AudioRegion::SourceList sources;
|
AudioRegion::SourceList sources;
|
||||||
string idspec;
|
string idspec;
|
||||||
string linked_path;
|
string linked_path;
|
||||||
SNDFILE *sf;
|
SoundFileInfo finfo;
|
||||||
SF_INFO finfo;
|
|
||||||
|
|
||||||
/* lets see if we can link it into the session */
|
/* lets see if we can link it into the session */
|
||||||
|
|
||||||
|
|
@ -2204,18 +2201,11 @@ Editor::embed_sndfile (string path, bool split, bool multiple_files, bool& check
|
||||||
path = linked_path;
|
path = linked_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (&finfo, 0, sizeof(finfo));
|
|
||||||
|
|
||||||
/* note that we temporarily truncated _id at the colon */
|
/* note that we temporarily truncated _id at the colon */
|
||||||
|
if (!get_soundfile_info (path, finfo)) {
|
||||||
if ((sf = sf_open (path.c_str(), SFM_READ, &finfo)) == 0) {
|
error << string_compose(_("Editor: cannot open file \"%1\""), selection ) << endmsg;
|
||||||
char errbuf[256];
|
|
||||||
sf_error_str (0, errbuf, sizeof (errbuf) - 1);
|
|
||||||
error << string_compose(_("Editor: cannot open file \"%1\" (%2)"), selection, errbuf) << endmsg;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sf_close (sf);
|
|
||||||
sf = 0;
|
|
||||||
|
|
||||||
if (check_sample_rate) {
|
if (check_sample_rate) {
|
||||||
switch (reject_because_rate_differs (path, finfo, "Embed", multiple_files)) {
|
switch (reject_because_rate_differs (path, finfo, "Embed", multiple_files)) {
|
||||||
|
|
@ -2319,8 +2309,7 @@ Editor::insert_sndfile (bool as_tracks)
|
||||||
void
|
void
|
||||||
Editor::insert_paths_as_new_tracks (vector<string> paths, bool split)
|
Editor::insert_paths_as_new_tracks (vector<string> paths, bool split)
|
||||||
{
|
{
|
||||||
SNDFILE *sf;
|
SoundFileInfo finfo;
|
||||||
SF_INFO finfo;
|
|
||||||
bool multiple_files;
|
bool multiple_files;
|
||||||
bool check_sample_rate = true;
|
bool check_sample_rate = true;
|
||||||
|
|
||||||
|
|
@ -2328,18 +2317,12 @@ Editor::insert_paths_as_new_tracks (vector<string> paths, bool split)
|
||||||
|
|
||||||
for (vector<string>::iterator p = paths.begin(); p != paths.end(); ++p) {
|
for (vector<string>::iterator p = paths.begin(); p != paths.end(); ++p) {
|
||||||
|
|
||||||
memset (&finfo, 0, sizeof(finfo));
|
if (!get_soundfile_info((*p), finfo)) {
|
||||||
|
|
||||||
if ((sf = sf_open ((*p).c_str(), SFM_READ, &finfo)) == 0) {
|
|
||||||
char errbuf[256];
|
char errbuf[256];
|
||||||
sf_error_str (0, errbuf, sizeof (errbuf) - 1);
|
error << string_compose(_("Editor: cannot open file \"%1\""), (*p)) << endmsg;
|
||||||
error << string_compose(_("Editor: cannot open file \"%1\" (%2)"), (*p), errbuf) << endmsg;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sf_close (sf);
|
|
||||||
sf = 0;
|
|
||||||
|
|
||||||
/* add a new track */
|
/* add a new track */
|
||||||
|
|
||||||
if (check_sample_rate) {
|
if (check_sample_rate) {
|
||||||
|
|
@ -2399,21 +2382,15 @@ Editor::insert_sndfile_into (const string & path, bool multi, AudioTimeAxisView*
|
||||||
SndFileSource *source = 0; /* keep g++ quiet */
|
SndFileSource *source = 0; /* keep g++ quiet */
|
||||||
AudioRegion::SourceList sources;
|
AudioRegion::SourceList sources;
|
||||||
string idspec;
|
string idspec;
|
||||||
SNDFILE *sf;
|
SoundFileInfo finfo;
|
||||||
SF_INFO finfo;
|
|
||||||
|
|
||||||
memset (&finfo, 0, sizeof(finfo));
|
|
||||||
|
|
||||||
/* note that we temporarily truncated _id at the colon */
|
/* note that we temporarily truncated _id at the colon */
|
||||||
|
|
||||||
if ((sf = sf_open (path.c_str(), SFM_READ, &finfo)) == 0) {
|
if (!get_soundfile_info (path, finfo)) {
|
||||||
char errbuf[256];
|
char errbuf[256];
|
||||||
sf_error_str (0, errbuf, sizeof (errbuf) - 1);
|
error << string_compose(_("Editor: cannot open file \"%1\" (%2)"), path) << endmsg;
|
||||||
error << string_compose(_("Editor: cannot open file \"%1\" (%2)"), path, errbuf) << endmsg;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sf_close (sf);
|
|
||||||
sf = 0;
|
|
||||||
|
|
||||||
if (prompt && (reject_because_rate_differs (path, finfo, "Insert", false) != 0)) {
|
if (prompt && (reject_because_rate_differs (path, finfo, "Insert", false) != 0)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
|
||||||
#include <sndfile.h>
|
|
||||||
|
|
||||||
#include <pbd/basename.h>
|
#include <pbd/basename.h>
|
||||||
|
|
||||||
#include <gtkmm/box.h>
|
#include <gtkmm/box.h>
|
||||||
|
|
@ -42,7 +40,7 @@
|
||||||
|
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
|
|
||||||
std::string length2string (const int32_t frames, const int32_t sample_rate);
|
std::string length2string (const int32_t frames, const float sample_rate);
|
||||||
|
|
||||||
SoundFileBox::SoundFileBox ()
|
SoundFileBox::SoundFileBox ()
|
||||||
:
|
:
|
||||||
|
|
@ -121,30 +119,15 @@ SoundFileBox::setup_labels (string filename)
|
||||||
{
|
{
|
||||||
path = filename;
|
path = filename;
|
||||||
|
|
||||||
SNDFILE *sf;
|
if(!get_soundfile_info (filename, sf_info)) {
|
||||||
|
|
||||||
sf_info.format = 0; // libsndfile says to clear this before sf_open().
|
|
||||||
|
|
||||||
if ((sf = sf_open ((char *) filename.c_str(), SFM_READ, &sf_info)) < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
sf_close (sf);
|
|
||||||
|
|
||||||
if (sf_info.frames == 0 && sf_info.channels == 0 &&
|
|
||||||
sf_info.samplerate == 0 && sf_info.format == 0 &&
|
|
||||||
sf_info.sections == 0) {
|
|
||||||
/* .. ok, it's not a sound file */
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
length.set_alignment (0.0f, 0.0f);
|
length.set_alignment (0.0f, 0.0f);
|
||||||
length.set_text (string_compose("Length: %1", length2string(sf_info.frames, sf_info.samplerate)));
|
length.set_text (string_compose("Length: %1", length2string(sf_info.length, sf_info.samplerate)));
|
||||||
|
|
||||||
format.set_alignment (0.0f, 0.0f);
|
format.set_alignment (0.0f, 0.0f);
|
||||||
format.set_text (string_compose("Format: %1, %2",
|
format.set_text (sf_info.format_name);
|
||||||
sndfile_major_format(sf_info.format),
|
|
||||||
sndfile_minor_format(sf_info.format)));
|
|
||||||
|
|
||||||
channels.set_alignment (0.0f, 0.0f);
|
channels.set_alignment (0.0f, 0.0f);
|
||||||
channels.set_text (string_compose("Channels: %1", sf_info.channels));
|
channels.set_text (string_compose("Channels: %1", sf_info.channels));
|
||||||
|
|
@ -363,9 +346,9 @@ SoundFileOmega::import_clicked ()
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
length2string (const int32_t frames, const int32_t sample_rate)
|
length2string (const int32_t frames, const float sample_rate)
|
||||||
{
|
{
|
||||||
int secs = (int) (frames / (float) sample_rate);
|
int secs = (int) (frames / sample_rate);
|
||||||
int hrs = secs / 3600;
|
int hrs = secs / 3600;
|
||||||
secs -= (hrs * 3600);
|
secs -= (hrs * 3600);
|
||||||
int mins = secs / 60;
|
int mins = secs / 60;
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <sndfile.h>
|
|
||||||
|
|
||||||
#include <sigc++/signal.h>
|
#include <sigc++/signal.h>
|
||||||
|
|
||||||
#include <gtkmm/box.h>
|
#include <gtkmm/box.h>
|
||||||
|
|
@ -41,6 +39,7 @@
|
||||||
#include <gtkmm/treeview.h>
|
#include <gtkmm/treeview.h>
|
||||||
|
|
||||||
#include <ardour/session.h>
|
#include <ardour/session.h>
|
||||||
|
#include <ardour/sndfile_helpers.h>
|
||||||
|
|
||||||
#include "ardour_dialog.h"
|
#include "ardour_dialog.h"
|
||||||
|
|
||||||
|
|
@ -68,7 +67,7 @@ class SoundFileBox : public Gtk::VBox
|
||||||
|
|
||||||
LabelModelColumns label_columns;
|
LabelModelColumns label_columns;
|
||||||
|
|
||||||
SF_INFO sf_info;
|
SoundFileInfo sf_info;
|
||||||
|
|
||||||
pid_t current_pid;
|
pid_t current_pid;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue