Exemplo n.º 1
0
 void setSynthPreset(Synth1Preset preset)
 {
     foreach (var para in preset.Parameters)
     {
         VSTForm.vst.pluginContext.PluginCommandStub.SetParameter(para.Key, Synth1PresetHandler.ConvertParaToVstPara(para.Key, para.Value, 13));
     }
 }
Exemplo n.º 2
0
        void PresetRecording()
        {
            int programNumber           = 0;
            int testDataCount           = 0;
            List <Synth1Preset> presets =
                Synth1PresetHandler.GetPresetsFromFolderAndSubfolders(@"C:\Users\patri_000\Desktop\Synth1Presets");

            // Synth1 can max save 12800 programs
            while (programNumber < presets.Count)
            {
                if (!UtilityAudio.IsStreamingToDisk())
                {
                    VSTForm.vst.pluginContext.PluginCommandStub.SetProgram(0);
                    var programmName = presets[programNumber].Name;

                    // step over empty programs
                    if (programmName != "initial sound")
                    {
                        setSynthPreset(presets[programNumber]);
                        UtilityAudio.SaveStream(Path.Combine(recordDestinationPath, "Test" + testDataCount + ".wav"));

                        // start audio recording
                        UtilityAudio.StartStreamingToDisk();

                        const byte midiNote     = 60; // C4
                        byte       midiVelocity = 100;

                        progressLog1.LogMessage(Color.Blue, "TestSample No. " + testDataCount + " recording from presets started...");

                        UtilityAudio.StartReadNonRealtime();

                        // only bother with the keys that trigger midi notes
                        if (VSTForm.vst != null && midiNote != 0)
                        {
                            // start synth processing
                            VSTForm.vst.MIDI_NoteOn(midiNote, midiVelocity);
                        }

                        // sleep for duration how long the note is hold
                        Thread.Sleep(7);

                        midiVelocity = 0;

                        if (VSTForm.vst != null && midiNote != 0)
                        {
                            // stop synth processing
                            VSTForm.vst.MIDI_NoteOn(midiNote, midiVelocity);
                        }

                        var testDataXml =
                            new XDocument(
                                new XElement("Synth1Testdata",
                                             new XElement("TestdataCount", testDataCount),
                                             new XElement("PresetName", programmName)
                                             )
                                );

                        for (int i = 0; i < 99; i++)
                        {
                            var parameter = new XElement("Parameter",
                                                         new XAttribute("index", i), new XAttribute("vstValue", VSTForm.vst.pluginContext.PluginCommandStub.GetParameter(i)), new XAttribute("presetValue", Synth1PresetHandler.ConvertVstParaToParaV113(i, VSTForm.vst.pluginContext.PluginCommandStub.GetParameter(i))));

                            testDataXml.Element("Synth1Testdata")?.Add(parameter);
                        }

                        testDataXml.Save(Path.Combine(recordDestinationPath, "Test" + testDataCount + ".xml"));

                        testDataCount++;
                    }

                    programNumber++;
                }

                Thread.Sleep(5);
            }
        }