summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt2
-rw-r--r--examples/CMakeLists.txt10
-rw-r--r--examples/wav.c13
-rw-r--r--include/mossrose.h1
-rw-r--r--src/load/CMakeLists.txt1
-rw-r--r--src/mossrose.c5
7 files changed, 32 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 89efb0f..12d83cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
build
*.swp
+*~
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 437601c..bcaff18 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,7 +13,7 @@ option(MOSSROSE_BUILD_TESTS "Build the tests" OFF)
######## third-party libraries ########
add_subdirectory(${CMAKE_SOURCE_DIR}/3rdparty/portaudio EXCLUDE_FROM_ALL)
add_subdirectory(${CMAKE_SOURCE_DIR}/3rdparty/plibsys EXCLUDE_FROM_ALL)
-#add_subdirectory(${CMAKE_SOURCE_DIR}/3rdparty/libwav EXCLUDE_FROM_ALL)
+add_subdirectory(${CMAKE_SOURCE_DIR}/3rdparty/libwav EXCLUDE_FROM_ALL)
add_library(mossrose)
set_target_properties(mossrose PROPERTIES
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 3797392..7e783ee 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -25,3 +25,13 @@ target_link_libraries(mp3 mossrose)
add_dependencies(examples mp3)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/sine-mono.mp3 DESTINATION .)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/weird-stereo.mp3 DESTINATION .)
+
+add_executable(wave ${CMAKE_CURRENT_LIST_DIR}/wav.c)
+target_link_libraries(wave mossrose)
+add_dependencies(examples wave)
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/mono-16bit-pcm.wav DESTINATION .)
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/mono-24bit-pcm.wav DESTINATION .)
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/mono-float-pcm.wav DESTINATION .)
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/stereo-16bit-pcm.wav DESTINATION .)
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/stereo-24bit-pcm.wav DESTINATION .)
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/stereo-float-pcm.wav DESTINATION .)
diff --git a/examples/wav.c b/examples/wav.c
new file mode 100644
index 0000000..6d6f336
--- /dev/null
+++ b/examples/wav.c
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <mossrose.h>
+
+int main()
+{
+ mossrose_load_wav("mono-16bit-pcm.wav");
+ mossrose_load_wav("mono-24bit-pcm.wav");
+ mossrose_load_wav("mono-float-pcm.wav");
+ mossrose_load_wav("stereo-16bit-pcm.wav");
+ mossrose_load_wav("stereo-16bit-pcm.wav");
+ mossrose_load_wav("stereo-16bit-pcm.wav");
+ return 0;
+}
diff --git a/include/mossrose.h b/include/mossrose.h
index 04aef94..42997df 100644
--- a/include/mossrose.h
+++ b/include/mossrose.h
@@ -26,6 +26,7 @@ void mossrose_channel_set_callback(int channel, mossrose_channel_callback_t call
void mossrose_poll_callbacks();
struct mossrose_sound_t * mossrose_load_mp3(const char *filename);
+struct mossrose_sound_t * mossrose_load_wav(const char *filename);
void mossrose_free_sound(struct mossrose_sound_t *sound);
#endif
diff --git a/src/load/CMakeLists.txt b/src/load/CMakeLists.txt
index 3369dd2..c435621 100644
--- a/src/load/CMakeLists.txt
+++ b/src/load/CMakeLists.txt
@@ -2,6 +2,7 @@ project(mossrose)
target_sources(mossrose PUBLIC
${CMAKE_CURRENT_LIST_DIR}/load-mp3.c
+ ${CMAKE_CURRENT_LIST_DIR}/load-wav.c
)
target_include_directories(mossrose PUBLIC ${CMAKE_SOURCE_DIR}/3rdparty/minimp3)
diff --git a/src/mossrose.c b/src/mossrose.c
index 61ee27b..bf45eef 100644
--- a/src/mossrose.c
+++ b/src/mossrose.c
@@ -160,6 +160,11 @@ struct mossrose_sound_t * mossrose_load_mp3(const char *filename)
return load_mp3(filename);
}
+struct mossrose_sound_t * mossrose_load_wav(const char *filename)
+{
+ return load_wav(filename);
+}
+
void mossrose_free_sound(struct mossrose_sound_t *sound)
{