fd = open (path.c_str(), O_WRONLY|O_CREAT|O_EXCL, 0664);
while (fd < 0) {
if (errno == EEXIST) {
- /* tell any UI's that this file already exists and ask them what to do */
- bool overwrite = Plugin::PresetFileExists(); // EMIT SIGNAL
- if (overwrite) {
- fd = open (path.c_str(), O_WRONLY, 0664);
- continue;
- } else {
- return 0;
- }
+ error << string_compose (_("Preset file %1 exists; not overwriting"), path);
+ } else {
+ error << string_compose (_("Cannot open preset file %1 (%2)"), path, strerror (errno)) << endmsg;
}
- error << string_compose (_("Cannot open preset file %1 (%2)"), path, strerror (errno)) << endmsg;
CFRelease (xmlData);
return -1;
}
return 0;
}
-nframes_t
+framecnt_t
AUPlugin::signal_latency () const
{
return unit->Latency() * _session.frame_rate();
void
AUPlugin::set_parameter (uint32_t which, float val)
{
- if (which < descriptors.size()) {
- const AUParameterDescriptor& d (descriptors[which]);
- TRACE_API ("set parameter %d in scope %d element %d to %f\n", d.id, d.scope, d.element, val);
- unit->SetParameter (d.id, d.scope, d.element, val);
-
- /* tell the world what we did */
-
- AudioUnitEvent theEvent;
-
- theEvent.mEventType = kAudioUnitEvent_ParameterValueChange;
- theEvent.mArgument.mParameter.mAudioUnit = unit->AU();
- theEvent.mArgument.mParameter.mParameterID = d.id;
- theEvent.mArgument.mParameter.mScope = d.scope;
- theEvent.mArgument.mParameter.mElement = d.element;
-
- TRACE_API ("notify about parameter change\n");
- AUEventListenerNotify (NULL, NULL, &theEvent);
+ if (which >= descriptors.size()) {
+ return;
}
+
+ const AUParameterDescriptor& d (descriptors[which]);
+ TRACE_API ("set parameter %d in scope %d element %d to %f\n", d.id, d.scope, d.element, val);
+ unit->SetParameter (d.id, d.scope, d.element, val);
+
+ /* tell the world what we did */
+
+ AudioUnitEvent theEvent;
+
+ theEvent.mEventType = kAudioUnitEvent_ParameterValueChange;
+ theEvent.mArgument.mParameter.mAudioUnit = unit->AU();
+ theEvent.mArgument.mParameter.mParameterID = d.id;
+ theEvent.mArgument.mParameter.mScope = d.scope;
+ theEvent.mArgument.mParameter.mElement = d.element;
+
+ TRACE_API ("notify about parameter change\n");
+ AUEventListenerNotify (NULL, NULL, &theEvent);
+
+ Plugin::set_parameter (which, val);
}
float
int
-AUPlugin::set_block_size (nframes_t nframes)
+AUPlugin::set_block_size (pframes_t nframes)
{
bool was_initialized = initialized;
UInt32 numFrames = nframes;
}
int
-AUPlugin::connect_and_run (BufferSet& bufs, ChanMapping, ChanMapping, nframes_t nframes, nframes_t offset)
+AUPlugin::connect_and_run (BufferSet& bufs, ChanMapping in_map, ChanMapping out_map, pframes_t nframes, framecnt_t offset)
{
+ Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
+
AudioUnitRenderActionFlags flags = 0;
AudioTimeStamp ts;
OSErr err;
return kAudioUnitErr_CannotDoInCurrentContext;
}
- BBT_Time bbt;
+ Timecode::BBT_Time bbt;
TempoMetric metric = tmap.metric_at (_session.transport_frame() + current_offset);
tmap.bbt_time_with_metric (_session.transport_frame() + current_offset, bbt, metric);
float beat;
beat = metric.meter().beats_per_bar() * bbt.bars;
beat += bbt.beats;
- beat += bbt.ticks / Meter::ticks_per_beat;
+ beat += bbt.ticks / BBT_Time::ticks_per_beat;
*outCurrentBeat = beat;
}
return kAudioUnitErr_CannotDoInCurrentContext;
}
- BBT_Time bbt;
+ Timecode::BBT_Time bbt;
TempoMetric metric = tmap.metric_at (_session.transport_frame() + current_offset);
tmap.bbt_time_with_metric (_session.transport_frame() + current_offset, bbt, metric);
/* on the beat */
*outDeltaSampleOffsetToNextBeat = 0;
} else {
- *outDeltaSampleOffsetToNextBeat = (UInt32) floor (((Meter::ticks_per_beat - bbt.ticks)/Meter::ticks_per_beat) * // fraction of a beat to next beat
+ *outDeltaSampleOffsetToNextBeat = (UInt32) floor (((BBT_Time::ticks_per_beat - bbt.ticks)/BBT_Time::ticks_per_beat) * // fraction of a beat to next beat
metric.tempo().frames_per_beat(_session.frame_rate(), metric.meter())); // frames per beat
}
}
return kAudioUnitErr_CannotDoInCurrentContext;
}
- BBT_Time bbt;
+ Timecode::BBT_Time bbt;
if (outCycleStartBeat) {
TempoMetric metric = tmap.metric_at (loc->start() + current_offset);
float beat;
beat = metric.meter().beats_per_bar() * bbt.bars;
beat += bbt.beats;
- beat += bbt.ticks / Meter::ticks_per_beat;
+ beat += bbt.ticks / BBT_Time::ticks_per_beat;
*outCycleStartBeat = beat;
}
float beat;
beat = metric.meter().beats_per_bar() * bbt.bars;
beat += bbt.beats;
- beat += bbt.ticks / Meter::ticks_per_beat;
+ beat += bbt.ticks / BBT_Time::ticks_per_beat;
*outCycleEndBeat = beat;
}
return false;
}
-XMLNode&
-AUPlugin::get_state()
+void
+AUPlugin::add_state (XMLNode* root)
{
LocaleGuard lg (X_("POSIX"));
- XMLNode *root = new XMLNode (state_node_name());
#ifdef AU_STATE_SUPPORT
CFDataRef xmlData;
TRACE_API ("get preset state\n");
if (unit->GetAUPreset (propertyList) != noErr) {
- return *root;
+ return;
}
// Convert the property list into XML data.
seen_get_state_message = true;
}
#endif
-
- return *root;
}
int
-AUPlugin::set_state(const XMLNode& node, int /* version*/)
+AUPlugin::set_state(const XMLNode& node, int version)
{
#ifdef AU_STATE_SUPPORT
int ret = -1;
CFRelease (propertyList);
}
+ Plugin::set_state (node, version);
return ret;
#else
if (!seen_set_state_message) {
PROGRAM_NAME)
<< endmsg;
}
- return 0;
+ return Plugin::set_state (node, version);
#endif
}
bool
-AUPlugin::load_preset (const string& preset_label)
+AUPlugin::load_preset (PluginRecord r)
{
+ Plugin::load_preset (r);
+
#ifdef AU_STATE_SUPPORT
bool ret = false;
CFPropertyListRef propertyList;
return preset_name;
}
-vector<Plugin::PresetRecord>
-AUPlugin::get_presets ()
+void
+AUPlugin::find_presets ()
{
- vector<Plugin::PresetRecord> presets;
-
#ifdef AU_STATE_SUPPORT
vector<string*>* preset_files;
PathScanner scanner;
preset_files = scanner (preset_search_path, au_preset_filter, this, true, true, -1, true);
if (!preset_files) {
- return presets;
+ return;
}
for (vector<string*>::iterator x = preset_files->begin(); x != preset_files->end(); ++x) {
/* now fill the vector<string> with the names we have */
for (UserPresetMap::iterator i = user_preset_map.begin(); i != user_preset_map.end(); ++i) {
- presets.push_back (Plugin::PresetRecord (i->second, i->first));
+ _presets.insert (i->second, Plugin::PresetRecord (i->second, i->first));
}
/* add factory presets */
for (FactoryPresetMap::iterator i = factory_preset_map.begin(); i != factory_preset_map.end(); ++i) {
- presets.push_back (Plugin::PresetRecord ("", i->first));
+ /* XXX: dubious */
+ string const uri = string_compose ("%1", _presets.size ());
+ _presets.push_back (uri, Plugin::PresetRecord (uri, i->first));
}
#endif
-
- return presets;
}
bool