introduce MDESound

This commit is contained in:
Nishi 2025-11-24 19:49:08 +09:00
commit b2e83e695d
Signed by: nishi
GPG key ID: 27EF69B208EB9343
10 changed files with 318 additions and 9 deletions

View file

@ -1,5 +1,5 @@
#ifndef __MDE_AUDIO_H__
#define __MDE_AUDIO_H__
#ifndef __MDE_AUDIO_AUDIO_H__
#define __MDE_AUDIO_AUDIO_H__
#include <MDE/MachDep.h>
@ -12,15 +12,17 @@ extern "C" {
/* always stereo, btw */
#define MDEAudioRate 48000
typedef void* MDEAudio;
/* S16, stereo. frames*2*2 == bytes */
typedef void (*MDEAudioHandler)(void* handle, void* user, void* data, int frames);
typedef void (*MDEAudioHandler)(MDEAudio handle, void* user, void* data, int frames);
/* driver functions */
void* MDEAudioOpen(MDEAudioHandler handler, void* user);
MDEAudio MDEAudioOpen(MDEAudioHandler handler, void* user);
void MDEAudioClose(void* handle);
void MDEAudioClose(MDEAudio handle);
void MDEAudioStart(void* handle);
void MDEAudioStart(MDEAudio handle);
#ifdef __cplusplus
}

View file

@ -10,4 +10,7 @@
#include <MDE/Audio/Audio.h>
#include <MDE/Sound/Sound.h>
#include <MDE/Sound/ID3.h>
#endif

18
include/MDE/Sound/ID3.h Normal file
View file

@ -0,0 +1,18 @@
#ifndef __MDE_SOUND_ID3_H__
#define __MDE_SOUND_ID3_H__
#include <MDE/MachDep.h>
#ifdef __cplusplus
extern "C" {
#endif
char* MDEID3GetTag(const char* path, const char* name, size_t* size);
char* MDEID3GetString(const char* path, const char* name);
#ifdef __cplusplus
}
#endif
#endif

54
include/MDE/Sound/Sound.h Normal file
View file

@ -0,0 +1,54 @@
#ifndef __MDE_SOUND_SOUND_H__
#define __MDE_SOUND_SOUND_H__
#include <MDE/MachDep.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _MDESoundDriver MDESoundDriverRec, *MDESoundDriver;
typedef struct _MDESoundContext* MDESoundContext;
typedef struct _MDESound* MDESound;
struct _MDESoundContext {
int sample_rate;
int channels;
int frames;
void* opaque;
char* title;
char* album;
char* artist;
char* genre;
};
struct _MDESoundDriver {
MDESoundContext (*open)(const char* path);
void (*close)(MDESoundContext context);
int (*read)(MDESoundContext context, short* out, int frames);
void (*seek)(MDESoundContext context, int frames);
};
struct _MDESound {
MDESoundContext context;
MDESoundDriver driver;
};
extern MDESoundDriver MDESoundDriverMP3;
MDESound MDESoundOpen(const char* path);
int MDESoundRead(MDESound sound, short* out, int frames);
int MDESoundReadFloat(MDESound sound, float* out, int frames);
void MDESoundSeek(MDESound sound, int frames);
void MDESoundClose(MDESound sound);
#ifdef __cplusplus
}
#endif
#endif