From 25698b0baa13955c47c93967970599e071b44fab Mon Sep 17 00:00:00 2001 From: 9mmilly <9mmilly@protonmail.com> Date: Tue, 15 Apr 2025 01:46:36 +0200 Subject: initial commit (you get it cuz i did wrote the boring initalization code) --- Makefile | 20 ++++++++++++++++++++ README.md | 3 +++ src/audio.c | 33 +++++++++++++++++++++++++++++++++ src/base.h | 19 +++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 Makefile create mode 100644 README.md create mode 100644 src/audio.c create mode 100644 src/base.h diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4f6a822 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +CC=gcc +CFLAGS=-std=c99 -Wall -Werror -O2 -march=native $(shell pkg-config --cflags SDL2_mixer) +LDFLAGS=$(shell pkg-config --libs SDL2_mixer) + + +SRC=$(wildcard src/*.c) +OBJ=$(SRC:.c=.o) + +LIBS=$(wildcard $(LIB)/*.c) + +BIN=audio + +$(BIN): $(OBJ) + $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) + +*.o: *.c + $(CC) -o $@ -c $< $(CFLAGS) + +clean: + $(RM) -r obj/* src/*.o $(BIN) diff --git a/README.md b/README.md new file mode 100644 index 0000000..8916e58 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +audio thing + +only ogg and flac support (flip other filetypes) diff --git a/src/audio.c b/src/audio.c new file mode 100644 index 0000000..bc139a2 --- /dev/null +++ b/src/audio.c @@ -0,0 +1,33 @@ +#include +#include + +#include +#include + +#include "base.h" + +#define MIXER_FLAGS MIX_INIT_OGG | MIX_INIT_FLAC + +int main (int argc, char *argv[] ) { + + // initialization of SDLs audio system and the mixer + if (SDL_Init(SDL_INIT_AUDIO) != 0) { + fprintf(stderr, "error initializing sdl_mixer: %s\n", SDL_GetError()); + } + + s32 mixflags = Mix_Init(MIXER_FLAGS); + if ((mixflags & MIXER_FLAGS) != mixflags) { + fprintf(stderr, "error initializing sdl_mixer: %s\n", Mix_GetError()); + } + + // setting up the default audio device for playback (using common defaults) + Mix_OpenAudio(48000, AUDIO_F32SYS, 2, 2048); + + + + Mix_CloseAudio(); + Mix_Quit(); + SDL_Quit(); + return 0; +} + diff --git a/src/base.h b/src/base.h new file mode 100644 index 0000000..8807c53 --- /dev/null +++ b/src/base.h @@ -0,0 +1,19 @@ +#ifndef BASE_H +#define BASE_H + +#include + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; + +typedef float f32; +typedef double f64; + +#endif // BASE_H -- cgit v1.2.3