aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2017-11-16 01:51:56 +0300
committerWohlstand <admin@wohlnet.ru>2017-11-16 01:51:56 +0300
commitd491f6ef69dea336f61fdadf79f431d12f0454f2 (patch)
tree5a0157e6b57321c4cf5cf362a6911041c1c7e7b4
parent5cdfbaf362dc3fd4bff8c11a7b5cf61cbbb4b15f (diff)
downloadlibADLMIDI-d491f6ef69dea336f61fdadf79f431d12f0454f2.tar.gz
libADLMIDI-d491f6ef69dea336f61fdadf79f431d12f0454f2.tar.bz2
libADLMIDI-d491f6ef69dea336f61fdadf79f431d12f0454f2.zip
Clean-up and beautifying
-rw-r--r--include/adlmidi.h10
-rw-r--r--src/adlmidi.cpp33
-rw-r--r--src/adlmidi_load.cpp2
-rw-r--r--src/adlmidi_midiplay.cpp2
-rw-r--r--src/adlmidi_private.hpp2
5 files changed, 24 insertions, 25 deletions
diff --git a/include/adlmidi.h b/include/adlmidi.h
index c997f9b..6dc930c 100644
--- a/include/adlmidi.h
+++ b/include/adlmidi.h
@@ -124,7 +124,7 @@ extern const char *adl_linkedLibraryVersion();
extern const char *adl_errorString();
/*Returns string which contains last error message on specific device*/
-extern const char *adl_errorInfo(ADL_MIDIPlayer *device);
+extern const char *adl_errorInfo(struct ADL_MIDIPlayer *device);
/*Initialize ADLMIDI Player device*/
extern struct ADL_MIDIPlayer *adl_init(long sample_rate);
@@ -198,7 +198,7 @@ extern const struct Adl_MarkerEntry adl_metaMarker(struct ADL_MIDIPlayer *device
extern int adl_play(struct ADL_MIDIPlayer *device, int sampleCount, short out[]);
/*Generate audio output from chip emulators without iteration of MIDI timers. 512 samples per channel is a maximum*/
-extern int adl_generate(ADL_MIDIPlayer *device, int sampleCount, short *out);
+extern int adl_generate(struct ADL_MIDIPlayer *device, int sampleCount, short *out);
/**
* @brief Periodic tick handler.
@@ -210,13 +210,13 @@ extern int adl_generate(ADL_MIDIPlayer *device, int sampleCount, short *out);
* Use it for Hardware OPL3 mode or when you want to process events differently from adl_play() function.
* DON'T USE IT TOGETHER WITH adl_play()!!!
*/
-extern double adl_tickEvents(ADL_MIDIPlayer *device, double seconds, double granuality);
+extern double adl_tickEvents(struct ADL_MIDIPlayer *device, double seconds, double granuality);
/*Returns 1 if music position has reached end*/
-extern int adl_atEnd(ADL_MIDIPlayer *device);
+extern int adl_atEnd(struct ADL_MIDIPlayer *device);
/*Force Off all notes on all channels*/
-extern void adl_panic(ADL_MIDIPlayer *device);
+extern void adl_panic(struct ADL_MIDIPlayer *device);
/**Hooks**/
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index f620b5e..18e5243 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -326,7 +326,7 @@ ADLMIDI_EXPORT const char *adl_errorString()
return ADLMIDI_ErrorString.c_str();
}
-ADLMIDI_EXPORT const char *adl_errorInfo(ADL_MIDIPlayer *device)
+ADLMIDI_EXPORT const char *adl_errorInfo(struct ADL_MIDIPlayer *device)
{
if(!device)
return adl_errorString();
@@ -336,7 +336,7 @@ ADLMIDI_EXPORT const char *adl_errorInfo(ADL_MIDIPlayer *device)
return play->getErrorString().c_str();
}
-ADLMIDI_EXPORT const char *adl_getMusicTitle(ADL_MIDIPlayer *device)
+ADLMIDI_EXPORT const char *adl_getMusicTitle(struct ADL_MIDIPlayer *device)
{
if(!device)
return "";
@@ -346,7 +346,7 @@ ADLMIDI_EXPORT const char *adl_getMusicTitle(ADL_MIDIPlayer *device)
return play->musTitle.c_str();
}
-ADLMIDI_EXPORT void adl_close(ADL_MIDIPlayer *device)
+ADLMIDI_EXPORT void adl_close(struct ADL_MIDIPlayer *device)
{
if(device->adl_midiPlayer)
delete reinterpret_cast<MIDIplay *>(device->adl_midiPlayer);
@@ -355,7 +355,7 @@ ADLMIDI_EXPORT void adl_close(ADL_MIDIPlayer *device)
device = NULL;
}
-ADLMIDI_EXPORT void adl_reset(ADL_MIDIPlayer *device)
+ADLMIDI_EXPORT void adl_reset(struct ADL_MIDIPlayer *device)
{
if(!device)
return;
@@ -365,7 +365,7 @@ ADLMIDI_EXPORT void adl_reset(ADL_MIDIPlayer *device)
play->opl.Reset(play->m_setup.PCM_RATE);
}
-ADLMIDI_EXPORT double adl_totalTimeLength(ADL_MIDIPlayer *device)
+ADLMIDI_EXPORT double adl_totalTimeLength(struct ADL_MIDIPlayer *device)
{
if(!device)
return -1.0;
@@ -516,7 +516,6 @@ inline static void SendStereoAudio(MIDIplay::Setup &device,
{
if(!in_size)
return;
-
device.stored_samples = 0;
size_t offset = static_cast<size_t>(out_pos);
size_t inSamples = static_cast<size_t>(in_size * 2);
@@ -538,7 +537,9 @@ inline static void SendStereoAudio(MIDIplay::Setup &device,
ADLMIDI_EXPORT int adl_play(ADL_MIDIPlayer *device, int sampleCount, short *out)
{
#ifdef ADLMIDI_HW_OPL
- (void)device; (void)sampleCount; (void)out;
+ (void)device;
+ (void)sampleCount;
+ (void)out;
return 0;
#else
sampleCount -= sampleCount % 2; //Avoid even sample requests
@@ -602,8 +603,8 @@ ADLMIDI_EXPORT int adl_play(ADL_MIDIPlayer *device, int sampleCount, short *out)
//fill buffer with zeros
int16_t *out_buf = player->outBuf;
std::memset(out_buf, 0, static_cast<size_t>(in_generatedPhys) * sizeof(int16_t));
-
- if(player->m_setup.NumCards == 1)
+ unsigned int chips = player->opl.NumCards;
+ if(chips == 1)
{
#ifdef ADLMIDI_USE_DOSBOX_OPL
player->opl.cards[0].GenerateArr(out_buf, &in_generatedStereo);
@@ -615,7 +616,7 @@ ADLMIDI_EXPORT int adl_play(ADL_MIDIPlayer *device, int sampleCount, short *out)
else if(n_periodCountStereo > 0)
{
/* Generate data from every chip and mix result */
- for(unsigned card = 0; card < player->m_setup.NumCards; ++card)
+ for(unsigned card = 0; card < chips; ++card)
{
#ifdef ADLMIDI_USE_DOSBOX_OPL
player->opl.cards[card].GenerateArrMix(out_buf, &in_generatedStereo);
@@ -641,10 +642,12 @@ ADLMIDI_EXPORT int adl_play(ADL_MIDIPlayer *device, int sampleCount, short *out)
}
-ADLMIDI_EXPORT int adl_generate(ADL_MIDIPlayer *device, int sampleCount, short *out)
+ADLMIDI_EXPORT int adl_generate(struct ADL_MIDIPlayer *device, int sampleCount, short *out)
{
#ifdef ADLMIDI_HW_OPL
- (void)device; (void)sampleCount; (void)out;
+ (void)device;
+ (void)sampleCount;
+ (void)out;
return 0;
#else
sampleCount -= sampleCount % 2; //Avoid even sample requests
@@ -689,7 +692,7 @@ ADLMIDI_EXPORT int adl_generate(ADL_MIDIPlayer *device, int sampleCount, short *
#endif
}
-ADLMIDI_EXPORT double adl_tickEvents(ADL_MIDIPlayer *device, double seconds, double granuality)
+ADLMIDI_EXPORT double adl_tickEvents(struct ADL_MIDIPlayer *device, double seconds, double granuality)
{
if(!device)
return -1.0;
@@ -699,7 +702,7 @@ ADLMIDI_EXPORT double adl_tickEvents(ADL_MIDIPlayer *device, double seconds, dou
return player->Tick(seconds, granuality);
}
-ADLMIDI_EXPORT int adl_atEnd(ADL_MIDIPlayer *device)
+ADLMIDI_EXPORT int adl_atEnd(struct ADL_MIDIPlayer *device)
{
if(!device)
return 1;
@@ -709,7 +712,7 @@ ADLMIDI_EXPORT int adl_atEnd(ADL_MIDIPlayer *device)
return (int)player->atEnd;
}
-ADLMIDI_EXPORT void adl_panic(ADL_MIDIPlayer *device)
+ADLMIDI_EXPORT void adl_panic(struct ADL_MIDIPlayer *device)
{
if(!device)
return;
diff --git a/src/adlmidi_load.cpp b/src/adlmidi_load.cpp
index 67faead..ad184e4 100644
--- a/src/adlmidi_load.cpp
+++ b/src/adlmidi_load.cpp
@@ -329,10 +329,8 @@ bool MIDIplay::LoadMIDI(const std::string &filename)
{
fileReader file;
file.openFile(filename.c_str());
-
if(!LoadMIDI(file))
return false;
-
return true;
}
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp
index 51da17e..6024373 100644
--- a/src/adlmidi_midiplay.cpp
+++ b/src/adlmidi_midiplay.cpp
@@ -1237,7 +1237,7 @@ void MIDIplay::realTime_Controller(uint8_t channel, uint8_t type, uint8_t value)
case 121: // Reset all controllers
Ch[channel].bend = 0;
Ch[channel].volume = 100;
- Ch[channel].expression = 100;
+ Ch[channel].expression = 127;
Ch[channel].sustain = 0;
Ch[channel].vibrato = 0;
Ch[channel].vibspeed = 2 * 3.141592653 * 5.0;
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp
index bdf9577..5162c11 100644
--- a/src/adlmidi_private.hpp
+++ b/src/adlmidi_private.hpp
@@ -893,9 +893,7 @@ private:
MIDIchannel::activenoteiterator i,
unsigned props_mask,
int32_t select_adlchn = -1);
- bool ProcessEvents();
bool ProcessEventsNew(bool isSeek = false);
- void HandleEvent(size_t tk);
void HandleEvent(size_t tk, const MidiEvent &evt, int &status);
// Determine how good a candidate this adlchannel