mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-10 20:35:14 +00:00
Merge pull request #347 from a740g/audio-enhancements
Audio enhancements
This commit is contained in:
commit
06a3e03083
|
@ -7,23 +7,13 @@
|
|||
//
|
||||
// QB64-PE Audio Engine powered by miniaudio (https://miniaud.io/)
|
||||
//
|
||||
// Copyright (c) 2022 Samuel Gomes
|
||||
// https://github.com/a740g
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// HEADER FILES
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// MACROS
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
#if defined(AUDIO_DEBUG) && AUDIO_DEBUG > 0
|
||||
# ifdef _MSC_VER
|
||||
# define AUDIO_DEBUG_PRINT(_fmt_, ...) fprintf(stderr, "DEBUG: %s:%d:%s(): " _fmt_ "\n", __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
|
@ -35,30 +25,22 @@
|
|||
AUDIO_DEBUG_PRINT("Condition (%s) failed", #_exp_)
|
||||
#else
|
||||
# ifdef _MSC_VER
|
||||
# define AUDIO_DEBUG_PRINT(_fmt_, ...) // Don't do anything in release builds
|
||||
# define AUDIO_DEBUG_PRINT(_fmt_, ...) // Don't do anything in release builds
|
||||
# else
|
||||
# define AUDIO_DEBUG_PRINT(_fmt_, _args_...) // Don't do anything in release builds
|
||||
# endif
|
||||
# define AUDIO_DEBUG_CHECK(_exp_) // Don't do anything in release builds
|
||||
# define AUDIO_DEBUG_CHECK(_exp_) // Don't do anything in release builds
|
||||
#endif
|
||||
|
||||
// We always use 48000
|
||||
#define MA_DEFAULT_SAMPLE_RATE 48000
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// FORWARD DECLARATIONS
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
struct qbs;
|
||||
struct mem_block;
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// FUNCTIONS
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
void sub_sound(double frequency, double lengthInClockTicks);
|
||||
void sub_sound(double frequency, double lengthInClockTicks, double volume, double panning, int32_t waveform, int32_t passed);
|
||||
void sub_beep();
|
||||
void sub_play(qbs *str);
|
||||
void sub_play(const qbs *str);
|
||||
int32_t func_play(int32_t ignore);
|
||||
|
||||
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_un_init();
|
||||
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)
|
||||
//
|
||||
// Copyright (c) 2022 Samuel Gomes
|
||||
// https://github.com/a740g
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "../miniaudio.h"
|
||||
#include "audio.h"
|
||||
#include "filepath.h"
|
||||
#include "hivelytracker/hvl_replay.h"
|
||||
#include <cstring>
|
||||
|
||||
#include "hivelytracker/hvl_replay.h"
|
||||
|
||||
#include "vtables.h"
|
||||
|
||||
constexpr auto MAX_HIVELY_FRAMES = 10 * 60 * 50; // maximium *hively* frames before timeout
|
||||
|
||||
struct ma_hively {
|
||||
|
@ -522,7 +522,12 @@ static void ma_decoding_backend_uninit__hively(void *pUserData, ma_data_source *
|
|||
ma_free(pmaHively, pAllocationCallbacks);
|
||||
}
|
||||
|
||||
ma_decoding_backend_vtable ma_vtable_hively = {ma_decoding_backend_init__hively, ma_decoding_backend_init_file__hively, NULL, /* onInitFileW() */
|
||||
NULL, /* onInitMemory() */
|
||||
ma_decoding_backend_uninit__hively};
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// 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() */
|
||||
ma_decoding_backend_uninit__hively
|
||||
};
|
||||
// clang-format on
|
||||
|
|
|
@ -7,23 +7,20 @@
|
|||
//
|
||||
// QB64-PE Audio Engine powered by miniaudio (https://miniaud.io/)
|
||||
//
|
||||
// This implements a data source that decodes MIDI files using TinySoundFont + TinyMidiLoader
|
||||
// https://github.com/schellingb/TinySoundFont (MIT)
|
||||
// This implements a data source that decodes MIDI files using TinySoundFont + TinyMidiLoader
|
||||
// https://github.com/schellingb/TinySoundFont (MIT)
|
||||
//
|
||||
// Soundfont (awe32rom.h) from dos-like
|
||||
// https://github.com/mattiasgustavsson/dos-like (MIT)
|
||||
// Soundfont (awe32rom.h) from dos-like
|
||||
// https://github.com/mattiasgustavsson/dos-like (MIT)
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "libqb-common.h"
|
||||
|
||||
#include "../miniaudio.h"
|
||||
#include "audio.h"
|
||||
#include "filepath.h"
|
||||
|
||||
#include "libqb-common.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "../miniaudio.h"
|
||||
|
||||
#define STB_VORBIS_HEADER_ONLY
|
||||
#include "stb_vorbis.c"
|
||||
#define TSF_IMPLEMENTATION
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
#include "vtables.h"
|
||||
|
||||
ma_decoding_backend_vtable ma_vtable_midi = { };
|
||||
ma_decoding_backend_vtable ma_vtable_midi = {};
|
||||
|
|
|
@ -7,31 +7,22 @@
|
|||
//
|
||||
// QB64-PE Audio Engine powered by miniaudio (https://miniaud.io/)
|
||||
//
|
||||
// This implements a data source that decodes MOD, S3M, XM & IT files using libxmp-lite
|
||||
// https://github.com/libxmp/libxmp/tree/master/lite (MIT)
|
||||
//
|
||||
// Copyright (c) 2022 Samuel Gomes
|
||||
// https://github.com/a740g
|
||||
// This implements a data source that decodes MOD, S3M, XM & IT files using libxmp-lite
|
||||
// https://github.com/libxmp/libxmp/tree/master/lite (MIT)
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// HEADER FILES
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
#include "libqb-common.h"
|
||||
#include "audio.h"
|
||||
#include "filepath.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../miniaudio.h"
|
||||
#include "audio.h"
|
||||
#include "filepath.h"
|
||||
#include "libqb-common.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BUILDING_STATIC 1
|
||||
#include "libxmp-lite/xmp.h"
|
||||
|
||||
#include "vtables.h"
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ma_modplay {
|
||||
// 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);
|
||||
}
|
||||
|
||||
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 off
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
ma_decoding_backend_vtable ma_vtable_modplay = {
|
||||
ma_decoding_backend_init__modplay,
|
||||
ma_decoding_backend_init_file__modplay,
|
||||
|
@ -513,5 +512,4 @@ ma_decoding_backend_vtable ma_vtable_modplay = {
|
|||
NULL, /* onInitMemory() */
|
||||
ma_decoding_backend_uninit__modplay
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// clang-format on
|
||||
|
|
|
@ -7,56 +7,24 @@
|
|||
//
|
||||
// QB64-PE Audio Engine powered by miniaudio (https://miniaud.io/)
|
||||
//
|
||||
// This implements a data source that decodes Reality Adlib Tracker 2 tunes
|
||||
// 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
|
||||
// This implements a data source that decodes Reality Adlib Tracker 2 tunes
|
||||
// https://realityproductions.itch.io/rad (Public Domain)
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// HEADER FILES
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
#include "libqb-common.h"
|
||||
#include "audio.h"
|
||||
#include "filepath.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../miniaudio.h"
|
||||
#include "audio.h"
|
||||
#include "filepath.h"
|
||||
#include "libqb-common.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "radv2/opal.cpp"
|
||||
#define RAD_DETECT_REPEATS 1
|
||||
#include "radv2/player20.cpp"
|
||||
#include "radv2/validate20.cpp"
|
||||
|
||||
#include "vtables.h"
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
struct ma_radv2 {
|
||||
// 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);
|
||||
}
|
||||
|
||||
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 off
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
ma_decoding_backend_vtable ma_vtable_radv2 = {
|
||||
ma_decoding_backend_init__radv2,
|
||||
ma_decoding_backend_init_file__radv2,
|
||||
|
@ -616,4 +592,4 @@ ma_decoding_backend_vtable ma_vtable_radv2 = {
|
|||
NULL, /* onInitMemory() */
|
||||
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/)
|
||||
//
|
||||
// Copyright (c) 2022 Samuel Gomes
|
||||
// https://github.com/a740g
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
// Enable Ogg Vorbis decoding
|
||||
|
|
|
@ -7,22 +7,10 @@
|
|||
//
|
||||
// QB64-PE Audio Engine powered by miniaudio (https://miniaud.io/)
|
||||
//
|
||||
// Copyright (c) 2022 Samuel Gomes
|
||||
// https://github.com/a740g
|
||||
//
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// HEADER FILES
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
#include "audio.h"
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
// FUNCTIONS
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
void snd_mainloop() { return; }
|
||||
void snd_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_randomize(double seed, 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
|
||||
// extern double func_abs(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 double func_sqr(double value);
|
||||
extern void sub_beep();
|
||||
extern void snd_check();
|
||||
extern qbs *func_command(int32 index, int32 passed);
|
||||
extern int32 func__commandcount();
|
||||
|
|
|
@ -3022,9 +3022,10 @@ clearid
|
|||
id.n = "Sound": id.Dependency = DEPENDENCY_AUDIO_OUT
|
||||
id.subfunc = 2
|
||||
id.callname = "sub_sound"
|
||||
id.args = 2
|
||||
id.arg = MKL$(DOUBLETYPE - ISPOINTER) + MKL$(DOUBLETYPE - ISPOINTER)
|
||||
id.hr_syntax = "SOUND frequency, duration"
|
||||
id.args = 5
|
||||
id.arg = MKL$(DOUBLETYPE - ISPOINTER) + MKL$(DOUBLETYPE - ISPOINTER) + MKL$(DOUBLETYPE - ISPOINTER) + MKL$(DOUBLETYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER)
|
||||
id.specialformat = "?,?[,[?][,[?][,?]]]"
|
||||
id.hr_syntax = "SOUND frequency#, duration#[, volume#][, panning#][, waveform&]"
|
||||
regid
|
||||
|
||||
clearid
|
||||
|
|
Loading…
Reference in a new issue