diff --git a/libs/ardour/ardour/surround_return.h b/libs/ardour/ardour/surround_return.h index 0aaf0ae4fe..699461c6ef 100644 --- a/libs/ardour/ardour/surround_return.h +++ b/libs/ardour/ardour/surround_return.h @@ -97,7 +97,7 @@ public: samplecnt_t signal_latency () const; /* XXX this is only for testing */ - void set_bed_mix (bool on, int32_t types[10], int32_t ids[10], double); + void set_bed_mix (bool on, std::string const& ref); int set_state (XMLNode const&, int version); @@ -161,6 +161,7 @@ private: samplepos_t _export_end; bool _rolling; bool _with_bed; + std::string _export_reference; std::atomic _flush; }; diff --git a/libs/ardour/ardour/uri_map.h b/libs/ardour/ardour/uri_map.h index 09fe17b8f7..7c38e00e5f 100644 --- a/libs/ardour/ardour/uri_map.h +++ b/libs/ardour/ardour/uri_map.h @@ -123,6 +123,7 @@ public: uint32_t surr_WarpMode; uint32_t surr_ExportStart; uint32_t surr_ExportStop; + uint32_t surr_ReferenceFile; #endif }; diff --git a/libs/ardour/surround_return.cc b/libs/ardour/surround_return.cc index 37ac813e75..001b3b0ac8 100644 --- a/libs/ardour/surround_return.cc +++ b/libs/ardour/surround_return.cc @@ -17,6 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include +#include + #include "ardour/amp.h" #include "ardour/audio_buffer.h" #include "ardour/lv2_plugin.h" @@ -261,36 +264,15 @@ SurroundReturn::flush () } void -SurroundReturn::set_bed_mix (bool on, int32_t chan_types[10], int32_t bed_ids[10], double ffoa) { +SurroundReturn::set_bed_mix (bool on, std::string const& ref) +{ _with_bed = on; if (!_with_bed) { + _export_reference.clear (); return; } - - URIMap::URIDs const& urids = URIMap::instance ().urids; - LV2_Atom_Forge_Frame frame; - lv2_atom_forge_set_buffer (&_forge, _atom_buf, sizeof (_atom_buf)); - lv2_atom_forge_frame_time (&_forge, 0); - LV2_Atom* msg = (LV2_Atom*)lv2_atom_forge_object (&_forge, &frame, 1, urids.surr_ChannelDescription); - lv2_atom_forge_key (&_forge, urids.surr_ChannelTypes); - lv2_atom_forge_vector(&_forge, sizeof(int32_t), urids.atom_Int, 10, chan_types); - lv2_atom_forge_key (&_forge, urids.surr_ChannelBedIds); - lv2_atom_forge_vector(&_forge, sizeof(int32_t), urids.atom_Int, 10, bed_ids); - lv2_atom_forge_pop (&_forge, &frame); - _surround_processor->write_from_ui (0, urids.atom_eventTransfer, lv2_atom_total_size (msg), (const uint8_t*)msg); - - lv2_atom_forge_set_buffer (&_forge, _atom_buf, sizeof (_atom_buf)); - lv2_atom_forge_frame_time (&_forge, 0); - msg = (LV2_Atom*)lv2_atom_forge_object (&_forge, &frame, 1, urids.surr_ProgramData); - lv2_atom_forge_key (&_forge, urids.surr_ContentFFOA); - lv2_atom_forge_float (&_forge, ffoa); - lv2_atom_forge_key (&_forge, urids.surr_ContentStart); - lv2_atom_forge_float (&_forge, 0); // TODO - lv2_atom_forge_key (&_forge, urids.surr_ContentFPS); - lv2_atom_forge_int (&_forge, 0); // TODO - lv2_atom_forge_pop (&_forge, &frame); - _surround_processor->write_from_ui (0, urids.atom_eventTransfer, lv2_atom_total_size (msg), (const uint8_t*)msg); + _export_reference = ref; } void @@ -651,7 +633,18 @@ SurroundReturn::set_playback_offset (samplecnt_t cnt) void SurroundReturn::setup_export (std::string const& fn, samplepos_t ss, samplepos_t es) { - if (0 == _surround_processor->setup_export (fn.c_str ())) { + URIMap::URIDs const& urids = URIMap::instance ().urids; + + bool have_ref = !_export_reference.empty () && Glib::file_test (_export_reference, Glib::FileTest (Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_REGULAR)); + + uint32_t len = _export_reference.size () + 1; + LV2_Options_Option options[] = { + { LV2_OPTIONS_INSTANCE, 0, urids.surr_ReferenceFile, + len, urids.atom_Path, _export_reference.c_str()}, + { LV2_OPTIONS_INSTANCE, 0, 0, 0, 0, NULL } + }; + + if (0 == _surround_processor->setup_export (fn.c_str (), have_ref ? options : NULL)) { //std::cout << "SurroundReturn::setup export "<< ss << " to " << es << "\n"; _exporting = true; _export_start = ss - effective_latency (); diff --git a/libs/ardour/uri_map.cc b/libs/ardour/uri_map.cc index ba315103fa..80e9933b1e 100644 --- a/libs/ardour/uri_map.cc +++ b/libs/ardour/uri_map.cc @@ -100,6 +100,7 @@ URIMap::URIDs::init(URIMap& uri_map) surr_WarpMode = uri_map.uri_to_id("urn:ardour:a-vapor#WarpMode"); surr_ExportStart = uri_map.uri_to_id("urn:ardour:a-vapor#ExportStart"); surr_ExportStop = uri_map.uri_to_id("urn:ardour:a-vapor#ExportStop"); + surr_ReferenceFile = uri_map.uri_to_id("urn:ardour:a-vapor#ReferenceFile"); #endif } diff --git a/share/scripts/_adm_bwf.lua b/share/scripts/_adm_bwf.lua index 5de7d7a393..2617cd0f64 100644 --- a/share/scripts/_adm_bwf.lua +++ b/share/scripts/_adm_bwf.lua @@ -14,40 +14,16 @@ function factory () return function () return 0 -- "Undefined" ie "Mid" end - function parse_channel_type (t) - if tonumber (t) ~= nil then return t end - if t == "L" then return 0 end - if t == "R" then return 1 end - if t == "C" then return 2 end - if t == "LFE" then return 3 end - if t == "Ls" then return 4 end - if t == "Rs" then return 5 end - if t == "Lss" then return 6 end - if t == "Rss" then return 7 end - if t == "Lrs" or t == "Lb" then return 8 end - if t == "Rrs" or t == "Rb" then return 9 end - if t == "Lfh" or t == "Lvh" then return 10 end - if t == "Rfh" or t == "Rfh" then return 11 end - if t == "Ltm" or t == "Lts" then return 12 end - if t == "Rtm" or t == "Rts" then return 13 end - if t == "Lrh" then return 14 end - if t == "Rrh" then return 15 end - if t == "Lw" then return 16 end - if t == "Rw" then return 17 end - if t == "LFE2" then return 18 end - return -1 -- object - end - local rv = LuaDialog.Dialog ("Load ADM/BWF File", { - { type = "file", key = "file", title = "", path = ARDOUR.LuaAPI.build_filename("tmp", "input_D_Ren_24_48k_24.wav") }, + { type = "file", key = "file", title = "Choose ADM/BWF File", path = "" }, }):run() if (not rv or not ARDOUR.LuaAPI.file_test (rv['file'], ARDOUR.LuaAPI.FileTest.Exists)) then return end - -- this is `Dolby_Atmos_Storage_SIDK_v2.3.2/Tools/linux/lin64_fpic/master_info` + -- place `Dolby_Atmos_Storage_SIDK_v2.3.2/Tools/linux/lin64_fpic/master_info` in $PATH os.execute ("master_info -printProgramData -printMetadata \"" .. rv['file'] .. "\" > /tmp/adm.info") if Session:get_tracks():size() == 0 then @@ -135,16 +111,6 @@ function factory () return function () ::skip:: end - local chan_types = C.IntVector() - local bed_ids = C.IntVector() - for k = 0, 9 do - v = chan_type[k] or k - chan_types:add ({parse_channel_type(v)}) - v = chan_beds[k] or 0 - bed_ids:add ({v}) - end - assert (chan_types:size () > 9) - assert (bed_ids:size () > 9) - Session:surround_master():surround_return():set_bed_mix (true, chan_types:to_array(), bed_ids:to_array(), ffoa_sec) + Session:surround_master():surround_return():set_bed_mix (true, rv['file']) print ("OK") end end