Skip to content

Commit

Permalink
chore: Add support for reading audio files on Windows and macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed May 5, 2024
1 parent 4c699a8 commit b2957dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/audio-utils/read-audio-file.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if defined(_WIN32) || defined(__APPLE__)

extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
Expand Down Expand Up @@ -131,3 +133,5 @@ AudioDataFloat read_audio_file(const char *filename, int targetSampleRate)

return audioFrames;
}

#endif
2 changes: 2 additions & 0 deletions src/audio-utils/read-audio-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ inline enum speaker_layout convert_speaker_layout(uint8_t channels)

typedef std::vector<float> AudioDataFloat;

#if defined(_WIN32) || defined(__APPLE__)
AudioDataFloat read_audio_file(const char *filename, int targetSampleRate = 48000);
#endif

#endif // READ_AUDIO_FILE_H
8 changes: 6 additions & 2 deletions src/cleanstream-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,10 @@ obs_properties_t *cleanstream_properties(void *data)
obs_property_list_add_int(replace_sounds_list, "Beep", REPLACE_SOUNDS_BEEP);
obs_property_list_add_int(replace_sounds_list, "Silence", REPLACE_SOUNDS_SILENCE);
obs_property_list_add_int(replace_sounds_list, "Horn", REPLACE_SOUNDS_HORN);
// on windows and mac, add external file path for replace sound
#if defined(_WIN32) || defined(__APPLE__)
obs_property_list_add_int(replace_sounds_list, "External", REPLACE_SOUNDS_EXTERNAL);
#endif

// add external file path for replace sound
obs_property_t *replace_sound_path = obs_properties_add_path(
Expand All @@ -423,11 +426,12 @@ obs_properties_t *cleanstream_properties(void *data)

obs_property_set_modified_callback2(
replace_sound_path,
[](void *data, obs_properties_t *props, obs_property_t *property,
[](void *data_, obs_properties_t *props, obs_property_t *property,
obs_data_t *settings) {
UNUSED_PARAMETER(property);
UNUSED_PARAMETER(props);
struct cleanstream_data *gf_ = static_cast<struct cleanstream_data *>(data);
struct cleanstream_data *gf_ =
static_cast<struct cleanstream_data *>(data_);
// load the sound file and cache it
std::string replace_sound_path_ =
obs_data_get_string(settings, "replace_sound_path");
Expand Down

0 comments on commit b2957dc

Please sign in to comment.