void IZMachineIO.PlaySoundSample(ushort number, SoundAction action, byte volume, byte repeats, SoundFinishedCallback callback) { switch (action) { case SoundAction.Prepare: Glk.glk_sound_load_hint(number, true); break; case SoundAction.FinishWith: Glk.glk_sound_load_hint(number, false); break; case SoundAction.Start: if (soundChannel.IsNull) { soundChannel = Glk.glk_schannel_create(0); } if (!soundChannel.IsNull) { volume = Math.Min(volume, (byte)8); Glk.glk_schannel_set_volume(soundChannel, (uint)(volume << 13)); soundCallback = callback; Glk.glk_schannel_play_ext(soundChannel, number, repeats, 1); } break; case SoundAction.Stop: if (!soundChannel.IsNull) { Glk.glk_schannel_stop(soundChannel); soundChannel = schanid_t.Null; soundCallback = null; } break; } }
public static extern void glk_schannel_set_volume(schanid_t chan, uint vol);
public static extern void glk_schannel_stop(schanid_t chan);
public static extern uint glk_schannel_play_ext(schanid_t chan, uint snd, uint repeats, uint notify);
public static extern uint glk_schannel_play(schanid_t chan, uint snd);
public static extern uint glk_schannel_get_rock(schanid_t chan);
public static extern schanid_t glk_schannel_iterate(schanid_t chan, out uint rockptr);
public static extern void glk_schannel_destroy(schanid_t chan);