diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index e668cc2..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: 1.0.{build} -build: - verbosity: minimal -artifacts: - - path: PK Piano\bin\Debug\PK Piano.exe - name: PKPiano - type: zip diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ec389b8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: csharp -script: - - msbuild /version - - msbuild /p:Configuration=Release "PK Piano/PK Piano.csproj" diff --git a/PK Piano/App.config b/PK Piano/App.config index d0f8440..92c094c 100644 --- a/PK Piano/App.config +++ b/PK Piano/App.config @@ -2,5 +2,5 @@ - + diff --git a/PK Piano/Form1.cs b/PK Piano/Form1.cs index 5ce5b8c..618b9ab 100644 --- a/PK Piano/Form1.cs +++ b/PK Piano/Form1.cs @@ -1,10 +1,9 @@ -using System; -using System.Windows.Forms; -using System.Media; -using System.Text; -using NAudio.Wave; +using NAudio.Wave; using NAudio.Wave.SampleProviders; +using System; using System.Collections.Generic; +using System.Media; +using System.Windows.Forms; namespace PK_Piano { @@ -731,43 +730,44 @@ private void btnMPTconvert_Click(object sender, EventArgs e) private void btnC8eraser_Click(object sender, EventArgs e) { //VALIDATION - //string clipboardContents = Clipboard.GetText(); - //if (string.IsNullOrWhiteSpace(clipboardContents)) return; //only continue if there's something there - //if (clipboardContents.Contains("Not enough rows to process")) return; - - //clipboardContents = clipboardContents.Replace("[", "").Replace("]", ""); //get rid of brackets - //var input = SongPiece.StringToBytes(clipboardContents); - var input = SongPiece.StringToBytes("0C 7F A7 C8 0C A7 C8"); - var goodVersion = SongPiece.StringToBytes("18 7F A7 18 A7"); + string clipboardContents = Clipboard.GetText(); + if (string.IsNullOrWhiteSpace(clipboardContents)) return; //only continue if there's something there + if (clipboardContents.Contains("Not enough rows to process")) return; + clipboardContents = clipboardContents.Replace("[", "").Replace("]", ""); //get rid of brackets + + List input; + + try + { + input = SongPiece.StringToBytes(clipboardContents); + } + catch(Exception ex) + { + MessageBox.Show(ex.Message); + return; + } + + //var input = SongPiece.StringToBytes("0C A7 C8 C8"); //DIY Unit Test + //var goodVersion = SongPiece.StringToBytes("24 A7"); var optimizedBytes = ProcessBytes(input); + //RunTest(optimizedBytes, goodVersion); - RunTest(optimizedBytes, goodVersion); - //Clipboard.SetText(result.ToString()); + Clipboard.SetText(optimizedBytes); if (sfxEnabled) sfxEquipped.Play(); } - public static List ProcessBytes(List bytesInput) + public static string ProcessBytes(List bytesInput) { + const string NO_NOTE_LENGTH_ERROR = "In order for the C8 Eraser function to work correctly, each note needs a note length in front of it."; var result = new List(); var piece = new SongPiece(); bool lastByteWasANote = false; bool lastByteWasANoteLength = false; - bool lastByteWasAnEffect = false; - int effectSkip = 0; foreach (var b in bytesInput) { - if (effectSkip > 0) //for effects with parameters, which shouldn't be processed - { - effectSkip--; - piece.tempNoteCollection.Add(b); //add the effect, byte by byte - continue; - } - - if (lastByteWasAnEffect) + if (piece.tempNoteCollection.Count > 1) { - result.AddRange(piece.ParseHex()); - piece = new SongPiece(piece.noteLength, piece.noteLengthMultiplier); //keep the old note settings! - lastByteWasAnEffect = false; + throw new Exception(NO_NOTE_LENGTH_ERROR); } if (SongPiece.IsNoteLength(b)) @@ -805,61 +805,74 @@ public static List ProcessBytes(List bytesInput) if (b == 0xC8) { piece.noteLengthMultiplier++; //keep track of how many C8s there have been - continue; } else { piece.tempNoteCollection.Add(b); //add the note to the collection } + continue; } if (SongPiece.IsEffect(b)) { - effectSkip = SongPiece.GetNumberOfParameters(b); - piece.tempNoteCollection.Add(b); - lastByteWasAnEffect = true; + //I'm abandoning this functionality, but if anyone would like to try + //implementing it, I'd greatly appreciate it. + throw new Exception($"Effects such as {b:X2} are not supported yet."); } } + if (piece.noteLength == 0xFF) + { + throw new Exception(NO_NOTE_LENGTH_ERROR); + } + //Add any remaining notes to result result.AddRange(piece.ParseHex()); - return result; - } - public static void RunTest(List resultBytes, List goodVersionBytes) - { - //DIY unit test - string result = ""; - foreach (var b in resultBytes) + //Convert the byte array to a string + var resultString = ""; + foreach (var num in result) { - result += b.ToString("X2") + " "; //convert the list back into a string + resultString += num.ToString("X2") + ' '; } - string goodVersion = ""; - foreach (var b in goodVersionBytes) - { - goodVersion += b.ToString("X2") + " "; //convert the list back into a string - } + return resultString.TrimEnd(' '); + } - result = result.Trim(); - goodVersion = goodVersion.Trim(); + //public static void RunTest(List resultBytes, List goodVersionBytes) + //{ + // //DIY Unit Test + // string result = ""; + // foreach (var b in resultBytes) + // { + // result += b.ToString("X2") + " "; //convert the list back into a string + // } - var message = ""; - if (result == goodVersion) - message += "*** PASS ***\r\n"; - else - message += "*** FAIL ***\r\n"; - message += "Result:\r\n" + result + "\r\nDesired output:\r\n" + goodVersion; - MessageBox.Show(message); - } + // string goodVersion = ""; + // foreach (var b in goodVersionBytes) + // { + // goodVersion += b.ToString("X2") + " "; //convert the list back into a string + // } + + // result = result.Trim(); + // goodVersion = goodVersion.Trim(); + + // var message = ""; + // if (result == goodVersion) + // message += "*** PASS ***\r\n"; + // else + // message += "*** FAIL ***\r\n"; + // message += "Result:\r\n" + result + "\r\nDesired output:\r\n" + goodVersion; + // MessageBox.Show(message); + //} //Text blip stuff //If the sfxEnabled boolean value is set to true, then various parts of the UI will give audio feedback. //I'm getting kind of tired of it, though, so I'm going to make it toggleable in the future. byte numberOfLettersBeforeSound; - SoundPlayer sfxTextBlip = new SoundPlayer(Properties.Resources.ExtraAudio_Text_Blip); //adding these so it doesn't make a new instance of SoundPlayer *every* time - SoundPlayer sfxEquipped = new SoundPlayer(Properties.Resources.ExtraAudio_Equipped_); + readonly SoundPlayer sfxTextBlip = new SoundPlayer(Properties.Resources.ExtraAudio_Text_Blip); //adding these so it doesn't make a new instance of SoundPlayer *every* time + readonly SoundPlayer sfxEquipped = new SoundPlayer(Properties.Resources.ExtraAudio_Equipped_); private void PlayTextTypeSound(string type) { @@ -958,6 +971,14 @@ private void Form1_Load(object sender, EventArgs e) toolTip1.SetToolTip(btnCopySlidingPan, "[E2 length panning]"); toolTip1.SetToolTip(btnCopySlidingVolume, "[EE length volume]"); + toolTip1.SetToolTip(btnTremolo, "[EB start speed range]"); + toolTip1.SetToolTip(btnChannelTranspose, "Transpose a channel by a number of semitones."); + toolTip1.SetToolTip(btnMPTconvert, "Convert a single channel of notes copied from an OpenMPT module."); + toolTip1.SetToolTip(btnC8eraser, "Take a bunch of notes in the clipboard and attempt to optimize them."); + + toolTip1.SetToolTip(btnTempo, "[E7 tempo]"); + toolTip1.SetToolTip(btnGlobalVolume, "[E5 volume]"); + //toolTip1.SetToolTip(ANYTHING, ""); //toolTip1.SetToolTip(ANYTHING, ""); //toolTip1.SetToolTip(ANYTHING, ""); diff --git a/PK Piano/PK Piano.csproj b/PK Piano/PK Piano.csproj index e75571e..b8b6cea 100644 --- a/PK Piano/PK Piano.csproj +++ b/PK Piano/PK Piano.csproj @@ -9,11 +9,13 @@ Properties PK_Piano PK Piano - v4.7.2 + v4.8 512 false - C:\Users\Vince\Desktop\delet this\ + + + C:\Users\vince\Dropbox\Programming scratchpad\pkpiano\Release Dump\ true Disk false @@ -22,12 +24,13 @@ Days false false - true - 1 - 1.0.0.%2a + false + false + 0 + 3.0.0.0 false true - true + false AnyCPU @@ -51,7 +54,7 @@ prompt 4 false - false + true 6FC77D3DBEDC95B0D2E84C0F2A870F4F20B6C0A3 @@ -79,6 +82,11 @@ Properties\app.manifest + + ..\packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll + True + True + ..\packages\Microsoft.Win32.Registry.4.7.0\lib\net461\Microsoft.Win32.Registry.dll @@ -104,13 +112,134 @@ ..\packages\NAudio.WinMM.2.0.1\lib\netstandard2.0\NAudio.WinMM.dll + + ..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll + True + True + + + + ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll + True + True + + + ..\packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll + True + True + + + ..\packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll + True + True + + + ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll + True + True + + + ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + True + True + + + + ..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll + True + True + + + ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + True + True + + + ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + True + True + + + ..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll + True + True + + + ..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll + True + True + + + ..\packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll + True + True + + + ..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll + True + True + + + + ..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll + True + True + + + ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll + True + True + + + ..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll + True + True + + + ..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll + True + True + + + ..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + True + True + ..\packages\System.Security.AccessControl.4.7.0\lib\net461\System.Security.AccessControl.dll + + ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll + True + True + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + True + ..\packages\System.Security.Principal.Windows.4.7.0\lib\net461\System.Security.Principal.Windows.dll + + ..\packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll + True + True + @@ -119,6 +248,11 @@ + + ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + True + True + @@ -162,9 +296,9 @@ - + False - Microsoft .NET Framework 4 %28x86 and x64%29 + Microsoft .NET Framework 4.8 %28x86 and x64%29 true @@ -191,6 +325,18 @@ + + + False + + + + + Exclude + True + File + +