OpenTTD Source  20241108-master-g80f628063a
win32_m.cpp File Reference

Music playback for Windows. More...

#include "../stdafx.h"
#include "../string_func.h"
#include "win32_m.h"
#include <windows.h>
#include <mmsystem.h>
#include "../os/windows/win32.h"
#include "../debug.h"
#include "midifile.hpp"
#include "midi.h"
#include "../base_media_base.h"
#include "../core/mem_func.hpp"
#include <mutex>
#include "../safeguards.h"

Go to the source code of this file.

Data Structures

struct  PlaybackSegment
 

Functions

static uint8_t ScaleVolume (uint8_t original, uint8_t scale)
 
void CALLBACK MidiOutProc (HMIDIOUT hmo, UINT wMsg, DWORD_PTR, DWORD_PTR dwParam1, DWORD_PTR)
 
static void TransmitChannelMsg (uint8_t status, uint8_t p1, uint8_t p2=0)
 
static void TransmitSysex (const uint8_t *&msg_start, size_t &remaining)
 
static void TransmitStandardSysex (MidiSysexMessage msg)
 
void CALLBACK TimerCallback (UINT uTimerID, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR)
 Realtime MIDI playback service routine. More...
 

Variables

struct {
   UINT   time_period
 obtained timer precision value
 
   HMIDIOUT   midi_out
 handle to open midiOut
 
   UINT   timer_id
 ID of active multimedia timer.
 
   std::mutex   lock
 synchronization for playback status fields
 
   bool   playing
 flag indicating that playback is active
 
   int   do_start
 flag for starting playback of next_file at next opportunity
 
   bool   do_stop
 flag for stopping playback at next opportunity
 
   uint8_t   current_volume
 current effective volume setting
 
   uint8_t   new_volume
 volume setting to change to
 
   MidiFile   current_file
 file currently being played from
 
   PlaybackSegment   current_segment
 segment info for current playback
 
   DWORD   playback_start_time
 timestamp current file began playback
 
   size_t   current_block
 next block index to send
 
   MidiFile   next_file
 upcoming file to play
 
   PlaybackSegment   next_segment
 segment info for upcoming file
 
   uint8_t   channel_volumes [16]
 last seen volume controller values in raw data
 
_midi
 
static FMusicDriver_Win32 iFMusicDriver_Win32
 

Detailed Description

Music playback for Windows.

Definition in file win32_m.cpp.

Function Documentation

◆ TimerCallback()

void CALLBACK TimerCallback ( UINT  uTimerID,
UINT  ,
DWORD_PTR  ,
DWORD_PTR  ,
DWORD_PTR   
)

Realtime MIDI playback service routine.

This is called by the multimedia timer.

Definition at line 111 of file win32_m.cpp.

References _midi, and Debug.

Referenced by MusicDriver_Win32::PlaySong().