Skip to content

Commit

Permalink
Merge branch 'fix-wav-source-preset'
Browse files Browse the repository at this point in the history
* fix-wav-source-preset:
  TODO--
  TEMPLATES: remove cantained data from wav source preset
  GLUI: do not load contained wav sources for wav source preset
  LIB: Project: support load without loading contained wav source data

Signed-off-by: Stefan Westerfeld <[email protected]>
  • Loading branch information
swesterfeld committed Jun 11, 2024
2 parents f5b53a1 + b867736 commit a22c2b0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ NEWER TODOS:
1.0.0-beta1:
- presets for 1.0.0
- update clap 3rdparty code
- 1-instrument-wav-source contains the data - not a good idea!
- LV2 archive storage doesn't seem to work
- new video tutorial
- update manual
Expand Down
Binary file modified data/templates/1-instrument-wav-source.smplan
Binary file not shown.
8 changes: 4 additions & 4 deletions glui/smmorphplanwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ MorphPlanWindow::add_op_menu_item (Menu *op_menu, const std::string& text, const


Error
MorphPlanWindow::load (const std::string& filename)
MorphPlanWindow::load (const std::string& filename, bool load_wav_souces)
{
Error error = m_morph_plan->project()->load (filename);
Error error = m_morph_plan->project()->load (filename, load_wav_souces);

if (!error)
set_filename (filename);
Expand All @@ -162,7 +162,7 @@ MorphPlanWindow::on_load_preset (const std::string& rel_filename)
{
std::string filename = sm_get_install_dir (INSTALL_DIR_TEMPLATES) + "/" + rel_filename;

Error error = load (filename);
Error error = load (filename, false);
if (error)
{
MessageBox::critical (this, "Error",
Expand All @@ -177,7 +177,7 @@ MorphPlanWindow::on_file_import_clicked()
open_file_dialog ("Select SpectMorph Preset to import", formats, [=](string filename) {
if (filename != "")
{
Error error = load (filename);
Error error = load (filename, true);

if (error)
{
Expand Down
2 changes: 1 addition & 1 deletion glui/smmorphplanwindow.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MorphPlanWindow : public Window

void add_op_menu_item (Menu *op_menu, const std::string& text, const std::string& op_name);

Error load (const std::string& filename);
Error load (const std::string& filename, bool load_wav_sources);
Error save (const std::string& filename);
public:
void
Expand Down
13 changes: 7 additions & 6 deletions lib/smproject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,19 @@ Project::post_load()
}

Error
Project::load (const string& filename)
Project::load (const string& filename, bool load_wav_sources)
{
if (ZipReader::is_zip (filename))
{
ZipReader zip_reader (filename);
if (zip_reader.error())
return zip_reader.error();

return load (zip_reader, nullptr);
return load (zip_reader, nullptr, load_wav_sources);
}
else
{
assert (!load_wav_sources); /* we only need this for preset loading, which are in new format */
GenericIn *file = GenericIn::open (filename);
if (file)
{
Expand All @@ -395,7 +396,7 @@ Project::load (const string& filename)
}

Error
Project::load (ZipReader& zip_reader, MorphPlan::ExtraParameters *params)
Project::load (ZipReader& zip_reader, MorphPlan::ExtraParameters *params, bool load_wav_sources)
{
/* backup old plan */
vector<unsigned char> data;
Expand All @@ -406,7 +407,7 @@ Project::load (ZipReader& zip_reader, MorphPlan::ExtraParameters *params)
map<int, std::unique_ptr<Instrument>> old_instrument_map;
old_instrument_map.swap (instrument_map);

Error error = load_internal (zip_reader, params);
Error error = load_internal (zip_reader, params, load_wav_sources);
if (error)
{
/* restore old plan/instruments if something went wrong */
Expand All @@ -420,7 +421,7 @@ Project::load (ZipReader& zip_reader, MorphPlan::ExtraParameters *params)
}

Error
Project::load_internal (ZipReader& zip_reader, MorphPlan::ExtraParameters *params)
Project::load_internal (ZipReader& zip_reader, MorphPlan::ExtraParameters *params, bool load_wav_sources)
{
vector<uint8_t> plan = zip_reader.read ("plan.smplan");
if (zip_reader.error())
Expand All @@ -440,7 +441,7 @@ Project::load_internal (ZipReader& zip_reader, MorphPlan::ExtraParameters *param
Instrument *inst = new Instrument();
instrument_map[object_id].reset (inst);

if (m_storage_model == StorageModel::COPY)
if (m_storage_model == StorageModel::COPY && load_wav_sources)
{
string inst_file = string_printf ("instrument%d.sminst", object_id);
vector<uint8_t> inst_data = zip_reader.read (inst_file);
Expand Down
6 changes: 3 additions & 3 deletions lib/smproject.hh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private:

std::vector<MorphWavSource *> list_wav_sources();

Error load_internal (ZipReader& zip_reader, MorphPlan::ExtraParameters *params);
Error load_internal (ZipReader& zip_reader, MorphPlan::ExtraParameters *params, bool load_wav_sources);
void post_load();

void on_plan_changed();
Expand Down Expand Up @@ -151,8 +151,8 @@ public:

Error save (const std::string& filename);
Error save (ZipWriter& zip_writer, MorphPlan::ExtraParameters *params);
Error load (const std::string& filename);
Error load (ZipReader& zip_reader, MorphPlan::ExtraParameters *params);
Error load (const std::string& filename, bool load_wav_sources = true);
Error load (ZipReader& zip_reader, MorphPlan::ExtraParameters *params, bool load_wav_sources = true);
Error load_compat (GenericIn *in, MorphPlan::ExtraParameters *params);

std::string save_plan_lv2 (std::function<std::string(std::string)> abstract_path);
Expand Down

0 comments on commit a22c2b0

Please sign in to comment.