aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakamichi Horikawa <takamichiho@gmail.com>2017-11-23 13:51:14 +0900
committerTakamichi Horikawa <takamichiho@gmail.com>2017-11-23 13:51:14 +0900
commitf774afc5387887f4ce8067502412f5f64899632f (patch)
tree71d588865295f3da64d0ba31ae044d7fc48f64f2
parentdfe585145747ee3d41297367f97d320230df26b3 (diff)
libopna: make levelmeter and oscillo conditional
-rw-r--r--common/fmplayer_file_unix.c4
-rw-r--r--gtk/Makefile.am2
-rw-r--r--libopna/opna.c13
-rw-r--r--libopna/opnaadpcm.c6
-rw-r--r--libopna/opnaadpcm.h5
-rw-r--r--libopna/opnadrum.c4
-rw-r--r--libopna/opnadrum.h4
-rw-r--r--libopna/opnafm.c10
-rw-r--r--libopna/opnafm.h5
-rw-r--r--libopna/opnassg-sinc-c.c2
-rw-r--r--libopna/opnassg.c10
-rw-r--r--libopna/opnassg.h4
-rw-r--r--win32/fmplayer.mak3
13 files changed, 65 insertions, 7 deletions
diff --git a/common/fmplayer_file_unix.c b/common/fmplayer_file_unix.c
index d2855c3..d6fb4ed 100644
--- a/common/fmplayer_file_unix.c
+++ b/common/fmplayer_file_unix.c
@@ -125,3 +125,7 @@ err:
void *fmplayer_path_dup(const void *path) {
return strdup(path);
}
+
+char *fmplayer_path_filename_sjis(const void *path) {
+ return 0;
+}
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 69d604b..0b3e8bc 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -36,7 +36,7 @@ endif
fmplayer_CPPFLAGS=-Wall -Wextra -pedantic \
-I$(top_srcdir)/.. -I$(top_srcdir)/../soundout \
$(GTK3_CFLAGS) $(JACK_CFLAGS) $(PULSE_CFLAGS) $(ALSA_CFLAGS) $(SNDFILE_CFLAGS) \
- -DPACC_GL_3
+ -DPACC_GL_3 -DLIBOPNA_ENABLE_LEVELDATA -DLIBOPNA_ENABLE_OSCILLO
fmplayer_LDADD=$(GTK3_LIBS) $(JACK_LIBS) $(PULSE_LIBS) $(ALSA_LIBS) $(SNDFILE_LIBS) -lm -lpthread
if ENABLE_NEON
diff --git a/libopna/opna.c b/libopna/opna.c
index 9f87ff3..8998a59 100644
--- a/libopna/opna.c
+++ b/libopna/opna.c
@@ -1,5 +1,7 @@
#include "opna.h"
+#ifdef LIBOPNA_ENABLE_OSCILLO
#include "oscillo/oscillo.h"
+#endif
#include <string.h>
void opna_reset(struct opna *opna) {
@@ -30,6 +32,7 @@ void opna_mix(struct opna *opna, int16_t *buf, unsigned samples) {
}
void opna_mix_oscillo(struct opna *opna, int16_t *buf, unsigned samples, struct oscillodata *oscillo) {
+#ifdef LIBOPNA_ENABLE_OSCILLO
if (oscillo) {
for (int i = 0; i < LIBOPNA_OSCILLO_TRACK_COUNT; i++) {
memmove(&oscillo[i].buf[0],
@@ -38,9 +41,15 @@ void opna_mix_oscillo(struct opna *opna, int16_t *buf, unsigned samples, struct
}
}
unsigned offset = OSCILLO_SAMPLE_COUNT - samples;
- opna_fm_mix(&opna->fm, buf, samples, oscillo ? &oscillo[0] : 0, offset);
+ struct oscillodata *oscillofm = oscillo ? &oscillo[0] : 0;
+ struct oscillodata *oscillossg = oscillo ? &oscillo[6] : 0;
+#else
+ struct oscillodata *oscillofm = 0, *oscillossg = 0;
+ unsigned offset = 0;
+#endif
+ opna_fm_mix(&opna->fm, buf, samples, oscillofm, offset);
opna_ssg_mix_55466(&opna->ssg, &opna->resampler, buf, samples,
- oscillo ? &oscillo[6] : 0, offset);
+ oscillossg, offset);
opna_drum_mix(&opna->drum, buf, samples);
opna_adpcm_mix(&opna->adpcm, buf, samples);
opna->generated_frames += samples;
diff --git a/libopna/opnaadpcm.c b/libopna/opnaadpcm.c
index 7825c40..4001dc1 100644
--- a/libopna/opnaadpcm.c
+++ b/libopna/opnaadpcm.c
@@ -35,7 +35,9 @@ void opna_adpcm_reset(struct opna_adpcm *adpcm) {
adpcm->prev_acc = 0;
adpcm->adpcmd = 127;
adpcm->out = 0;
+#ifdef LIBOPNA_ENABLE_LEVELDATA
leveldata_init(&adpcm->leveldata);
+#endif
}
static uint32_t addr_conv(const struct opna_adpcm *adpcm, uint16_t a) {
@@ -184,7 +186,9 @@ void opna_adpcm_writereg(struct opna_adpcm *adpcm, unsigned reg, unsigned val) {
void opna_adpcm_mix(struct opna_adpcm *adpcm, int16_t *buf, unsigned samples) {
unsigned level = 0;
if (!adpcm->ram || !(adpcm->control1 & C1_START)) {
+#ifdef LIBOPNA_ENABLE_LEVELDATA
leveldata_update(&adpcm->leveldata, level);
+#endif
return;
}
for (unsigned i = 0; i < samples; i++) {
@@ -208,7 +212,9 @@ void opna_adpcm_mix(struct opna_adpcm *adpcm, int16_t *buf, unsigned samples) {
}
if (!(adpcm->control1 & C1_START)) return;
}
+#ifdef LIBOPNA_ENABLE_LEVELDATA
leveldata_update(&adpcm->leveldata, level);
+#endif
}
void opna_adpcm_set_ram_256k(struct opna_adpcm *adpcm, void *ram) {
diff --git a/libopna/opnaadpcm.h b/libopna/opnaadpcm.h
index 27a0be3..ce06b37 100644
--- a/libopna/opnaadpcm.h
+++ b/libopna/opnaadpcm.h
@@ -3,7 +3,9 @@
#include <stdint.h>
#include <stdbool.h>
+#ifdef LIBOPNA_ENABLE_LEVELDATA
#include "leveldata/leveldata.h"
+#endif
#ifdef __cplusplus
extern "C" {
@@ -25,8 +27,9 @@ struct opna_adpcm {
uint16_t adpcmd;
int16_t out;
bool masked;
- atomic_uint levelvu;
+#ifdef LIBOPNA_ENABLE_LEVELDATA
struct leveldata leveldata;
+#endif
};
void opna_adpcm_reset(struct opna_adpcm *adpcm);
diff --git a/libopna/opnadrum.c b/libopna/opnadrum.c
index 5bb3f56..2f5761c 100644
--- a/libopna/opnadrum.c
+++ b/libopna/opnadrum.c
@@ -23,7 +23,9 @@ void opna_drum_reset(struct opna_drum *drum) {
drum->drums[d].level = 0;
drum->drums[d].left = false;
drum->drums[d].right = false;
+#ifdef LIBOPNA_ENABLE_LEVELDATA
leveldata_init(&drum->drums[d].leveldata);
+#endif
}
drum->total_level = 0;
drum->mask = 0;
@@ -114,9 +116,11 @@ void opna_drum_mix(struct opna_drum *drum, int16_t *buf, int samples) {
buf[i*2+0] = lo;
buf[i*2+1] = ro;
}
+#ifdef LIBOPNA_ENABLE_LEVELDATA
for (int d = 0; d < 6; d++) {
leveldata_update(&drum->drums[d].leveldata, levels[d]);
}
+#endif
}
void opna_drum_writereg(struct opna_drum *drum, unsigned reg, unsigned val) {
diff --git a/libopna/opnadrum.h b/libopna/opnadrum.h
index 7260995..df42927 100644
--- a/libopna/opnadrum.h
+++ b/libopna/opnadrum.h
@@ -3,7 +3,9 @@
#include <stdint.h>
#include <stdbool.h>
+#ifdef LIBOPNA_ENABLE_LEVELDATA
#include "leveldata/leveldata.h"
+#endif
#ifdef __cplusplus
extern "C" {
@@ -33,7 +35,9 @@ struct opna_drum {
unsigned level;
bool left;
bool right;
+#ifdef LIBOPNA_ENABLE_LEVELDATA
struct leveldata leveldata;
+#endif
} drums[6];
unsigned total_level;
int16_t rom_bd[OPNA_ROM_BD_SIZE];
diff --git a/libopna/opnafm.c b/libopna/opnafm.c
index 2874e71..b96d727 100644
--- a/libopna/opnafm.c
+++ b/libopna/opnafm.c
@@ -1,5 +1,7 @@
#include "opnafm.h"
+#ifdef LIBOPNA_ENABLE_OSCILLO
#include "oscillo/oscillo.h"
+#endif
#include "opnatables.h"
@@ -28,7 +30,9 @@ static void opna_fm_slot_reset(struct opna_fm_slot *slot) {
void opna_fm_chan_reset(struct opna_fm_channel *chan) {
+#ifdef LIBOPNA_ENABLE_LEVELDATA
leveldata_init(&chan->leveldata);
+#endif
for (int i = 0; i < 4; i++) {
opna_fm_slot_reset(&chan->slot[i]);
}
@@ -620,6 +624,7 @@ static int gcd(int a, int b) {
void opna_fm_mix(struct opna_fm *fm, int16_t *buf, unsigned samples,
struct oscillodata *oscillo, unsigned offset) {
+#ifdef LIBOPNA_ENABLE_OSCILLO
if (oscillo) {
for (unsigned c = 0; c < 6; c++) {
const struct opna_fm_channel *ch = &fm->channel[c];
@@ -641,6 +646,7 @@ void opna_fm_mix(struct opna_fm *fm, int16_t *buf, unsigned samples,
}
}
}
+#endif
unsigned level[6] = {0};
for (unsigned i = 0; i < samples; i++) {
if (!fm->env_div3) {
@@ -666,7 +672,9 @@ void opna_fm_mix(struct opna_fm *fm, int16_t *buf, unsigned samples,
nlevel[1] = o.data[1] > 0 ? o.data[1] : -o.data[1];
if (nlevel[1] > nlevel[0]) nlevel[0] = nlevel[1];
if (nlevel[0] > level[c]) level[c] = nlevel[0];
+#ifdef LIBOPNA_ENABLE_OSCILLO
if (oscillo) oscillo[c].buf[offset+i] = o.data[0] + o.data[1];
+#endif
// TODO: CSM
if (c == 2 && fm->ch3.mode != CH3_MODE_NORMAL) {
opna_fm_chan_phase_se(&fm->channel[c], fm);
@@ -704,7 +712,9 @@ void opna_fm_mix(struct opna_fm *fm, int16_t *buf, unsigned samples,
}
fm->env_div3--;
}
+#ifdef LIBOPNA_ENABLE_LEVELDATA
for (int c = 0; c < 6; c++) {
leveldata_update(&fm->channel[c].leveldata, level[c]);
}
+#endif
}
diff --git a/libopna/opnafm.h b/libopna/opnafm.h
index 1549041..51bf214 100644
--- a/libopna/opnafm.h
+++ b/libopna/opnafm.h
@@ -3,7 +3,9 @@
#include <stdint.h>
#include <stdbool.h>
+#ifdef LIBOPNA_ENABLE_LEVELDATA
#include "leveldata/leveldata.h"
+#endif
#ifdef __cplusplus
extern "C" {
@@ -69,8 +71,9 @@ struct opna_fm_channel {
uint8_t fb;
uint16_t fnum;
uint8_t blk;
-
+#ifdef LIBOPNA_ENABLE_LEVELDATA
struct leveldata leveldata;
+#endif
};
struct opna_fm {
diff --git a/libopna/opnassg-sinc-c.c b/libopna/opnassg-sinc-c.c
index 5f9baee..dedf1c7 100644
--- a/libopna/opnassg-sinc-c.c
+++ b/libopna/opnassg-sinc-c.c
@@ -1,4 +1,4 @@
-#include "libopna/opnassg.h"
+#include "opnassg.h"
void opna_ssg_sinc_calc_c(unsigned resampler_index, const int16_t *inbuf, int32_t *outbuf) {
for (int c = 0; c < 3; c++) {
diff --git a/libopna/opnassg.c b/libopna/opnassg.c
index a40e6c8..ee6498a 100644
--- a/libopna/opnassg.c
+++ b/libopna/opnassg.c
@@ -1,5 +1,7 @@
#include "opnassg.h"
+#ifdef LIBOPNA_ENABLE_OSCILLO
#include "oscillo/oscillo.h"
+#endif
// if (i < 2) voltable[i] = 0;
// else voltable[i] = round((0x7fff / 3.0) * pow(2.0, (i - 31)/4.0));
@@ -153,9 +155,11 @@ void opna_ssg_resampler_reset(struct opna_ssg_resampler *resampler) {
resampler->buf[i] = 0;
}
resampler->index = 0;
+#ifdef LIBOPNA_ENABLE_LEVELDATA
for (int c = 0; c < 3; c++) {
leveldata_init(&resampler->leveldata[c]);
}
+#endif
}
void opna_ssg_writereg(struct opna_ssg *ssg, unsigned reg, unsigned val) {
@@ -300,6 +304,7 @@ void opna_ssg_mix_55466(
int16_t *buf, int samples,
struct oscillodata *oscillo, unsigned offset
) {
+#ifdef LIBOPNA_ENABLE_OSCILLO
if (oscillo) {
for (unsigned c = 0; c < 3; c++) {
unsigned period = (opna_ssg_tone_period(ssg, c) << OSCILLO_OFFSET_SHIFT) * 2 * 32 / 144;
@@ -311,6 +316,7 @@ void opna_ssg_mix_55466(
}
}
}
+#endif
unsigned level[3] = {0};
for (int i = 0; i < samples; i++) {
{
@@ -350,7 +356,9 @@ void opna_ssg_mix_55466(
}
}
for (int ch = 0; ch < 3; ch++) {
+#ifdef LIBOPNA_ENABLE_OSCILLO
if (oscillo) oscillo[ch].buf[offset+i] = outbuf[ch] << 1;
+#endif
int32_t nlevel = outbuf[ch];
if (nlevel < 0) nlevel = -nlevel;
if (((unsigned)nlevel) > level[ch]) level[ch] = nlevel;
@@ -368,8 +376,10 @@ void opna_ssg_mix_55466(
buf[i*2+0] = lo;
buf[i*2+1] = ro;
}
+#ifdef LIBOPNA_ENABLE_LEVELDATA
for (int c = 0; c < 3; c++) {
leveldata_update(&resampler->leveldata[c], level[c]);
}
+#endif
}
#undef BUFINDEX
diff --git a/libopna/opnassg.h b/libopna/opnassg.h
index 6b1d0cd..a0a50be 100644
--- a/libopna/opnassg.h
+++ b/libopna/opnassg.h
@@ -4,7 +4,9 @@
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
+#ifdef LIBOPNA_ENABLE_LEVELDATA
#include "leveldata/leveldata.h"
+#endif
#ifdef __cplusplus
extern "C" {
@@ -39,7 +41,9 @@ struct opna_ssg {
struct opna_ssg_resampler {
int16_t buf[OPNA_SSG_SINCTABLELEN*4 * 2];
unsigned index;
+#ifdef LIBOPNA_ENABLE_LEVELDATA
struct leveldata leveldata[3];
+#endif
};
void opna_ssg_reset(struct opna_ssg *ssg);
diff --git a/win32/fmplayer.mak b/win32/fmplayer.mak
index 1fc8d7c..383186b 100644
--- a/win32/fmplayer.mak
+++ b/win32/fmplayer.mak
@@ -5,7 +5,8 @@ ICONFILES=../fmplayer.png ../fmplayer32.png
DEFINES=UNICODE _UNICODE \
WINVER=0x0500 _WIN32_WINNT=0x0500 \
- DIRECTSOUND_VERSION=0x0800 FMPLAYER_FILE_WIN_UTF16
+ DIRECTSOUND_VERSION=0x0800 FMPLAYER_FILE_WIN_UTF16 \
+ LIBOPNA_ENABLE_LEVELDATA LIBOPNA_ENABLE_OSCILLO
FMDRIVER_OBJS=fmdriver_pmd \
fmdriver_fmp \