void Update() { if (Input.GetKeyUp(KeyCode.Space)) { SfxrParams coinParams = new SfxrParams("0,,0.08,0.25,0.2193,0.5168,,,,,,0.3126,0.5738,,,,,,1,,,,,0.5"); //SfxrParams coinParams = new SfxrParams("0,,0.0736,0.4591,0.3858,0.5416,,,,,,0.5273,0.5732,,,,,,1,,,,,0.5"); coinParams.Mutate(0.1); _synth.CreateSound(coinParams, _blockSize); _synth.Play(); } else if (Input.GetKeyUp(KeyCode.Backspace)) { SfxrParams laserParams = new SfxrParams("0,,0.0359,,0.4491,0.2968,,0.2727,,,,,,0.0191,,0.5249,,,1,,,,,0.5"); laserParams.Mutate(0.15); _synth.CreateSound(laserParams, _blockSize); _synth.Play(); } else if (Input.GetKeyUp(KeyCode.Return)) { SfxrParams explosionParams = new SfxrParams("3,,0.3113,0.6514,0.0025,0.1876,,-0.363,,,,,,,,,,,1,,,,,0.5"); //explosionParams.Mutate(0.1); _synth.CreateSound(explosionParams, _blockSize); _synth.Play(); } }
public void OnStraightUpdate(object source, EventArgs args) { if (playing) { targetSynth.parameters.startFrequency = FrequencyManager.AllFreqs [(int)straightSequence [sequencePosition]]; targetSynth.Play(); sequencePosition++; if (sequencePosition > 7) { sequencePosition = 0; } } }
/// <summary> /// play one column of the grids /// </summary> private void PlayColumn(short xCell) { if ((Width * NumberOfGrids) % 2 == 0) { //play kick on root note if (xCell == 0) { Synthesizer.Kick(); } if (xCell == (float)(Width * NumberOfGrids) / 2) { Synthesizer.Snare(); } else { Synthesizer.Hat(); } } else { //play kick on root note if (xCell == 0 && Kick) { Synthesizer.Kick(); Kick = !Kick; Synthesizer.Hat(); } else if (xCell == 0) { Synthesizer.Snare(); Kick = !Kick; } else { Synthesizer.Hat(); } } //divide grids int z = 0; //determine grid while (xCell >= Width) { z++; xCell -= Width; } //play column if (Numeric) { short key = Numbers.Zero; for (short yCell = 0; yCell < Height; yCell++) { if (CellValues[z][xCell, yCell]) { key++; } } if (progressive) { Synthesizer.Play(key, 1, (short)ChordProgression[_CellularAutomata[0].Iterations % _CellularAutomata[0].Repeat]); } else { Synthesizer.Play(key, 1, 0); } } else { int i = Numbers.Zero; for (short yCell = 0; yCell < Height; yCell++) { if (CellValues[z][xCell, yCell]) { i++; } } for (short yCell = 0; yCell < Height; yCell++) { if (CellValues[z][xCell, yCell]) { if (progressive) { Synthesizer.Play((short)(Height - 1 - yCell), i, (short)ChordProgression[_CellularAutomata[0].Iterations % _CellularAutomata[0].Repeat]); } else { Synthesizer.Play((short)(Height - 1 - yCell), i, 0); } } } } //if ((xCell % Width == 0) || (xCell % ((double)Width / 2) == 0)) //s += xCell + ": Kick"; //Console.WriteLine(s); }
private Synthesizer synthesizer = null; // TODO(alexguirre): dispose synthesizer private void SynthPlayButton_Click(object sender, EventArgs e) { var newSynth = AssembleSynth(); if (newSynth == null) { StatusLabel.Text = "Failed to assemble synth"; } else { //#if !DEBUG try { //#endif if (synthesizer == null) { synthesizer = new Synthesizer(); synthesizer.Stopped += (t, _) => { BeginInvoke((Action)(() => { SynthPlayButton.Enabled = true; SynthStopButton.Enabled = false; })); }; synthesizer.FrameSynthesized += (t, _) => { float[][] buffersCopy = new float[synthesizer.Buffers.Length][]; for (int i = 0; i < buffersCopy.Length; i++) { buffersCopy[i] = new float[synthesizer.Buffers[i].Length]; Array.Copy(synthesizer.Buffers[i], buffersCopy[i], synthesizer.Buffers[i].Length); } BeginInvoke((Action)(() => { //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(); foreach (var v in buffersCopy[i]) { series.Points.AddY(v); } } })); }; } SynthBufferChart.Series.Clear(); for (int i = 0; i < newSynth.BuffersCount; i++) { var series = SynthBufferChart.Series.Add($"B{i}"); series.IsXValueIndexed = true; series.ChartType = SeriesChartType.FastLine; } SynthPlayButton.Enabled = false; SynthStopButton.Enabled = true; synthesizer.Play(newSynth); //#if !DEBUG } catch (Exception ex) { SynthPlayButton.Enabled = true; SynthStopButton.Enabled = false; StatusLabel.Text = $"Synthesizer error: {ex}"; } //#endif } }