Skip to content

Commit

Permalink
Updated libOPNMIDI
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohlstand committed Jul 3, 2023
1 parent 85e16e2 commit 5899582
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 13 deletions.
17 changes: 14 additions & 3 deletions OPNMIDI-Player/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,24 @@ if(NOT MSVC AND NOT MSDOS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVITA -DVITA=1 -fcompare-debug-second")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVITA -DVITA=1 -fcompare-debug-second")
endif()
if(NINTENDO_3DS OR NINTENDO_WII OR NINTENDO_WIIU OR NINTENDO_SWITCH)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcompare-debug-second")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcompare-debug-second")
endif()
endif()

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
if(NINTENDO_3DS OR NINTENDO_WII OR NINTENDO_WIIU OR NINTENDO_SWITCH)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
endif()

string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
if(DEFINED CMAKE_BUILD_TYPE)
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
endif()
if(CMAKE_BUILD_TYPE_LOWER EQUAL "release")
add_definitions(-DNDEBUG)
ENDIF()
Expand Down
2 changes: 1 addition & 1 deletion OPNMIDI-Player/src/main/cpp/src/chips/mame/mame_ym2612fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2395,7 +2395,7 @@ void ym2612_pre_generate(void *chip)
refresh_fc_eg_chan( OPN, &cch[5] );
}

void ym2612_generate_one_native(void *chip, FMSAMPLE buffer[])
void ym2612_generate_one_native(void *chip, FMSAMPLE *buffer)
{
YM2612 *F2612 = (YM2612 *)chip;
FM_OPN *OPN = &F2612->OPN;
Expand Down
2 changes: 1 addition & 1 deletion OPNMIDI-Player/src/main/cpp/src/chips/mame/mame_ym2612fm.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void ym2612_pre_generate(void *chip);
* @param chip Chip instance
* @param buffer One stereo PCM frame
*/
void ym2612_generate_one_native(void *chip, FMSAMPLE buffer[2]);
void ym2612_generate_one_native(void *chip, FMSAMPLE *buffer);

/* void ym2612_post_generate(void *chip, int length); */

Expand Down
6 changes: 5 additions & 1 deletion OPNMIDI-Player/src/main/cpp/src/chips/np2/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
#define SOUNDCALL FASTCALL

#ifndef MAX_PATH
#define MAX_PATH 256
# ifdef _WIN32
# define MAX_PATH 256
# else
# define MAX_PATH 2048
# endif
#endif

#endif
2 changes: 1 addition & 1 deletion OPNMIDI-Player/src/main/cpp/src/chips/np2/fmgen_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool FileIO::Open(const char* filename, uint flg)
char mode[5] = "rwb";
Close();

strncpy(path, filename, MAX_PATH);
strncpy(path, filename, MAX_PATH - 1);

if(flg & readonly)
strcpy(mode, "rb");
Expand Down
11 changes: 9 additions & 2 deletions OPNMIDI-Player/src/main/cpp/src/midi_sequencer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,15 @@ class BW_MidiSequencer
{}
};
std::vector<TrackInfo> track;
Position(): began(false), wait(0.0), absTimePosition(0.0), track()
{}
Position():
began(false),
wait(0.0),
absTimePosition(0.0),
track()
{
for(size_t i = 0; i < 7; ++i)
__padding[i] = 0;
}
};

//! MIDI Output interface context
Expand Down
5 changes: 3 additions & 2 deletions OPNMIDI-Player/src/main/cpp/src/midi_sequencer_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <assert.h>

#if defined(VITA)
#define timingsafe_memcmp timingsafe_memcmp_workaround // Workaround to fix the C declaration conflict
#include <psp2kern/kernel/sysclib.h> // snprintf
#endif

Expand Down Expand Up @@ -853,7 +854,7 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
{
fraction<uint64_t> currentTempo = m_tempo;
double time = 0.0;
uint64_t abs_position = 0;
// uint64_t abs_position = 0;
size_t tempo_change_index = 0;
MidiTrackQueue &track = m_trackData[tk];
if(track.empty())
Expand Down Expand Up @@ -965,7 +966,7 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
std::fflush(stdout);
#endif

abs_position += pos.delay;
// abs_position += pos.delay;
posPrev = &pos;
}

Expand Down
2 changes: 1 addition & 1 deletion OPNMIDI-Player/src/main/cpp/src/wopn/wopn_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static void WOPN_parseInstrument(WOPNInstrument *ins, uint8_t *cursor, uint16_t
{
int l;
strncpy(ins->inst_name, (const char*)cursor, 32);
ins->inst_name[32] = '\0';
ins->inst_name[31] = '\0';
ins->note_offset = toSint16BE(cursor + 32);
ins->midi_velocity_offset = 0; /* TODO: for future version > 2 */
ins->percussion_key_number = cursor[34];
Expand Down
2 changes: 1 addition & 1 deletion OPNMIDI-Player/src/main/cpp/src/wopn/wopn_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ typedef struct WOPNOperator
typedef struct WOPNInstrument
{
/* Title of the instrument */
char inst_name[34];
char inst_name[32];
/* MIDI note key (half-tone) offset for an instrument (or a first voice in pseudo-4-op mode) */
int16_t note_offset;
/* Reserved */
Expand Down

0 comments on commit 5899582

Please sign in to comment.