mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 15:02:54 +08:00
Realtime editing of synth variables and outputs
This commit is contained in:
parent
bc14a1fd22
commit
1371c0390e
54
CodeWalker/Forms/RelForm.Designer.cs
generated
54
CodeWalker/Forms/RelForm.Designer.cs
generated
@ -29,10 +29,10 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
||||
System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RelForm));
|
||||
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
||||
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
|
||||
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||
this.RelPropertyGrid = new CodeWalker.WinForms.PropertyGridFix();
|
||||
this.MainTabControl = new System.Windows.Forms.TabControl();
|
||||
this.XmlTabPage = new System.Windows.Forms.TabPage();
|
||||
@ -48,6 +48,7 @@
|
||||
this.SearchButton = new System.Windows.Forms.Button();
|
||||
this.SearchResultsGrid = new CodeWalker.WinForms.PropertyGridFix();
|
||||
this.SynthsTabPage = new System.Windows.Forms.TabPage();
|
||||
this.SynthStopButton = new System.Windows.Forms.Button();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.SynthVariablesTextBox = new System.Windows.Forms.TextBox();
|
||||
@ -78,7 +79,6 @@
|
||||
this.wIPToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.OpenFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.SynthStopButton = new System.Windows.Forms.Button();
|
||||
this.MainTabControl.SuspendLayout();
|
||||
this.XmlTabPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.XmlTextBox)).BeginInit();
|
||||
@ -311,6 +311,18 @@
|
||||
this.SynthsTabPage.Text = "Synths";
|
||||
this.SynthsTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// SynthStopButton
|
||||
//
|
||||
this.SynthStopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.SynthStopButton.Enabled = false;
|
||||
this.SynthStopButton.Location = new System.Drawing.Point(724, 2);
|
||||
this.SynthStopButton.Name = "SynthStopButton";
|
||||
this.SynthStopButton.Size = new System.Drawing.Size(104, 23);
|
||||
this.SynthStopButton.TabIndex = 43;
|
||||
this.SynthStopButton.Text = "Stop";
|
||||
this.SynthStopButton.UseVisualStyleBackColor = true;
|
||||
this.SynthStopButton.Click += new System.EventHandler(this.SynthStopButton_Click);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
@ -336,6 +348,7 @@
|
||||
this.SynthVariablesTextBox.Name = "SynthVariablesTextBox";
|
||||
this.SynthVariablesTextBox.Size = new System.Drawing.Size(293, 87);
|
||||
this.SynthVariablesTextBox.TabIndex = 40;
|
||||
this.SynthVariablesTextBox.TextChanged += new System.EventHandler(this.SynthVariablesTextBox_TextChanged);
|
||||
//
|
||||
// SynthOutputsTextBox
|
||||
//
|
||||
@ -343,23 +356,24 @@
|
||||
this.SynthOutputsTextBox.Name = "SynthOutputsTextBox";
|
||||
this.SynthOutputsTextBox.Size = new System.Drawing.Size(293, 20);
|
||||
this.SynthOutputsTextBox.TabIndex = 39;
|
||||
this.SynthOutputsTextBox.TextChanged += new System.EventHandler(this.SynthOutputsTextBox_TextChanged);
|
||||
//
|
||||
// SynthBufferChart
|
||||
//
|
||||
this.SynthBufferChart.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
chartArea2.Name = "ChartArea1";
|
||||
this.SynthBufferChart.ChartAreas.Add(chartArea2);
|
||||
legend2.Name = "Legend1";
|
||||
this.SynthBufferChart.Legends.Add(legend2);
|
||||
chartArea1.Name = "ChartArea1";
|
||||
this.SynthBufferChart.ChartAreas.Add(chartArea1);
|
||||
legend1.Name = "Legend1";
|
||||
this.SynthBufferChart.Legends.Add(legend1);
|
||||
this.SynthBufferChart.Location = new System.Drawing.Point(363, 31);
|
||||
this.SynthBufferChart.Name = "SynthBufferChart";
|
||||
series2.ChartArea = "ChartArea1";
|
||||
series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
|
||||
series2.IsXValueIndexed = true;
|
||||
series2.Legend = "Legend1";
|
||||
series2.Name = "Buffer";
|
||||
this.SynthBufferChart.Series.Add(series2);
|
||||
series1.ChartArea = "ChartArea1";
|
||||
series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
|
||||
series1.IsXValueIndexed = true;
|
||||
series1.Legend = "Legend1";
|
||||
series1.Name = "Buffer";
|
||||
this.SynthBufferChart.Series.Add(series1);
|
||||
this.SynthBufferChart.Size = new System.Drawing.Size(460, 112);
|
||||
this.SynthBufferChart.TabIndex = 38;
|
||||
this.SynthBufferChart.Text = "chart1";
|
||||
@ -613,18 +627,6 @@
|
||||
//
|
||||
this.SaveFileDialog.Filter = "XML files|*.xml|All files|*.*";
|
||||
//
|
||||
// SynthStopButton
|
||||
//
|
||||
this.SynthStopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.SynthStopButton.Enabled = false;
|
||||
this.SynthStopButton.Location = new System.Drawing.Point(724, 2);
|
||||
this.SynthStopButton.Name = "SynthStopButton";
|
||||
this.SynthStopButton.Size = new System.Drawing.Size(104, 23);
|
||||
this.SynthStopButton.TabIndex = 43;
|
||||
this.SynthStopButton.Text = "Stop";
|
||||
this.SynthStopButton.UseVisualStyleBackColor = true;
|
||||
this.SynthStopButton.Click += new System.EventHandler(this.SynthStopButton_Click);
|
||||
//
|
||||
// RelForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -56,6 +56,9 @@ namespace CodeWalker.Forms
|
||||
public RpfFileEntry rpfFileEntry { get; private set; } = null;
|
||||
private MetaFormat metaFormat = MetaFormat.XML;
|
||||
|
||||
private bool loadingSynth = false;
|
||||
private Dat10Synth currentSynth = null;
|
||||
|
||||
|
||||
public RelForm(ExploreForm owner)
|
||||
{
|
||||
@ -414,7 +417,15 @@ namespace CodeWalker.Forms
|
||||
if (outputs.Length <= i)
|
||||
break;
|
||||
|
||||
outputsIndices[i] = byte.Parse(outputs[i].Substring(1));
|
||||
var output = "0";
|
||||
if (outputs[i].Length > 1)
|
||||
{
|
||||
output = outputs[i].Substring(1);
|
||||
}
|
||||
if (byte.TryParse(output, out byte ind))
|
||||
{
|
||||
outputsIndices[i] = ind;
|
||||
}
|
||||
}
|
||||
|
||||
return outputsIndices;
|
||||
@ -429,8 +440,8 @@ namespace CodeWalker.Forms
|
||||
var parts = variablesLines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
variables[i] = new Dat10SynthVariable
|
||||
{
|
||||
Name = XmlMeta.GetHash(parts[0]),
|
||||
Value = FloatUtil.Parse(parts[1]),
|
||||
Name = XmlMeta.GetHash((parts.Length > 0) ? parts[0] : ""),
|
||||
Value = FloatUtil.Parse((parts.Length > 1) ? parts[1] : ""),
|
||||
};
|
||||
}
|
||||
|
||||
@ -448,7 +459,7 @@ namespace CodeWalker.Forms
|
||||
if (error)
|
||||
return null;
|
||||
|
||||
return new Dat10Synth(CurrentFile)
|
||||
currentSynth = new Dat10Synth(CurrentFile)
|
||||
{
|
||||
BuffersCount = result.BuffersCount,
|
||||
RegistersCount = result.RegistersCount,
|
||||
@ -462,6 +473,8 @@ namespace CodeWalker.Forms
|
||||
Variables = variables,
|
||||
RuntimeCost = 123
|
||||
};
|
||||
|
||||
return currentSynth;
|
||||
}
|
||||
|
||||
|
||||
@ -648,6 +661,8 @@ namespace CodeWalker.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
loadingSynth = true;
|
||||
|
||||
SynthTextBox.Text = Dat10Synth.Disassemble(synth.Bytecode, synth.Constants, synth.Variables, false).Disassembly;
|
||||
SynthTextBox.ClearUndo();
|
||||
SynthAssemblySyntaxHighlight(SynthTextBox.Range);
|
||||
@ -657,6 +672,10 @@ namespace CodeWalker.Forms
|
||||
|
||||
SynthOutputsTextBox.Clear();
|
||||
SynthOutputsTextBox.Text = string.Join(" ", synth.OutputsIndices.Take(synth.OutputsCount).Select(bufferIdx => $"B{bufferIdx}"));
|
||||
|
||||
currentSynth = synth;
|
||||
|
||||
loadingSynth = false;
|
||||
}
|
||||
|
||||
private void SynthTextBox_TextChangedDelayed(object sender, TextChangedEventArgs e)
|
||||
@ -729,6 +748,7 @@ namespace CodeWalker.Forms
|
||||
{
|
||||
//for (int i = 0; i < buffersCopy.Length; i++)
|
||||
int i = synthesizer.Synth.OutputsIndices[0];
|
||||
if (i < SynthBufferChart.Series.Count)
|
||||
{
|
||||
var series = SynthBufferChart.Series[$"B{i}"];
|
||||
series.Points.Clear();
|
||||
@ -767,5 +787,23 @@ namespace CodeWalker.Forms
|
||||
if (synthesizer != null)
|
||||
synthesizer.Stop();
|
||||
}
|
||||
|
||||
private void SynthVariablesTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (loadingSynth) return;
|
||||
if (currentSynth == null) return;
|
||||
|
||||
currentSynth.Variables = ParseSynthVariables();
|
||||
|
||||
}
|
||||
|
||||
private void SynthOutputsTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (loadingSynth) return;
|
||||
if (currentSynth == null) return;
|
||||
|
||||
currentSynth.OutputsIndices = ParseSynthOutputs();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -91,7 +91,11 @@ namespace CodeWalker.Utils
|
||||
}
|
||||
|
||||
SynthesizeFrame();
|
||||
var audioDataStream = DataStream.Create(Buffers[Synth.OutputsIndices[0]], true, false);
|
||||
|
||||
var bufferIndex = Synth.OutputsIndices[0];
|
||||
if ((bufferIndex < 0) || (bufferIndex >= Buffers.Length)) bufferIndex = 0;
|
||||
|
||||
var audioDataStream = DataStream.Create(Buffers[bufferIndex], true, false);
|
||||
var audioBuffer = new AudioBuffer
|
||||
{
|
||||
Stream = audioDataStream,
|
||||
@ -694,7 +698,10 @@ namespace CodeWalker.Utils
|
||||
}
|
||||
break;
|
||||
case Dat10Synth.Opcode.READ_VARIABLE:
|
||||
SetRegister(param[0], Synth.Variables[param[1].Value & 0xFF].Value);
|
||||
if ((param[1].Value & 0xFF) < Synth.Variables.Length)
|
||||
{
|
||||
SetRegister(param[0], Synth.Variables[param[1].Value & 0xFF]?.Value ?? 0);
|
||||
}
|
||||
break;
|
||||
case Dat10Synth.Opcode.STOP:
|
||||
stop = GetScalar(param[0]) >= 1.0f;
|
||||
|
Loading…
Reference in New Issue
Block a user