Note that there are some explanatory texts on larger screens.

plurals
  1. POPlay one of more wav files while key is pressed
    primarykey
    data
    text
    <p>I need to play a sound or sounds while a key is pressed, when the key or keys are no longer pressed the sound stops immediately.</p> <p>I am currently using BASS.net sound library and the sound is called like this:</p> <pre><code> public class Foo { public static int GetStream1(string path) { return Bass.BASS_StreamCreateFile(path, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN); } public static int GetStream2(string path) { return Bass.BASS_StreamCreateFile(path, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN); } } private void setupPlayer() { stream1 = Foo.GetStream1(path1.Text); stream2 = Foo.GetStream2(path2.Text); } //when the key1 is down/something to handle when the key is down Bass.BASS_Init(1, 44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle); Bass.BASS_SetDevice(1); Bass.BASS_ChannelPlay(Foo.GetStream1(path1.Text), false); //when the key1 is up/something to handle when the key is up Bass.BASS_StreamFree(Foo.GetStream1(path1.Text)); Bass.BASS_SetDevice(1); Bass.BASS_Free(); //when the key2 is down/something to handle when the key is down Bass.BASS_Init(2, 44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle); Bass.BASS_SetDevice(2); Bass.BASS_ChannelPlay(Foo.GetStream1(path2.Text), false); //when the key2 is up/something to handle when the key is up Bass.BASS_StreamFree(Foo.GetStream2(path2.Text)); Bass.BASS_SetDevice(2); Bass.BASS_Free(); </code></pre> <p>As I said when the key is down play the sound, when the key is up the sound stops. In adition, you can press more than 1 key and the files will play independently of the other key pressed or released, in other terms, pressing and releasing a key should not affect the other keys being pressed or released at the same time.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload