In Turbo C++ we have a header file called dos.h
which exposes three functions sound
, nosound
and delay
. Using these three functions it was possible to write a rudimentary piano program in C++.
I wanted to achieve the same result using Java. My options were either to use the library provided by jfugue or javax.sound.sampled
. The problem is that I don't know the duration each note is played beforehand.
I want to start playing a certain frequency when the user presses a certain key and stop only when the user releases it. How may I tackle this problem?