mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-12 17:46:34 +01:00
BWF offset changes from Ben Loftis, hacked by hand into current svn
git-svn-id: svn://localhost/ardour2/trunk@674 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
26843b34fd
commit
c3b4df9867
9 changed files with 45 additions and 67 deletions
|
|
@ -95,7 +95,7 @@ class AudioFileSource : public AudioSource {
|
|||
static void set_bwf_serial_number (int);
|
||||
|
||||
static void set_search_path (string);
|
||||
static void set_header_position_offset (jack_nframes_t offset, bool negative);
|
||||
static void set_header_position_offset (jack_nframes_t offset );
|
||||
|
||||
static sigc::signal<void> HeaderPositionOffsetChanged;
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ class AudioFileSource : public AudioSource {
|
|||
to cause issues.
|
||||
*/
|
||||
|
||||
void handle_header_position_change ();
|
||||
virtual void handle_header_position_change () {}
|
||||
|
||||
protected:
|
||||
|
||||
|
|
@ -141,7 +141,6 @@ class AudioFileSource : public AudioSource {
|
|||
static char bwf_serial_number[13];
|
||||
|
||||
static uint64_t header_position_offset;
|
||||
static bool header_position_negative;
|
||||
|
||||
virtual void set_timeline_position (jack_nframes_t pos);
|
||||
virtual void set_header_timeline_position () = 0;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ class DestructiveFileSource : public SndFileSource {
|
|||
protected:
|
||||
jack_nframes_t write_unlocked (Sample *src, jack_nframes_t cnt, char * workbuf);
|
||||
|
||||
virtual void handle_header_position_change ();
|
||||
|
||||
private:
|
||||
static jack_nframes_t xfade_frames;
|
||||
static gain_t* out_coefficient;
|
||||
|
|
|
|||
|
|
@ -51,8 +51,6 @@ class SndFileSource : public AudioFileSource {
|
|||
int update_header (jack_nframes_t when, struct tm&, time_t);
|
||||
int flush_header ();
|
||||
|
||||
void handle_smpte_offset_change (jack_nframes_t offset, bool negative);
|
||||
|
||||
protected:
|
||||
void set_header_timeline_position ();
|
||||
|
||||
|
|
|
|||
|
|
@ -56,8 +56,7 @@ string AudioFileSource::peak_dir = "";
|
|||
string AudioFileSource::search_path;
|
||||
|
||||
sigc::signal<void> AudioFileSource::HeaderPositionOffsetChanged;
|
||||
bool AudioFileSource::header_position_negative;
|
||||
uint64_t AudioFileSource::header_position_offset;
|
||||
uint64_t AudioFileSource::header_position_offset = 0;
|
||||
|
||||
char AudioFileSource::bwf_country_code[3] = "US";
|
||||
char AudioFileSource::bwf_organization_code[4] = "LAS";
|
||||
|
|
@ -592,25 +591,13 @@ AudioFileSource::set_search_path (string p)
|
|||
}
|
||||
|
||||
void
|
||||
AudioFileSource::set_header_position_offset (jack_nframes_t offset, bool negative)
|
||||
AudioFileSource::set_header_position_offset (jack_nframes_t offset)
|
||||
{
|
||||
header_position_offset = offset;
|
||||
header_position_negative = negative;
|
||||
|
||||
HeaderPositionOffsetChanged ();
|
||||
}
|
||||
|
||||
void
|
||||
AudioFileSource::handle_header_position_change ()
|
||||
{
|
||||
cerr << _path << " handling header position change " << writable() << endl;
|
||||
|
||||
if (writable()) {
|
||||
set_header_timeline_position ();
|
||||
flush_header ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioFileSource::set_timeline_position (jack_nframes_t pos)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -75,6 +75,9 @@ DestructiveFileSource::DestructiveFileSource (string path, SampleFormat samp_for
|
|||
_capture_start = false;
|
||||
_capture_end = false;
|
||||
file_pos = 0;
|
||||
|
||||
timeline_position = header_position_offset;
|
||||
AudioFileSource::HeaderPositionOffsetChanged.connect (mem_fun (*this, &DestructiveFileSource::handle_header_position_change));
|
||||
}
|
||||
|
||||
DestructiveFileSource::DestructiveFileSource (const XMLNode& node)
|
||||
|
|
@ -85,6 +88,9 @@ DestructiveFileSource::DestructiveFileSource (const XMLNode& node)
|
|||
_capture_start = false;
|
||||
_capture_end = false;
|
||||
file_pos = 0;
|
||||
|
||||
timeline_position = header_position_offset;
|
||||
AudioFileSource::HeaderPositionOffsetChanged.connect (mem_fun (*this, &DestructiveFileSource::handle_header_position_change));
|
||||
}
|
||||
|
||||
DestructiveFileSource::~DestructiveFileSource()
|
||||
|
|
@ -365,9 +371,20 @@ DestructiveFileSource::get_state ()
|
|||
return node;
|
||||
}
|
||||
|
||||
void
|
||||
DestructiveFileSource::handle_header_position_change ()
|
||||
{
|
||||
if ( _length != 0 ) {
|
||||
error << string_compose(_("Filesource: start time is already set for existing file (%1): Cannot change start time."), _path ) << endmsg;
|
||||
//in the future, pop up a dialog here that allows user to regenerate file with new start offset
|
||||
} else if (writable()) {
|
||||
timeline_position = header_position_offset;
|
||||
set_header_timeline_position (); //this will get flushed if/when the file is recorded to
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DestructiveFileSource::set_timeline_position (jack_nframes_t pos)
|
||||
{
|
||||
/* destructive tracks always start at where our reference frame zero is */
|
||||
timeline_position = 0;
|
||||
//destructive track timeline postion does not change except at instantion or when header_position_offset (session start) changes
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include <pbd/xml++.h>
|
||||
|
||||
#include <ardour/location.h>
|
||||
#include <ardour/audiofilesource.h>
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
|
|
@ -71,6 +72,9 @@ Location::set_start (jack_nframes_t s)
|
|||
_start = s;
|
||||
_end = s;
|
||||
start_changed(this); /* EMIT SIGNAL */
|
||||
if ( is_start() ) {
|
||||
AudioFileSource::set_header_position_offset ( s );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include <ardour/audioengine.h>
|
||||
#include <ardour/session.h>
|
||||
#include <ardour/tempo.h>
|
||||
#include <ardour/audiofilesource.h>
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
|
|
@ -93,8 +92,6 @@ Session::set_smpte_offset (jack_nframes_t off)
|
|||
_smpte_offset = off;
|
||||
last_smpte_valid = false;
|
||||
|
||||
AudioFileSource::set_header_position_offset (_smpte_offset, _smpte_offset_negative);
|
||||
|
||||
SMPTEOffsetChanged (); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
|
|
@ -104,8 +101,6 @@ Session::set_smpte_offset_negative (bool neg)
|
|||
_smpte_offset_negative = neg;
|
||||
last_smpte_valid = false;
|
||||
|
||||
AudioFileSource::set_header_position_offset (_smpte_offset, _smpte_offset_negative);
|
||||
|
||||
SMPTEOffsetChanged (); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,6 +156,8 @@ SndFileSource::SndFileSource (string idstr, SampleFormat sfmt, HeaderFormat hf,
|
|||
utsinfo.version);
|
||||
|
||||
_broadcast_info->version = 1;
|
||||
_broadcast_info->time_reference_low = 0;
|
||||
_broadcast_info->time_reference_high = 0;
|
||||
|
||||
/* XXX do something about this field */
|
||||
|
||||
|
|
@ -183,6 +185,7 @@ SndFileSource::SndFileSource (string idstr, SampleFormat sfmt, HeaderFormat hf,
|
|||
}
|
||||
|
||||
AudioSourceCreated (this); /* EMIT SIGNAL */
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -241,6 +244,7 @@ SndFileSource::open ()
|
|||
/* if the file has data but no broadcast info, then clearly, there is no broadcast info */
|
||||
|
||||
if (_length) {
|
||||
error << "SndFileSource: file has no broadcast info" << endmsg;
|
||||
free (_broadcast_info);
|
||||
_broadcast_info = 0;
|
||||
_flags = Flag (_flags & ~Broadcast);
|
||||
|
|
@ -259,10 +263,6 @@ SndFileSource::open ()
|
|||
|
||||
if (writable()) {
|
||||
sf_command (sf, SFC_SET_UPDATE_HEADER_AUTO, 0, SF_FALSE);
|
||||
|
||||
/* update header if header offset info changes */
|
||||
|
||||
AudioFileSource::HeaderPositionOffsetChanged.connect (mem_fun (*this, &AudioFileSource::handle_header_position_change));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -474,7 +474,7 @@ SndFileSource::setup_broadcast_info (jack_nframes_t when, struct tm& now, time_t
|
|||
now.tm_mon,
|
||||
now.tm_mday);
|
||||
|
||||
snprintf (_broadcast_info->origination_time, sizeof (_broadcast_info->origination_time), "%02d-%02d-%02d",
|
||||
snprintf (_broadcast_info->origination_time, sizeof (_broadcast_info->origination_time), "%02d:%02d:%02d",
|
||||
now.tm_hour,
|
||||
now.tm_min,
|
||||
now.tm_sec);
|
||||
|
|
@ -497,37 +497,12 @@ SndFileSource::setup_broadcast_info (jack_nframes_t when, struct tm& now, time_t
|
|||
void
|
||||
SndFileSource::set_header_timeline_position ()
|
||||
{
|
||||
uint64_t pos;
|
||||
|
||||
if (!(_flags & Broadcast)) {
|
||||
return;
|
||||
}
|
||||
|
||||
cerr << "timeline pos = " << timeline_position << " offset = " << header_position_offset << endl;
|
||||
|
||||
_broadcast_info->time_reference_high = 0;
|
||||
|
||||
if (header_position_negative) {
|
||||
|
||||
if (ULONG_LONG_MAX - header_position_offset < timeline_position) {
|
||||
pos = ULONG_LONG_MAX; // impossible
|
||||
} else {
|
||||
pos = timeline_position + header_position_offset;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (timeline_position < header_position_offset) {
|
||||
pos = 0;
|
||||
} else {
|
||||
pos = timeline_position - header_position_offset;
|
||||
}
|
||||
}
|
||||
|
||||
_broadcast_info->time_reference_high = (pos >> 32);
|
||||
_broadcast_info->time_reference_low = (pos & 0xffffffff);
|
||||
|
||||
cerr << "set binfo pos to " << _broadcast_info->time_reference_high << " + " << _broadcast_info->time_reference_low << endl;
|
||||
_broadcast_info->time_reference_high = (timeline_position >> 32);
|
||||
_broadcast_info->time_reference_low = (timeline_position & 0xffffffff);
|
||||
|
||||
if (sf_command (sf, SFC_SET_BROADCAST_INFO, _broadcast_info, sizeof (*_broadcast_info)) != SF_TRUE) {
|
||||
error << string_compose (_("cannot set broadcast info for audio file %1; Dropping broadcast info for this file"), _path) << endmsg;
|
||||
|
|
|
|||
|
|
@ -1065,13 +1065,12 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
|
|||
memcpy (data, psf->loop_info, sizeof (SF_LOOP_INFO)) ;
|
||||
return SF_TRUE ;
|
||||
|
||||
case SFC_SET_BROADCAST_INFO :
|
||||
{ int format = psf->sf.format & SF_FORMAT_TYPEMASK ;
|
||||
case SFC_SET_BROADCAST_INFO : {
|
||||
int format = psf->sf.format & SF_FORMAT_TYPEMASK ;
|
||||
|
||||
/* Only WAV supports the BEXT (Broadcast) chunk. */
|
||||
if (format != SF_FORMAT_WAV && format != SF_FORMAT_WAVEX)
|
||||
return SF_FALSE ;
|
||||
} ;
|
||||
|
||||
/* Can only do this is in SFM_RDWR or SFM_WRITE modes. */
|
||||
if (psf->mode == SFM_READ)
|
||||
|
|
@ -1089,7 +1088,9 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
|
|||
|
||||
if (psf->auto_header && psf->write_header)
|
||||
psf->write_header (psf, SF_TRUE) ;
|
||||
|
||||
return SF_TRUE ;
|
||||
}
|
||||
|
||||
case SFC_GET_BROADCAST_INFO :
|
||||
if (datasize != sizeof (SF_BROADCAST_INFO) || data == NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue