Skip to content

Commit

Permalink
1.1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonako1 committed May 6, 2024
1 parent 1a8e1ac commit 68b7733
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 122 deletions.
4 changes: 3 additions & 1 deletion AudioWhisper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
<ItemGroup>
<PackageReference Include="NAudio" Version="2.2.1" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="SharpHook" Version="5.3.2" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- 1 = Edit values
- 2 = Help message
- 3 = Return
- F7 = Toggle playback while app is out of focus
- Q = Exit program

---
Expand Down
14 changes: 1 addition & 13 deletions build_setup_executable.bat
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
@ECHO OFF
SET "outputPath=.\nsis"
SET "inputPath=.\bin\Debug\net7.0\publish"
SET "inputPath=.\bin\Release\net7.0\win10-x64\publish"

COPY /Y .\src\json\save.json %outputPath%
RENAME %outputPath%\save.json backup_save.json
COPY /Y .\src\json\save.json %outputPath%
COPY /Y license.txt %outputPath%
COPY /Y AudioWhisper.ico %outputPath%
COPY /Y %inputPath%\AudioWhisper.exe %outputPath%
COPY /Y %inputPath%\AudioWhisper.dll %outputPath%
COPY /Y %inputPath%\AudioWhisper.deps.json %outputPath%
COPY /Y %inputPath%\AudioWhisper.dll %outputPath%
COPY /Y %inputPath%\AudioWhisper.exe %outputPath%
COPY /Y %inputPath%\AudioWhisper.pdb %outputPath%
COPY /Y %inputPath%\AudioWhisper.runtimeconfig.json %outputPath%
COPY /Y %inputPath%\NAudio.Asio.dll %outputPath%
COPY /Y %inputPath%\NAudio.Core.dll %outputPath%
COPY /Y %inputPath%\NAudio.dll %outputPath%
COPY /Y %inputPath%\NAudio.Midi.dll %outputPath%
COPY /Y %inputPath%\NAudio.Wasapi.dll %outputPath%
COPY /Y %inputPath%\NAudio.WinMM.dll %outputPath%
makensis.exe %outputPath%\script.nsi
IF NOT EXIST ".\build\" MKDIR .\build\
COPY /B /Y .\nsis\AudioWhisper-Setup.exe .\build\
Expand Down
104 changes: 2 additions & 102 deletions nsis/script.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Var /GLOBAL switch_overwrite
Outfile "AudioWhisper-Setup.exe"
RequestExecutionLevel admin

BrandingText /TRIMCENTER "AudioWhisper 1.0.2 Setup"
Name "AudioWhisper 1.0.2 Setup"
BrandingText /TRIMCENTER "AudioWhisper 1.1.0.4 Setup"
Name "AudioWhisper 1.1.0.4 Setup"
ManifestSupportedOS Win10
DetailsButtonText "Show progress"

Expand Down Expand Up @@ -53,61 +53,6 @@ SectionGroup "!Main Program" RO
SectionIn 1 ${sec1_id}
File "license.txt"
SectionEnd
Section !AudioWhisper.dll sec2_id
SectionInstType ${IT_FULL} ${IT_MIN} RO
SectionIn 1 ${sec1_id}
SetOutPath "$TEMP\temp_AudioWhisper_mic_playback"
File "AudioWhisper.dll"
SectionEnd

