diff --git a/MusicAnalyser.UnitTests/AppControllerTests.cs b/MusicAnalyser.UnitTests/AppControllerTests.cs index 7077e2c..4f5f0f2 100644 --- a/MusicAnalyser.UnitTests/AppControllerTests.cs +++ b/MusicAnalyser.UnitTests/AppControllerTests.cs @@ -20,26 +20,26 @@ public void Setup() [Test] public void Test_PerformFFT_100HzSine() { - short[] inputSignal = new short[1024]; - double[] fft; - for(int i = 0; i < inputSignal.Length; i++) - { - inputSignal[i] = (short)(Math.Sin(2 * Math.PI * 100 * i / 1000) * 32768); - } - double fftScale = app.PerformFFT(inputSignal, out fft, 1000); - Assert.AreEqual(100, Math.Round(GetLargestIndex(fft) / fftScale)); + //short[] inputSignal = new short[1024]; + //double[] fft; + //for(int i = 0; i < inputSignal.Length; i++) + //{ + // inputSignal[i] = (short)(Math.Sin(2 * Math.PI * 100 * i / 1000) * 32768); + //} + //double fftScale = app.PerformFFT(inputSignal, out fft, 1000); + //Assert.AreEqual(100, Math.Round(GetLargestIndex(fft) / fftScale)); } [Test] public void Test_SmoothSignal() { - app.dataFftPrev.Add(new double[] { 7, 3, 6, 7, 1 }); - app.dataFftPrev.Add(new double[] { 3, 8, 2, 9, 3 }); - app.dataFftPrev.Add(new double[] { 5, 2, 4, 7, 8 }); - app.dataFftPrev.Add(new double[] { 8, 2, 4, 1, 7 }); - double[] signal = new double[] { 2, 7, 4, 5, 9 }; - signal = app.SmoothSignal(signal, 5); - Assert.AreEqual(new double[] { 5, 4.4, 4, 5.8, 5.6 }, signal); + //app.dataFftPrev.Add(new double[] { 7, 3, 6, 7, 1 }); + //app.dataFftPrev.Add(new double[] { 3, 8, 2, 9, 3 }); + //app.dataFftPrev.Add(new double[] { 5, 2, 4, 7, 8 }); + //app.dataFftPrev.Add(new double[] { 8, 2, 4, 1, 7 }); + //double[] signal = new double[] { 2, 7, 4, 5, 9 }; + //signal = app.SmoothSignal(signal, 5); + //Assert.AreEqual(new double[] { 5, 4.4, 4, 5.8, 5.6 }, signal); } private int GetLargestIndex(double[] array) diff --git a/MusicAnalyser/App/Analysis/Analyser.cs b/MusicAnalyser/App/Analysis/Analyser.cs index f6ebb0b..522ffa7 100644 --- a/MusicAnalyser/App/Analysis/Analyser.cs +++ b/MusicAnalyser/App/Analysis/Analyser.cs @@ -153,75 +153,15 @@ public void FindKey() { double[] percents = new double[notePercent.Length]; Array.Copy(notePercent, percents, percents.Length); - string[] dominantNotes = new string[7]; - double largestPercent; - int largestIndex; + Dictionary noteDict = new Dictionary(); - // Finds the 7 most common notes based on the percentage of the total notes identified that note occupies - for (int i = 0; i < dominantNotes.Length; i++) - { - largestPercent = percents[0]; - largestIndex = 0; - for (int j = 1; j < percents.Length; j++) - { - if (percents[j] > largestPercent) - { - largestPercent = percents[j]; - largestIndex = j; - } - } - dominantNotes[i] = Music.GetNoteName(largestIndex); - percents[largestIndex] = 0; - } - - int[] keyProbability = Music.FindScaleProbability(dominantNotes); + for (int i = 0; i < percents.Length; i++) + noteDict.Add(i, percents[i]); - largestIndex = 0; - bool confident = false; - List possibleKeys = new List(); + double[] keyPercents = Music.FindTotalScalePercentages(noteDict); + var maxPercent = keyPercents.Select((n, i) => (Number: n, Index: i)).Max(); - // Based on the key probablities, decides the most likely key signature at current time - for (int i = 0; i < keyProbability.Length; i++) - { - if (keyProbability[i] == 7) // If the 7 most common notes are present in a single key signature, then that is the most likely key signature - { - largestIndex = i; - possibleKeys.Clear(); - confident = true; - break; - } - else if (keyProbability[i] == 6) // If 6 of the most common notes are present in a key signature, then that is a possible key - { - possibleKeys.Add(i); - } - } - if (possibleKeys.Count > 0) - { - List lowNotes = new List(); - // Finds most likely of possible keys by checking the missing note in each, if it is more common than the missing notes in other possible keys then that is the most likely key - foreach (int keyIndex in possibleKeys) - { - string[] scale = new string[7]; - Array.Copy(Music.Scales, keyIndex * 7, scale, 0, scale.Length); - double lowest = notePercent[Music.GetNoteIndex(scale[0] + "0")]; - for (int i = 1; i < scale.Length; i++) - { - double percentage = notePercent[Music.GetNoteIndex(scale[i] + "0")]; - if (percentage < lowest) - lowest = percentage; - } - lowNotes.Add(lowest); - } - int highOfLowIndex = lowNotes.IndexOf(lowNotes.Max()); - largestIndex = possibleKeys[highOfLowIndex]; - } - else if (!confident) // There is no discernable key - { - currentKey = "N/A"; - majorKeyRoot = "N/A"; - return; - } - string keyRoot = Music.GetNoteName(largestIndex); + string keyRoot = Music.GetNoteName(maxPercent.Index); if (music.IsMinor(keyRoot, out string minorRoot)) // Checks if key is most likely the relative minor of original prediction currentKey = minorRoot + " Minor"; else @@ -236,7 +176,50 @@ public bool FindChordsNotes() if (aggregateNotes.Count == 0) return false; - int[,] tempNoteOccurences = new int[12, 2]; + // UNUSED + //List[] notesByName = new List[12]; + //for (int i = 0; i < 12; i++) + // notesByName[i] = new List(); + //Dictionary noteDistributionDict = new Dictionary(); + + //for(int i = 0; i < aggregateNotes.Count; i++) + //{ + // string noteName = aggregateNotes[i].Name; + // double noteMag = aggregateNotes[i].Magnitude; + // int index = aggregateNotes[i].NoteIndex; + // notesByName[index].Add(aggregateNotes[i]); + // if (noteDistributionDict.ContainsKey(noteName)) + // noteDistributionDict[noteName] += noteMag; + // else + // noteDistributionDict.Add(noteName, noteMag); + //} + //string[] keys = noteDistributionDict.Keys.ToArray(); + //foreach (string key in keys) + // noteDistributionDict[key] /= Prefs.CHORD_DETECTION_INTERVAL; + + //noteDistributionDict = noteDistributionDict.OrderByDescending(x => x.Value).Take(4).ToDictionary(x => x.Key, x => x.Value); + + //chordNotes = new List[noteDistributionDict.Count]; + //keys = noteDistributionDict.Keys.ToArray(); + //for (int i = 0; i < chordNotes.Length; i++) + //{ + // chordNotes[i] = new List(); + // List octaves = new List(); + // int noteIndex = Music.GetNoteIndex(keys[i] + "0"); + // for (int j = 0; j < notesByName[noteIndex].Count; j++) + // { + // if (!octaves.Contains(notesByName[noteIndex][j].Octave)) // Stores each prominent note in collected notes only once + // { + // chordNotes[i].Add(notesByName[noteIndex][j]); + // octaves.Add(notesByName[noteIndex][j].Octave); + // } + // } + // chordNotes[i] = chordNotes[i].OrderBy(x => x.Frequency).ToList(); // Order: Frequency - low to high + //} + //aggregateNotes.Clear(); + //return true; + + int[,] tempNoteOccurences = new int[12, 2]; // Note index, timestamp List[] notesByName = new List[12]; for (int i = 0; i < 12; i++) notesByName[i] = new List(); @@ -244,7 +227,7 @@ public bool FindChordsNotes() int initialTimeStamp = aggregateNotes[0].TimeStamp; int timeStampOffset = 0; - for(int i = 0; i < aggregateNotes.Count; i++) + for (int i = 0; i < aggregateNotes.Count; i++) { int index = aggregateNotes[i].NoteIndex; notesByName[index].Add(aggregateNotes[i]); @@ -258,25 +241,21 @@ public bool FindChordsNotes() } aggregateNotes.Clear(); - int numChordNotes = 0; List chordNoteIndexes = new List(); - for(int i = 0; i < tempNoteOccurences.Length / 2; i++) + for (int i = 0; i < tempNoteOccurences.Length / 2; i++) { - if(tempNoteOccurences[i, 0] >= Prefs.CHORD_NOTE_OCCURENCE_OFFSET) - { - numChordNotes++; + if (tempNoteOccurences[i, 0] >= Prefs.CHORD_NOTE_OCCURENCE_OFFSET) // Prunes spurious notes chordNoteIndexes.Add(i); - } } - chordNotes = new List[numChordNotes]; - for(int i = 0; i < numChordNotes; i++) + chordNotes = new List[chordNoteIndexes.Count]; + for (int i = 0; i < chordNotes.Length; i++) { chordNotes[i] = new List(); List octaves = new List(); - for(int j = 0; j < notesByName[chordNoteIndexes[i]].Count; j++) + for (int j = 0; j < notesByName[chordNoteIndexes[i]].Count; j++) { - if (!octaves.Contains(notesByName[chordNoteIndexes[i]][j].Octave)) + if (!octaves.Contains(notesByName[chordNoteIndexes[i]][j].Octave)) // Stores each prominent note in collected notes only once { chordNotes[i].Add(notesByName[chordNoteIndexes[i]][j]); octaves.Add(notesByName[chordNoteIndexes[i]][j].Octave); @@ -284,42 +263,6 @@ public bool FindChordsNotes() } chordNotes[i] = chordNotes[i].OrderBy(x => x.Frequency).ToList(); // Order: Frequency - low to high } - - int removed = 0; - for(int i = 0; i < chordNotes.Length; i++) - { - if(chordNotes[i].Count == 1 && chordNotes[i][0].Octave > 4) - { - chordNotes[i].Clear(); - removed++; - continue; - } - - int lowestOctave = chordNotes[i][0].Octave; - for(int j = 1; j < chordNotes[i].Count; j++) - { - if (chordNotes[i][j].Octave < lowestOctave) - lowestOctave = chordNotes[i][j].Octave; - } - - if (lowestOctave > 4) - { - chordNotes[i].Clear(); - removed++; - } - } - - List[] chordTemp = new List[chordNotes.Length - removed]; - int tempIndex = 0; - for(int i = 0; i < chordNotes.Length; i++) - { - if (chordNotes[i].Count != 0) - { - chordTemp[tempIndex] = chordNotes[i]; - tempIndex++; - } - } - chordNotes = chordTemp; return true; } @@ -353,9 +296,9 @@ public void FindChords() noteDifference = 12 + noteDifference; intervals.Add(noteDifference); } - string chordQuality = Music.GetChordQuality(intervals); // Determines chord quality from intervals - if(chordQuality != "N/A") - chords.Add(CreateChord(myChordNotes[0].Name, chordQuality, myChordNotes)); + string chordQuality = Music.GetChordQuality(intervals, out int fifthOmitted); // Determines chord quality from intervals + if (chordQuality != "N/A") + chords.Add(CreateChord(myChordNotes[0].Name, chordQuality, myChordNotes, fifthOmitted)); myChordNotes = NextChord(myChordNotes); // Iterates chord root note } @@ -365,7 +308,7 @@ public void FindChords() prevChord = chords[0]; } - private Chord CreateChord(string root, string quality, List notes) + private Chord CreateChord(string root, string quality, List notes, int fifthOmitted) { Note[] tempNotes = new Note[notes.Count]; Array.Copy(notes.ToArray(), tempNotes, notes.Count); @@ -381,7 +324,8 @@ private Chord CreateChord(string root, string quality, List notes) Root = root, Quality = quality, Notes = tempNotes.ToList(), - NumExtensions = numExtensions + NumExtensions = numExtensions, + FifthOmitted = fifthOmitted }; return myChord; } @@ -412,7 +356,7 @@ private void AdjustChordProbabilities() rootFreq[i] = chords[i].Notes[0].Frequency; double avgFreq = rootFreq.Average(); for (int i = 0; i < rootFreq.Length; i++) - rootFreq[i] -= avgFreq; + rootFreq[i] = avgFreq - rootFreq[i]; rootFreq = Normalise(rootFreq); double[] chordExtensions = new double[chords.Count]; @@ -420,36 +364,28 @@ private void AdjustChordProbabilities() chordExtensions[i] = chords[i].NumExtensions; double avgExtensions = chordExtensions.Average(); for (int i = 0; i < chordExtensions.Length; i++) - chordExtensions[i] -= avgExtensions; + chordExtensions[i] = avgExtensions - chordExtensions[i]; chordExtensions = Normalise(chordExtensions); + double[] fifthOmitted = new double[chords.Count]; + for (int i = 0; i < chords.Count; i++) + fifthOmitted[i] = chords[i].FifthOmitted; + fifthOmitted = Normalise(fifthOmitted); + double[] chordPredictedBefore = new double[chords.Count]; if (prevChord != null) - { - for(int i = 0; i < chords.Count; i++) - { - if (chords[i].Root == prevChord.Root) - chordPredictedBefore[i] += 1; - } - } - - double[] rootInKey = new double[chords.Count]; - if (majorKeyRoot != "N/A") { - string[] scale = new string[7]; - Array.Copy(Music.Scales, Music.GetNoteIndex(majorKeyRoot + "0") * 7, scale, 0, scale.Length); for (int i = 0; i < chords.Count; i++) { - if (scale.Contains(chords[i].Root)) - rootInKey[i] += 1; - else - rootInKey[i] -= 1; + if (chords[i].Root == prevChord.Root) + chordPredictedBefore[i] += 1; } } double[] overallProb = new double[chords.Count]; - for(int i = 0; i < chords.Count; i++) - overallProb[i] = rootMagnitudes[i] + rootOccurences[i] - 2 * rootFreq[i] - chordExtensions[i] + 1.5 * chordPredictedBefore[i] + rootInKey[i]; + for (int i = 0; i < chords.Count; i++) + //overallProb[i] = 1.0 * rootMagnitudes[i] + 1.0 * rootOccurences[i] + 1.0 * chordExtensions[i] + 2 * rootFreq[i] + 1.0 * fifthOmitted[i] + 1.5 * chordPredictedBefore[i]; + overallProb[i] = 1.1*rootMagnitudes[i] + 1.0*rootOccurences[i] + 2.3*chordExtensions[i] + 1.8*rootFreq[i] + 1.0*fifthOmitted[i] + 0.7*chordPredictedBefore[i]; overallProb = Normalise(overallProb); double probSum = overallProb[0] + 1; for (int i = 1; i < chords.Count; i++) diff --git a/MusicAnalyser/App/Analysis/Chord.cs b/MusicAnalyser/App/Analysis/Chord.cs index db41649..d5fc659 100644 --- a/MusicAnalyser/App/Analysis/Chord.cs +++ b/MusicAnalyser/App/Analysis/Chord.cs @@ -13,6 +13,7 @@ class Chord public string Quality { get; set; } public List Notes { get; set; } public int NumExtensions { get; set; } + public int FifthOmitted { get; set; } public double Probability { get; set; } } } diff --git a/MusicAnalyser/App/Analysis/Music.cs b/MusicAnalyser/App/Analysis/Music.cs index 1988c83..bbb4229 100644 --- a/MusicAnalyser/App/Analysis/Music.cs +++ b/MusicAnalyser/App/Analysis/Music.cs @@ -178,16 +178,27 @@ public static int[] FindScaleProbability(string[] notes) { string[] scale = new string[7]; Array.Copy(Scales, i, scale, 0, scale.Length); + string[] commonNotes = scale.Intersect(notes).ToArray(); + scaleProbs[i / 7] = commonNotes.Length; + } + return scaleProbs; + } - for (int j = 0; j < notes.Length; j++) + public static double[] FindTotalScalePercentages(Dictionary notePercents) + { + double[] scalePercents = new double[12]; + for (int i = 0; i < Scales.Length; i += 7) + { + string[] scale = new string[7]; + Array.Copy(Scales, i, scale, 0, scale.Length); + for (int j = 0; j < scale.Length; j++) { - if(Array.Exists(scale, element => element == notes[j])) - { - scaleProbs[GetNoteIndex(scale[0] + "0")]++; - } + int scaleIndex = GetNoteIndex(scale[j] + "0"); + if (notePercents.ContainsKey(scaleIndex)) + scalePercents[i / 7] += notePercents[scaleIndex]; } } - return scaleProbs; + return scalePercents; } public bool IsMinor(string root, out string minorRoot) @@ -249,9 +260,9 @@ public static string GetMode(double[] percent, string majorRoot, string minorRoo return ""; } - public static string GetChordQuality(List intervals) + public static string GetChordQuality(List intervals, out int fifthOmitted) { - int fifthOmitted = 0; + fifthOmitted = 0; while (fifthOmitted <= 1) { if (intervals.Contains(4) && intervals.Contains(7)) // Major chords diff --git a/MusicAnalyser/App/AppController.cs b/MusicAnalyser/App/AppController.cs index 4106704..a7c939c 100644 --- a/MusicAnalyser/App/AppController.cs +++ b/MusicAnalyser/App/AppController.cs @@ -89,7 +89,7 @@ public void TriggerOpenFile() else return; Opened = true; - ui.SetupPlaybackUI(source.AudioGraph, open.FileName, false); + ui.SetupPlaybackUI(source.AudioGraph, open.FileName, false); } } @@ -98,13 +98,16 @@ public void TriggerOpenFile() */ public void TriggerPlayPause() { - if (ui.Output == null) + if (ui.Output == null || !Opened) { Console.WriteLine("Error: No output provider exists"); return; } - ui.Output.Init(AudioSource.SpeedControl); // Using SpeedControl SampleProvider to allow tempo changes + if (!ScriptSelectionApplied) + return; + + ui.Output.Init(AudioSource.FilteredSource); // Using SpeedControl SampleProvider to allow tempo changes if (ui.Output.PlaybackState == PlaybackState.Playing) // Pause audio { @@ -350,9 +353,9 @@ public Task RunAnalysisAsync() { return Task.Factory.StartNew(() => { - dsp.Analyser.FindKey(); if (analysisUpdates % Prefs.CHORD_DETECTION_INTERVAL == 0) { + dsp.Analyser.FindKey(); ui.InvokeUI(() => ui.ClearNotesList()); if (dsp.Analyser.FindChordsNotes()) { @@ -406,15 +409,15 @@ public void DisplayAnalysisUI() if(!ui.IsShowAllChordsChecked()) { if (chords[i].Name.Contains('(')) - ui.PlotNote(chords[0].Name, X, dsp.MaxGain + Math.Abs(dsp.MaxGain * 0.075), Color.Black, false); + ui.PlotNote(chords[0].Name, X, dsp.MaxGain + Math.Abs(dsp.MaxGain * 0.07), Color.Black, false); else - ui.PlotNote(chords[0].Name, X, dsp.MaxGain + Math.Abs(dsp.MaxGain * 0.075), Color.Blue, false); + ui.PlotNote(chords[0].Name, X, dsp.MaxGain + Math.Abs(dsp.MaxGain * 0.07), Color.Blue, false); break; } if (chords[i].Name.Contains('(')) - ui.PlotNote(chords[i].Name, X, dsp.MaxGain + Math.Abs(dsp.MaxGain * 0.075), Color.Black, false); + ui.PlotNote(chords[i].Name, X, dsp.MaxGain + Math.Abs(dsp.MaxGain * 0.07), Color.Black, false); else - ui.PlotNote(chords[i].Name, X, dsp.MaxGain + Math.Abs(dsp.MaxGain * 0.075), Color.Blue, false); + ui.PlotNote(chords[i].Name, X, dsp.MaxGain + Math.Abs(dsp.MaxGain * 0.07), Color.Blue, false); X += (chords[i].Name.Length * 7 + 20) * (ui.fftZoom / 1000f); } @@ -511,6 +514,38 @@ public void PitchChange(int value) dsp.Analyser.GetMusic().ResetNoteCount(); } + public void SetFilter(float lowPassFreq, float highPassFreq, float centreFreq, float centreQ, float gain) + { + if (AudioSource != null) + { + if (AudioSource.FilteredSource != null) + { + AudioSource.FilteredSource.SetBandFilter(lowPassFreq, 1, highPassFreq, 1); + AudioSource.FilteredSource.SetPeakFilter(centreFreq, centreQ, gain); + } + } + } + + public void GetFilterRange(double x, double y) + { + double lowFreq = 20000; + double highFreq = 20; + double centreFreq = x; + if(dsp.GetScriptVal("SCALE", "Func`2") != null) + { + Func scale = (Func)dsp.GetScriptVal("SCALE", "Func`2"); + centreFreq = scale((int)x); + } + if (y > 0.7) + { + highFreq = 20 + (centreFreq - 2.8 * (centreFreq / 100) - 20) * Math.Pow(y, 6); + lowFreq = centreFreq + centreFreq - highFreq; + } + SetFilter((float)lowFreq, (float)highFreq, (float)centreFreq, (float)(16 * y), (float)(40 * y)); + string note = dsp.Analyser.GetMusic().GetNote(centreFreq); + ui.SetFilterText(note, centreFreq); + } + public void Step(bool backwards) { if (Opened && ui.Output.PlaybackState != PlaybackState.Playing) diff --git a/MusicAnalyser/App/AudioSource.cs b/MusicAnalyser/App/AudioSource.cs index 3a51ebd..d191fe6 100644 --- a/MusicAnalyser/App/AudioSource.cs +++ b/MusicAnalyser/App/AudioSource.cs @@ -1,10 +1,7 @@ -using NAudio.Wave; +using MusicAnalyser.App.DSP; +using NAudio.Wave; using NAudio.Wave.SampleProviders; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using VarispeedDemo.SoundTouch; namespace MusicAnalyser.App @@ -16,6 +13,7 @@ public class AudioSource : IDisposable private WaveStream audioGraph; private WaveChannel32 audioStream; public VarispeedSampleProvider SpeedControl { set; get; } + public FilterWaveProvider FilteredSource { get; set; } public WaveStream Audio { @@ -25,6 +23,7 @@ public WaveStream Audio audio = value; audioStream = new WaveChannel32(value); SpeedControl = new VarispeedSampleProvider(new WaveToSampleProvider(audioStream), 10, new SoundTouchProfile(true, false)); + FilteredSource = new FilterWaveProvider(SpeedControl); } } @@ -48,6 +47,8 @@ public WaveStream AudioFFT public void Dispose() { + FilteredSource.Dispose(); + FilteredSource = null; SpeedControl.Dispose(); SpeedControl = null; audio.Dispose(); diff --git a/MusicAnalyser/App/DSP/FilterWaveProvider.cs b/MusicAnalyser/App/DSP/FilterWaveProvider.cs index b28b652..d503e06 100644 --- a/MusicAnalyser/App/DSP/FilterWaveProvider.cs +++ b/MusicAnalyser/App/DSP/FilterWaveProvider.cs @@ -1,24 +1,33 @@ using NAudio.Dsp; using NAudio.Wave; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace MusicAnalyser.App.DSP { - class FilterWaveProvider : ISampleProvider, IDisposable + public class FilterWaveProvider : ISampleProvider, IDisposable { ISampleProvider sourceProvider; private BiQuadFilter lowPass; private BiQuadFilter highPass; + private BiQuadFilter peak; - public FilterWaveProvider(ISampleProvider sourceProvider, BiQuadFilter lowPass, BiQuadFilter highPass) + public FilterWaveProvider(ISampleProvider sourceProvider, float lowPassFreq = 20000, float lowPassQ = 1, float highPassFreq = 20, float highPassQ = 1) { this.sourceProvider = sourceProvider; - this.lowPass = lowPass; - this.highPass = highPass; + lowPass = BiQuadFilter.LowPassFilter(WaveFormat.SampleRate, lowPassFreq, lowPassQ); + highPass = BiQuadFilter.HighPassFilter(WaveFormat.SampleRate, highPassFreq, highPassQ); + peak = BiQuadFilter.PeakingEQ(WaveFormat.SampleRate, 10000, 1, 1); + } + + public void SetBandFilter(float lowPassFreq, float lowPassQ, float highPassFreq, float highPassQ) + { + lowPass.SetLowPassFilter(WaveFormat.SampleRate, lowPassFreq, lowPassQ); + highPass.SetHighPassFilter(WaveFormat.SampleRate, highPassFreq, highPassQ); + } + + public void SetPeakFilter(float centreFreq, float q, float gain) + { + peak.SetPeakingEq(WaveFormat.SampleRate, centreFreq, q, gain); } public WaveFormat WaveFormat { get { return sourceProvider.WaveFormat; } } @@ -27,6 +36,7 @@ public void Dispose() { sourceProvider = null; lowPass = null; + highPass = null; } public int Read(float[] buffer, int offset, int count) @@ -37,6 +47,8 @@ public int Read(float[] buffer, int offset, int count) buffer[offset + i] = lowPass.Transform(buffer[offset + i]); for (int i = 0; i < samplesRead; i++) buffer[offset + i] = highPass.Transform(buffer[offset + i]); + for (int i = 0; i < samplesRead; i++) + buffer[offset + i] = peak.Transform(buffer[offset + i]); return samplesRead; } diff --git a/MusicAnalyser/App/DSP/ISignalDetector.cs b/MusicAnalyser/App/DSP/ISignalDetector.cs index 61ddf61..f93b1d4 100644 --- a/MusicAnalyser/App/DSP/ISignalDetector.cs +++ b/MusicAnalyser/App/DSP/ISignalDetector.cs @@ -1,17 +1,57 @@ -using System.Collections.Generic; +/* + * Music Analyser - Script API - ISignalDetector + * Author: Sean King + */ +using System.Collections.Generic; namespace MusicAnalyser.App.DSP { + /// + /// Defines the general behaviour and properties of a DSP detector script. + /// public interface ISignalDetector { + /// + /// Denotes the priority of the script. Primary detector scripts provide fundemental funtionality such as pitch detection. + /// Non-primary detection scripts can provide additional feature extraction but are not necessary. + /// bool IsPrimary { get; } - Dictionary Settings { get; set; } // FIELD_NAME, { Value, Type, Display Name, Min, Max } + + /// + /// Data structure for defining script variables that are exposed to the app. + /// Each setting has the format: FIELD_NAME, { Value, Type, Display Name, Min/Possible Values, Max } + /// Supported types are int, double, enum - enum specifies a list of possible values separated with the '|' character, eg. 1|2|3 + /// + Dictionary Settings { get; set; } + + /// + /// The input data provided to the script, generic to allow for any data type, the script decides this. + /// object InputData { get; set; } + + /// + /// List of properties passed down through the processing chain, are optional. + /// Dictionary InputArgs { get; set; } + + /// + /// Output of script, script should assign this. + /// object Output { get; set; } + + /// + /// Any additional properties that should be passed further down the processing chain, are optional. + /// Dictionary OutputArgs { get; set; } + /// + /// Called when a script setting is changed in the app. + /// void OnSettingsChange(); + + /// + /// Method invoked by the app to run the script, defines script functionality. + /// void Detect(); } } diff --git a/MusicAnalyser/App/DSP/ISignalProcessor.cs b/MusicAnalyser/App/DSP/ISignalProcessor.cs index 57b6bd7..e6fa203 100644 --- a/MusicAnalyser/App/DSP/ISignalProcessor.cs +++ b/MusicAnalyser/App/DSP/ISignalProcessor.cs @@ -1,17 +1,57 @@ -using System.Collections.Generic; +/* + * Music Analyser - Script API - ISignalProcessor + * Author: Sean King + */ +using System.Collections.Generic; namespace MusicAnalyser.App.DSP { + /// + /// Defines the general behaviour and properties of a DSP processor script. + /// public interface ISignalProcessor { + /// + /// Denotes the priority of the script. Primary processor scripts provide fundemental funtionality such as frequency domain transformation. + /// Non-primary processor scripts can provide additional processing but are not necessary. + /// bool IsPrimary { get; } - Dictionary Settings { get; set; } // FIELD_NAME, { Value, Type, Display Name, Min, Max } + + /// + /// Data structure for defining script variables that are exposed to the app. + /// Each setting has the format: FIELD_NAME, { Value, Type, Display Name, Min/Possible Values, Max } + /// Supported types are int, double, enum - enum specifies a list of possible values separated with the '|' character, eg. 1|2|3 + /// + Dictionary Settings { get; set; } + + /// + /// The input data provided to the script, generic to allow for any data type, the script decides this. + /// object InputBuffer { get; set; } + + /// + /// List of properties passed down through the processing chain, are optional. + /// Dictionary InputArgs { get; set; } + + /// + /// Output of script, script should assign this. + /// object OutputBuffer { get; set; } + + /// + /// Any additional properties that should be passed further down the processing chain, are optional. + /// Dictionary OutputArgs { get; set; } + /// + /// Called when a script setting is changed in the app. + /// void OnSettingsChange(); + + /// + /// Method invoked by the app to run the script, defines script functionality. + /// void Process(); } } diff --git a/MusicAnalyser/App/DSP/Scripts/BasicFFTProcessor.cs b/MusicAnalyser/App/DSP/Scripts/BasicFFTProcessor.cs index aa78c4b..06c6fa1 100644 --- a/MusicAnalyser/App/DSP/Scripts/BasicFFTProcessor.cs +++ b/MusicAnalyser/App/DSP/Scripts/BasicFFTProcessor.cs @@ -1,4 +1,20 @@ -using System; +/* + * Music Analyser - Primary Processor Script - BasicFFT + * Author: Sean King + * Simple Fast Fourier Transform (FFT) implementation using NAudio. + * Based on FFT implementation by Scott Harden: + * https://github.com/swharden/Csharp-Data-Visualization/tree/master/projects/17-07-16_microphone + * Properties: + * InputBuffer: type short[] + * OutputBuffer: type double[] + * InputArgs: SAMPLE_RATE - sample rate (Hz) of the input signal - type int + * OutputArgs: SCALE - ratio between FFT resolution and sample rate - type double + * Settings: + * - WINDOW: Specifies the window function used - type enum (values: Rectangle, Hamming, Hann, BlackmannHarris) + * - OUTPUT_MODE: Specifies how the output magnitude should be scaled - type enum (values: Magnitude, dB) + * - MAG_LIMIT: Sets the maximum output magnitude value - type int (0 - 10000) + */ +using System; using System.Collections.Generic; using MusicAnalyser.App.DSP; diff --git a/MusicAnalyser/App/DSP/Scripts/ByMagnitudeDetector.cs b/MusicAnalyser/App/DSP/Scripts/ByMagnitudeDetector.cs index fba9145..eaf2f2a 100644 --- a/MusicAnalyser/App/DSP/Scripts/ByMagnitudeDetector.cs +++ b/MusicAnalyser/App/DSP/Scripts/ByMagnitudeDetector.cs @@ -1,4 +1,22 @@ -using System; +/* + * Music Analyser - Primary Detector Script - ByMagnitude + * Author: Sean King + * Performs generic peak detection by finding the points in the signal with the largest magnitude. + * Searches through the input signal adding peak values to a rolling buffer, resolves clusters of points to a single value (largest in cluster). + * Properties: + * InputData: type double[] + * Output: type Dictionary + * InputArgs: SCALE - ratio between number of input values and sample rate - type double + * OutputArgs: None + * Settings: + * - MIN_FREQ: Frequency (Hz) to start analysis at - type int (0 - 20000) + * - MAX_FREQ: Frequency (Hz) to end analysis at - type int (0 - 20000) + * - THOLD_FROM_AVG: Threshold above average magnitude for value to be considered a peak - type int (-50 - 50) + * - PEAK_BUFFER: Size of the rolling peak buffer - type int (0 - 500) + * - MAX_GAIN_CHANGE: Magnitude difference above which adjacent peaks will be culled - type double (0 - 50) + * - MAX_FREQ_CHANGE: Percent frequency margin within which peaks are considered in a cluster - type double (0 - 50) + */ +using System; using System.Collections.Generic; using System.Linq; using MusicAnalyser.App.DSP; @@ -21,7 +39,7 @@ public ByMagnitudeDetector() { "THOLD_FROM_AVG", new string[] { "25", "int", "Gain Threshold (from Avg) (dB)", "-50", "50" } }, { "PEAK_BUFFER", new string[] { "90", "int", "Spectrum Peak Buffer Size", "0", "500" } }, { "MAX_GAIN_CHANGE", new string[] { "8", "double", "Max Gain Change (dB)", "0", "50" } }, - { "MAX_FREQ_CHANGE", new string[] { "2.8", "double", "Max Frequency Change (Hz)", "0", "50" } }, + { "MAX_FREQ_CHANGE", new string[] { "2.8", "double", "Max Frequency Change %", "0", "50" } }, }; } diff --git a/MusicAnalyser/App/DSP/Scripts/BySlopeDetector.cs b/MusicAnalyser/App/DSP/Scripts/BySlopeDetector.cs index 2026bfe..538be58 100644 --- a/MusicAnalyser/App/DSP/Scripts/BySlopeDetector.cs +++ b/MusicAnalyser/App/DSP/Scripts/BySlopeDetector.cs @@ -1,4 +1,17 @@ -using System; +/* + * Music Analyser - Primary Detector Script - BySlope (WIP) + * Author: Sean King + * Performs generic peak detection by finding the points in the signal with the steepest slope. + * Properties: + * InputData: type double[] + * Output: type Dictionary + * InputArgs: SCALE - ratio between number of input values and sample rate - type double + * OutputArgs: None + * Settings: + * - MIN_FREQ: Frequency (Hz) to start analysis at - type int (0 - 20000) + * - MAX_FREQ: Frequency (Hz) to end analysis at - type int (0 - 20000) + */ +using System; using System.Collections.Generic; using System.Linq; using MusicAnalyser.App.DSP; diff --git a/MusicAnalyser/App/DSP/Scripts/CQTByMagnitudeDetector.cs b/MusicAnalyser/App/DSP/Scripts/CQTByMagnitudeDetector.cs index 36edc49..28f9ae6 100644 --- a/MusicAnalyser/App/DSP/Scripts/CQTByMagnitudeDetector.cs +++ b/MusicAnalyser/App/DSP/Scripts/CQTByMagnitudeDetector.cs @@ -1,4 +1,16 @@ -using MusicAnalyser.App.DSP; +/* + * Music Analyser - Primary Detector Script - CQTByMagnitude + * Author: Sean King + * Peak detection algorithm optimised for a CQT spectrum, finds peaks by largest magnitude. + * Properties: + * InputData: type double[] + * Output: type Dictionary + * InputArgs: SCALE - Non-linear scale function to map each frequency bin to a frequency value - type Func + * OutputArgs: POSITIONS - The frequency bin position of each peak - type double[] + * Settings: + * - THRESHOLD_FACTOR: Threshold above which point is considered a peak, relative to max magnitude-average magnitude - type double (0 - 1) + */ +using MusicAnalyser.App.DSP; using System; using System.Collections.Generic; using System.Linq; diff --git a/MusicAnalyser/App/DSP/Scripts/CQTProcessor.cs b/MusicAnalyser/App/DSP/Scripts/CQTProcessor.cs index 25b5e4f..310a2fa 100644 --- a/MusicAnalyser/App/DSP/Scripts/CQTProcessor.cs +++ b/MusicAnalyser/App/DSP/Scripts/CQTProcessor.cs @@ -1,4 +1,22 @@ -using System; +/* + * Music Analyser - Primary Processor Script - CQT + * Author: Sean King + * Constant-Q Transform (CQT) implementation with optimised kernel calculation, set up for 12 tone equal temperment analysis. + * Based on the efficient CQT algorithm by Benjamin Blankertz: + * http://doc.ml.tu-berlin.de/bbci/material/publications/Bla_constQ.pdf + * Properties: + * InputBuffer: type short[] + * OutputBuffer: type double[] + * InputArgs: SAMPLE_RATE - sample rate (Hz) of the input signal - type int + * OutputArgs: SCALE - Non-linear scale function to map each frequency bin to a frequency value - type Func + * Settings: + * - OCTAVES: Number of octaves to analyse - type int (1 - 10) + * - BINS_PER_OCTAVE: Number of frequency bins per octave - type enum (values: 12, 24, 36, 48, 60, 72, 84, 96) + * - MIN_FREQ: Starting frequency (Hz), for analysis in standard tuning use appropriate note frequency (eg. C1 = 32.7 Hz) - type double (1 - 1000) + * - N_WEIGHTING: Frequency weighting factor, lower values emphasise the magnitude of low frequencies and vice versa - type double (0 - 1) + * - OUTPUT_MODE: Specifies how the output magnitude should be scaled - type enum (values: Magnitude, dB) + */ +using System; using System.Collections.Generic; using System.Linq; using System.Numerics; @@ -21,7 +39,7 @@ public CQTProcessor() Settings = new Dictionary() { { "OCTAVES", new string[] { "5", "int", "Octaves", "1", "10" } }, - { "BINS_PER_OCTAVE", new string[] { "48", "enum", "Bins Per Octave", "12|24|48|60|72|84|96", "" } }, + { "BINS_PER_OCTAVE", new string[] { "48", "enum", "Bins Per Octave", "12|24|36|48|60|72|84|96", "" } }, { "MIN_FREQ", new string[] { "32.7", "double", "Minimum Frequency (Hz)", "1", "1000" } }, { "N_WEIGHTING", new string[] { "0.5", "double", "Frequency Weighting Factor", "0", "1" } }, { "OUTPUT_MODE", new string[] { "Magnitude", "enum", "Output Mode", "Magnitude|dB", "" } }, diff --git a/MusicAnalyser/App/DSP/Scripts/HPSDownsamplerProcessor.cs b/MusicAnalyser/App/DSP/Scripts/HPSDownsamplerProcessor.cs new file mode 100644 index 0000000..1f89cc5 --- /dev/null +++ b/MusicAnalyser/App/DSP/Scripts/HPSDownsamplerProcessor.cs @@ -0,0 +1,113 @@ +/* + * Music Analyser - Secondary Processor Script - HPSDownsampler + * Author: Sean King + * Implementation of the Harmonic Product Spectrum (HPS) algorithm, to be used in conjunction with a FFT processor script. + * Based on HPS method described here: + * https://cnx.org/contents/aY7_vV4-@5.8:i5AAkZCP@2/Pitch-Detection-Algorithms + * Properties: + * InputBuffer: type double[] (Output of FFT) + * OutputBuffer: type double[] + * InputArgs: None + * OutputArgs: None + * Settings: + * - HARMONICS: Specifies the number of harmonics to merge via downsampling - type int (values: 0 - 5) + * - INTERP: Specifies an interpolation factor to upsample output spectrum - type int (values: 1 - 5) + * - MAG_SCALE: Specifies a value to scale down the output magnitude exponentially - type double (1 - 5) + * - FLOOR: Specifies the minimum output spectrum value - type double (0 - 10) + */ +using MusicAnalyser.App.DSP; +using System; +using System.Collections.Generic; +using System.Linq; + +class HPSDownsamplerProcessor : ISignalProcessor +{ + public bool IsPrimary { get { return false; } } + public Dictionary Settings { get; set; } + public object InputBuffer { get; set; } + public Dictionary InputArgs { get; set; } + public object OutputBuffer { get; set; } + public Dictionary OutputArgs { get; set; } + + public HPSDownsamplerProcessor() + { + Settings = new Dictionary() + { + { "HARMONICS", new string[] { "2", "int", "Number of Harmonics", "0", "5" } }, + { "INTERP", new string[] { "2", "int", "Interpolation Factor", "1", "5" } }, + { "MAG_SCALE", new string[] { "2", "double", "Magnitude Scale Factor", "1", "5" } }, + { "FLOOR", new string[] { "1", "double", "Spectrum Floor", "0", "10" } }, + }; + } + + public void OnSettingsChange() { } + + public void Process() + { + double[] input = null; + if (InputBuffer.GetType().Name == "Double[]") + input = (double[])InputBuffer; + if (input == null) + return; + + for (int i = 0; i < input.Length; i++) + input[i] += double.Parse(Settings["FLOOR"][0]); + + List spectrums = new List(); + spectrums.Add(input); + + for(int i = 0; i < int.Parse(Settings["HARMONICS"][0]); i++) + { + double[] downsampledSpectrum = Downsample(input, i + 2); + spectrums.Add(downsampledSpectrum); + } + + double[] productSpectrum = new double[spectrums[spectrums.Count - 1].Length]; + for(int i = 0; i < productSpectrum.Length; i++) + { + productSpectrum[i] = 1; + for (int j = 0; j < spectrums.Count; j++) + productSpectrum[i] *= spectrums[j][i]; + productSpectrum[i] = Math.Pow(productSpectrum[i], 1.0 / double.Parse(Settings["MAG_SCALE"][0])); + } + if (int.Parse(Settings["INTERP"][0]) > 1) + OutputBuffer = Interpolate(productSpectrum, int.Parse(Settings["INTERP"][0])); + else + OutputBuffer = productSpectrum; + } + + private double[] Downsample(double[] source, int sampleFactor) + { + if (sampleFactor > 0) + { + List output = new List(); + for (int i = 0; i < source.Length - sampleFactor + 1; i += sampleFactor) + { + double avgVal = 0; + for (int j = 0; j < sampleFactor; j++) + avgVal += source[i + j]; + avgVal /= sampleFactor; + output.Add(avgVal); + } + return output.ToArray(); + } + return null; + } + + private double[] Interpolate(double[] source, int interpolationFactor) + { + if (interpolationFactor > 0) + { + List output = new List(); + for (int i = 0; i < source.Length - 1; i++) + { + output.Add(source[i]); + double delta = source[i + 1] - source[i]; + for (int j = 1; j < interpolationFactor; j++) + output.Add(source[i] + delta * ((double)j / interpolationFactor)); + } + return output.ToArray(); + } + return null; + } +} diff --git a/MusicAnalyser/App/DSP/Scripts/PitchByMagnitudeDetector.cs b/MusicAnalyser/App/DSP/Scripts/PitchByMagnitudeDetector.cs index 4bf29d0..e11f50f 100644 --- a/MusicAnalyser/App/DSP/Scripts/PitchByMagnitudeDetector.cs +++ b/MusicAnalyser/App/DSP/Scripts/PitchByMagnitudeDetector.cs @@ -1,4 +1,22 @@ -using MusicAnalyser.App.DSP; +/* + * Music Analyser - Primary Detector Script - PitchByMagnitude + * Author: Sean King + * Peak detection algorithm optimised for detecting musical pitches (12 tone equal temperment) from an FFT spectrum. + * Searches through chunks of the input signal at intervals corresponding to musical pitches, resolves clusters of points to a single value (largest in cluster), returns largest n values. + * Properties: + * InputData: type double[] + * Output: type Dictionary + * InputArgs: SCALE - Ratio between number of input values and sample rate - type double + * TUNING - Percentage difference from standard tuning - type double + * OutputArgs: None + * Settings: + * - MIN_FREQ: Starting frequency (Hz), for analysis in standard tuning use appropriate note frequency (eg. C1 = 32.7 Hz) - type double (1 - 1000) + * - OCTAVES: Number of octaves to analyse - type int (1 - 10) + * - MAX_VALS: Maximum number of peaks to return - tyoe int (1 - 100) + * - MAG_THRESHOLD: Threshold above which point is considered a peak, relative to max magnitude-average magnitude - type double (0 - 1) + * - FREQ_TOLERANCE: Percentage tolerance from musical pitch, if within this a frequency bin is considered for analysis - type double (0 - 50) + */ +using MusicAnalyser.App.DSP; using System; using System.Collections.Generic; using System.Linq; @@ -62,6 +80,9 @@ public void Detect() while (clusterSize / scale <= noteFreqs[i] / 100 * double.Parse(Settings["FREQ_TOLERANCE"][0])) clusterSize++; + if (inputIndex + clusterSize > input.Length) + break; + double avgMag = 0; double maxVal = 0, maxIndex = 0; for (int j = -clusterSize; j < clusterSize; j++) diff --git a/MusicAnalyser/App/DSP/Scripts/RemoveKickNoiseProcessor.cs b/MusicAnalyser/App/DSP/Scripts/RemoveKickNoiseProcessor.cs index 6420382..59555a6 100644 --- a/MusicAnalyser/App/DSP/Scripts/RemoveKickNoiseProcessor.cs +++ b/MusicAnalyser/App/DSP/Scripts/RemoveKickNoiseProcessor.cs @@ -1,4 +1,18 @@ -using System; +/* + * Music Analyser - Secondary Processor Script - RemoveKickNoise + * Auther: Sean King + * Culls detected peaks which may have been caused by low frequency noise (eg. kick drum) + * Properties: + * InputBuffer: type Dictionary + * OutputBuffer: type Dictionary + * InputArgs: None + * OutputArgs: None + * Settings: + * - CUTOFF_FREQ: Maximum frequency (Hz) considered for processing - type double (0 - 1000) + * - MAX_FREQ_CHANGE: Considers peaks for culling if they are within this percentage difference - type double (0 - 50) + * - SIMILAR_GAIN_THRESHOLD: Threshold within which adjacent peaks are considered similar in magnitude - type double (0 - 50) + */ +using System; using System.Collections.Generic; using System.Linq; using MusicAnalyser.App.DSP; diff --git a/MusicAnalyser/App/DSP/Scripts/SpectrumFilterProcessor.cs b/MusicAnalyser/App/DSP/Scripts/SpectrumFilterProcessor.cs new file mode 100644 index 0000000..fdd5007 --- /dev/null +++ b/MusicAnalyser/App/DSP/Scripts/SpectrumFilterProcessor.cs @@ -0,0 +1,89 @@ +/* + * Music Analyser - Secondary Processor Script - SpectrumFilter + * Author: Sean King + * Performs a band pass filter operation on the frequency spectrum. + * Can be used with both linearly scaled (eg. FFT) and non-linearly scaled (eg. CQT) spectrums. + * Properties: + * InputBuffer: type double[] (Spectrum) + * OutputBuffer: type double[] + * InputArgs: SCALE - Frequency scale value/function - type double (linear) or Func (non-linear) + * OutputArgs: None + * Settings: + * - ENABLED: Specifies if filter is active or bypassed - type enum (values: Yes, No) + * - LOW_CUT: Specifies the low cutoff frequency (Hz) of the band pass filter - type double (values: 0 - 2000) + * - HIGH_CUT: Specifies the high cutoff frequency (Hz) of the band pass filter - type double (values: 0 - 2000) + * - ATT_FACTOR: Specifies the sharpness of the attenuated bands - type double (0 - 1) + */ +using MusicAnalyser.App.DSP; +using System; +using System.Collections.Generic; +using System.Linq; + +class SpectrumFilterProcessor : ISignalProcessor +{ + public bool IsPrimary { get { return false; } } + public Dictionary Settings { get; set; } + public object InputBuffer { get; set; } + public Dictionary InputArgs { get; set; } + public object OutputBuffer { get; set; } + public Dictionary OutputArgs { get; set; } + + public SpectrumFilterProcessor() + { + Settings = new Dictionary() + { + { "ENABLED", new string[] { "Yes", "enum", "Enabled", "Yes|No", "" } }, + { "LOW_CUT", new string[] { "200", "double", "Low Cutoff (Hz)", "0", "2000" } }, + { "HIGH_CUT", new string[] { "2000", "double", "High Cutoff (Hz)", "0", "2000" } }, + { "ATT_FACTOR", new string[] { "1", "double", "Attentuation Factor", "0", "1" } }, + }; + } + + public void OnSettingsChange() { } + + public void Process() + { + double[] input = null; + if (InputBuffer.GetType().Name == "Double[]") + input = (double[])InputBuffer; + if (input == null) + return; + if (InputArgs.ContainsKey("SCALE")) + { + if (InputArgs["SCALE"] == null) + return; + } + else + return; + + if (Settings["ENABLED"][0] == "Yes") + { + double[] output = new double[input.Length]; + for (int i = 0; i < input.Length; i++) + { + if (InputArgs["SCALE"].GetType().Name == "Double") + { + output[i] = GetFilteredSample(i * (double)InputArgs["SCALE"], input[i]); + } + else if (InputArgs["SCALE"].GetType().Name == "Func`2") + { + var scaleFunc = (Func)InputArgs["SCALE"]; + output[i] = GetFilteredSample(scaleFunc(i), input[i]); + } + } + OutputBuffer = output; + } + else + OutputBuffer = input; + } + + private double GetFilteredSample(double freq, double mag) + { + double output = mag; + if (freq < double.Parse(Settings["LOW_CUT"][0])) + output = mag * Math.Pow(freq / double.Parse(Settings["LOW_CUT"][0]), 20 * double.Parse(Settings["ATT_FACTOR"][0])); + else if (freq > double.Parse(Settings["HIGH_CUT"][0])) + output = mag * Math.Pow(double.Parse(Settings["HIGH_CUT"][0]) / freq, 20 * double.Parse(Settings["ATT_FACTOR"][0])); + return output; + } +} diff --git a/MusicAnalyser/App/FileHandler.cs b/MusicAnalyser/App/FileHandler.cs index e4c7865..f50ea6f 100644 --- a/MusicAnalyser/App/FileHandler.cs +++ b/MusicAnalyser/App/FileHandler.cs @@ -50,10 +50,7 @@ public static WaveStream ResampleWav(WaveFileReader reader, int sampleRate) using (var resampledReader = new AudioFileReader(outFile)) { - var lowPass = BiQuadFilter.LowPassFilter(sampleRate, sampleRate / 4, 1); - var highPass = BiQuadFilter.HighPassFilter(sampleRate, 80, 1); - - using (var filter = new FilterWaveProvider(resampledReader, lowPass, highPass)) + using (var filter = new FilterWaveProvider(resampledReader, sampleRate / 4, 1, 80, 1)) { outFile = Path.Combine(Path.GetTempPath(), "resample_and_filtered.wav"); WaveFileWriter.CreateWaveFile16(outFile, filter); diff --git a/MusicAnalyser/App/Prefs.cs b/MusicAnalyser/App/Prefs.cs index 048200a..a18e3fd 100644 --- a/MusicAnalyser/App/Prefs.cs +++ b/MusicAnalyser/App/Prefs.cs @@ -21,7 +21,7 @@ public static class Prefs public static int MIN_UPDATE_TIME = 10; public static int UPDATE_MODE = 0; public static int UI_THEME = 0; - public static float MODAL_ROOT_DIFF = 2.0f; + public static float MODAL_ROOT_DIFF = 4.0f; public static int CHORD_DETECTION_INTERVAL = 10; public static int CHORD_NOTE_OCCURENCE_OFFSET = 8; public static int CAPTURE_DEVICE = 0; diff --git a/MusicAnalyser/MusicAnalyser.csproj b/MusicAnalyser/MusicAnalyser.csproj index 7bd2881..e5e0b67 100644 --- a/MusicAnalyser/MusicAnalyser.csproj +++ b/MusicAnalyser/MusicAnalyser.csproj @@ -114,6 +114,9 @@ ..\packages\Accord.Math.3.8.0\lib\net46\Accord.Math.Core.dll + + ..\packages\Control.Draggable.1.0.5049.269\lib\net35-Client\Control.Draggable.dll + ..\packages\IronPython.2.7.10\lib\net45\IronPython.dll @@ -141,17 +144,17 @@ ..\packages\NAudio.1.10.0\lib\net35\NAudio.dll - - ..\packages\ScottPlot.4.0.42\lib\netstandard2.0\ScottPlot.dll + + ..\packages\ScottPlot.4.0.48\lib\netstandard2.0\ScottPlot.dll - - ..\packages\ScottPlot.WinForms.4.0.42\lib\net472\ScottPlot.WinForms.dll + + ..\packages\ScottPlot.WinForms.4.0.48\lib\net472\ScottPlot.WinForms.dll - ..\packages\System.Drawing.Common.4.7.0\lib\net461\System.Drawing.Common.dll + ..\packages\System.Drawing.Common.5.0.0\lib\net461\System.Drawing.Common.dll @@ -176,6 +179,7 @@ + @@ -184,6 +188,7 @@ + UserControl @@ -217,6 +222,9 @@ + + Component + UserControl diff --git a/MusicAnalyser/UI/Form1.Designer.cs b/MusicAnalyser/UI/Form1.Designer.cs index 20ca26f..e5fc670 100644 --- a/MusicAnalyser/UI/Form1.Designer.cs +++ b/MusicAnalyser/UI/Form1.Designer.cs @@ -92,7 +92,6 @@ private void InitializeComponent() this.lblLoopDuration = new System.Windows.Forms.Label(); this.txtLoopTime = new System.Windows.Forms.TextBox(); this.prbLevelMeter = new System.Windows.Forms.ProgressBar(); - this.flpScripts = new System.Windows.Forms.FlowLayoutPanel(); this.btnAddScript = new System.Windows.Forms.Button(); this.label6 = new System.Windows.Forms.Label(); this.lblSelMessage = new System.Windows.Forms.Label(); @@ -103,10 +102,14 @@ private void InitializeComponent() this.cbPresets = new System.Windows.Forms.ComboBox(); this.label21 = new System.Windows.Forms.Label(); this.btnSavePreset = new System.Windows.Forms.Button(); - this.cwvViewer = new MusicAnalyser.CustomWaveViewer(); this.segMode = new XanderUI.XUISegment(); this.numStepVal = new System.Windows.Forms.NumericUpDown(); this.lblStep = new System.Windows.Forms.Label(); + this.chbFilter = new System.Windows.Forms.CheckBox(); + this.lblFilterFreq = new System.Windows.Forms.Label(); + this.flpScripts = new System.Windows.Forms.TableLayoutPanel(); + this.btnFilterDrag = new MusicAnalyser.UI.RoundButton(); + this.cwvViewer = new MusicAnalyser.CustomWaveViewer(); ((System.ComponentModel.ISupportInitialize)(this.barVolume)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.barTempo)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.barPitch)).BeginInit(); @@ -117,7 +120,9 @@ private void InitializeComponent() // // btnOpenClose // + this.btnOpenClose.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnOpenClose.Location = new System.Drawing.Point(13, 31); + this.btnOpenClose.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnOpenClose.Name = "btnOpenClose"; this.btnOpenClose.Size = new System.Drawing.Size(75, 27); this.btnOpenClose.TabIndex = 0; @@ -128,7 +133,9 @@ private void InitializeComponent() // btnPlay // this.btnPlay.Enabled = false; + this.btnPlay.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnPlay.Location = new System.Drawing.Point(13, 64); + this.btnPlay.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnPlay.Name = "btnPlay"; this.btnPlay.Size = new System.Drawing.Size(156, 27); this.btnPlay.TabIndex = 1; @@ -139,7 +146,9 @@ private void InitializeComponent() // btnStop // this.btnStop.Enabled = false; - this.btnStop.Location = new System.Drawing.Point(94, 31); + this.btnStop.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnStop.Location = new System.Drawing.Point(93, 31); + this.btnStop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnStop.Name = "btnStop"; this.btnStop.Size = new System.Drawing.Size(75, 27); this.btnStop.TabIndex = 0; @@ -153,9 +162,9 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.spFFT.BackColor = System.Drawing.SystemColors.Control; this.spFFT.Location = new System.Drawing.Point(13, 533); - this.spFFT.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.spFFT.Margin = new System.Windows.Forms.Padding(5, 5, 5, 5); this.spFFT.Name = "spFFT"; - this.spFFT.Size = new System.Drawing.Size(1509, 369); + this.spFFT.Size = new System.Drawing.Size(1433, 369); this.spFFT.TabIndex = 3; // // timerFFT @@ -166,27 +175,31 @@ private void InitializeComponent() // lstChords // this.lstChords.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lstChords.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lstChords.FormattingEnabled = true; - this.lstChords.ItemHeight = 16; - this.lstChords.Location = new System.Drawing.Point(1710, 626); + this.lstChords.ItemHeight = 18; + this.lstChords.Location = new System.Drawing.Point(1618, 623); + this.lstChords.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.lstChords.Name = "lstChords"; - this.lstChords.Size = new System.Drawing.Size(120, 100); + this.lstChords.Size = new System.Drawing.Size(120, 94); this.lstChords.TabIndex = 5; // // label1 // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(1710, 596); + this.label1.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(1614, 593); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(101, 17); + this.label1.Size = new System.Drawing.Size(107, 19); this.label1.TabIndex = 6; this.label1.Text = "Chords Found:"; // // barVolume // this.barVolume.Enabled = false; - this.barVolume.Location = new System.Drawing.Point(431, 34); + this.barVolume.Location = new System.Drawing.Point(440, 34); + this.barVolume.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.barVolume.Maximum = 20; this.barVolume.Name = "barVolume"; this.barVolume.Size = new System.Drawing.Size(199, 56); @@ -197,36 +210,40 @@ private void InitializeComponent() // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(439, 68); + this.label2.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(448, 69); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(28, 17); + this.label2.Size = new System.Drawing.Size(29, 19); this.label2.TabIndex = 8; this.label2.Text = "0%"; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(516, 68); + this.label3.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(525, 69); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(36, 17); + this.label3.Size = new System.Drawing.Size(37, 19); this.label3.TabIndex = 9; this.label3.Text = "50%"; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(596, 68); + this.label4.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Location = new System.Drawing.Point(605, 69); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(44, 17); + this.label4.Size = new System.Drawing.Size(45, 19); this.label4.TabIndex = 10; this.label4.Text = "100%"; // // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(362, 39); + this.label5.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.Location = new System.Drawing.Point(371, 39); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(63, 17); + this.label5.Size = new System.Drawing.Size(67, 19); this.label5.TabIndex = 11; this.label5.Text = "Volume: "; // @@ -235,27 +252,31 @@ private void InitializeComponent() this.chbFollow.AutoSize = true; this.chbFollow.Checked = true; this.chbFollow.CheckState = System.Windows.Forms.CheckState.Checked; - this.chbFollow.Location = new System.Drawing.Point(1604, 35); + this.chbFollow.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.chbFollow.Location = new System.Drawing.Point(1604, 34); + this.chbFollow.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.chbFollow.Name = "chbFollow"; - this.chbFollow.Size = new System.Drawing.Size(130, 21); + this.chbFollow.Size = new System.Drawing.Size(135, 23); this.chbFollow.TabIndex = 13; this.chbFollow.Text = "Follow Playback"; this.chbFollow.UseVisualStyleBackColor = true; // // txtPlayTime // - this.txtPlayTime.Location = new System.Drawing.Point(1095, 33); + this.txtPlayTime.Location = new System.Drawing.Point(1091, 33); + this.txtPlayTime.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.txtPlayTime.Name = "txtPlayTime"; - this.txtPlayTime.Size = new System.Drawing.Size(90, 22); + this.txtPlayTime.Size = new System.Drawing.Size(89, 22); this.txtPlayTime.TabIndex = 16; this.txtPlayTime.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // lblPlayTime // this.lblPlayTime.AutoSize = true; - this.lblPlayTime.Location = new System.Drawing.Point(971, 36); + this.lblPlayTime.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblPlayTime.Location = new System.Drawing.Point(971, 34); this.lblPlayTime.Name = "lblPlayTime"; - this.lblPlayTime.Size = new System.Drawing.Size(104, 17); + this.lblPlayTime.Size = new System.Drawing.Size(108, 19); this.lblPlayTime.TabIndex = 17; this.lblPlayTime.Text = "Playback Time:"; // @@ -263,10 +284,10 @@ private void InitializeComponent() // this.lblC.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblC.AutoSize = true; - this.lblC.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblC.Location = new System.Drawing.Point(1541, 596); + this.lblC.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblC.Location = new System.Drawing.Point(1465, 596); this.lblC.Name = "lblC"; - this.lblC.Size = new System.Drawing.Size(37, 17); + this.lblC.Size = new System.Drawing.Size(34, 19); this.lblC.TabIndex = 18; this.lblC.Text = "C: 0"; // @@ -274,10 +295,10 @@ private void InitializeComponent() // this.lblDb.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblDb.AutoSize = true; - this.lblDb.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblDb.Location = new System.Drawing.Point(1541, 613); + this.lblDb.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblDb.Location = new System.Drawing.Point(1465, 613); this.lblDb.Name = "lblDb"; - this.lblDb.Size = new System.Drawing.Size(47, 17); + this.lblDb.Size = new System.Drawing.Size(44, 19); this.lblDb.TabIndex = 19; this.lblDb.Text = "Db: 0"; // @@ -285,10 +306,10 @@ private void InitializeComponent() // this.lblD.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblD.AutoSize = true; - this.lblD.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblD.Location = new System.Drawing.Point(1541, 630); + this.lblD.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblD.Location = new System.Drawing.Point(1465, 630); this.lblD.Name = "lblD"; - this.lblD.Size = new System.Drawing.Size(38, 17); + this.lblD.Size = new System.Drawing.Size(35, 19); this.lblD.TabIndex = 20; this.lblD.Text = "D: 0"; // @@ -296,10 +317,10 @@ private void InitializeComponent() // this.lblEb.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblEb.AutoSize = true; - this.lblEb.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblEb.Location = new System.Drawing.Point(1541, 647); + this.lblEb.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblEb.Location = new System.Drawing.Point(1465, 647); this.lblEb.Name = "lblEb"; - this.lblEb.Size = new System.Drawing.Size(46, 17); + this.lblEb.Size = new System.Drawing.Size(42, 19); this.lblEb.TabIndex = 20; this.lblEb.Text = "Eb: 0"; // @@ -307,10 +328,10 @@ private void InitializeComponent() // this.lblE.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblE.AutoSize = true; - this.lblE.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblE.Location = new System.Drawing.Point(1541, 664); + this.lblE.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblE.Location = new System.Drawing.Point(1465, 665); this.lblE.Name = "lblE"; - this.lblE.Size = new System.Drawing.Size(37, 17); + this.lblE.Size = new System.Drawing.Size(33, 19); this.lblE.TabIndex = 20; this.lblE.Text = "E: 0"; // @@ -318,10 +339,10 @@ private void InitializeComponent() // this.lblF.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblF.AutoSize = true; - this.lblF.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblF.Location = new System.Drawing.Point(1541, 681); + this.lblF.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblF.Location = new System.Drawing.Point(1465, 681); this.lblF.Name = "lblF"; - this.lblF.Size = new System.Drawing.Size(36, 17); + this.lblF.Size = new System.Drawing.Size(32, 19); this.lblF.TabIndex = 20; this.lblF.Text = "F: 0"; // @@ -329,10 +350,10 @@ private void InitializeComponent() // this.lblGb.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblGb.AutoSize = true; - this.lblGb.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblGb.Location = new System.Drawing.Point(1541, 698); + this.lblGb.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblGb.Location = new System.Drawing.Point(1465, 698); this.lblGb.Name = "lblGb"; - this.lblGb.Size = new System.Drawing.Size(48, 17); + this.lblGb.Size = new System.Drawing.Size(44, 19); this.lblGb.TabIndex = 20; this.lblGb.Text = "Gb: 0"; // @@ -340,10 +361,10 @@ private void InitializeComponent() // this.lblG.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblG.AutoSize = true; - this.lblG.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblG.Location = new System.Drawing.Point(1541, 715); + this.lblG.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblG.Location = new System.Drawing.Point(1465, 715); this.lblG.Name = "lblG"; - this.lblG.Size = new System.Drawing.Size(39, 17); + this.lblG.Size = new System.Drawing.Size(35, 19); this.lblG.TabIndex = 20; this.lblG.Text = "G: 0"; // @@ -351,10 +372,10 @@ private void InitializeComponent() // this.lblAb.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblAb.AutoSize = true; - this.lblAb.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblAb.Location = new System.Drawing.Point(1541, 732); + this.lblAb.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblAb.Location = new System.Drawing.Point(1465, 732); this.lblAb.Name = "lblAb"; - this.lblAb.Size = new System.Drawing.Size(46, 17); + this.lblAb.Size = new System.Drawing.Size(43, 19); this.lblAb.TabIndex = 20; this.lblAb.Text = "Ab: 0"; // @@ -362,10 +383,10 @@ private void InitializeComponent() // this.lblA.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblA.AutoSize = true; - this.lblA.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblA.Location = new System.Drawing.Point(1541, 749); + this.lblA.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblA.Location = new System.Drawing.Point(1465, 750); this.lblA.Name = "lblA"; - this.lblA.Size = new System.Drawing.Size(37, 17); + this.lblA.Size = new System.Drawing.Size(34, 19); this.lblA.TabIndex = 20; this.lblA.Text = "A: 0"; // @@ -373,10 +394,10 @@ private void InitializeComponent() // this.lblBb.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblBb.AutoSize = true; - this.lblBb.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblBb.Location = new System.Drawing.Point(1541, 766); + this.lblBb.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblBb.Location = new System.Drawing.Point(1465, 766); this.lblBb.Name = "lblBb"; - this.lblBb.Size = new System.Drawing.Size(46, 17); + this.lblBb.Size = new System.Drawing.Size(43, 19); this.lblBb.TabIndex = 20; this.lblBb.Text = "Bb: 0"; // @@ -384,10 +405,10 @@ private void InitializeComponent() // this.lblB.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblB.AutoSize = true; - this.lblB.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblB.Location = new System.Drawing.Point(1541, 783); + this.lblB.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblB.Location = new System.Drawing.Point(1465, 783); this.lblB.Name = "lblB"; - this.lblB.Size = new System.Drawing.Size(37, 17); + this.lblB.Size = new System.Drawing.Size(34, 19); this.lblB.TabIndex = 20; this.lblB.Text = "B: 0"; // @@ -395,10 +416,10 @@ private void InitializeComponent() // this.lblKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblKey.AutoSize = true; - this.lblKey.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblKey.Location = new System.Drawing.Point(1544, 819); + this.lblKey.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblKey.Location = new System.Drawing.Point(1468, 818); this.lblKey.Name = "lblKey"; - this.lblKey.Size = new System.Drawing.Size(119, 17); + this.lblKey.Size = new System.Drawing.Size(112, 19); this.lblKey.TabIndex = 21; this.lblKey.Text = "Predicted Key: "; // @@ -407,16 +428,18 @@ private void InitializeComponent() this.lblExeTime.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lblExeTime.AutoSize = true; + this.lblExeTime.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblExeTime.Location = new System.Drawing.Point(47, 473); this.lblExeTime.Name = "lblExeTime"; - this.lblExeTime.Size = new System.Drawing.Size(142, 17); + this.lblExeTime.Size = new System.Drawing.Size(151, 19); this.lblExeTime.TabIndex = 4; this.lblExeTime.Text = "Execution Time: 0 ms"; // // barTempo // this.barTempo.Enabled = false; - this.barTempo.Location = new System.Drawing.Point(766, 34); + this.barTempo.Location = new System.Drawing.Point(728, 31); + this.barTempo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.barTempo.Maximum = 20; this.barTempo.Name = "barTempo"; this.barTempo.Size = new System.Drawing.Size(199, 56); @@ -427,36 +450,40 @@ private void InitializeComponent() // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(698, 41); + this.label7.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label7.Location = new System.Drawing.Point(660, 38); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(60, 17); + this.label7.Size = new System.Drawing.Size(63, 19); this.label7.TabIndex = 11; this.label7.Text = "Tempo: "; // // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(769, 69); + this.label8.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label8.Location = new System.Drawing.Point(731, 66); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(36, 17); + this.label8.Size = new System.Drawing.Size(37, 19); this.label8.TabIndex = 8; this.label8.Text = "50%"; // // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(846, 69); + this.label9.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label9.Location = new System.Drawing.Point(808, 66); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(44, 17); + this.label9.Size = new System.Drawing.Size(45, 19); this.label9.TabIndex = 9; this.label9.Text = "100%"; // // label10 // this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(931, 68); + this.label10.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label10.Location = new System.Drawing.Point(893, 65); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(44, 17); + this.label10.Size = new System.Drawing.Size(45, 19); this.label10.TabIndex = 10; this.label10.Text = "150%"; // @@ -464,6 +491,7 @@ private void InitializeComponent() // this.barPitch.Enabled = false; this.barPitch.Location = new System.Drawing.Point(493, 473); + this.barPitch.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.barPitch.Maximum = 100; this.barPitch.Name = "barPitch"; this.barPitch.Size = new System.Drawing.Size(199, 56); @@ -474,100 +502,110 @@ private void InitializeComponent() // label11 // this.label11.AutoSize = true; - this.label11.Location = new System.Drawing.Point(490, 508); + this.label11.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label11.Location = new System.Drawing.Point(491, 508); this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(29, 17); + this.label11.Size = new System.Drawing.Size(30, 19); this.label11.TabIndex = 8; this.label11.Text = "-50"; // // label12 // this.label12.AutoSize = true; + this.label12.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label12.Location = new System.Drawing.Point(585, 508); this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(16, 17); + this.label12.Size = new System.Drawing.Size(17, 19); this.label12.TabIndex = 9; this.label12.Text = "0"; // // label13 // this.label13.AutoSize = true; + this.label13.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label13.Location = new System.Drawing.Point(660, 508); this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(32, 17); + this.label13.Size = new System.Drawing.Size(33, 19); this.label13.TabIndex = 10; this.label13.Text = "+50"; // // label14 // this.label14.AutoSize = true; + this.label14.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label14.Location = new System.Drawing.Point(405, 473); this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(82, 17); + this.label14.Size = new System.Drawing.Size(85, 19); this.label14.TabIndex = 11; this.label14.Text = "Pitch Sync: "; // // barZoom // - this.barZoom.Location = new System.Drawing.Point(274, 473); + this.barZoom.Location = new System.Drawing.Point(275, 473); + this.barZoom.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.barZoom.Maximum = 2; this.barZoom.Name = "barZoom"; - this.barZoom.Size = new System.Drawing.Size(110, 56); + this.barZoom.Size = new System.Drawing.Size(109, 56); this.barZoom.TabIndex = 7; this.barZoom.Value = 1; // // label16 // this.label16.AutoSize = true; + this.label16.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label16.Location = new System.Drawing.Point(361, 512); this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(23, 17); + this.label16.Size = new System.Drawing.Size(24, 19); this.label16.TabIndex = 8; this.label16.Text = "2k"; // // label17 // this.label17.AutoSize = true; + this.label17.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label17.Location = new System.Drawing.Point(271, 512); this.label17.Name = "label17"; - this.label17.Size = new System.Drawing.Size(32, 17); + this.label17.Size = new System.Drawing.Size(33, 19); this.label17.TabIndex = 8; this.label17.Text = "500"; // // label18 // this.label18.AutoSize = true; - this.label18.Location = new System.Drawing.Point(318, 512); + this.label18.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label18.Location = new System.Drawing.Point(317, 512); this.label18.Name = "label18"; - this.label18.Size = new System.Drawing.Size(23, 17); + this.label18.Size = new System.Drawing.Size(24, 19); this.label18.TabIndex = 8; this.label18.Text = "1k"; // // label19 // this.label19.AutoSize = true; + this.label19.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label19.Location = new System.Drawing.Point(209, 473); this.label19.Name = "label19"; - this.label19.Size = new System.Drawing.Size(48, 17); + this.label19.Size = new System.Drawing.Size(50, 19); this.label19.TabIndex = 11; this.label19.Text = "Zoom:"; // // lblError // this.lblError.AutoSize = true; - this.lblError.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblError.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblError.Location = new System.Drawing.Point(748, 473); this.lblError.Name = "lblError"; - this.lblError.Size = new System.Drawing.Size(75, 17); + this.lblError.Size = new System.Drawing.Size(70, 19); this.lblError.TabIndex = 18; this.lblError.Text = "+ 0 cents"; // // label20 // this.label20.AutoSize = true; - this.label20.Location = new System.Drawing.Point(698, 473); + this.label20.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label20.Location = new System.Drawing.Point(699, 473); this.label20.Name = "label20"; - this.label20.Size = new System.Drawing.Size(44, 17); + this.label20.Size = new System.Drawing.Size(47, 19); this.label20.TabIndex = 6; this.label20.Text = "Error:"; // @@ -580,7 +618,8 @@ private void InitializeComponent() this.helpToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(1908, 28); + this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2); + this.menuStrip1.Size = new System.Drawing.Size(1832, 28); this.menuStrip1.TabIndex = 22; this.menuStrip1.Text = "menuStrip1"; // @@ -661,10 +700,10 @@ private void InitializeComponent() // this.lblMode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblMode.AutoSize = true; - this.lblMode.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblMode.Location = new System.Drawing.Point(1648, 845); + this.lblMode.Font = new System.Drawing.Font("Open Sans Semibold", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblMode.Location = new System.Drawing.Point(1560, 847); this.lblMode.Name = "lblMode"; - this.lblMode.Size = new System.Drawing.Size(47, 17); + this.lblMode.Size = new System.Drawing.Size(48, 19); this.lblMode.TabIndex = 21; this.lblMode.Text = "Mode"; // @@ -672,9 +711,11 @@ private void InitializeComponent() // this.chbAllChords.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.chbAllChords.AutoSize = true; - this.chbAllChords.Location = new System.Drawing.Point(1710, 745); + this.chbAllChords.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.chbAllChords.Location = new System.Drawing.Point(1619, 746); + this.chbAllChords.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.chbAllChords.Name = "chbAllChords"; - this.chbAllChords.Size = new System.Drawing.Size(83, 21); + this.chbAllChords.Size = new System.Drawing.Size(88, 23); this.chbAllChords.TabIndex = 13; this.chbAllChords.Text = "Show All"; this.chbAllChords.UseVisualStyleBackColor = true; @@ -682,61 +723,56 @@ private void InitializeComponent() // lblSelectTime // this.lblSelectTime.AutoSize = true; - this.lblSelectTime.Location = new System.Drawing.Point(1191, 36); + this.lblSelectTime.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblSelectTime.Location = new System.Drawing.Point(1187, 34); this.lblSelectTime.Name = "lblSelectTime"; - this.lblSelectTime.Size = new System.Drawing.Size(86, 17); + this.lblSelectTime.Size = new System.Drawing.Size(90, 19); this.lblSelectTime.TabIndex = 24; this.lblSelectTime.Text = "Select Time:"; // // txtSelectTime // this.txtSelectTime.Location = new System.Drawing.Point(1283, 33); + this.txtSelectTime.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.txtSelectTime.Name = "txtSelectTime"; - this.txtSelectTime.Size = new System.Drawing.Size(90, 22); + this.txtSelectTime.Size = new System.Drawing.Size(89, 22); this.txtSelectTime.TabIndex = 23; this.txtSelectTime.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // lblLoopDuration // this.lblLoopDuration.AutoSize = true; - this.lblLoopDuration.Location = new System.Drawing.Point(1379, 36); + this.lblLoopDuration.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblLoopDuration.Location = new System.Drawing.Point(1379, 34); this.lblLoopDuration.Name = "lblLoopDuration"; - this.lblLoopDuration.Size = new System.Drawing.Size(102, 17); + this.lblLoopDuration.Size = new System.Drawing.Size(108, 19); this.lblLoopDuration.TabIndex = 26; this.lblLoopDuration.Text = "Loop Duration:"; // // txtLoopTime // - this.txtLoopTime.Location = new System.Drawing.Point(1487, 33); + this.txtLoopTime.Location = new System.Drawing.Point(1493, 33); + this.txtLoopTime.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.txtLoopTime.Name = "txtLoopTime"; - this.txtLoopTime.Size = new System.Drawing.Size(90, 22); + this.txtLoopTime.Size = new System.Drawing.Size(89, 22); this.txtLoopTime.TabIndex = 25; this.txtLoopTime.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // prbLevelMeter // - this.prbLevelMeter.Location = new System.Drawing.Point(1309, 32); + this.prbLevelMeter.Location = new System.Drawing.Point(1308, 32); + this.prbLevelMeter.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.prbLevelMeter.Name = "prbLevelMeter"; this.prbLevelMeter.Size = new System.Drawing.Size(268, 23); this.prbLevelMeter.TabIndex = 28; this.prbLevelMeter.Visible = false; // - // flpScripts - // - this.flpScripts.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.flpScripts.AutoScroll = true; - this.flpScripts.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.flpScripts.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; - this.flpScripts.Location = new System.Drawing.Point(1528, 173); - this.flpScripts.Name = "flpScripts"; - this.flpScripts.Size = new System.Drawing.Size(255, 116); - this.flpScripts.TabIndex = 29; - this.flpScripts.WrapContents = false; - // // btnAddScript // this.btnAddScript.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnAddScript.Location = new System.Drawing.Point(1789, 223); + this.btnAddScript.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnAddScript.Location = new System.Drawing.Point(1713, 223); + this.btnAddScript.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnAddScript.Name = "btnAddScript"; this.btnAddScript.Size = new System.Drawing.Size(88, 30); this.btnAddScript.TabIndex = 30; @@ -748,10 +784,10 @@ private void InitializeComponent() // this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label6.AutoSize = true; - this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label6.Location = new System.Drawing.Point(1636, 86); + this.label6.Font = new System.Drawing.Font("Open Sans Semibold", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label6.Location = new System.Drawing.Point(1560, 86); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(157, 20); + this.label6.Size = new System.Drawing.Size(148, 23); this.label6.TabIndex = 31; this.label6.Text = "Processing Chain"; // @@ -761,7 +797,7 @@ private void InitializeComponent() this.lblSelMessage.AutoSize = true; this.lblSelMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lblSelMessage.ForeColor = System.Drawing.Color.Crimson; - this.lblSelMessage.Location = new System.Drawing.Point(1529, 114); + this.lblSelMessage.Location = new System.Drawing.Point(1453, 114); this.lblSelMessage.Name = "lblSelMessage"; this.lblSelMessage.Size = new System.Drawing.Size(0, 17); this.lblSelMessage.TabIndex = 32; @@ -769,7 +805,9 @@ private void InitializeComponent() // btnApplyScripts // this.btnApplyScripts.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnApplyScripts.Location = new System.Drawing.Point(1789, 259); + this.btnApplyScripts.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnApplyScripts.Location = new System.Drawing.Point(1713, 258); + this.btnApplyScripts.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnApplyScripts.Name = "btnApplyScripts"; this.btnApplyScripts.Size = new System.Drawing.Size(88, 30); this.btnApplyScripts.TabIndex = 33; @@ -783,7 +821,9 @@ private void InitializeComponent() this.tblSettings.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; this.tblSettings.ColumnCount = 1; this.tblSettings.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tblSettings.Location = new System.Drawing.Point(1528, 296); + this.tblSettings.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tblSettings.Location = new System.Drawing.Point(1452, 295); + this.tblSettings.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.tblSettings.Name = "tblSettings"; this.tblSettings.RowCount = 1; this.tblSettings.RowStyles.Add(new System.Windows.Forms.RowStyle()); @@ -793,7 +833,9 @@ private void InitializeComponent() // btnSave // this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnSave.Location = new System.Drawing.Point(1789, 421); + this.btnSave.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnSave.Location = new System.Drawing.Point(1713, 421); + this.btnSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(88, 30); this.btnSave.TabIndex = 36; @@ -805,7 +847,9 @@ private void InitializeComponent() // this.btnDefaults.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnDefaults.Enabled = false; - this.btnDefaults.Location = new System.Drawing.Point(1695, 421); + this.btnDefaults.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnDefaults.Location = new System.Drawing.Point(1618, 421); + this.btnDefaults.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnDefaults.Name = "btnDefaults"; this.btnDefaults.Size = new System.Drawing.Size(88, 30); this.btnDefaults.TabIndex = 37; @@ -815,26 +859,33 @@ private void InitializeComponent() // // cbPresets // + this.cbPresets.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.cbPresets.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.cbPresets.FormattingEnabled = true; - this.cbPresets.Location = new System.Drawing.Point(1596, 141); + this.cbPresets.Location = new System.Drawing.Point(1520, 142); + this.cbPresets.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.cbPresets.Name = "cbPresets"; - this.cbPresets.Size = new System.Drawing.Size(187, 24); + this.cbPresets.Size = new System.Drawing.Size(187, 26); this.cbPresets.TabIndex = 38; this.cbPresets.SelectedIndexChanged += new System.EventHandler(this.cbPresets_SelectedIndexChanged); // // label21 // + this.label21.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label21.AutoSize = true; - this.label21.Location = new System.Drawing.Point(1541, 144); + this.label21.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label21.Location = new System.Drawing.Point(1465, 144); this.label21.Name = "label21"; - this.label21.Size = new System.Drawing.Size(49, 17); + this.label21.Size = new System.Drawing.Size(51, 19); this.label21.TabIndex = 39; this.label21.Text = "Preset"; // // btnSavePreset // this.btnSavePreset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnSavePreset.Location = new System.Drawing.Point(1789, 137); + this.btnSavePreset.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnSavePreset.Location = new System.Drawing.Point(1713, 137); + this.btnSavePreset.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.btnSavePreset.Name = "btnSavePreset"; this.btnSavePreset.Size = new System.Drawing.Size(88, 30); this.btnSavePreset.TabIndex = 40; @@ -842,31 +893,13 @@ private void InitializeComponent() this.btnSavePreset.UseVisualStyleBackColor = true; this.btnSavePreset.Click += new System.EventHandler(this.btnSavePreset_Click); // - // cwvViewer - // - this.cwvViewer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.cwvViewer.BackColor = System.Drawing.SystemColors.ControlLight; - this.cwvViewer.BytesPerSample = 0; - this.cwvViewer.LeftSample = ((long)(0)); - this.cwvViewer.Location = new System.Drawing.Point(32, 114); - this.cwvViewer.LoopEndSample = ((long)(0)); - this.cwvViewer.Name = "cwvViewer"; - this.cwvViewer.PenColor = System.Drawing.Color.DodgerBlue; - this.cwvViewer.PenWidth = 1F; - this.cwvViewer.RightSample = ((long)(0)); - this.cwvViewer.SamplesPerPixel = 128; - this.cwvViewer.SelectSample = ((long)(0)); - this.cwvViewer.Size = new System.Drawing.Size(1490, 301); - this.cwvViewer.StartPosition = ((long)(0)); - this.cwvViewer.TabIndex = 2; - this.cwvViewer.WaveStream = null; - // // segMode // this.segMode.Cursor = System.Windows.Forms.Cursors.Hand; + this.segMode.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.segMode.Items = "Play Mode, Step Mode, Record Mode"; this.segMode.Location = new System.Drawing.Point(175, 33); + this.segMode.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.segMode.Name = "segMode"; this.segMode.SegmentActiveTextColor = System.Drawing.Color.White; this.segMode.SegmentBackColor = System.Drawing.SystemColors.Control; @@ -880,7 +913,9 @@ private void InitializeComponent() // // numStepVal // - this.numStepVal.Location = new System.Drawing.Point(94, 67); + this.numStepVal.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.numStepVal.Location = new System.Drawing.Point(92, 66); + this.numStepVal.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.numStepVal.Maximum = new decimal(new int[] { 1000, 0, @@ -892,7 +927,7 @@ private void InitializeComponent() 0, 0}); this.numStepVal.Name = "numStepVal"; - this.numStepVal.Size = new System.Drawing.Size(75, 22); + this.numStepVal.Size = new System.Drawing.Size(75, 25); this.numStepVal.TabIndex = 42; this.numStepVal.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; this.numStepVal.Value = new decimal(new int[] { @@ -906,19 +941,102 @@ private void InitializeComponent() // lblStep // this.lblStep.AutoSize = true; - this.lblStep.Location = new System.Drawing.Point(15, 69); + this.lblStep.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblStep.Location = new System.Drawing.Point(13, 68); this.lblStep.Name = "lblStep"; - this.lblStep.Size = new System.Drawing.Size(73, 17); + this.lblStep.Size = new System.Drawing.Size(75, 19); this.lblStep.TabIndex = 43; this.lblStep.Text = "Step (ms):"; this.lblStep.Visible = false; // + // chbFilter + // + this.chbFilter.AutoSize = true; + this.chbFilter.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.chbFilter.Location = new System.Drawing.Point(861, 473); + this.chbFilter.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.chbFilter.Name = "chbFilter"; + this.chbFilter.Size = new System.Drawing.Size(166, 23); + this.chbFilter.TabIndex = 45; + this.chbFilter.Text = "Note Highlight Filter"; + this.chbFilter.UseVisualStyleBackColor = true; + this.chbFilter.CheckedChanged += new System.EventHandler(this.chbFilter_CheckedChanged); + // + // lblFilterFreq + // + this.lblFilterFreq.AutoSize = true; + this.lblFilterFreq.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblFilterFreq.ForeColor = System.Drawing.Color.Gray; + this.lblFilterFreq.Location = new System.Drawing.Point(764, 654); + this.lblFilterFreq.Name = "lblFilterFreq"; + this.lblFilterFreq.Size = new System.Drawing.Size(54, 19); + this.lblFilterFreq.TabIndex = 46; + this.lblFilterFreq.Text = "440 Hz"; + this.lblFilterFreq.Visible = false; + // + // flpScripts + // + this.flpScripts.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.flpScripts.AutoScroll = true; + this.flpScripts.AutoScrollMinSize = new System.Drawing.Size(0, 5); + this.flpScripts.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; + this.flpScripts.ColumnCount = 1; + this.flpScripts.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.flpScripts.Location = new System.Drawing.Point(1452, 172); + this.flpScripts.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.flpScripts.Name = "flpScripts"; + this.flpScripts.RowCount = 1; + this.flpScripts.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.flpScripts.Size = new System.Drawing.Size(255, 118); + this.flpScripts.TabIndex = 47; + // + // btnFilterDrag + // + this.btnFilterDrag.BackColor = System.Drawing.SystemColors.ControlLight; + this.btnFilterDrag.Enabled = false; + this.btnFilterDrag.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnFilterDrag.Location = new System.Drawing.Point(728, 647); + this.btnFilterDrag.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.btnFilterDrag.Name = "btnFilterDrag"; + this.btnFilterDrag.Size = new System.Drawing.Size(29, 30); + this.btnFilterDrag.TabIndex = 44; + this.btnFilterDrag.TabStop = false; + this.btnFilterDrag.UseVisualStyleBackColor = false; + this.btnFilterDrag.Visible = false; + this.btnFilterDrag.Move += new System.EventHandler(this.btnFilterDrag_Move); + // + // cwvViewer + // + this.cwvViewer.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cwvViewer.BackColor = System.Drawing.SystemColors.ControlLight; + this.cwvViewer.BytesPerSample = 0; + this.cwvViewer.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cwvViewer.LeftSample = ((long)(0)); + this.cwvViewer.Location = new System.Drawing.Point(32, 114); + this.cwvViewer.LoopEndSample = ((long)(0)); + this.cwvViewer.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.cwvViewer.Name = "cwvViewer"; + this.cwvViewer.PenColor = System.Drawing.Color.DodgerBlue; + this.cwvViewer.PenWidth = 1F; + this.cwvViewer.RightSample = ((long)(0)); + this.cwvViewer.SamplesPerPixel = 128; + this.cwvViewer.SelectSample = ((long)(0)); + this.cwvViewer.Size = new System.Drawing.Size(1414, 302); + this.cwvViewer.StartPosition = ((long)(0)); + this.cwvViewer.TabIndex = 2; + this.cwvViewer.WaveStream = null; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Control; - this.ClientSize = new System.Drawing.Size(1908, 945); + this.ClientSize = new System.Drawing.Size(1832, 945); + this.Controls.Add(this.flpScripts); + this.Controls.Add(this.lblFilterFreq); + this.Controls.Add(this.chbFilter); + this.Controls.Add(this.btnFilterDrag); this.Controls.Add(this.lblStep); this.Controls.Add(this.numStepVal); this.Controls.Add(this.segMode); @@ -932,7 +1050,6 @@ private void InitializeComponent() this.Controls.Add(this.lblSelMessage); this.Controls.Add(this.label6); this.Controls.Add(this.btnAddScript); - this.Controls.Add(this.flpScripts); this.Controls.Add(this.prbLevelMeter); this.Controls.Add(this.lblLoopDuration); this.Controls.Add(this.txtLoopTime); @@ -989,6 +1106,7 @@ private void InitializeComponent() this.Controls.Add(this.menuStrip1); this.KeyPreview = true; this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "Form1"; this.Text = "Music Analyser"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); @@ -1071,7 +1189,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem saveRecordingToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem stopToolStripMenuItem; - private System.Windows.Forms.FlowLayoutPanel flpScripts; private System.Windows.Forms.Button btnAddScript; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label lblSelMessage; @@ -1085,6 +1202,10 @@ private void InitializeComponent() private XanderUI.XUISegment segMode; private System.Windows.Forms.NumericUpDown numStepVal; private System.Windows.Forms.Label lblStep; + private MusicAnalyser.UI.RoundButton btnFilterDrag; + private System.Windows.Forms.CheckBox chbFilter; + private System.Windows.Forms.Label lblFilterFreq; + private System.Windows.Forms.TableLayoutPanel flpScripts; } } diff --git a/MusicAnalyser/UI/Form1.cs b/MusicAnalyser/UI/Form1.cs index 82bc00d..c4e06fa 100644 --- a/MusicAnalyser/UI/Form1.cs +++ b/MusicAnalyser/UI/Form1.cs @@ -19,6 +19,7 @@ public partial class Form1 : Form private AppController app; private int selectedScript; + private Point filterDragPoint; public Form1() { @@ -27,6 +28,13 @@ public Form1() SetupFFTPlot(); barVolume.Value = 10; SetModeText(""); + flpScripts.AutoScroll = false; + flpScripts.HorizontalScroll.Enabled = false; + flpScripts.HorizontalScroll.Visible = false; + flpScripts.HorizontalScroll.Maximum = 0; + flpScripts.AutoScroll = true; + btnFilterDrag.Location = new Point(spFFT.Location.X + spFFT.Width / 2, spFFT.Location.Y + spFFT.Height / 2); + btnFilterDrag.Draggable(true); flpScripts.Controls.Add(new ScriptSelector(this) { Parent = flpScripts, Label = "Script " + flpScripts.Controls.Count }); flpScripts.Controls.Add(new ScriptSelector(this) { Parent = flpScripts, Label = "Script " + flpScripts.Controls.Count }); OnSelectorChange(); @@ -139,6 +147,7 @@ public void CheckAppState() { btnOpenClose.Text = "Close"; btnOpenClose.Enabled = true; + chbFilter.Enabled = true; if (app.ScriptSelectionValid) { btnPlay.Enabled = true; @@ -167,11 +176,13 @@ public void CheckAppState() btnStop.Enabled = false; stopToolStripMenuItem.Enabled = false; playToolStripMenuItem.Enabled = false; + chbFilter.Enabled = false; } } else if(segMode.SelectedIndex == 1) { - if(app.Opened && app.ScriptSelectionValid) + chbFilter.Enabled = false; + if (app.Opened && app.ScriptSelectionValid) { btnOpenClose.Enabled = true; btnStop.Enabled = true; @@ -184,7 +195,8 @@ public void CheckAppState() } else if(segMode.SelectedIndex == 2) { - if(app.IsRecording) + chbFilter.Enabled = false; + if (app.IsRecording) btnPlay.Text = "Stop Recording"; else btnPlay.Text = "Start Recording"; @@ -212,6 +224,7 @@ private void btnPlay_Click(object sender, EventArgs e) public void ClearUI() { + chbFilter.Checked = false; this.Text = "Music Analyser"; lstChords.Items.Clear(); spFFT.plt.Clear(); @@ -415,9 +428,9 @@ private void timerFFT_Tick(object sender, EventArgs e) private void SetupFFTPlot() { - spFFT.plt.Title("Frequency Spectrum"); - spFFT.plt.YLabel("Magnitude", fontSize: 12); - spFFT.plt.XLabel("Frequency (Hz)", fontSize: 12); + spFFT.plt.Title("Frequency Spectrum", fontName: "Open Sans"); + spFFT.plt.YLabel("Magnitude", fontName: "Open Sans", fontSize: 12); + spFFT.plt.XLabel("Frequency (Hz)", fontName: "Open Sans", fontSize: 12); spFFT.Render(); } @@ -453,7 +466,7 @@ public void DrawPlayUI() public void EnableTimer(bool enable) { timerFFT.Enabled = enable; } public void ClearNotesList() { lstChords.Items.Clear(); } public void PrintChord(string text) { lstChords.Items.Add(text); } - public void PlotNote(string name, double freq, double gain, Color color, bool isBold) { spFFT.plt.PlotText(name, freq, gain, color, fontSize: 16, bold: isBold); } + public void PlotNote(string name, double freq, double gain, Color color, bool isBold) { spFFT.plt.PlotText(name, freq, gain, color, fontName: "Open Sans", fontSize: 16, bold: isBold); } public void SetKeyText(string text) { lblKey.Text = text; } public void SetModeText(string text) { lblMode.Text = text; } public void SetErrorText(string text) { lblError.Text = text; } @@ -525,7 +538,7 @@ private void Form1_KeyDown(object sender, KeyEventArgs e) if (Output != null) app.TriggerPlayPause(); break; - case Keys.Back: + case Keys.F2: if (Output != null) app.TriggerStop(); break; @@ -533,10 +546,10 @@ private void Form1_KeyDown(object sender, KeyEventArgs e) if (Output != null) app.TriggerClose(); break; - case Keys.O: + case Keys.F1: app.TriggerOpenFile(); break; - case Keys.Tab: + case Keys.ShiftKey: if (Output != null) cwvViewer.FitToScreen(); break; @@ -599,7 +612,7 @@ private void btnAddScript_Click(object sender, EventArgs e) private void OnAddScript() { - flpScripts.Controls.Add(new ScriptSelector(this) { Parent = flpScripts, Label = "Script " + flpScripts.Controls.Count }); + flpScripts.Controls.Add(new ScriptSelector(this) { Parent = flpScripts, Label = "Script " + flpScripts.Controls.Count}); app.AddScript(); OnSelectorChange(); } @@ -675,6 +688,7 @@ public void DisplayScriptSettings(int scriptIndex) tblSettings.AutoScroll = false; tblSettings.VerticalScroll.Visible = false; tblSettings.AutoScroll = true; + int scrollWidth = 10; Dictionary settings = app.GetScriptSettings(scriptIndex); @@ -688,11 +702,12 @@ public void DisplayScriptSettings(int scriptIndex) { btnDefaults.Enabled = true; tblSettings.ColumnCount = 2; - tblSettings.ColumnStyles[0] = new ColumnStyle(SizeType.Absolute, 220); + tblSettings.ColumnStyles[0] = new ColumnStyle(SizeType.AutoSize); foreach (string[] setting in settings.Values) { tblSettings.RowCount++; - tblSettings.Controls.Add(new Label() { Text = setting[2], MaximumSize = new Size(220, 0), AutoSize = true }, 0, tblSettings.RowCount - 1); + tblSettings.Controls.Add(new Label() { Text = setting[2], MinimumSize = new Size(tblSettings.Size.Width / 2 - scrollWidth, 0), + MaximumSize = new Size((int)(tblSettings.Size.Width / 1.75) - scrollWidth, 0), AutoSize = true }, 0, tblSettings.RowCount - 1); if (setting[1] == "int") { var control = new NumericUpDown() @@ -700,7 +715,7 @@ public void DisplayScriptSettings(int scriptIndex) Minimum = int.Parse(setting[3]), Maximum = int.Parse(setting[4]), Value = int.Parse(setting[0]), - Size = new Size(100, 20) + Size = new Size(95, 20), }; control.ValueChanged += new EventHandler(SettingChanged); tblSettings.Controls.Add(control, 1, tblSettings.RowCount - 1); @@ -713,7 +728,7 @@ public void DisplayScriptSettings(int scriptIndex) Maximum = (decimal)double.Parse(setting[4]), Value = (decimal)double.Parse(setting[0]), DecimalPlaces = 2, - Size = new Size(100, 20) + Size = new Size(95, 20) }; control.ValueChanged += new EventHandler(SettingChanged); tblSettings.Controls.Add(control, 1, tblSettings.RowCount - 1); @@ -721,6 +736,7 @@ public void DisplayScriptSettings(int scriptIndex) else if(setting[1] == "enum") { var control = new ComboBox(); + control.Size = new Size(95, 20); string[] options = setting[3].Split('|'); control.Items.AddRange(options); control.SelectedItem = setting[0]; @@ -730,6 +746,7 @@ public void DisplayScriptSettings(int scriptIndex) else { var control = new TextBox() { Text = setting[0] }; + control.Size = new Size(95, 20); control.TextChanged += new EventHandler(SettingChanged); tblSettings.Controls.Add(control, 1, tblSettings.RowCount - 1); } @@ -801,5 +818,45 @@ private void numStepVal_ValueChanged(object sender, EventArgs e) { app.StepMilliseconds = (int)numStepVal.Value; } + + private void btnFilterDrag_Move(object sender, EventArgs e) + { + if(btnFilterDrag.Location.X > spFFT.Location.X + 50 && btnFilterDrag.Location.X < spFFT.Location.X + spFFT.Width - 40 + && btnFilterDrag.Location.Y > spFFT.Location.Y + 20 && btnFilterDrag.Location.Y < spFFT.Location.Y + spFFT.Height - 60) + { + if (Output != null) + { + lblFilterFreq.Location = new Point(btnFilterDrag.Location.X + 35, btnFilterDrag.Location.Y + 5); + double xCoord = spFFT.plt.CoordinateFromPixelX(btnFilterDrag.Location.X); + double yPercent = (double)Math.Abs(btnFilterDrag.Location.Y - (spFFT.Location.Y + spFFT.Height - 60)) / (spFFT.Height - 80); + app.GetFilterRange(xCoord, yPercent); + } + } + else + { + btnFilterDrag.Location = filterDragPoint; + } + filterDragPoint = btnFilterDrag.Location; + } + + private void chbFilter_CheckedChanged(object sender, EventArgs e) + { + if(chbFilter.Checked) + { + btnFilterDrag.Enabled = true; + btnFilterDrag.Visible = true; + lblFilterFreq.Visible = true; + btnFilterDrag_Move(null, null); + } + else + { + btnFilterDrag.Enabled = false; + btnFilterDrag.Visible = false; + lblFilterFreq.Visible = false; + app.SetFilter(20000, 20, 10000, 1, 1); + } + } + + public void SetFilterText(string note, double freq) { lblFilterFreq.Text = note + "\n" + Math.Round(freq, 1) + " Hz"; } } } diff --git a/MusicAnalyser/UI/RoundButton.cs b/MusicAnalyser/UI/RoundButton.cs new file mode 100644 index 0000000..8fd8b2c --- /dev/null +++ b/MusicAnalyser/UI/RoundButton.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Drawing.Drawing2D; +using System.Drawing; + +namespace MusicAnalyser.UI +{ + class RoundButton : Button + { + public RoundButton() + { + TabStop = false; + FlatStyle = FlatStyle.Flat; + FlatAppearance.BorderSize = 0; + FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255); + } + + protected override void OnPaint(PaintEventArgs e) + { + GraphicsPath graphics = new GraphicsPath(); + graphics.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height); + Region = new Region(graphics); + base.OnPaint(e); + } + } +} diff --git a/MusicAnalyser/UI/ScriptSelector.Designer.cs b/MusicAnalyser/UI/ScriptSelector.Designer.cs index 491c82a..fe30541 100644 --- a/MusicAnalyser/UI/ScriptSelector.Designer.cs +++ b/MusicAnalyser/UI/ScriptSelector.Designer.cs @@ -36,9 +36,12 @@ private void InitializeComponent() // cbScript // this.cbScript.FormattingEnabled = true; - this.cbScript.Location = new System.Drawing.Point(63, 3); + this.cbScript.Location = new System.Drawing.Point(47, 2); + this.cbScript.Margin = new System.Windows.Forms.Padding(2); + this.cbScript.MaximumSize = new System.Drawing.Size(114, 0); + this.cbScript.MinimumSize = new System.Drawing.Size(50, 0); this.cbScript.Name = "cbScript"; - this.cbScript.Size = new System.Drawing.Size(121, 24); + this.cbScript.Size = new System.Drawing.Size(96, 21); this.cbScript.TabIndex = 0; this.cbScript.SelectedIndexChanged += new System.EventHandler(this.cbScript_SelectedIndexChanged); this.cbScript.Click += new System.EventHandler(this.cbScript_Click); @@ -46,18 +49,21 @@ private void InitializeComponent() // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(3, 6); + this.label1.Font = new System.Drawing.Font("Open Sans", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(2, 4); + this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(60, 17); + this.label1.Size = new System.Drawing.Size(45, 15); this.label1.TabIndex = 1; - this.label1.Text = "Script 1:"; + this.label1.Text = "Script 1"; this.label1.Click += new System.EventHandler(this.label1_Click); // // btnRemove // - this.btnRemove.Location = new System.Drawing.Point(190, 4); + this.btnRemove.Location = new System.Drawing.Point(147, 4); + this.btnRemove.Margin = new System.Windows.Forms.Padding(2); this.btnRemove.Name = "btnRemove"; - this.btnRemove.Size = new System.Drawing.Size(30, 23); + this.btnRemove.Size = new System.Drawing.Size(22, 19); this.btnRemove.TabIndex = 2; this.btnRemove.Text = "X"; this.btnRemove.TextAlign = System.Drawing.ContentAlignment.TopCenter; @@ -66,13 +72,15 @@ private void InitializeComponent() // // ScriptSelector // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.Controls.Add(this.btnRemove); this.Controls.Add(this.label1); this.Controls.Add(this.cbScript); + this.Margin = new System.Windows.Forms.Padding(2); this.Name = "ScriptSelector"; - this.Size = new System.Drawing.Size(224, 32); + this.Size = new System.Drawing.Size(172, 25); this.ResumeLayout(false); this.PerformLayout(); diff --git a/MusicAnalyser/UI/ScriptSelector.cs b/MusicAnalyser/UI/ScriptSelector.cs index ce63d20..3e7156d 100644 --- a/MusicAnalyser/UI/ScriptSelector.cs +++ b/MusicAnalyser/UI/ScriptSelector.cs @@ -1,13 +1,5 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; -using System.Diagnostics; namespace MusicAnalyser.UI { diff --git a/MusicAnalyser/packages.config b/MusicAnalyser/packages.config index 892a486..5384762 100644 --- a/MusicAnalyser/packages.config +++ b/MusicAnalyser/packages.config @@ -3,11 +3,12 @@ + - - - + + + \ No newline at end of file