Skip to content

Commit

Permalink
Merge pull request QB64-Phoenix-Edition#370 from a740g/audio-enhancem…
Browse files Browse the repository at this point in the history
…ents

Audio enhancements
  • Loading branch information
a740g authored Sep 20, 2023
2 parents 4aa4a3e + 4f004c1 commit 45b68b3
Show file tree
Hide file tree
Showing 23 changed files with 3,533 additions and 1,117 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ ifneq ($(filter y,$(DEP_AUDIO_MINIAUDIO)),)
CXXFLAGS += -DDEPENDENCY_AUDIO_MINIAUDIO
QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME))

LICENSE_IN_USE += miniaudio libxmp-lite radv2 stbvorbis hivelytracker
LICENSE_IN_USE += miniaudio stbvorbis libxmp-lite radv2 hivelytracker qoa

ifdef DEP_AUDIO_DECODE_MIDI
LICENSE_IN_USE += tinysoundfont tinymidiloader
Expand Down
3 changes: 2 additions & 1 deletion internal/c/parts/audio/extras/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ $(PATH_INTERNAL_C)/parts/audio/extras/hivelytracker/%.o: $(PATH_INTERNAL_C)/part
MA_VTABLES_SRCS := \
mod_ma_vtable.cpp \
radv2_ma_vtable.cpp \
hively_ma_vtable.cpp
hively_ma_vtable.cpp \
qoa_ma_vtable.cpp

MA_VTABLES_OBJS := $(patsubst %.cpp,$(PATH_INTERNAL_C)/parts/audio/extras/%.o,$(MA_VTABLES_SRCS))

