Просмотр исходного кода

Navegador: presets .fst do 3x Osc (duplo clique cria um canal synth com o preset)

Kauan 1 месяц назад
Родитель
Сommit
f68bf3e32a
2 измененных файлов с 32 добавлено и 1 удалено
  1. 31 0
      src/ui/BrowserComponent.cpp
  2. 1 1
      src/ui/BrowserComponent.h

+ 31 - 0
src/ui/BrowserComponent.cpp

@@ -1,5 +1,6 @@
 #include "ui/BrowserComponent.h"
 #include "ui/BrowserComponent.h"
 
 
+#include "core/FlpImport.h"
 #include "engine/Text.h"
 #include "engine/Text.h"
 #include "ui/Theme.h"
 #include "ui/Theme.h"
 
 
@@ -36,6 +37,7 @@ BrowserComponent::BrowserComponent (AudioEngine& e)
     add ("Samples do FL (Packs)", data.getChildFile ("Patches").getChildFile ("Packs"));
     add ("Samples do FL (Packs)", data.getChildFile ("Patches").getChildFile ("Packs"));
     add ("Projetos de exemplo do FL", data.getChildFile ("Demo projects"));
     add ("Projetos de exemplo do FL", data.getChildFile ("Demo projects"));
     add ("MIDI do FL", data.getChildFile ("Patches").getChildFile ("Scores"));
     add ("MIDI do FL", data.getChildFile ("Patches").getChildFile ("Scores"));
+    add ("Presets do 3x Osc (FL)", data.getChildFile ("Patches").getChildFile ("Channel presets").getChildFile ("3x Osc"));
     add ("Documentos", juce::File::getSpecialLocation (juce::File::userDocumentsDirectory));
     add ("Documentos", juce::File::getSpecialLocation (juce::File::userDocumentsDirectory));
     add (utf8 ("Música"), juce::File::getSpecialLocation (juce::File::userMusicDirectory));
     add (utf8 ("Música"), juce::File::getSpecialLocation (juce::File::userMusicDirectory));
     add (utf8 ("Área de trabalho"), juce::File::getSpecialLocation (juce::File::userDesktopDirectory));
     add (utf8 ("Área de trabalho"), juce::File::getSpecialLocation (juce::File::userDesktopDirectory));
@@ -112,6 +114,35 @@ void BrowserComponent::fileDoubleClicked (const juce::File& file)
         return;
         return;
     }
     }
 
 
+    // preset de canal do 3x Osc: canal novo com o synth interno ajustado pelo preset
+    if (file.hasFileExtension ("fst"))
+    {
+        juce::MemoryBlock data;
+
+        if (! file.loadFileAsData (data))
+            return;
+
+        const auto* bytes = static_cast<const std::uint8_t*> (data.getData());
+
+        if (auto synth = synthFromFlPreset (std::vector<std::uint8_t> (bytes, bytes + data.getSize())))
+        {
+            const auto name = file.getFileNameWithoutExtension().toStdString();
+            engine.editSong ([&] (Song& s) {
+                ChannelDef c;
+                c.name = name;
+                c.instrument = InstrumentKind::synth;
+                c.synth = *synth;
+                c.mixerTrack = s.nextFreeInsert();
+                s.channels.push_back (c);
+            });
+            engine.setSelectedChannel ((int) engine.getSong().channels.size() - 1);
+        }
+        else
+            juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::InfoIcon, "Preset",
+                                                    utf8 ("Por enquanto o LYNX lê presets de canal do 3x Osc."));
+        return;
+    }
+
     if (file.hasFileExtension ("lynx;flp;mid;midi") && onOpenProject)
     if (file.hasFileExtension ("lynx;flp;mid;midi") && onOpenProject)
         onOpenProject (file);
         onOpenProject (file);
 }
 }

+ 1 - 1
src/ui/BrowserComponent.h

@@ -35,7 +35,7 @@ private:
     juce::ComboBox rootBox;
     juce::ComboBox rootBox;
     juce::Array<juce::File> roots;
     juce::Array<juce::File> roots;
     juce::TimeSliceThread thread { "LYNX navegador" };
     juce::TimeSliceThread thread { "LYNX navegador" };
-    juce::WildcardFileFilter filter { "*.wav;*.flac;*.ogg;*.mp3;*.aif;*.aiff;*.mid;*.midi;*.lynx;*.flp", "*", "arquivos" };
+    juce::WildcardFileFilter filter { "*.wav;*.flac;*.ogg;*.mp3;*.aif;*.aiff;*.mid;*.midi;*.lynx;*.flp;*.fst", "*", "arquivos" };
     juce::DirectoryContentsList list { &filter, thread };
     juce::DirectoryContentsList list { &filter, thread };
     juce::FileTreeComponent tree { list };
     juce::FileTreeComponent tree { list };