mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-06 21:00:25 +00:00
Rename _NEWSOUND
to _SNDNEW
to align with _SND*
APIs
This commit is contained in:
parent
1179d3c084
commit
061bf6af3d
|
@ -86,7 +86,7 @@ void sub__sndrawdone(int32_t handle, int32_t passed);
|
|||
double func__sndrawlen(int32_t handle, int32_t passed);
|
||||
|
||||
mem_block func__memsound(int32_t handle, int32_t targetChannel);
|
||||
int32_t func__newsound(int32_t frames, int32_t channels, int32_t bits, int32_t rate, int32_t passed);
|
||||
int32_t func__sndnew(int32_t frames, int32_t channels, int32_t bits);
|
||||
|
||||
void snd_init();
|
||||
void snd_un_init();
|
||||
|
|
|
@ -1829,24 +1829,16 @@ double func__sndrawlen(int32_t handle, int32_t passed) {
|
|||
/// <param name="frames">The number of sample frames required</param>
|
||||
/// <param name="channels">The number of sound channels. This can be 1 (mono) or 2 (stereo)/param>
|
||||
/// <param name="bits">The bit depth of the sound. This can be 8 (unsigned 8-bit), 16 (signed 16-bit) or 32 (FP32)</param>
|
||||
/// <param name="rate">The sample rate of the sound. This will default to device sample rate</param>
|
||||
/// <param name="passed">How many parameters were passed?</param>
|
||||
/// <returns>A new sound handle if successful or 0 on failure</returns>
|
||||
int32_t func__newsound(int32_t frames, int32_t channels, int32_t bits, int32_t rate, int32_t passed) {
|
||||
int32_t func__sndnew(int32_t frames, int32_t channels, int32_t bits) {
|
||||
if (!audioEngine.isInitialized || frames <= 0) {
|
||||
AUDIO_DEBUG_CHECK(frames > 0);
|
||||
return INVALID_SOUND_HANDLE;
|
||||
}
|
||||
|
||||
// Set sample rate to engine sample rate if not passed
|
||||
if (!passed) {
|
||||
rate = audioEngine.sampleRate;
|
||||
AUDIO_DEBUG_PRINT("Defaulting sample rate to %u", rate);
|
||||
}
|
||||
|
||||
// Validate all parameters
|
||||
if (rate <= 0 || (channels != 1 && channels != 2) || (bits != 16 && bits != 32 && bits != 8)) {
|
||||
AUDIO_DEBUG_PRINT("Invalid channels (%i), bits (%i) or rate (%i)", channels, bits, rate);
|
||||
if ((channels != 1 && channels != 2) || (bits != 16 && bits != 32 && bits != 8)) {
|
||||
AUDIO_DEBUG_PRINT("Invalid channels (%i) or bits (%i)", channels, bits);
|
||||
return INVALID_SOUND_HANDLE;
|
||||
}
|
||||
|
||||
|
@ -1862,8 +1854,10 @@ int32_t func__newsound(int32_t frames, int32_t channels, int32_t bits, int32_t r
|
|||
audioEngine.soundHandles[handle]->maAudioBufferConfig = ma_audio_buffer_config_init(
|
||||
(bits == 32 ? ma_format::ma_format_f32 : (bits == 16 ? ma_format::ma_format_s16 : ma_format::ma_format_u8)), channels, frames, NULL, NULL);
|
||||
|
||||
// Set the sample rate
|
||||
audioEngine.soundHandles[handle]->maAudioBufferConfig.sampleRate = rate;
|
||||
// This currently has no effect. Sample rate always defaults to engine sample rate
|
||||
// Sample rate support for audio buffer is coming in miniaudio version 0.12
|
||||
// Once we have support, we can add sample rate as an optional 4th parameter
|
||||
// audioEngine.soundHandles[handle]->maAudioBufferConfig.sampleRate = audioEngine.sampleRate;
|
||||
|
||||
// Allocate and initialize ma_audio_buffer
|
||||
audioEngine.maResult =
|
||||
|
@ -1885,7 +1879,7 @@ int32_t func__newsound(int32_t frames, int32_t channels, int32_t bits, int32_t r
|
|||
return INVALID_SOUND_HANDLE;
|
||||
}
|
||||
|
||||
AUDIO_DEBUG_PRINT("Frames = %i, Channels = %i, Bits = %i, Rate = %i", frames, channels, bits, rate);
|
||||
AUDIO_DEBUG_PRINT("Frames = %i, Channels = %i, Bits = %i", frames, channels, bits);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
|
|
@ -2060,15 +2060,14 @@ regid
|
|||
|
||||
' a740g: Feature request #28
|
||||
clearid
|
||||
id.n = qb64prefix$ + "NewSound" ' Name in CaMeL case
|
||||
id.n = qb64prefix$ + "SndNew" ' Name in CaMeL case
|
||||
id.Dependency = DEPENDENCY_AUDIO_OUT ' QB64-PE library dependency
|
||||
id.subfunc = 1 ' 1 = function, 2 = sub
|
||||
id.callname = "func__newsound" ' C/C++ function name
|
||||
id.args = 4 ' number of arguments "passed"
|
||||
id.callname = "func__sndnew" ' C/C++ function name
|
||||
id.args = 3 ' number of arguments "passed"
|
||||
id.arg = MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) ' arguments & types
|
||||
id.specialformat = "?,?,?[,?]" ' special format (optional in []; functions can have only one optional)
|
||||
id.ret = LONGTYPE - ISPOINTER ' return type for functions
|
||||
id.hr_syntax = "_NEWSOUND(frames&, channels&, bits&[, rate&])" ' syntax help
|
||||
id.hr_syntax = "_SNDNEW(frames&, channels&, bits&)" ' syntax help
|
||||
regid
|
||||
' a740g: Feature request #28
|
||||
|
||||
|
|
|
@ -6,5 +6,5 @@ listOfKeywords$ = listOfKeywords$ + "_GLPOPATTRIB@_GLPOPCLIENTATTRIB@_GLPOPMATRI
|
|||
listOfKeywords$ = listOfKeywords$ + "_SOFTWARE@_SQUAREPIXELS@_STRETCH@_ALLOWFULLSCREEN@_ALL@_ECHO@_INSTRREV@_TRIM$@_ACCEPTFILEDROP@_FINISHDROP@_TOTALDROPPEDFILES@_DROPPEDFILE@_DROPPEDFILE$@_SHR@_SHL@_ROR@_ROL@" ' a740g: added ROR & ROL
|
||||
listOfKeywords$ = listOfKeywords$ + "_DEFLATE$@_INFLATE$@_READBIT@_RESETBIT@_SETBIT@_TOGGLEBIT@$ASSERTS@_ASSERT@_CAPSLOCK@_NUMLOCK@_SCROLLLOCK@_TOGGLE@_CONSOLEFONT@_CONSOLECURSOR@_CONSOLEINPUT@_CINP@$NOPREFIX@$COLOR@$DEBUG@_ENVIRONCOUNT@$UNSTABLE@$MIDISOUNDFONT@"
|
||||
listOfKeywords$ = listOfKeywords$ + "_NOTIFYPOPUP@_MESSAGEBOX@_INPUTBOX$@_SELECTFOLDERDIALOG$@_COLORCHOOSERDIALOG@_OPENFILEDIALOG$@_SAVEFILEDIALOG$@" ' a740g: added common dialog keywords
|
||||
listOfKeywords$ = listOfKeywords$ + "_STATUSCODE@_NEWSOUND@"
|
||||
listOfKeywords$ = listOfKeywords$ + "_STATUSCODE@_SNDNEW@"
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ $Console:Only
|
|||
Option _Explicit
|
||||
Option _ExplicitArray
|
||||
|
||||
Dim h As Long: h = _NewSound(1024, 2, 32)
|
||||
Dim h As Long: h = _SndNew(1024, 2, 32)
|
||||
Print "Handle ="; h
|
||||
|
||||
Dim m As _MEM: m = _MemSound(h, 0)
|
||||
|
|
Loading…
Reference in a new issue