Expand Down
4 changes: 2 additions & 2 deletions internal/c/parts/audio/extras/hively_ma_vtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ static ma_result ma_hively_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tel
const ma_decoding_backend_config *pConfig, const ma_allocation_callbacks *pAllocationCallbacks, ma_hively *pmaHively) {
ma_result result;

(void)pAllocationCallbacks; /* Can't seem to find a way to configure memory allocations in libopus. */
(void)pAllocationCallbacks;

result = ma_hively_init_internal(pConfig, pmaHively);
if (result != MA_SUCCESS) {
Expand Down Expand Up @@ -408,7 +408,7 @@ static ma_result ma_hively_init_file(const char *pFilePath, const ma_decoding_ba
ma_hively *pmaHively) {
ma_result result;

(void)pAllocationCallbacks; /* Can't seem to find a way to configure memory allocations in libopus. */
(void)pAllocationCallbacks;

result = ma_hively_init_internal(pConfig, pmaHively);
if (result != MA_SUCCESS) {
Expand Down
17 changes: 12 additions & 5 deletions internal/c/parts/audio/extras/hivelytracker/hvl_replay.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ struct hvl_tune *hvl_load_ahx(const uint8 *buf, uint32 buflen, uint32 defstereo,
return NULL;
}

strncpy(ht->ht_Name, (TEXT *)&buf[(buf[4] << 8) | buf[5]], 128);
strncpy(ht->ht_Name, (TEXT *)&buf[(buf[4] << 8) | buf[5]], 127);
ht->ht_Name[127] = '\0';
nptr = (TEXT *)&buf[((buf[4] << 8) | buf[5]) + strlen(ht->ht_Name) + 1];

bptr = &buf[14];
Expand Down Expand Up @@ -609,7 +610,8 @@ struct hvl_tune *hvl_load_ahx(const uint8 *buf, uint32 buflen, uint32 defstereo,
// Instruments
for (i = 1; i <= ht->ht_InstrumentNr; i++) {
if (nptr < (TEXT *)(buf + buflen)) {
strncpy(ht->ht_Instruments[i].ins_Name, nptr, 128);
strncpy(ht->ht_Instruments[i].ins_Name, nptr, 127);
ht->ht_Instruments[i].ins_Name[127] = '\0';
nptr += strlen(nptr) + 1;
} else {
ht->ht_Instruments[i].ins_Name[0] = 0;
Expand Down Expand Up @@ -764,7 +766,8 @@ struct hvl_tune *hvl_load_hvl(const uint8 *buf, uint32 buflen, uint32 defstereo,
return NULL;
}

strncpy(ht->ht_Name, (TEXT *)&buf[(buf[4] << 8) | buf[5]], 128);
strncpy(ht->ht_Name, (TEXT *)&buf[(buf[4] << 8) | buf[5]], 127);
ht->ht_Name[127] = '\0';
nptr = (TEXT *)&buf[((buf[4] << 8) | buf[5]) + strlen(ht->ht_Name) + 1];

bptr = &buf[16];
Expand Down Expand Up @@ -822,7 +825,8 @@ struct hvl_tune *hvl_load_hvl(const uint8 *buf, uint32 buflen, uint32 defstereo,
// Instruments
for (i = 1; i <= ht->ht_InstrumentNr; i++) {
if (nptr < (TEXT *)(buf + buflen)) {
strncpy(ht->ht_Instruments[i].ins_Name, nptr, 128);
strncpy(ht->ht_Instruments[i].ins_Name, nptr, 127);
ht->ht_Instruments[i].ins_Name[127] = '\0';
nptr += strlen(nptr) + 1;
} else {
ht->ht_Instruments[i].ins_Name[0] = 0;
Expand Down Expand Up @@ -1371,7 +1375,7 @@ void hvl_plist_command_parse(const struct hvl_tune *ht, struct hvl_voice *voice,
voice->vc_RingPlantPeriod = 1;
break;

/* New in HivelyTracker 1.4 */
/* New in HivelyTracker 1.4 */
case 9:
if (FXParam > 127)
FXParam -= 256;
Expand Down Expand Up @@ -1470,15 +1474,18 @@ void hvl_process_frame(struct hvl_tune *ht, struct hvl_voice *voice) {

if (--voice->vc_ADSR.aFrames <= 0)
voice->vc_ADSRVolume = voice->vc_Instrument->ins_Envelope.aVolume << 8;

} else if (voice->vc_ADSR.dFrames) {

voice->vc_ADSRVolume += voice->vc_ADSR.dVolume;

if (--voice->vc_ADSR.dFrames <= 0)
voice->vc_ADSRVolume = voice->vc_Instrument->ins_Envelope.dVolume << 8;

} else if (voice->vc_ADSR.sFrames) {

voice->vc_ADSR.sFrames--;

} else if (voice->vc_ADSR.rFrames) {

voice->vc_ADSRVolume += voice->vc_ADSR.rVolume;
Expand Down
4 changes: 2 additions & 2 deletions internal/c/parts/audio/extras/midi_ma_vtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ static ma_result ma_tsf_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_tell_p
const ma_decoding_backend_config *pConfig, const ma_allocation_callbacks *pAllocationCallbacks, ma_tsf *pTsf) {
ma_result result;

(void)pAllocationCallbacks; /* Can't seem to find a way to configure memory allocations in libopus. */
(void)pAllocationCallbacks;

result = ma_tsf_init_internal(pConfig, pTsf);
if (result != MA_SUCCESS) {
Expand Down Expand Up @@ -451,7 +451,7 @@ static ma_result ma_tsf_init_file(const char *pFilePath, const ma_decoding_backe
ma_tsf *pTsf) {
ma_result result;

(void)pAllocationCallbacks; /* Can't seem to find a way to configure memory allocations in libopus. */
(void)pAllocationCallbacks;

result = ma_tsf_init_internal(pConfig, pTsf);
if (result != MA_SUCCESS) {
Expand Down
4 changes: 2 additions & 2 deletions internal/c/parts/audio/extras/mod_ma_vtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ static ma_result ma_modplay_init(ma_read_proc onRead, ma_seek_proc onSeek, ma_te
const ma_decoding_backend_config *pConfig, const ma_allocation_callbacks *pAllocationCallbacks, ma_modplay *pModplay) {
ma_result result;

(void)pAllocationCallbacks; /* Can't seem to find a way to configure memory allocations in libopus. */
(void)pAllocationCallbacks;

result = ma_modplay_init_internal(pConfig, pModplay);
if (result != MA_SUCCESS) {
Expand Down Expand Up @@ -379,7 +379,7 @@ static ma_result ma_modplay_init_file(const char *pFilePath, const ma_decoding_b
ma_modplay *pModplay) {
ma_result result;

(void)pAllocationCallbacks; /* Can't seem to find a way to configure memory allocations in libopus. */
(void)pAllocationCallbacks;

result = ma_modplay_init_internal(pConfig, pModplay);
if (result != MA_SUCCESS) {
Expand Down
Loading

0 comments on commit 45b68b3

Please sign in to comment.