mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-09-08 12:20:15 +00:00
Merge pull request #347 from a740g/audio-enhancements
Audio enhancements
This commit is contained in:
commit
06a3e03083
12 changed files with 10219 additions and 11614 deletions
|
@ -7,23 +7,13 @@
|
||||||
//
|
//
|
||||||
// QB64-PE Audio Engine powered by miniaudio (https://miniaud.io/)
|
// QB64-PE Audio Engine powered by miniaudio (https://miniaud.io/)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2022 Samuel Gomes
|
|
||||||
// https://github.com/a740g
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
// HEADER FILES
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
// MACROS
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
#if defined(AUDIO_DEBUG) && AUDIO_DEBUG > 0
|
#if defined(AUDIO_DEBUG) && AUDIO_DEBUG > 0
|
||||||
# ifdef _MSC_VER
|
# ifdef _MSC_VER
|
||||||
# define AUDIO_DEBUG_PRINT(_fmt_, ...) fprintf(stderr, "DEBUG: %s:%d:%s(): " _fmt_ "\n", __FILE__, __LINE__, __func__, __VA_ARGS__)
|
# define AUDIO_DEBUG_PRINT(_fmt_, ...) fprintf(stderr, "DEBUG: %s:%d:%s(): " _fmt_ "\n", __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||||
|
@ -44,21 +34,13 @@
|
||||||
|
|
||||||
// We always use 48000
|
// We always use 48000
|
||||||
#define MA_DEFAULT_SAMPLE_RATE 48000
|
#define MA_DEFAULT_SAMPLE_RATE 48000
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
// FORWARD DECLARATIONS
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
struct qbs;
|
struct qbs;
|
||||||
struct mem_block;
|
struct mem_block;
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
void sub_sound(double frequency, double lengthInClockTicks, double volume, double panning, int32_t waveform, int32_t passed);
|
||||||
// FUNCTIONS
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
void sub_sound(double frequency, double lengthInClockTicks);
|
|
||||||
void sub_beep();
|
void sub_beep();
|
||||||
void sub_play(qbs *str);
|
void sub_play(const qbs *str);
|
||||||
int32_t func_play(int32_t ignore);
|
int32_t func_play(int32_t ignore);
|
||||||
|
|
||||||
int32_t func__sndrate();
|
int32_t func__sndrate();
|
||||||
|
@ -91,5 +73,3 @@ int32_t func__sndnew(int32_t frames, int32_t channels, int32_t bits);
|
||||||
void snd_init();
|
void snd_init();
|
||||||
void snd_un_init();
|
void snd_un_init();
|
||||||
void snd_mainloop();
|
void snd_mainloop();
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,17 +11,17 @@
|
||||||
//
|
//
|
||||||
// https://github.com/pete-gordon/hivelytracker (BSD 3-Clause)
|
// https://github.com/pete-gordon/hivelytracker (BSD 3-Clause)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2022 Samuel Gomes
|
|
||||||
// https://github.com/a740g
|
|
||||||
//
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "../miniaudio.h"
|
#include "../miniaudio.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "filepath.h"
|
#include "filepath.h"
|
||||||
#include "hivelytracker/hvl_replay.h"
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "hivelytracker/hvl_replay.h"
|
||||||
|
|
||||||
|
#include "vtables.h"
|
||||||
|
|
||||||
constexpr auto MAX_HIVELY_FRAMES = 10 * 60 * 50; // maximium *hively* frames before timeout
|
constexpr auto MAX_HIVELY_FRAMES = 10 * 60 * 50; // maximium *hively* frames before timeout
|
||||||
|
|
||||||
struct ma_hively {
|
struct ma_hively {
|
||||||
|
@ -522,7 +522,12 @@ static void ma_decoding_backend_uninit__hively(void *pUserData, ma_data_source *
|
||||||
ma_free(pmaHively, pAllocationCallbacks);
|
ma_free(pmaHively, pAllocationCallbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
ma_decoding_backend_vtable ma_vtable_hively = {ma_decoding_backend_init__hively, ma_decoding_backend_init_file__hively, NULL, /* onInitFileW() */
|
// clang-format off
|
||||||
|
ma_decoding_backend_vtable ma_vtable_hively = {
|
||||||
|
ma_decoding_backend_init__hively,
|
||||||
|
ma_decoding_backend_init_file__hively,
|
||||||
|
NULL, /* onInitFileW() */
|
||||||
NULL, /* onInitMemory() */
|
NULL, /* onInitMemory() */
|
||||||
ma_decoding_backend_uninit__hively};
|
ma_decoding_backend_uninit__hively
|
||||||
//-----------------------------------------------------------------------------------------------------
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
|
@ -15,15 +15,12 @@
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "libqb-common.h"
|
#include "../miniaudio.h"
|
||||||
|
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "filepath.h"
|
#include "filepath.h"
|
||||||
|
#include "libqb-common.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../miniaudio.h"
|
|
||||||
|
|
||||||
#define STB_VORBIS_HEADER_ONLY
|
#define STB_VORBIS_HEADER_ONLY
|
||||||
#include "stb_vorbis.c"
|
#include "stb_vorbis.c"
|
||||||
#define TSF_IMPLEMENTATION
|
#define TSF_IMPLEMENTATION
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
#include "vtables.h"
|
#include "vtables.h"
|
||||||
|
|
||||||
ma_decoding_backend_vtable ma_vtable_midi = { };
|
ma_decoding_backend_vtable ma_vtable_midi = {};
|
||||||
|
|
|
@ -10,28 +10,19 @@
|
||||||
// This implements a data source that decodes MOD, S3M, XM & IT files using libxmp-lite
|
// This implements a data source that decodes MOD, S3M, XM & IT files using libxmp-lite
|
||||||
// https://github.com/libxmp/libxmp/tree/master/lite (MIT)
|
// https://github.com/libxmp/libxmp/tree/master/lite (MIT)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2022 Samuel Gomes
|
|
||||||
// https://github.com/a740g
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
// HEADER FILES
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
#include "libqb-common.h"
|
|
||||||
#include "audio.h"
|
|
||||||
#include "filepath.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "../miniaudio.h"
|
#include "../miniaudio.h"
|
||||||
|
#include "audio.h"
|
||||||
|
#include "filepath.h"
|
||||||
|
#include "libqb-common.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define BUILDING_STATIC 1
|
#define BUILDING_STATIC 1
|
||||||
#include "libxmp-lite/xmp.h"
|
#include "libxmp-lite/xmp.h"
|
||||||
|
|
||||||
#include "vtables.h"
|
#include "vtables.h"
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
struct ma_modplay {
|
struct ma_modplay {
|
||||||
// This part is for miniaudio
|
// This part is for miniaudio
|
||||||
|
@ -199,8 +190,15 @@ static ma_result ma_modplay_ds_get_length(ma_data_source *pDataSource, ma_uint64
|
||||||
return ma_modplay_get_length_in_pcm_frames((ma_modplay *)pDataSource, pLength);
|
return ma_modplay_get_length_in_pcm_frames((ma_modplay *)pDataSource, pLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ma_data_source_vtable ma_data_source_vtable_modplay = {ma_modplay_ds_read, ma_modplay_ds_seek, ma_modplay_ds_get_data_format, ma_modplay_ds_get_cursor,
|
// clang-format off
|
||||||
ma_modplay_ds_get_length};
|
static ma_data_source_vtable ma_data_source_vtable_modplay = {
|
||||||
|
ma_modplay_ds_read,
|
||||||
|
ma_modplay_ds_seek,
|
||||||
|
ma_modplay_ds_get_data_format,
|
||||||
|
ma_modplay_ds_get_cursor,
|
||||||
|
ma_modplay_ds_get_length
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
static int ma_modplay_of_callback__read(void *pUserData, unsigned char *pBufferOut, int bytesToRead) {
|
static int ma_modplay_of_callback__read(void *pUserData, unsigned char *pBufferOut, int bytesToRead) {
|
||||||
ma_modplay *pModplay = (ma_modplay *)pUserData;
|
ma_modplay *pModplay = (ma_modplay *)pUserData;
|
||||||
|
@ -506,6 +504,7 @@ static void ma_decoding_backend_uninit__modplay(void *pUserData, ma_data_source
|
||||||
ma_free(pModplay, pAllocationCallbacks);
|
ma_free(pModplay, pAllocationCallbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
ma_decoding_backend_vtable ma_vtable_modplay = {
|
ma_decoding_backend_vtable ma_vtable_modplay = {
|
||||||
ma_decoding_backend_init__modplay,
|
ma_decoding_backend_init__modplay,
|
||||||
ma_decoding_backend_init_file__modplay,
|
ma_decoding_backend_init_file__modplay,
|
||||||
|
@ -513,5 +512,4 @@ ma_decoding_backend_vtable ma_vtable_modplay = {
|
||||||
NULL, /* onInitMemory() */
|
NULL, /* onInitMemory() */
|
||||||
ma_decoding_backend_uninit__modplay
|
ma_decoding_backend_uninit__modplay
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
|
|
|
@ -10,53 +10,21 @@
|
||||||
// This implements a data source that decodes Reality Adlib Tracker 2 tunes
|
// This implements a data source that decodes Reality Adlib Tracker 2 tunes
|
||||||
// https://realityproductions.itch.io/rad (Public Domain)
|
// https://realityproductions.itch.io/rad (Public Domain)
|
||||||
//
|
//
|
||||||
// From: Willy Reeve <shayde0@gmail.com>
|
|
||||||
// Sent: Sunday, 7 August, 2022 01:23 PM
|
|
||||||
// To: Samuel Gomes <v_2samg@hotmail.com>
|
|
||||||
// Cc: Carl Pettitt <carl@clonestudios.co.uk>
|
|
||||||
// Subject: Re: Contact from Reality website
|
|
||||||
//
|
|
||||||
// Hi Samuel,
|
|
||||||
//
|
|
||||||
// The player source code is Public Domain.
|
|
||||||
//
|
|
||||||
// Shayde
|
|
||||||
//
|
|
||||||
// On Fri, Aug 5, 2022 at 6:33 AM Reality website <rogue@3eality.com> wrote:
|
|
||||||
// Contact from the Reality website:
|
|
||||||
// Name: Samuel Gomes
|
|
||||||
// Email: v_2samg@hotmail.com
|
|
||||||
// Message:
|
|
||||||
//
|
|
||||||
// RADv2 - great stuff! I am planning to integrate the included player code in my projects. Can you please
|
|
||||||
// let me know the license type for the player code? If there is one, putting it somewhere on the site or
|
|
||||||
// zip would be fantastic!
|
|
||||||
//
|
|
||||||
// Thanks!
|
|
||||||
//
|
|
||||||
// Copyright (c) 2022 Samuel Gomes
|
|
||||||
// https://github.com/a740g
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
// HEADER FILES
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
#include "libqb-common.h"
|
|
||||||
#include "audio.h"
|
|
||||||
#include "filepath.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "../miniaudio.h"
|
#include "../miniaudio.h"
|
||||||
|
#include "audio.h"
|
||||||
|
#include "filepath.h"
|
||||||
|
#include "libqb-common.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "radv2/opal.cpp"
|
#include "radv2/opal.cpp"
|
||||||
#define RAD_DETECT_REPEATS 1
|
#define RAD_DETECT_REPEATS 1
|
||||||
#include "radv2/player20.cpp"
|
#include "radv2/player20.cpp"
|
||||||
#include "radv2/validate20.cpp"
|
#include "radv2/validate20.cpp"
|
||||||
|
|
||||||
#include "vtables.h"
|
#include "vtables.h"
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
struct ma_radv2 {
|
struct ma_radv2 {
|
||||||
// This part is for miniaudio
|
// This part is for miniaudio
|
||||||
|
@ -234,8 +202,15 @@ static ma_result ma_radv2_ds_get_length(ma_data_source *pDataSource, ma_uint64 *
|
||||||
return ma_radv2_get_length_in_pcm_frames((ma_radv2 *)pDataSource, pLength);
|
return ma_radv2_get_length_in_pcm_frames((ma_radv2 *)pDataSource, pLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ma_data_source_vtable ma_data_source_vtable_radv2 = {ma_radv2_ds_read, ma_radv2_ds_seek, ma_radv2_ds_get_data_format, ma_radv2_ds_get_cursor,
|
// clang-format off
|
||||||
ma_radv2_ds_get_length};
|
static ma_data_source_vtable ma_data_source_vtable_radv2 = {
|
||||||
|
ma_radv2_ds_read,
|
||||||
|
ma_radv2_ds_seek,
|
||||||
|
ma_radv2_ds_get_data_format,
|
||||||
|
ma_radv2_ds_get_cursor,
|
||||||
|
ma_radv2_ds_get_length
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
static int ma_radv2_of_callback__read(void *pUserData, unsigned char *pBufferOut, int bytesToRead) {
|
static int ma_radv2_of_callback__read(void *pUserData, unsigned char *pBufferOut, int bytesToRead) {
|
||||||
ma_radv2 *pRadv2 = (ma_radv2 *)pUserData;
|
ma_radv2 *pRadv2 = (ma_radv2 *)pUserData;
|
||||||
|
@ -609,6 +584,7 @@ static void ma_decoding_backend_uninit__radv2(void *pUserData, ma_data_source *p
|
||||||
ma_free(pRadv2, pAllocationCallbacks);
|
ma_free(pRadv2, pAllocationCallbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
ma_decoding_backend_vtable ma_vtable_radv2 = {
|
ma_decoding_backend_vtable ma_vtable_radv2 = {
|
||||||
ma_decoding_backend_init__radv2,
|
ma_decoding_backend_init__radv2,
|
||||||
ma_decoding_backend_init_file__radv2,
|
ma_decoding_backend_init_file__radv2,
|
||||||
|
@ -616,4 +592,4 @@ ma_decoding_backend_vtable ma_vtable_radv2 = {
|
||||||
NULL, /* onInitMemory() */
|
NULL, /* onInitMemory() */
|
||||||
ma_decoding_backend_uninit__radv2
|
ma_decoding_backend_uninit__radv2
|
||||||
};
|
};
|
||||||
//-----------------------------------------------------------------------------------------------------
|
// clang-format on
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,9 +7,6 @@
|
||||||
//
|
//
|
||||||
// QB64-PE Audio Engine powered by miniaudio (https://miniaud.io/)
|
// QB64-PE Audio Engine powered by miniaudio (https://miniaud.io/)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2022 Samuel Gomes
|
|
||||||
// https://github.com/a740g
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Enable Ogg Vorbis decoding
|
// Enable Ogg Vorbis decoding
|
||||||
|
|
|
@ -7,22 +7,10 @@
|
||||||
//
|
//
|
||||||
// QB64-PE Audio Engine powered by miniaudio (https://miniaud.io/)
|
// QB64-PE Audio Engine powered by miniaudio (https://miniaud.io/)
|
||||||
//
|
//
|
||||||
// Copyright (c) 2022 Samuel Gomes
|
|
||||||
// https://github.com/a740g
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
// HEADER FILES
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
// FUNCTIONS
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
void snd_mainloop() { return; }
|
void snd_mainloop() { return; }
|
||||||
void snd_init() { return; }
|
void snd_init() { return; }
|
||||||
void snd_un_init() { return; }
|
void snd_un_init() { return; }
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
//-----------------------------------------------------------------------------------------------------
|
|
||||||
|
|
|
@ -439,7 +439,6 @@ extern long double func_val(qbs *s);
|
||||||
extern void sub_out(int32 port, int32 data);
|
extern void sub_out(int32 port, int32 data);
|
||||||
extern void sub_randomize(double seed, int32 passed);
|
extern void sub_randomize(double seed, int32 passed);
|
||||||
extern float func_rnd(float n, int32 passed);
|
extern float func_rnd(float n, int32 passed);
|
||||||
extern void sub_sound(double frequency, double lengthinclockticks);
|
|
||||||
// following are declared below to allow for inlining
|
// following are declared below to allow for inlining
|
||||||
// extern double func_abs(double d);
|
// extern double func_abs(double d);
|
||||||
// extern long double func_abs(long double d);
|
// extern long double func_abs(long double d);
|
||||||
|
@ -537,7 +536,6 @@ extern qbs *func_input(int32 n, int32 i, int32 passed);
|
||||||
extern int32 func__statusCode(int32 handle);
|
extern int32 func__statusCode(int32 handle);
|
||||||
|
|
||||||
extern double func_sqr(double value);
|
extern double func_sqr(double value);
|
||||||
extern void sub_beep();
|
|
||||||
extern void snd_check();
|
extern void snd_check();
|
||||||
extern qbs *func_command(int32 index, int32 passed);
|
extern qbs *func_command(int32 index, int32 passed);
|
||||||
extern int32 func__commandcount();
|
extern int32 func__commandcount();
|
||||||
|
|
|
@ -3022,9 +3022,10 @@ clearid
|
||||||
id.n = "Sound": id.Dependency = DEPENDENCY_AUDIO_OUT
|
id.n = "Sound": id.Dependency = DEPENDENCY_AUDIO_OUT
|
||||||
id.subfunc = 2
|
id.subfunc = 2
|
||||||
id.callname = "sub_sound"
|
id.callname = "sub_sound"
|
||||||
id.args = 2
|
id.args = 5
|
||||||
id.arg = MKL$(DOUBLETYPE - ISPOINTER) + MKL$(DOUBLETYPE - ISPOINTER)
|
id.arg = MKL$(DOUBLETYPE - ISPOINTER) + MKL$(DOUBLETYPE - ISPOINTER) + MKL$(DOUBLETYPE - ISPOINTER) + MKL$(DOUBLETYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER)
|
||||||
id.hr_syntax = "SOUND frequency, duration"
|
id.specialformat = "?,?[,[?][,[?][,?]]]"
|
||||||
|
id.hr_syntax = "SOUND frequency#, duration#[, volume#][, panning#][, waveform&]"
|
||||||
regid
|
regid
|
||||||
|
|
||||||
clearid
|
clearid
|
||||||
|
|
Loading…
Reference in a new issue