OpenTTD Source: src/music/win32_m.cpp File Reference

OpenTTD Source 15.0-beta1

Data Structures | Functions | Variables
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.

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

## Detailed Description

Music playback for Windows.

Definition in file win32_m.cpp.

## Function Documentation

## ◆ MidiOutProc()

void CALLBACK MidiOutProc | ( | HMIDIOUT | hmo,
|  | UINT | wMsg,
|  | DWORD_PTR | ,
|  | DWORD_PTR | dwParam1,
|  | DWORD_PTR |
| ) |  |

Definition at line 62 of file win32_m.cpp.

## ◆ ScaleVolume()

static uint8_t ScaleVolume | ( | uint8_t | original,
|  | uint8_t | scale
| ) |  |
| static

Definition at line 56 of file win32_m.cpp.

## ◆ 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 MidiFile::DataBlock::data, Debug, lengthof, MidiFile::DataBlock::realtime, and MidiFile::DataBlock::ticktime.

Referenced by MusicDriver_Win32::PlaySong().

## ◆ TransmitChannelMsg()

static void TransmitChannelMsg | ( | uint8_t | status,
|  | uint8_t | p1,
|  | uint8_t | p2 = `0`
| ) |  |
| static

Definition at line 71 of file win32_m.cpp.

## ◆ TransmitStandardSysex()

static void TransmitStandardSysex | ( | MidiSysexMessage | msg | ) |
| static

Definition at line 100 of file win32_m.cpp.

## ◆ TransmitSysex()

static void TransmitSysex | ( | const uint8_t *& | msg_start,
|  | size_t & | remaining
| ) |  |
| static

Definition at line 76 of file win32_m.cpp.

## Variable Documentation

## ◆ channel_volumes

uint8_t channel_volumes[16]

last seen volume controller values in raw data

Definition at line 50 of file win32_m.cpp.

## ◆ current_block

size_t current_block

next block index to send

Definition at line 46 of file win32_m.cpp.

## ◆ current_file

MidiFile current_file

file currently being played from

Definition at line 43 of file win32_m.cpp.

## ◆ current_segment

PlaybackSegment current_segment

segment info for current playback

Definition at line 44 of file win32_m.cpp.

## ◆ current_volume

uint8_t current_volume

current effective volume setting

Definition at line 40 of file win32_m.cpp.

## ◆ do_start

int do_start

flag for starting playback of next_file at next opportunity

Definition at line 38 of file win32_m.cpp.

## ◆ do_stop

bool do_stop

flag for stopping playback at next opportunity

Definition at line 39 of file win32_m.cpp.

## ◆ iFMusicDriver_Win32

FMusicDriver_Win32 iFMusicDriver_Win32
| static

Definition at line 53 of file win32_m.cpp.

## ◆ lock

std::mutex lock

synchronization for playback status fields

Definition at line 35 of file win32_m.cpp.

Referenced by SmallStack< Titem, Tindex, Tinvalid, Tgrowth_step, Tmax_size >::Branch(), NetworkHTTPSocketHandler::Connect(), SmallStack< Titem, Tindex, Tinvalid, Tgrowth_step, Tmax_size >::Contains(), CopyPalette(), DebugPrint(), DebugSendRemoteMessages(), PacketWriter::Destroy(), VideoDriver::DrainCommandQueue(), PacketWriter::Finish(), VideoDriver::GameLoopPause(), HTTPThreadSafeCallback::HandleQueue(), NetworkHTTPSocketHandler::HTTPReceive(), HTTPThreadSafeCallback::IsQueueEmpty(), MusicDriver_FluidSynth::IsSongPlaying(), MakeScreenshot(), MxSetMusicSource(), NetworkHTTPRequest::NetworkHTTPRequest(), NetworkHTTPRequest::NetworkHTTPRequest(), NetworkHTTPUninitialize(), HTTPThreadSafeCallback::OnFailure(), HTTPThreadSafeCallback::OnReceiveData(), MusicDriver_DMusic::PlaySong(), MusicDriver_FluidSynth::PlaySong(), SmallStack< Titem, Tindex, Tinvalid, Tgrowth_step, Tmax_size >::Pop(), SmallStack< Titem, Tindex, Tinvalid, Tgrowth_step, Tmax_size >::Push(), VideoDriver::QueueOnMainThread(), MusicDriver_FluidSynth::SetVolume(), MusicDriver_FluidSynth::Start(), StartNewThread(), MusicDriver_FluidSynth::Stop(), MusicDriver_FluidSynth::StopSong(), PacketWriter::TransferToNetworkQueue(), NetworkSurveyHandler::Transmit(), HTTPThreadSafeCallback::WaitTillEmptyOrCondition(), PacketWriter::Write(), NetworkHTTPRequest::~NetworkHTTPRequest(), and PacketWriter::~PacketWriter().

## ◆ midi_out

HMIDIOUT midi_out

handle to open midiOut

Definition at line 33 of file win32_m.cpp.

## ◆ new_volume

uint8_t new_volume

volume setting to change to

Definition at line 41 of file win32_m.cpp.

## ◆ next_file

MidiFile next_file

upcoming file to play

Definition at line 47 of file win32_m.cpp.

## ◆ next_segment

PlaybackSegment next_segment

segment info for upcoming file

Definition at line 48 of file win32_m.cpp.

## ◆ playback_start_time

DWORD playback_start_time

timestamp current file began playback

Definition at line 45 of file win32_m.cpp.

## ◆ playing

bool playing

flag indicating that playback is active

Definition at line 37 of file win32_m.cpp.

## ◆ time_period

UINT time_period

obtained timer precision value

Definition at line 32 of file win32_m.cpp.

## ◆ timer_id

UINT timer_id

ID of active multimedia timer.

Definition at line 34 of file win32_m.cpp.