Пример #1
0
 private void HandleKitNumberChanged(object sender, TextChangedEventArgs e)
 {
     TextConversions.TryGetKitRoot(kitNumber.Text, schema, null, out var root);
     SelectedKit            = root;
     acceptButton.IsEnabled = root != null;
     kitName.Content        = root?.KitOnlyDescription.Format(root.Context, data);
 }
Пример #2
0
 protected override void SaveToStream(Stream stream)
 {
     if (!TextConversions.TryGetKitRoot(defaultKitNumber.Text, Schema, Logger, out var targetKitRoot))
     {
         MessageBox.Show("The default kit number is invalid; please correct before saving.", "Invalid kit number");
         return;
     }
     kit.DefaultKitNumber = targetKitRoot.KitNumber.Value;
     kit.Save(stream);
 }
        private Config TryCreateConfig()
        {
            if (inputDevice.SelectedIndex == -1)
            {
                return(null);
            }
            string deviceName = (string)inputDevice.Items[inputDevice.SelectedIndex];
            int?   deviceId   = AudioDevices.GetAudioInputDeviceId(deviceName);

            if (deviceId == null)
            {
                return(null);
            }
            int midiChannel = int.Parse(midiChannelSelector.Text);

            if (!TextConversions.TryParseDecimal(recordingTime.Text, out var recordingSeconds))
            {
                return(null);
            }
            TimeSpan recordingDuration = TimeSpan.FromSeconds((double)recordingSeconds);

            if (!TextConversions.TryGetKitRoot(kitNumber.Text, schema, logger, out var kit))
            {
                return(null);
            }
            if (outputFile == null)
            {
                return(null);
            }
            if (!TextConversions.TryParseInt32(userSamples.Text, out int parsedUserSamples))
            {
                return(null);
            }
            if (parsedUserSamples < 0 || parsedUserSamples > schema.UserSampleInstruments.Count)
            {
                return(null);
            }

            return(new Config
            {
                KitRoot = kit,
                RecordingDuration = recordingDuration,
                OutputFile = outputFile,
                AudioDeviceId = deviceId.Value,
                InstrumentGroup = instrumentGroupSelector.SelectedIndex - 1,
                UserSamples = parsedUserSamples,
                MidiChannel = midiChannel,
                Attack = (int)attackSlider.Value,
            });
        }
Пример #4
0
        protected override async void CopyToDevice(object sender, RoutedEventArgs e)
        {
            if (!TextConversions.TryGetKitRoot(copyToDeviceKitNumber.Text, Schema, Logger, out var targetKitRoot))
            {
                return;
            }

            // It's simplest to clone our root node into a new ModuleData at the right place,
            // then send all those segments. It does involve copying the data in memory
            // twice, but that's much quicker than sending it to the kit anyway.
            var clonedData = RootNode.Context.CloneData(Data, targetKitRoot.Context.Address);
            var segments   = clonedData.GetSegments();

            await CopySegmentsToDeviceAsync(segments);
        }