Section !AudioWhisper.deps.json sec10_id
SectionInstType ${IT_FULL} ${IT_MIN} RO
SectionIn 1 ${sec1_id}
SetOutPath "$TEMP\temp_AudioWhisper_mic_playback"
File "AudioWhisper.deps.json"
SectionEnd
Section !AudioWhisper.runtimeconfig.json sec11_id
SectionInstType ${IT_FULL} ${IT_MIN} RO
SectionIn 1 ${sec1_id}
SetOutPath "$TEMP\temp_AudioWhisper_mic_playback"
File "AudioWhisper.runtimeconfig.json"
SectionEnd
Section !NAudio.Asio.dll sec12_id
SectionInstType ${IT_FULL} ${IT_MIN} RO
SectionIn 1 ${sec1_id}
SetOutPath "$TEMP\temp_AudioWhisper_mic_playback"
File "NAudio.Asio.dll"
SectionEnd
Section !NAudio.Core.dll sec13_id
SectionInstType ${IT_FULL} ${IT_MIN} RO
SectionIn 1 ${sec1_id}
SetOutPath "$TEMP\temp_AudioWhisper_mic_playback"
File "NAudio.Core.dll"
SectionEnd
Section !NAudio.dll sec14_id
SectionInstType ${IT_FULL} ${IT_MIN} RO
SectionIn 1 ${sec1_id}
SetOutPath "$TEMP\temp_AudioWhisper_mic_playback"
File "NAudio.dll"
SectionEnd
Section !NAudio.Midi.dll sec15_id
SectionInstType ${IT_FULL} ${IT_MIN} RO
SectionIn 1 ${sec1_id}
SetOutPath "$TEMP\temp_AudioWhisper_mic_playback"
File "NAudio.Midi.dll"
SectionEnd
Section !NAudio.Wasapi.dll sec16_id
SectionInstType ${IT_FULL} ${IT_MIN} RO
SectionIn 1 ${sec1_id}
SetOutPath "$TEMP\temp_AudioWhisper_mic_playback"
File "NAudio.Wasapi.dll"
SectionEnd
Section !NAudio.WinMM.dll sec17_id
SectionInstType ${IT_FULL} ${IT_MIN} RO
SectionIn 1 ${sec1_id}
SetOutPath "$TEMP\temp_AudioWhisper_mic_playback"
File "NAudio.WinMM.dll"
SectionEnd
Section !AudioWhisper.ico sec18_id
SectionInstType ${IT_FULL} ${IT_MIN} RO
SectionIn 1 ${sec1_id}
Expand Down Expand Up @@ -192,19 +137,10 @@ Section
; Delete the $TEMP folder stuff before extracting more files
; and taking up more space from the disk
Delete "$TEMP\temp_AudioWhisper_mic_playback\AudioWhisper.exe"
Delete "$TEMP\temp_AudioWhisper_mic_playback\AudioWhisper.dll"
Delete "$TEMP\temp_AudioWhisper_mic_playback\license.txt"
Delete "$TEMP\temp_AudioWhisper_mic_playback\Uninstall.exe"
Delete "$TEMP\temp_AudioWhisper_mic_playback\Setup.ps1"
Delete "$TEMP\temp_AudioWhisper_mic_playback\Uninstall.ps1"
Delete "$TEMP\temp_AudioWhisper_mic_playback\AudioWhisper.deps.json"
Delete "$TEMP\temp_AudioWhisper_mic_playback\AudioWhisper.runtimeconfig.json"
Delete "$TEMP\temp_AudioWhisper_mic_playback\NAudio.Asio.dll"
Delete "$TEMP\temp_AudioWhisper_mic_playback\NAudio.Core.dll"
Delete "$TEMP\temp_AudioWhisper_mic_playback\NAudio.dll"
Delete "$TEMP\temp_AudioWhisper_mic_playback\NAudio.Midi.dll"
Delete "$TEMP\temp_AudioWhisper_mic_playback\NAudio.Wasapi.dll"
Delete "$TEMP\temp_AudioWhisper_mic_playback\NAudio.WinMM.dll"
Delete "$TEMP\temp_AudioWhisper_mic_playback\save.json"
Delete "$TEMP\temp_AudioWhisper_mic_playback\backup_save.json"
Delete "$TEMP\temp_AudioWhisper_mic_playback\AudioWhisper.ico"
Expand Down Expand Up @@ -293,38 +229,11 @@ ${EndIf}
${If} ${SectionIsSelected} ${sec1_id}
File "AudioWhisper.exe"
${EndIf}
${If} ${SectionIsSelected} ${sec2_id}
File "AudioWhisper.dll"
${EndIf}

${If} ${SectionIsSelected} ${sec7_id}
File "license.txt"
${EndIf}

${If} ${SectionIsSelected} ${sec10_id}
File "AudioWhisper.deps.json"
${EndIf}
${If} ${SectionIsSelected} ${sec11_id}
File "AudioWhisper.runtimeconfig.json"
${EndIf}
${If} ${SectionIsSelected} ${sec12_id}
File "NAudio.Asio.dll"
${EndIf}
${If} ${SectionIsSelected} ${sec13_id}
File "NAudio.Core.dll"
${EndIf}
${If} ${SectionIsSelected} ${sec14_id}
File "NAudio.dll"
${EndIf}
${If} ${SectionIsSelected} ${sec15_id}
File "NAudio.Midi.dll"
${EndIf}
${If} ${SectionIsSelected} ${sec16_id}
File "NAudio.Wasapi.dll"
${EndIf}
${If} ${SectionIsSelected} ${sec17_id}
File "NAudio.WinMM.dll"
${EndIf}
${If} ${SectionIsSelected} ${sec18_id}
File "AudioWhisper.ico"
${EndIf}
Expand Down Expand Up @@ -368,19 +277,10 @@ nsExec::ExecToLog 'Powershell.exe -ExecutionPolicy Bypass -File "$INSTDIR\Uninst

