13
0

Vapor: simply ADM meta-data passing, pass reference file

This commit is contained in:
Robin Gareus 2024-02-23 17:03:41 +01:00
parent 22fef5ab2b
commit 45a7719ede
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
5 changed files with 26 additions and 64 deletions

View File

@ -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<int> _flush;
};

View File

@ -123,6 +123,7 @@ public:
uint32_t surr_WarpMode;
uint32_t surr_ExportStart;
uint32_t surr_ExportStop;
uint32_t surr_ReferenceFile;
#endif
};

View File

@ -17,6 +17,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <glibmm/miscutils.h>
#include <glibmm/fileutils.h>
#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 ();

View File

@ -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
}

View File

@ -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