Codechange: rename byte to uint8_t (#12308)

This commit is contained in:
Patric Stout
2024-03-16 23:59:32 +01:00
committed by GitHub
parent bd7120bae4
commit a3cfd23cf9
355 changed files with 1654 additions and 1656 deletions

View File

@@ -80,7 +80,7 @@ bool MusicDriver_Allegro::IsSongPlaying()
return midi_pos >= 0;
}
void MusicDriver_Allegro::SetVolume(byte vol)
void MusicDriver_Allegro::SetVolume(uint8_t vol)
{
set_volume(-1, vol);
}

View File

@@ -25,7 +25,7 @@ public:
bool IsSongPlaying() override;
void SetVolume(byte vol) override;
void SetVolume(uint8_t vol) override;
const char *GetName() const override { return "allegro"; }
};

View File

@@ -69,7 +69,7 @@ bool MusicDriver_BeMidi::IsSongPlaying()
return !this->midi_synth_file->IsFinished();
}
void MusicDriver_BeMidi::SetVolume(byte vol)
void MusicDriver_BeMidi::SetVolume(uint8_t vol)
{
this->current_volume = vol / 128.0;
if (this->midi_synth_file != nullptr) this->midi_synth_file->SetVolume(this->current_volume);

View File

@@ -28,7 +28,7 @@ public:
bool IsSongPlaying() override;
void SetVolume(byte vol) override;
void SetVolume(uint8_t vol) override;
const char *GetName() const override { return "bemidi"; }
private:

View File

@@ -37,7 +37,7 @@ static MusicPlayer _player = nullptr;
static MusicSequence _sequence = nullptr;
static MusicTimeStamp _seq_length = 0;
static bool _playing = false;
static byte _volume = 127;
static uint8_t _volume = 127;
/** Set the volume of the current sequence. */
@@ -193,7 +193,7 @@ void MusicDriver_Cocoa::StopSong()
*
* @param vol The desired volume, range of the value is @c 0-127
*/
void MusicDriver_Cocoa::SetVolume(byte vol)
void MusicDriver_Cocoa::SetVolume(uint8_t vol)
{
_volume = vol;
DoSetVolume();

View File

@@ -24,7 +24,7 @@ public:
bool IsSongPlaying() override;
void SetVolume(byte vol) override;
void SetVolume(uint8_t vol) override;
const char *GetName() const override { return "cocoa"; }
};

View File

@@ -128,7 +128,7 @@ static struct {
bool do_stop; ///< flag for stopping playback at next opportunity
int preload_time; ///< preload time for music blocks.
byte new_volume; ///< volume setting to change to
uint8_t new_volume; ///< volume setting to change to
MidiFile next_file; ///< upcoming file to play
PlaybackSegment next_segment; ///< segment info for upcoming file
@@ -519,12 +519,12 @@ bool DLSFile::LoadFile(const wchar_t *file)
}
static byte ScaleVolume(byte original, byte scale)
static uint8_t ScaleVolume(uint8_t original, uint8_t scale)
{
return original * scale / 127;
}
static void TransmitChannelMsg(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, byte status, byte p1, byte p2 = 0)
static void TransmitChannelMsg(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, uint8_t status, uint8_t p1, uint8_t p2 = 0)
{
if (buffer->PackStructured(rt, 0, status | (p1 << 8) | (p2 << 16)) == E_OUTOFMEMORY) {
/* Buffer is full, clear it and try again. */
@@ -535,10 +535,10 @@ static void TransmitChannelMsg(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, by
}
}
static void TransmitSysex(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, const byte *&msg_start, size_t &remaining)
static void TransmitSysex(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, const uint8_t *&msg_start, size_t &remaining)
{
/* Find end of message. */
const byte *msg_end = msg_start;
const uint8_t *msg_end = msg_start;
while (*msg_end != MIDIST_ENDSYSEX) msg_end++;
msg_end++; // Also include SysEx end byte.
@@ -558,7 +558,7 @@ static void TransmitSysex(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, const b
static void TransmitStandardSysex(IDirectMusicBuffer *buffer, REFERENCE_TIME rt, MidiSysexMessage msg)
{
size_t length = 0;
const byte *data = MidiGetStandardSysexMessage(msg, length);
const uint8_t *data = MidiGetStandardSysexMessage(msg, length);
TransmitSysex(buffer, rt, data, length);
}
@@ -594,8 +594,8 @@ static void MidiThreadProc()
MidiFile current_file; // file currently being played from
PlaybackSegment current_segment; // segment info for current playback
size_t current_block = 0; // next block index to send
byte current_volume = 0; // current effective volume setting
byte channel_volumes[16]; // last seen volume controller values in raw data
uint8_t current_volume = 0; // current effective volume setting
uint8_t channel_volumes[16]; // last seen volume controller values in raw data
/* Get pointer to the reference clock of our output port. */
IReferenceClock *clock;
@@ -650,7 +650,7 @@ static void MidiThreadProc()
clock->GetTime(&cur_time);
TransmitNotesOff(_buffer, block_time, cur_time);
MemSetT<byte>(channel_volumes, 127, lengthof(channel_volumes));
MemSetT<uint8_t>(channel_volumes, 127, lengthof(channel_volumes));
/* Invalidate current volume. */
current_volume = UINT8_MAX;
last_volume_time = 0;
@@ -735,13 +735,13 @@ static void MidiThreadProc()
block_time = playback_start_time + block.realtime * MIDITIME_TO_REFTIME;
Debug(driver, 9, "DMusic thread: Streaming block {} (cur={}, block={})", current_block, (long long)(current_time / MS_TO_REFTIME), (long long)(block_time / MS_TO_REFTIME));
const byte *data = block.data.data();
const uint8_t *data = block.data.data();
size_t remaining = block.data.size();
byte last_status = 0;
uint8_t last_status = 0;
while (remaining > 0) {
/* MidiFile ought to have converted everything out of running status,
* but handle it anyway just to be safe */
byte status = data[0];
uint8_t status = data[0];
if (status & 0x80) {
last_status = status;
data++;
@@ -1237,7 +1237,7 @@ bool MusicDriver_DMusic::IsSongPlaying()
}
void MusicDriver_DMusic::SetVolume(byte vol)
void MusicDriver_DMusic::SetVolume(uint8_t vol)
{
_playback.new_volume = vol;
}

View File

@@ -27,7 +27,7 @@ public:
bool IsSongPlaying() override;
void SetVolume(byte vol) override;
void SetVolume(uint8_t vol) override;
const char *GetName() const override { return "dmusic"; }
};

View File

@@ -95,7 +95,7 @@ bool MusicDriver_ExtMidi::IsSongPlaying()
return this->pid != -1;
}
void MusicDriver_ExtMidi::SetVolume(byte)
void MusicDriver_ExtMidi::SetVolume(uint8_t)
{
Debug(driver, 1, "extmidi: set volume not implemented");
}

View File

@@ -32,7 +32,7 @@ public:
bool IsSongPlaying() override;
void SetVolume(byte vol) override;
void SetVolume(uint8_t vol) override;
const char *GetName() const override { return "extmidi"; }
};

View File

@@ -183,7 +183,7 @@ bool MusicDriver_FluidSynth::IsSongPlaying()
return fluid_player_get_status(_midi.player) == FLUID_PLAYER_PLAYING;
}
void MusicDriver_FluidSynth::SetVolume(byte vol)
void MusicDriver_FluidSynth::SetVolume(uint8_t vol)
{
std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
if (_midi.settings == nullptr) return;

View File

@@ -25,7 +25,7 @@ public:
bool IsSongPlaying() override;
void SetVolume(byte vol) override;
void SetVolume(uint8_t vol) override;
const char *GetName() const override { return "fluidsynth"; }
};

View File

@@ -152,6 +152,6 @@ enum class MidiSysexMessage {
RolandSetReverb,
};
const byte *MidiGetStandardSysexMessage(MidiSysexMessage msg, size_t &length);
const uint8_t *MidiGetStandardSysexMessage(MidiSysexMessage msg, size_t &length);
#endif /* MUSIC_MIDI_H */

View File

@@ -30,12 +30,12 @@ static MidiFile *_midifile_instance = nullptr;
* @param[out] length Receives the length of the returned buffer
* @return Pointer to byte buffer with sysex message
*/
const byte *MidiGetStandardSysexMessage(MidiSysexMessage msg, size_t &length)
const uint8_t *MidiGetStandardSysexMessage(MidiSysexMessage msg, size_t &length)
{
static byte reset_gm_sysex[] = { 0xF0, 0x7E, 0x7F, 0x09, 0x01, 0xF7 };
static byte reset_gs_sysex[] = { 0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7 };
static byte reset_xg_sysex[] = { 0xF0, 0x43, 0x10, 0x4C, 0x00, 0x00, 0x7E, 0x00, 0xF7 };
static byte roland_reverb_sysex[] = { 0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x01, 0x30, 0x02, 0x04, 0x00, 0x40, 0x40, 0x00, 0x00, 0x09, 0xF7 };
static uint8_t reset_gm_sysex[] = { 0xF0, 0x7E, 0x7F, 0x09, 0x01, 0xF7 };
static uint8_t reset_gs_sysex[] = { 0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7 };
static uint8_t reset_xg_sysex[] = { 0xF0, 0x43, 0x10, 0x4C, 0x00, 0x00, 0x7E, 0x00, 0xF7 };
static uint8_t roland_reverb_sysex[] = { 0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x01, 0x30, 0x02, 0x04, 0x00, 0x40, 0x40, 0x00, 0x00, 0x09, 0xF7 };
switch (msg) {
case MidiSysexMessage::ResetGM:
@@ -60,7 +60,7 @@ const byte *MidiGetStandardSysexMessage(MidiSysexMessage msg, size_t &length)
* RAII-compliant to make teardown in error situations easier.
*/
class ByteBuffer {
std::vector<byte> buf;
std::vector<uint8_t> buf;
size_t pos;
public:
/**
@@ -104,7 +104,7 @@ public:
* @param[out] b returns the read value
* @return true if a byte was available for reading
*/
bool ReadByte(byte &b)
bool ReadByte(uint8_t &b)
{
if (this->IsEnd()) return false;
b = this->buf[this->pos++];
@@ -121,7 +121,7 @@ public:
bool ReadVariableLength(uint32_t &res)
{
res = 0;
byte b = 0;
uint8_t b = 0;
do {
if (this->IsEnd()) return false;
b = this->buf[this->pos++];
@@ -136,7 +136,7 @@ public:
* @param length number of bytes to read
* @return true if the requested number of bytes were available
*/
bool ReadBuffer(byte *dest, size_t length)
bool ReadBuffer(uint8_t *dest, size_t length)
{
if (this->IsEnd()) return false;
if (this->buf.size() - this->pos < length) return false;
@@ -188,9 +188,9 @@ public:
static bool ReadTrackChunk(FILE *file, MidiFile &target)
{
byte buf[4];
uint8_t buf[4];
const byte magic[] = { 'M', 'T', 'r', 'k' };
const uint8_t magic[] = { 'M', 'T', 'r', 'k' };
if (fread(buf, sizeof(magic), 1, file) != 1) {
return false;
}
@@ -213,7 +213,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target)
target.blocks.push_back(MidiFile::DataBlock());
MidiFile::DataBlock *block = &target.blocks.back();
byte last_status = 0;
uint8_t last_status = 0;
bool running_sysex = false;
while (!chunk.IsEnd()) {
/* Read deltatime for event, start new block */
@@ -227,7 +227,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target)
}
/* Read status byte */
byte status;
uint8_t status;
if (!chunk.ReadByte(status)) {
return false;
}
@@ -422,13 +422,13 @@ bool MidiFile::ReadSMFHeader(const std::string &filename, SMFHeader &header)
bool MidiFile::ReadSMFHeader(FILE *file, SMFHeader &header)
{
/* Try to read header, fixed size */
byte buffer[14];
uint8_t buffer[14];
if (fread(buffer, sizeof(buffer), 1, file) != 1) {
return false;
}
/* Check magic, 'MThd' followed by 4 byte length indicator (always = 6 in SMF) */
const byte magic[] = { 'M', 'T', 'h', 'd', 0x00, 0x00, 0x00, 0x06 };
const uint8_t magic[] = { 'M', 'T', 'h', 'd', 0x00, 0x00, 0x00, 0x06 };
if (MemCmpT(buffer, magic, sizeof(magic)) != 0) {
return false;
}
@@ -505,8 +505,8 @@ cleanup:
struct MpsMachine {
/** Starting parameter and playback status for one channel/track */
struct Channel {
byte cur_program; ///< program selected, used for velocity scaling (lookup into programvelocities array)
byte running_status; ///< last midi status code seen
uint8_t cur_program; ///< program selected, used for velocity scaling (lookup into programvelocities array)
uint8_t running_status; ///< last midi status code seen
uint16_t delay; ///< frames until next command
uint32_t playpos; ///< next byte to play this channel from
uint32_t startpos; ///< start position of master track
@@ -521,9 +521,9 @@ struct MpsMachine {
bool shouldplayflag; ///< not-end-of-song flag
static const int TEMPO_RATE;
static const byte programvelocities[128];
static const uint8_t programvelocities[128];
const byte *songdata; ///< raw data array
const uint8_t *songdata; ///< raw data array
size_t songdatalen; ///< length of song data
MidiFile &target; ///< recipient of data
@@ -534,12 +534,12 @@ struct MpsMachine {
MPSMIDIST_ENDSONG = 0xFF, ///< immediately end the song
};
static void AddMidiData(MidiFile::DataBlock &block, byte b1, byte b2)
static void AddMidiData(MidiFile::DataBlock &block, uint8_t b1, uint8_t b2)
{
block.data.push_back(b1);
block.data.push_back(b2);
}
static void AddMidiData(MidiFile::DataBlock &block, byte b1, byte b2, byte b3)
static void AddMidiData(MidiFile::DataBlock &block, uint8_t b1, uint8_t b2, uint8_t b3)
{
block.data.push_back(b1);
block.data.push_back(b2);
@@ -552,7 +552,7 @@ struct MpsMachine {
* @param length Length of the data buffer in bytes
* @param target MidiFile object to add decoded data to
*/
MpsMachine(const byte *data, size_t length, MidiFile &target)
MpsMachine(const uint8_t *data, size_t length, MidiFile &target)
: songdata(data), songdatalen(length), target(target)
{
uint32_t pos = 0;
@@ -580,7 +580,7 @@ struct MpsMachine {
/* Similar structure to segments list, but also has
* the MIDI channel number as a byte before the offset
* to next track. */
byte ch = this->songdata[pos++];
uint8_t ch = this->songdata[pos++];
this->channels[ch].startpos = pos + 4;
pos += FROM_LE16(*(const int16_t *)(this->songdata + pos));
}
@@ -593,7 +593,7 @@ struct MpsMachine {
*/
uint16_t ReadVariableLength(uint32_t &pos)
{
byte b = 0;
uint8_t b = 0;
uint16_t res = 0;
do {
b = this->songdata[pos++];
@@ -627,7 +627,7 @@ struct MpsMachine {
uint16_t PlayChannelFrame(MidiFile::DataBlock &outblock, int channel)
{
uint16_t newdelay = 0;
byte b1, b2;
uint8_t b1, b2;
Channel &chandata = this->channels[channel];
do {
@@ -811,7 +811,7 @@ struct MpsMachine {
/** Frames/ticks per second for music playback */
const int MpsMachine::TEMPO_RATE = 148;
/** Base note velocities for various GM programs */
const byte MpsMachine::programvelocities[128] = {
const uint8_t MpsMachine::programvelocities[128] = {
100, 100, 100, 100, 100, 90, 100, 100, 100, 100, 100, 90, 100, 100, 100, 100,
100, 100, 85, 100, 100, 100, 100, 100, 100, 100, 100, 100, 90, 90, 110, 80,
100, 100, 100, 90, 70, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
@@ -828,7 +828,7 @@ const byte MpsMachine::programvelocities[128] = {
* @param length size of data in bytes
* @return true if the data could be loaded
*/
bool MidiFile::LoadMpsData(const byte *data, size_t length)
bool MidiFile::LoadMpsData(const uint8_t *data, size_t length)
{
_midifile_instance = this;
@@ -844,7 +844,7 @@ bool MidiFile::LoadSong(const MusicSongInfo &song)
case MTT_MPSMIDI:
{
size_t songdatalen = 0;
byte *songdata = GetMusicCatEntryData(song.filename, song.cat_index, songdatalen);
uint8_t *songdata = GetMusicCatEntryData(song.filename, song.cat_index, songdatalen);
if (songdata != nullptr) {
bool result = this->LoadMpsData(songdata, songdatalen);
free(songdata);
@@ -878,21 +878,21 @@ void MidiFile::MoveFrom(MidiFile &other)
static void WriteVariableLen(FILE *f, uint32_t value)
{
if (value <= 0x7F) {
byte tb = value;
uint8_t tb = value;
fwrite(&tb, 1, 1, f);
} else if (value <= 0x3FFF) {
byte tb[2];
uint8_t tb[2];
tb[1] = value & 0x7F; value >>= 7;
tb[0] = (value & 0x7F) | 0x80; value >>= 7;
fwrite(tb, 1, sizeof(tb), f);
} else if (value <= 0x1FFFFF) {
byte tb[3];
uint8_t tb[3];
tb[2] = value & 0x7F; value >>= 7;
tb[1] = (value & 0x7F) | 0x80; value >>= 7;
tb[0] = (value & 0x7F) | 0x80; value >>= 7;
fwrite(tb, 1, sizeof(tb), f);
} else if (value <= 0x0FFFFFFF) {
byte tb[4];
uint8_t tb[4];
tb[3] = value & 0x7F; value >>= 7;
tb[2] = (value & 0x7F) | 0x80; value >>= 7;
tb[1] = (value & 0x7F) | 0x80; value >>= 7;
@@ -914,17 +914,17 @@ bool MidiFile::WriteSMF(const std::string &filename)
}
/* SMF header */
const byte fileheader[] = {
const uint8_t fileheader[] = {
'M', 'T', 'h', 'd', // block name
0x00, 0x00, 0x00, 0x06, // BE32 block length, always 6 bytes
0x00, 0x00, // writing format 0 (all in one track)
0x00, 0x01, // containing 1 track (BE16)
(byte)(this->tickdiv >> 8), (byte)this->tickdiv, // tickdiv in BE16
(uint8_t)(this->tickdiv >> 8), (uint8_t)this->tickdiv, // tickdiv in BE16
};
fwrite(fileheader, sizeof(fileheader), 1, f);
/* Track header */
const byte trackheader[] = {
const uint8_t trackheader[] = {
'M', 'T', 'r', 'k', // block name
0, 0, 0, 0, // BE32 block length, unknown at this time
};
@@ -953,7 +953,7 @@ bool MidiFile::WriteSMF(const std::string &filename)
/* Write tempo change if there is one */
if (nexttempo.ticktime <= block.ticktime) {
byte tempobuf[6] = { MIDIST_SMF_META, 0x51, 0x03, 0, 0, 0 };
uint8_t tempobuf[6] = { MIDIST_SMF_META, 0x51, 0x03, 0, 0, 0 };
tempobuf[3] = (nexttempo.tempo & 0x00FF0000) >> 16;
tempobuf[4] = (nexttempo.tempo & 0x0000FF00) >> 8;
tempobuf[5] = (nexttempo.tempo & 0x000000FF);
@@ -970,7 +970,7 @@ bool MidiFile::WriteSMF(const std::string &filename)
}
/* Write each block data command */
byte *dp = block.data.data();
uint8_t *dp = block.data.data();
while (dp < block.data.data() + block.data.size()) {
/* Always zero delta time inside blocks */
if (needtime) {
@@ -999,7 +999,7 @@ bool MidiFile::WriteSMF(const std::string &filename)
if (*dp == MIDIST_SYSEX) {
fwrite(dp, 1, 1, f);
dp++;
byte *sysexend = dp;
uint8_t *sysexend = dp;
while (*sysexend != MIDIST_ENDSYSEX) sysexend++;
ptrdiff_t sysexlen = sysexend - dp;
WriteVariableLen(f, sysexlen);
@@ -1015,7 +1015,7 @@ bool MidiFile::WriteSMF(const std::string &filename)
}
/* End of track marker */
static const byte track_end_marker[] = { 0x00, MIDIST_SMF_META, 0x2F, 0x00 };
static const uint8_t track_end_marker[] = { 0x00, MIDIST_SMF_META, 0x2F, 0x00 };
fwrite(&track_end_marker, sizeof(track_end_marker), 1, f);
/* Fill out the RIFF block length */
@@ -1078,7 +1078,7 @@ std::string MidiFile::GetSMFFile(const MusicSongInfo &song)
return output_filename;
}
byte *data;
uint8_t *data;
size_t datalen;
data = GetMusicCatEntryData(song.filename, song.cat_index, datalen);
if (data == nullptr) return std::string();
@@ -1098,7 +1098,7 @@ std::string MidiFile::GetSMFFile(const MusicSongInfo &song)
}
static bool CmdDumpSMF(byte argc, char *argv[])
static bool CmdDumpSMF(uint8_t argc, char *argv[])
{
if (argc == 0) {
IConsolePrint(CC_HELP, "Write the current song to a Standard MIDI File. Usage: 'dumpsmf <filename>'.");

View File

@@ -19,7 +19,7 @@ struct MidiFile {
struct DataBlock {
uint32_t ticktime; ///< tick number since start of file this block should be triggered at
uint32_t realtime = 0; ///< real-time (microseconds) since start of file this block should be triggered at
std::vector<byte> data; ///< raw midi data contained in block
std::vector<uint8_t> data; ///< raw midi data contained in block
DataBlock(uint32_t _ticktime = 0) : ticktime(_ticktime) { }
};
struct TempoChange {
@@ -36,7 +36,7 @@ struct MidiFile {
~MidiFile();
bool LoadFile(const std::string &filename);
bool LoadMpsData(const byte *data, size_t length);
bool LoadMpsData(const uint8_t *data, size_t length);
bool LoadSong(const MusicSongInfo &song);
void MoveFrom(MidiFile &other);

View File

@@ -38,7 +38,7 @@ public:
* Set the volume, if possible.
* @param vol The new volume.
*/
virtual void SetVolume(byte vol) = 0;
virtual void SetVolume(uint8_t vol) = 0;
/**
* Get the currently active instance of the music driver.

View File

@@ -25,7 +25,7 @@ public:
bool IsSongPlaying() override { return true; }
void SetVolume(byte) override { }
void SetVolume(uint8_t) override { }
const char *GetName() const override { return "null"; }
};

View File

@@ -37,8 +37,8 @@ static struct {
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
byte current_volume; ///< current effective volume setting
byte new_volume; ///< volume setting to change to
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
@@ -47,13 +47,13 @@ static struct {
MidiFile next_file; ///< upcoming file to play
PlaybackSegment next_segment; ///< segment info for upcoming file
byte channel_volumes[16]; ///< last seen volume controller values in raw data
uint8_t channel_volumes[16]; ///< last seen volume controller values in raw data
} _midi;
static FMusicDriver_Win32 iFMusicDriver_Win32;
static byte ScaleVolume(byte original, byte scale)
static uint8_t ScaleVolume(uint8_t original, uint8_t scale)
{
return original * scale / 127;
}
@@ -68,21 +68,21 @@ void CALLBACK MidiOutProc(HMIDIOUT hmo, UINT wMsg, DWORD_PTR, DWORD_PTR dwParam1
}
}
static void TransmitChannelMsg(byte status, byte p1, byte p2 = 0)
static void TransmitChannelMsg(uint8_t status, uint8_t p1, uint8_t p2 = 0)
{
midiOutShortMsg(_midi.midi_out, status | (p1 << 8) | (p2 << 16));
}
static void TransmitSysex(const byte *&msg_start, size_t &remaining)
static void TransmitSysex(const uint8_t *&msg_start, size_t &remaining)
{
/* find end of message */
const byte *msg_end = msg_start;
const uint8_t *msg_end = msg_start;
while (*msg_end != MIDIST_ENDSYSEX) msg_end++;
msg_end++; /* also include sysex end byte */
/* prepare header */
MIDIHDR *hdr = CallocT<MIDIHDR>(1);
hdr->lpData = reinterpret_cast<LPSTR>(const_cast<byte *>(msg_start));
hdr->lpData = reinterpret_cast<LPSTR>(const_cast<uint8_t *>(msg_start));
hdr->dwBufferLength = msg_end - msg_start;
if (midiOutPrepareHeader(_midi.midi_out, hdr, sizeof(*hdr)) == MMSYSERR_NOERROR) {
/* transmit - just point directly into the data buffer */
@@ -100,7 +100,7 @@ static void TransmitSysex(const byte *&msg_start, size_t &remaining)
static void TransmitStandardSysex(MidiSysexMessage msg)
{
size_t length = 0;
const byte *data = MidiGetStandardSysexMessage(msg, length);
const uint8_t *data = MidiGetStandardSysexMessage(msg, length);
TransmitSysex(data, length);
}
@@ -164,7 +164,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR
_midi.do_start = 0;
_midi.current_block = 0;
MemSetT<byte>(_midi.channel_volumes, 127, lengthof(_midi.channel_volumes));
MemSetT<uint8_t>(_midi.channel_volumes, 127, lengthof(_midi.channel_volumes));
/* Invalidate current volume. */
_midi.current_volume = UINT8_MAX;
volume_throttle = 0;
@@ -184,7 +184,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR
_midi.current_volume = _midi.new_volume;
volume_throttle = 20 / _midi.time_period;
for (int ch = 0; ch < 16; ch++) {
byte vol = ScaleVolume(_midi.channel_volumes[ch], _midi.current_volume);
uint8_t vol = ScaleVolume(_midi.channel_volumes[ch], _midi.current_volume);
TransmitChannelMsg(MIDIST_CONTROLLER | ch, MIDICT_CHANVOLUME, vol);
}
} else {
@@ -242,13 +242,13 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR, DWORD_PTR, DWORD_PTR
break;
}
const byte *data = block.data.data();
const uint8_t *data = block.data.data();
size_t remaining = block.data.size();
byte last_status = 0;
uint8_t last_status = 0;
while (remaining > 0) {
/* MidiFile ought to have converted everything out of running status,
* but handle it anyway just to be safe */
byte status = data[0];
uint8_t status = data[0];
if (status & 0x80) {
last_status = status;
data++;
@@ -361,7 +361,7 @@ bool MusicDriver_Win32::IsSongPlaying()
return _midi.playing || (_midi.do_start != 0);
}
void MusicDriver_Win32::SetVolume(byte vol)
void MusicDriver_Win32::SetVolume(uint8_t vol)
{
std::lock_guard<std::mutex> mutex_lock(_midi.lock);
_midi.new_volume = vol;

View File

@@ -25,7 +25,7 @@ public:
bool IsSongPlaying() override;
void SetVolume(byte vol) override;
void SetVolume(uint8_t vol) override;
const char *GetName() const override { return "win32"; }
};