Delete "$INSTDIR\AudioWhisper.exe"
Delete "$INSTDIR\save.json"
Delete "$INSTDIR\AudioWhisper.dll"
Delete "$INSTDIR\Uninstall.exe"
Delete "$INSTDIR\license.txt"
Delete "$INSTDIR\Uninstall.ps1"
Delete "$INSTDIR\Setup.ps1"
Delete "$INSTDIR\AudioWhisper.deps.json"
Delete "$INSTDIR\AudioWhisper.runtimeconfig.json"
Delete "$INSTDIR\NAudio.Asio.dll"
Delete "$INSTDIR\NAudio.Core.dll"
Delete "$INSTDIR\NAudio.dll"
Delete "$INSTDIR\NAudio.Midi.dll"
Delete "$INSTDIR\NAudio.Wasapi.dll"
Delete "$INSTDIR\NAudio.WinMM.dll"
Delete "$INSTDIR\AudioWhisper.ico"
Delete "$INSTDIR\save.json"
Delete "$INSTDIR\old_save.json"
Expand Down
68 changes: 64 additions & 4 deletions src/audio.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NAudio.Wave;
using NAudio.Dsp;
using System;

using SharpHook;
class Program {
public static string appdata_location = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Temp\\temp_AudioWhisper_mic_playback\\";
private static File_reader? json_file_reader = new();
Expand All @@ -11,7 +11,15 @@ static void Main(string[] args) {

// Create new folder
System.IO.Directory.CreateDirectory(appdata_location);
EmptyDir();
try{
EmptyDir();
} catch (Exception e){
Console.BackgroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Error. Audio file may be in use or the executable doesn't have permissions to read/write it: " + e.Message);
Console.ResetColor();
Environment.Exit(1);
}
Console.Clear();
Program audioplayer = new();
}
Expand All @@ -29,8 +37,9 @@ static void EmptyDir(){
private static WaveOutEvent? player;
private static bool playing = false;
private static SavingWaveProvider? filterSampleProvider;
private SharpHook.Native.KeyCode? hookKeyPress;

private static readonly string help_message = "Press '1' to start, '2' to stop, '3' to edit settings, 'Q' to exit.";
private static readonly string help_message = "Press '1' to start, '2' to stop, '3' to edit settings, 'F7' to toggle mic playback while out of focus, 'Q' to exit.";
public Program(){
// CHECK IF old_save.json EXISTS
if(settings.QuietStartMessage == false){
Expand Down Expand Up @@ -77,7 +86,30 @@ public Program(){
EmptyDir();
StartRecording();
}
// Init hook
InitializeSharpHook();
while (true){
// First try hook presses
// switch(hookKeyPress){
// case SharpHook.Native.KeyCode.VcF7:
// if(playing){
// playing = true;
// Global.playing = playing;
// StopRecording();
// EmptyDir();
// StartRecording();
// Console_writing("main");
// }
// else{
// playing = false;
// Global.playing = playing;
// StopRecording();
// EmptyDir();
// Console_writing("main");
// }
// continue;
// }

var key = Console.ReadKey().Key;
switch (key){
case ConsoleKey.D1:
Expand Down Expand Up @@ -111,10 +143,12 @@ public Program(){
EmptyDir();
Environment.Exit(0);
break;
case ConsoleKey.F7: break; // fallthrough
default:
Console_writing("error");
break;
}
// hookKeyPress = null;
}
}

Expand Down Expand Up @@ -189,7 +223,7 @@ private static void Console_writing(string what){
Console.Clear();
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"AudioWhisper 1.0.2. Active: {Global.playing}");
Console.WriteLine($"AudioWhisper 1.1.0.4. Active: {Global.playing}");
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Currently in:");
Expand All @@ -211,5 +245,31 @@ private static void Console_writing(string what){
}
Console.ResetColor();
}
private void OnKeyReleased(object? sender, KeyboardHookEventArgs e){
switch(e.Data.KeyCode){
case SharpHook.Native.KeyCode.VcF7:
if(!playing){
playing = true;
Global.playing = playing;
StopRecording();
EmptyDir();
StartRecording();
Console_writing("main");
}
else{
playing = false;
Global.playing = playing;
StopRecording();
EmptyDir();
Console_writing("main");
}
break;
}
}
private async void InitializeSharpHook(){
var hook = new TaskPoolGlobalHook();
hook.KeyReleased += OnKeyReleased; // EventHandler<KeyboardHookEventArgs>
await hook.RunAsync();
}
}

2 changes: 1 addition & 1 deletion src/read_saves.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ private void Console_writing(string what){
Console.Clear();
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"AudioWhisper 1.0.2. Active: {Global.playing}");
Console.WriteLine($"AudioWhisper 1.1.0.4. Active: {Global.playing}");
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Blue;
Console.WriteLine("Currently in:");
Expand Down
2 changes: 1 addition & 1 deletion zero_build.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dotnet publish
dotnet publish -r win10-x64 -c Release /p:PublishSingleFile=true --self-contained
build_setup_executable.bat

0 comments on commit 68b7733

Please sign in to comment.