when selecting one of a set of variable I/O configs for an AudioUnit so that its...
[ardour.git] / libs / ardour / audio_unit.cc
index d6348af2e3cac7b273e6d00970b4292df014ae28..9151e76bec5f93eb7c8adca011f6296651ddacfb 100644 (file)
@@ -1019,7 +1019,8 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out) con
 
        vector<pair<int,int> >& io_configs = pinfo->cache.io_configs;
 
-       DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("%1 has %2 IO configurations\n", name(), io_configs.size()));
+       DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("%1 has %2 IO configurations, looking for %3 in, %4 out\n", 
+                                                       name(), io_configs.size(), in, out));
 
        //Ardour expects the plugin to tell it the output
        //configuration but AU plugins can have multiple I/O
@@ -1034,7 +1035,13 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out) con
                int32_t possible_out = i->second;
 
                if ((possible_in == audio_in) && (possible_out == audio_out)) {
-                       DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("\tCHOSEN: in %1 out %2\n", in, out));
+                       DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("\tCHOSEN: %1 in %2 out to match in %3 out %4\n", 
+                                                                       possible_in, possible_out,
+                                                                       in, out));
+
+                       out.set (DataType::MIDI, 0);
+                       out.set (DataType::AUDIO, audio_out);
+
                        return 1;
                }
        }
@@ -1300,9 +1307,14 @@ AUPlugin::connect_and_run (BufferSet& bufs, ChanMapping in_map, ChanMapping out_
                _last_nframes = nframes;
        }
 
+       DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("%1 in %2 out %3 MIDI %4 bufs %5 (available %6)\n",
+                                                       name(), input_channels, output_channels, _has_midi_input,
+                                                       bufs.count(), bufs.available()));
+
        /* the apparent number of buffers matches our input configuration, but we know that the bufferset
           has the capacity to handle our outputs.
        */
+
        assert (bufs.available() >= ChanCount (DataType::AUDIO, output_channels));
 
        input_buffers = &bufs;
@@ -1310,10 +1322,6 @@ AUPlugin::connect_and_run (BufferSet& bufs, ChanMapping in_map, ChanMapping out_
        input_offset = offset;
        cb_offset = 0;
 
-       DEBUG_TRACE (DEBUG::AudioUnits, string_compose ("%1 in %2 out %3 MIDI %4 bufs %5 (available %6)\n",
-                                                       name(), input_channels, output_channels, _has_midi_input,
-                                                       bufs.count(), bufs.available()));
-
        buffers->mNumberBuffers = output_channels;
 
        for (int32_t i = 0; i < output_channels; ++i) {
@@ -1414,13 +1422,13 @@ AUPlugin::get_beat_and_tempo_callback (Float64* outCurrentBeat,
 
        Timecode::BBT_Time bbt;
        TempoMetric metric = tmap.metric_at (_session.transport_frame() + input_offset);
-       tmap.bbt_time_with_metric (_session.transport_frame() + input_offset, bbt, metric);
+       tmap.bbt_time (_session.transport_frame() + input_offset, bbt);
 
        if (outCurrentBeat) {
                float beat;
                beat = metric.meter().divisions_per_bar() * bbt.bars;
                beat += bbt.beats;
-               beat += bbt.ticks / Timecode::BBT_Time::ticks_per_bar_division;
+               beat += bbt.ticks / Timecode::BBT_Time::ticks_per_beat;
                *outCurrentBeat = beat;
        }
 
@@ -1453,7 +1461,7 @@ AUPlugin::get_musical_time_location_callback (UInt32*   outDeltaSampleOffsetToNe
 
        Timecode::BBT_Time bbt;
        TempoMetric metric = tmap.metric_at (_session.transport_frame() + input_offset);
-       tmap.bbt_time_with_metric (_session.transport_frame() + input_offset, bbt, metric);
+       tmap.bbt_time (_session.transport_frame() + input_offset, bbt);
 
        if (outDeltaSampleOffsetToNextBeat) {
                if (bbt.ticks == 0) {
@@ -1461,8 +1469,8 @@ AUPlugin::get_musical_time_location_callback (UInt32*   outDeltaSampleOffsetToNe
                        *outDeltaSampleOffsetToNextBeat = 0;
                } else {
                        *outDeltaSampleOffsetToNextBeat = (UInt32) 
-                               floor (((Timecode::BBT_Time::ticks_per_bar_division - bbt.ticks)/Timecode::BBT_Time::ticks_per_bar_division) * // fraction of a beat to next beat
-                                      metric.tempo().frames_per_beat(_session.frame_rate(), metric.meter())); // frames per beat
+                               floor (((Timecode::BBT_Time::ticks_per_beat - bbt.ticks)/Timecode::BBT_Time::ticks_per_beat) * // fraction of a beat to next beat
+                                      metric.tempo().frames_per_beat (_session.frame_rate())); // frames per beat
                }
        }
 
@@ -1548,24 +1556,24 @@ AUPlugin::get_transport_state_callback (Boolean*  outIsPlaying,
 
                                if (outCycleStartBeat) {
                                        TempoMetric metric = tmap.metric_at (loc->start() + input_offset);
-                                       _session.tempo_map().bbt_time_with_metric (loc->start(), bbt, metric);
+                                       _session.tempo_map().bbt_time (loc->start(), bbt);
 
                                        float beat;
                                        beat = metric.meter().divisions_per_bar() * bbt.bars;
                                        beat += bbt.beats;
-                                       beat += bbt.ticks / Timecode::BBT_Time::ticks_per_bar_division;
+                                       beat += bbt.ticks / Timecode::BBT_Time::ticks_per_beat;
 
                                        *outCycleStartBeat = beat;
                                }
 
                                if (outCycleEndBeat) {
                                        TempoMetric metric = tmap.metric_at (loc->end() + input_offset);
-                                       _session.tempo_map().bbt_time_with_metric (loc->end(), bbt, metric);
+                                       _session.tempo_map().bbt_time (loc->end(), bbt);
 
                                        float beat;
                                        beat = metric.meter().divisions_per_bar() * bbt.bars;
                                        beat += bbt.beats;
-                                       beat += bbt.ticks / Timecode::BBT_Time::ticks_per_bar_division;
+                                       beat += bbt.ticks / Timecode::BBT_Time::ticks_per_beat;
 
                                        *outCycleEndBeat = beat;
                                }