Beispiel #1
0
        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;
            }
        }