Пример #1
0
        static void SaveRuntime(IMidiParserUI modest, Loop loop, float volume)
        {
            MidiSmfFile newfile = new MidiSmfFile();
              newfile.Settings = new MidiSmfFileSettings();
              newfile.Settings.ConfigurationFile = modest.VstContainer.PluginManager.CurrentConfigurationFile;

              if (modest.MidiParser != null) {
            newfile.Settings.SelectedMidiTrack = modest.MidiParser.SelectedTrackNumber;
            newfile.Settings.MidiFileName = modest.MidiParser.MidiFileName;
              }

              newfile.Settings.MasterVolume = volume;

              // Modules
              // ---------------------------------------------------
              newfile.Settings.Generators = new List<VstModule>();

              if (modest.VstContainer.PluginManager.MasterPluginInstrument != null) {
            newfile.Settings.Generators.Add(
              new VstModule(modest.VstContainer.PluginManager.MasterPluginInstrument)
            );
              }
              // Generators
              // ---------------------------------------------------
              newfile.Settings.Modules = new List<VstModule>();

              if (modest.VstContainer.PluginManager.MasterPluginEffect != null) {
            newfile.Settings.Modules.Add(
              new VstModule(modest.VstContainer.PluginManager.MasterPluginEffect)
            );
              }

              // OLD MasterPluginInstrument
              // ---------------------------------------------------
              if (modest.VstContainer.PluginManager.MasterPluginInstrument != null) {
            newfile.Settings.Plugin = new Plugin(
              modest.VstContainer
                    .PluginManager.MasterPluginInstrument
            );
            newfile.Settings.Plugin.Path =
                    modest.VstContainer
                    .PluginManager.MasterPluginInstrument.PluginPath;
              }

              //
              // Bar
              // ---------------------------------------------------
              newfile.Settings.Bar = loop;
              // Automation
              // ---------------------------------------------------
              PulseValue bar = new PulseValue(modest.MidiParser.SmfFileHandle.Division * 4 * 4, DeltaType.Ticks);
              PulseValue measure = new PulseValue(bar.Value * 4, DeltaType.Ticks);

              newfile.Settings.AutoParams = new List<AutomationParam>();
              // one measure = 2:1:0
              // = 4bars = 4quarters*4 = (4*div)*4
              // incrementing per quarter note
              //    = 4 * 4 * 4 * value
              // or = value / 4 / 4 / 4
              // value is 0 - 1 (zero inclusive 64
              double m = 0.015625;
              int counter = 0;
              for (
                double i = 0;
                i < measure.Value;
                i += modest.MidiParser.SmfFileHandle.Division) {
            double d = i / modest.MidiParser.SmfFileHandle.Division;
            double v = counter * m;
            newfile.Settings.AutoParams.Add(AutomationParam.Create(i, DeltaType.Ticks, 0, v.ToSingle()));
            counter++;
              }

              // (string) ActiveInstrument
              // ---------------------------------------------------
              if (modest.VstContainer.PluginManager.MasterPluginInstrument != null)
            newfile.Settings.ActiveInstrument = modest
                    .VstContainer
                    .PluginManager.MasterPluginInstrument.Title;
              // (string) ActiveEffect
              // ---------------------------------------------------
              if (modest.VstContainer.PluginManager.MasterPluginEffect != null)
            newfile.Settings.ActiveEffect = modest.VstContainer
                    .PluginManager.MasterPluginEffect.Title;
              newfile.Save(newfile);
              // maybe we should have checked for errors.
              modest.VstContainer.RuntimeSettings = newfile;
        }
Пример #2
0
        public void TrySetProgram(MidiSmfFile newfile, VstPlugin plugin)
        {
            try {
            plugin.PluginCommandStub.BeginSetProgram();
            if (plugin.ActiveProgram == null) {
              plugin.ActiveProgram = new VstCCPgm(PluginManager.MasterPluginInstrument, 0);
            }
            plugin.PgmData = newfile.Settings.Plugin.ProgramDump;
            plugin.PluginCommandStub.EndSetProgram();

              } catch {
            MessageBox.Show("Error setting program", null, MessageBoxButtons.OK);
              }
        }