Low level sound player */
| 96 | |
| 97 | /* Low level sound player */ |
| 98 | static void StartSound(SoundID sound_id, float pan, uint volume) |
| 99 | { |
| 100 | if (volume == 0) return; |
| 101 | |
| 102 | SoundEntry *sound = GetSound(sound_id); |
| 103 | if (sound == nullptr) return; |
| 104 | |
| 105 | if (sound->rate == 0) { |
| 106 | /* If the sound's sample rate is not set then the sound needs to be loaded, but if the sound's file pointer |
| 107 | * is empty then an attempt was already made to load the sound but it failed. We don't want to try again. */ |
| 108 | if (sound->file == nullptr) return; |
| 109 | } |
| 110 | |
| 111 | MixerChannel *mc = MxAllocateChannel(); |
| 112 | if (mc == nullptr) return; |
| 113 | |
| 114 | if (!SetBankSource(mc, sound, sound_id)) return; |
| 115 | |
| 116 | /* Apply the sound effect's own volume. */ |
| 117 | volume = sound->volume * volume; |
| 118 | |
| 119 | MxSetChannelVolume(mc, volume, pan); |
| 120 | MxActivateChannel(mc); |
| 121 | } |
| 122 | |
| 123 | |
| 124 | static const uint8_t _vol_factor_by_zoom[] = {255, 255, 255, 190, 134, 87}; |
no test coverage detected