protected override async Task <int> InvokeAsync(InvocationContext context, IStandardStreamWriter console, RolandMidiClient client) { var schema = ModuleSchema.KnownSchemas[ModuleIdentifier.AE10].Value; var instrumentField = schema.PhysicalRoot.ResolveField("TemporaryStudioSet/Part[1]/Instrument"); var instrumentDataField = new EnumDataField((EnumField)instrumentField); var deviceController = new DeviceController(client, new ConsoleLogger(console)); var temporaryKitRoot = schema.LogicalRoot.ResolveNode("TemporaryStudioSet"); // First 100 presets client.SendData(0x01_00_00_05, new byte[] { 64 }); for (int i = 1; i <= 100; i++) { console.WriteLine($"Copying studio set {i}"); client.SendData(0x01_00_00_06, new byte[] { (byte)((i - 1) & 0x7f) }); await Task.Delay(40); var data = ModuleData.FromLogicalRootNode(temporaryKitRoot); await deviceController.LoadDescendants(data.LogicalRoot, null, progressHandler : null, cancellationToken : default); await deviceController.SaveDescendants(data.LogicalRoot, schema.GetKitRoot(i).Container.Address, progressHandler : null, cancellationToken : default); } return(0); }
protected override async Task <int> InvokeAsync(InvocationContext context, IStandardStreamWriter console, RolandMidiClient client) { var schema = ModuleSchema.KnownSchemas[ModuleIdentifier.AE10].Value; var instrumentField = schema.PhysicalRoot.ResolveField("TemporaryStudioSet/Part[1]/Instrument"); var instrumentDataField = new EnumDataField((EnumField)instrumentField); // Presets client.SendData(0x01_00_00_05, new byte[] { 64 }); for (int i = 1; i <= 128; i++) { await ShowStudioSet('P', i); } // Preset 129 is in a different bank... client.SendData(0x01_00_00_05, new byte[] { 65 }); for (int i = 129; i <= 129; i++) { await ShowStudioSet('P', i); } // User sets client.SendData(0x01_00_00_05, new byte[] { 0 }); for (int i = 1; i <= 100; i++) { await ShowStudioSet('U', i); } async Task ShowStudioSet(char prefix, int index) { client.SendData(0x01_00_00_06, new byte[] { (byte)((index - 1) & 0x7f) }); await Task.Delay(50); var common = await client.RequestDataAsync(0x18_00_00_00, 16, CancellationToken.None); string name = Encoding.UTF8.GetString(common); console.WriteLine($"{prefix}:{index:D3}: {name}"); for (int partIndex = 0; partIndex < 4; partIndex++) { var part = await client.RequestDataAsync(0x18_00_20_00 + partIndex * 0x1_00, 9, CancellationToken.None); if (part[1] != 1) { continue; } // The address doesn't matter, as only the offset is passed. var segment = new DataSegment(ModuleAddress.FromDisplayValue(0), part); instrumentDataField.Load(segment); console.WriteLine($"Part {partIndex + 1}: {instrumentDataField.Value}"); } console.WriteLine(); } return(0); }