VERSIÓ 1.5.9:
- [NEW] Audio passat al backend SDL3. Los últimos vestigios del antiguo jail_audio han sido barridos.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#ifndef JA_USESDLMIXER
|
||||
#include "jail_audio.h"
|
||||
#if BACKEND == SDL3
|
||||
|
||||
#include "backends/backend.h"
|
||||
#include "external/stb_vorbis.h"
|
||||
#include "other/log.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
// structs i variables
|
||||
// =============================
|
||||
namespace jail
|
||||
namespace backend
|
||||
{
|
||||
namespace audio
|
||||
{
|
||||
@@ -83,7 +83,7 @@ namespace jail
|
||||
|
||||
// Funcions
|
||||
// ==================
|
||||
namespace jail
|
||||
namespace backend
|
||||
{
|
||||
namespace audio
|
||||
{
|
||||
@@ -33,13 +33,6 @@ namespace backend
|
||||
void cursor(const bool value);
|
||||
}
|
||||
|
||||
namespace audio
|
||||
{
|
||||
void init();
|
||||
void quit();
|
||||
void render();
|
||||
}
|
||||
|
||||
namespace input
|
||||
{
|
||||
void reset();
|
||||
@@ -74,4 +67,53 @@ namespace backend
|
||||
int press();
|
||||
}
|
||||
}
|
||||
|
||||
namespace audio
|
||||
{
|
||||
void init();
|
||||
void quit();
|
||||
|
||||
namespace music
|
||||
{
|
||||
enum state { invalid, playing, paused, stopped, disabled };
|
||||
|
||||
int load(const char* filename);
|
||||
int load(const uint8_t* buffer, uint32_t length);
|
||||
void play(int mus, int loop = -1);
|
||||
void pause();
|
||||
void resume();
|
||||
void stop();
|
||||
void fadeOut(int milliseconds);
|
||||
state getState();
|
||||
void destroy(int mus);
|
||||
float setVolume(float vol);
|
||||
void setPosition(float value);
|
||||
float getPosition();
|
||||
void enable(bool value);
|
||||
bool isEnabled();
|
||||
}
|
||||
|
||||
namespace sound
|
||||
{
|
||||
int create(uint8_t* buffer, uint32_t length);
|
||||
int load(uint8_t* buffer, uint32_t length);
|
||||
int load(const char* filename);
|
||||
int play(int snd, int loop = 0);
|
||||
int playOnChannel(int snd, int chan, int loop = 0);
|
||||
void destroy(int snd);
|
||||
float setVolume(float vol);
|
||||
void enable(bool value);
|
||||
bool isEnabled();
|
||||
|
||||
namespace channel
|
||||
{
|
||||
enum state { invalid, free, playing, paused, disabled };
|
||||
void pause(int chan);
|
||||
void resume(int chan);
|
||||
void stop(int chan);
|
||||
state getState(int chan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+19
-24
@@ -1,5 +1,5 @@
|
||||
#include "audio.h"
|
||||
#include "jail_audio.h"
|
||||
#include "backends/backend.h"
|
||||
#include "mini/file/file.h"
|
||||
|
||||
namespace mini
|
||||
@@ -7,18 +7,13 @@ namespace mini
|
||||
namespace audio
|
||||
{
|
||||
int current_music = -1;
|
||||
//#define MAX_SOUNDS 50
|
||||
//JA_Sound_t *sounds[MAX_SOUNDS];
|
||||
|
||||
void init() {
|
||||
jail::audio::init();
|
||||
//for (int i=0;i<MAX_SOUNDS;++i) sounds[i] = NULL;
|
||||
backend::audio::init();
|
||||
}
|
||||
|
||||
void quit() {
|
||||
//if (current_music != NULL) JA_DeleteMusic(current_music);
|
||||
//for (int i=0;i<MAX_SOUNDS;++i) if (sounds[i]!=NULL) JA_DeleteSound(sounds[i]);
|
||||
jail::audio::quit();
|
||||
backend::audio::quit();
|
||||
}
|
||||
|
||||
namespace music
|
||||
@@ -26,45 +21,45 @@ namespace mini
|
||||
void play(const char *filename, const int loop) {
|
||||
int size;
|
||||
char *buffer = file::getfilebuffer(filename, size);
|
||||
if (current_music != -1) jail::audio::music::destroy(current_music);
|
||||
current_music = jail::audio::music::load((uint8_t*)buffer, size);
|
||||
jail::audio::music::play(current_music, loop);
|
||||
if (current_music != -1) backend::audio::music::destroy(current_music);
|
||||
current_music = backend::audio::music::load((uint8_t*)buffer, size);
|
||||
backend::audio::music::play(current_music, loop);
|
||||
}
|
||||
|
||||
void pause() {
|
||||
jail::audio::music::pause();
|
||||
backend::audio::music::pause();
|
||||
}
|
||||
|
||||
void resume() {
|
||||
jail::audio::music::resume();
|
||||
backend::audio::music::resume();
|
||||
}
|
||||
|
||||
void stop(const int t) {
|
||||
jail::audio::music::stop();
|
||||
backend::audio::music::stop();
|
||||
}
|
||||
|
||||
namespace pos {
|
||||
void set(float value)
|
||||
{
|
||||
jail::audio::music::setPosition(value);
|
||||
backend::audio::music::setPosition(value);
|
||||
}
|
||||
|
||||
float get()
|
||||
{
|
||||
return jail::audio::music::getPosition();
|
||||
return backend::audio::music::getPosition();
|
||||
}
|
||||
}
|
||||
|
||||
namespace enable {
|
||||
void set(const bool value)
|
||||
{
|
||||
jail::audio::music::enable(value);
|
||||
backend::audio::music::enable(value);
|
||||
file::setconfigvalue("music", value?"true":"false");
|
||||
}
|
||||
|
||||
const bool get()
|
||||
{
|
||||
return jail::audio::music::isEnabled();
|
||||
return backend::audio::music::isEnabled();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,32 +69,32 @@ namespace mini
|
||||
int load(const char *filename) {
|
||||
int size;
|
||||
char *buffer = file::getfilebuffer(filename, size);
|
||||
return jail::audio::sound::load((uint8_t*)buffer, size);
|
||||
return backend::audio::sound::load((uint8_t*)buffer, size);
|
||||
}
|
||||
|
||||
void free(int soundfile) {
|
||||
return jail::audio::sound::destroy(soundfile);
|
||||
return backend::audio::sound::destroy(soundfile);
|
||||
}
|
||||
|
||||
int play(int soundfile, const int volume) {
|
||||
// [TODO] Ficar el volumen
|
||||
return jail::audio::sound::play(soundfile, 0);
|
||||
return backend::audio::sound::play(soundfile, 0);
|
||||
}
|
||||
|
||||
void stop(int soundchannel) {
|
||||
return jail::audio::sound::channel::stop(soundchannel);
|
||||
return backend::audio::sound::channel::stop(soundchannel);
|
||||
}
|
||||
|
||||
namespace enable {
|
||||
void set(const bool value)
|
||||
{
|
||||
return jail::audio::sound::enable(value);
|
||||
return backend::audio::sound::enable(value);
|
||||
file::setconfigvalue("sound", value?"true":"false");
|
||||
}
|
||||
|
||||
const bool get()
|
||||
{
|
||||
return jail::audio::sound::isEnabled();
|
||||
return backend::audio::sound::isEnabled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
namespace jail
|
||||
{
|
||||
namespace audio
|
||||
{
|
||||
void init(/*const int freq, const SDL_AudioFormat format, const int channels*/);
|
||||
void quit();
|
||||
|
||||
namespace music
|
||||
{
|
||||
//struct JA_Music_t;
|
||||
enum state { invalid, playing, paused, stopped, disabled };
|
||||
|
||||
int load(const char* filename);
|
||||
int load(const uint8_t* buffer, uint32_t length);
|
||||
void play(int mus, int loop = -1);
|
||||
void pause();
|
||||
void resume();
|
||||
void stop();
|
||||
void fadeOut(int milliseconds);
|
||||
state getState();
|
||||
void destroy(int mus);
|
||||
float setVolume(float vol);
|
||||
void setPosition(float value);
|
||||
float getPosition();
|
||||
void enable(bool value);
|
||||
bool isEnabled();
|
||||
}
|
||||
|
||||
namespace sound
|
||||
{
|
||||
//struct JA_Sound_t;
|
||||
int create(uint8_t* buffer, uint32_t length);
|
||||
int load(uint8_t* buffer, uint32_t length);
|
||||
int load(const char* filename);
|
||||
int play(int snd, int loop = 0);
|
||||
int playOnChannel(int snd, int chan, int loop = 0);
|
||||
void destroy(int snd);
|
||||
float setVolume(float vol);
|
||||
void enable(bool value);
|
||||
bool isEnabled();
|
||||
|
||||
namespace channel
|
||||
{
|
||||
enum state { invalid, free, playing, paused, disabled };
|
||||
void pause(int chan);
|
||||
void resume(int chan);
|
||||
void stop(int chan);
|
||||
state getState(int chan);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define MINI_VERSION "1.5.8"
|
||||
#define MINI_VERSION "1.5.9"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "other/log.h"
|
||||
#include "mini/file/file.h"
|
||||
#include "mini/shader/shader.h"
|
||||
#include <backends/backend.h>
|
||||
#include "backends/backend.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user