paint: add sounds tab

This commit is contained in:
luboslenco
2026-07-05 17:24:59 +02:00
parent 054677afbb
commit 57a77f38e0
24 changed files with 419 additions and 81 deletions
+5 -6
View File
@@ -1815,7 +1815,7 @@ any_map_t *data_cached_materials = NULL;
any_map_t *data_cached_worlds = NULL;
any_map_t *data_cached_shaders = NULL;
any_map_t *data_cached_blobs = NULL;
any_map_t *data_cached_textures = NULL;
any_map_t *data_cached_textures = NULL;
any_map_t *data_cached_videos = NULL;
any_map_t *data_cached_fonts = NULL;
any_map_t *data_cached_sounds = NULL;
@@ -2013,7 +2013,6 @@ draw_font_t *data_get_font(char *file) {
return b;
}
#ifdef IRON_AUDIO
sound_t *data_get_sound(char *file) {
if (data_cached_sounds == NULL) {
data_cached_sounds = any_map_create();
@@ -2023,8 +2022,7 @@ sound_t *data_get_sound(char *file) {
if (cached != NULL) {
return cached;
}
sound_t *b = gc_alloc(sizeof(sound_t));
b->sound_ = iron_load_sound(data_resolve_path(file));
sound_t *b = iron_load_sound(data_resolve_path(file));
any_map_set(data_cached_sounds, file, b);
data_assets_loaded++;
return b;
@@ -2038,10 +2036,11 @@ void data_delete_sound(char *handle) {
if (sound == NULL) {
return;
}
iron_a1_sound_destroy(sound->sound_);
#ifdef IRON_AUDIO
iron_a1_sound_destroy(sound);
#endif
map_delete(data_cached_sounds, handle);
}
#endif
void data_delete_mesh(char *handle) {
if (data_cached_meshes == NULL) {
+13 -21
View File
@@ -536,9 +536,7 @@ void uniforms_set_material_const(i32 location, shader_const_t *shade
// ██████╔╝██║ ██║ ██║ ██║ ██║
// ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
typedef struct sound {
void *sound_;
} sound_t;
typedef void sound_t;
extern any_map_t *data_cached_scene_raws;
extern any_map_t *data_cached_meshes;
@@ -550,10 +548,8 @@ extern any_map_t *data_cached_blobs;
extern any_map_t *data_cached_textures;
extern any_map_t *data_cached_videos;
extern any_map_t *data_cached_fonts;
#ifdef IRON_AUDIO
extern any_map_t *data_cached_sounds;
#endif
extern i32 data_assets_loaded;
extern i32 data_assets_loaded;
mesh_data_t *data_get_mesh(char *file, char *name);
camera_data_t *data_get_camera(char *file, char *name);
@@ -565,21 +561,17 @@ gpu_texture_t *data_get_texture(char *file);
buffer_t *data_get_blob(char *file);
video_t *data_get_video(char *file);
draw_font_t *data_get_font(char *file);
#ifdef IRON_AUDIO
sound_t *data_get_sound(char *file);
#endif
void data_delete_mesh(char *handle);
void data_delete_blob(char *handle);
void data_delete_texture(char *handle);
void data_delete_video(char *handle);
void data_delete_font(char *handle);
#ifdef IRON_AUDIO
void data_delete_sound(char *handle);
#endif
bool data_is_abs(char *file);
bool data_is_up(char *file);
char *data_resolve_path(char *file);
char *data_path(void);
sound_t *data_get_sound(char *file);
void data_delete_mesh(char *handle);
void data_delete_blob(char *handle);
void data_delete_texture(char *handle);
void data_delete_video(char *handle);
void data_delete_font(char *handle);
void data_delete_sound(char *handle);
bool data_is_abs(char *file);
bool data_is_up(char *file);
char *data_resolve_path(char *file);
char *data_path(void);
// ███████╗ ██████╗███████╗███╗ ██╗███████╗
// ██╔════╝██╔════╝██╔════╝████╗ ██║██╔════╝
+3 -2
View File
@@ -867,13 +867,14 @@ gpu_texture_t *iron_load_texture(char *file) {
return gpu_create_texture_from_encoded_bytes(&buf, file);
}
#ifdef IRON_AUDIO
void *iron_load_sound(char *file) {
#ifdef IRON_AUDIO
iron_a1_init();
iron_a1_sound_t *sound = iron_a1_sound_create(file);
return sound;
}
#endif
return NULL;
}
buffer_t *iron_load_blob(char *file) {
#ifdef WITH_EMBED
+9 -1
View File
@@ -17,6 +17,12 @@
#include <stdlib.h>
#include <string.h>
void iron_a2_init(void);
void iron_a2_set_callback(void (*iron_a2_audio_callback)(iron_a2_buffer_t *buffer, uint32_t samples, void *userdata), void *userdata);
uint32_t iron_a2_samples_per_second(void);
void iron_a2_set_sample_rate_callback(void (*iron_a2_sample_rate_callback)(void *userdata), void *userdata);
void iron_a2_internal_sample_rate_callback(void);
struct iron_a1_channel {
iron_a1_sound_t *sound;
float position;
@@ -143,7 +149,9 @@ void iron_a1_init(void) {
iron_a2_set_callback(iron_a2_on_a1_mix, NULL);
}
iron_a1_channel_t *iron_a1_play_sound(iron_a1_sound_t *sound, bool loop, float pitch, bool unique) {
iron_a1_channel_t *audio_play(iron_a1_sound_t *sound, bool loop) {
float pitch = 1.0;
bool unique = false;
iron_a1_channel_t *channel = NULL;
iron_mutex_lock(&mutex);
bool found = false;
+4 -10
View File
@@ -47,7 +47,7 @@ struct iron_a1_stream_channel;
typedef struct iron_a1_stream_channel iron_a1_stream_channel_t;
void iron_a1_init(void);
iron_a1_channel_t *iron_a1_play_sound(iron_a1_sound_t *sound, bool loop, float pitch, bool unique);
iron_a1_channel_t *audio_play(iron_a1_sound_t *sound, bool loop);
void iron_a1_stop_sound(iron_a1_sound_t *sound);
void iron_a1_play_sound_stream(iron_a1_sound_stream_t *stream);
void iron_a1_stop_sound_stream(iron_a1_sound_stream_t *stream);
@@ -71,15 +71,9 @@ float iron_a1_sound_stream_position(iron_a1_sound_stream_t *st
void iron_a1_sound_stream_reset(iron_a1_sound_stream_t *stream);
float iron_a1_sound_stream_volume(iron_a1_sound_stream_t *stream);
void iron_a1_sound_stream_set_volume(iron_a1_sound_stream_t *stream, float value);
void iron_a2_init(void);
void iron_a2_set_callback(void (*iron_a2_audio_callback)(iron_a2_buffer_t *buffer, uint32_t samples, void *userdata), void *userdata);
uint32_t iron_a2_samples_per_second(void);
void iron_a2_set_sample_rate_callback(void (*iron_a2_sample_rate_callback)(void *userdata), void *userdata);
void iron_a2_shutdown(void);
void iron_a2_internal_init(void);
bool iron_a2_internal_callback(iron_a2_buffer_t *buffer, int samples);
void iron_a2_internal_sample_rate_callback(void);
void iron_a2_internal_init(void);
void iron_a2_shutdown(void);
bool iron_a2_internal_callback(iron_a2_buffer_t *buffer, int samples);
// struct iron_internal_video_channel;
// typedef struct iron_internal_video_channel iron_internal_video_channel_t;
+11 -11
View File
@@ -14,7 +14,7 @@ bool path_is_protected_linux = false;
string_array_t *_path_mesh_formats = NULL;
string_array_t *_path_texture_formats = NULL;
string_array_t *_path_audio_formats = NULL;
string_array_t *_path_sound_formats = NULL;
static string_array_t *_path_base_color_ext = NULL;
static string_array_t *_path_opacity_ext = NULL;
static string_array_t *_path_normal_map_ext = NULL;
@@ -50,14 +50,14 @@ string_array_t *path_texture_formats(void) {
return _path_texture_formats;
}
string_array_t *path_audio_formats(void) {
if (_path_audio_formats == NULL) {
_path_audio_formats = string_array_create(0);
gc_root(_path_audio_formats);
string_array_push(_path_audio_formats, "wav");
string_array_push(_path_audio_formats, "ogg");
string_array_t *path_sound_formats(void) {
if (_path_sound_formats == NULL) {
_path_sound_formats = string_array_create(0);
gc_root(_path_sound_formats);
string_array_push(_path_sound_formats, "wav");
string_array_push(_path_sound_formats, "ogg");
}
return _path_audio_formats;
return _path_sound_formats;
}
string_array_t *path_base_color_ext(void) {
@@ -251,9 +251,9 @@ bool path_is_texture(char *path) {
return false;
}
bool path_is_audio(char *path) {
bool path_is_sound(char *path) {
char *p = to_lower_case(path);
string_array_t *formats = path_audio_formats();
string_array_t *formats = path_sound_formats();
for (uint32_t i = 0; i < formats->length; ++i) {
char *s = formats->buffer[i];
char *ext = string(".%s", s);
@@ -300,7 +300,7 @@ bool path_is_lut(char *path) {
}
bool path_is_known(char *path) {
return path_is_mesh(path) || path_is_texture(path) || path_is_audio(path) || path_is_font(path) || path_is_project(path) || path_is_plugin(path) ||
return path_is_mesh(path) || path_is_texture(path) || path_is_sound(path) || path_is_font(path) || path_is_project(path) || path_is_plugin(path) ||
path_is_text(path) || path_is_ext_format(path) || path_is_lut(path);
}
+1 -1
View File
@@ -25,7 +25,7 @@ char *path_base_dir(char *path);
char *path_base_name(char *path);
bool path_is_mesh(char *path);
bool path_is_texture(char *path);
bool path_is_audio(char *path);
bool path_is_sound(char *path);
bool path_is_font(char *path);
bool path_is_project(char *path);
bool path_is_plugin(char *path);