0

I want to be able to use my computer keyboard as a piano keyboard, however the default version of AutoHotkey only supports one "voice" at a time. I tried running an instance for each note, but that doesn't fix it if I press the same note repeatedly.

I found this thread on how this might be solved with the BASS library, but I'm pretty green when it comes to coding and so I'm not certain how to incorporate the library into my simple code.

Here's another similar forum that might solve things, but it has a delay and the overlapping solution doesn't really solve my issue.

This is such a simple idea (play sound when a button is pressed), but somehow it's way out of my depth. Currently my code looks like this:

~1::
SoundPlay, C:\Users\Fires\Downloads\2489__jobro__piano-ff\39187__jobro__piano-ff-040.wav 

for each note

Edit:

~a::
FileDelete, %A_ScriptDIR%\Sound1.AHK
FileAppend,
(
SoundPlay, C:\Users\Fires\Desktop\New folder (4)\043.wav, Wait
), %A_ScriptDir%\Sound1.AHK
Run, %A_ScriptDIR%\Sound1.AHK
Return

is what I am using now, but it's still iffy when two are pressed at the same time.

karel
  • 5,489
  • 46
  • 45
  • 50

1 Answers1

0

Its likely due to the "Wait". according to the documentation: https://autohotkey.com/docs/commands/SoundPlay.htm

"If a file is playing and the current script plays a second file, the first file will be stopped so that the second one can play. On some systems, certain file types might stop playing even when an entirely separate script plays a new file."

It looks like this is an "issue" with AutoHotKey. And its not possible to open multiple "voices" or simultaneous sounds. it is completely possible to make a C# program that does the same thing, I've done it before. and i have bits of the code now still (it plays midi sounds, instead of wavs, but same concept play notes asynchronously).