react-native-audio-api 0.7.1-nightly-5a218c6-20250809 → 0.7.1-nightly-4d86c14-20250811

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/RNAudioAPI.podspec +31 -7
  2. package/android/src/main/cpp/audioapi/CMakeLists.txt +22 -1
  3. package/android/src/main/cpp/audioapi/android/core/AudioDecoder.cpp +81 -63
  4. package/common/cpp/audioapi/core/utils/AudioDecoder.h +54 -29
  5. package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
  6. package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
  7. package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
  8. package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
  9. package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
  10. package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
  11. package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
  12. package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
  13. package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
  14. package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
  15. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
  16. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
  17. package/common/cpp/audioapi/external/include/ogg/config_types.h +26 -0
  18. package/common/cpp/audioapi/external/include/ogg/config_types.h.in +26 -0
  19. package/common/cpp/audioapi/external/include/ogg/ogg.h +212 -0
  20. package/common/cpp/audioapi/external/include/ogg/os_types.h +157 -0
  21. package/common/cpp/audioapi/external/include/opus/opus.h +1286 -0
  22. package/common/cpp/audioapi/external/include/opus/opus_custom.h +390 -0
  23. package/common/cpp/audioapi/external/include/opus/opus_defines.h +896 -0
  24. package/common/cpp/audioapi/external/include/opus/opus_multistream.h +728 -0
  25. package/common/cpp/audioapi/external/include/opus/opus_projection.h +621 -0
  26. package/common/cpp/audioapi/external/include/opus/opus_types.h +170 -0
  27. package/common/cpp/audioapi/external/include/opusfile/opusfile.h +2151 -0
  28. package/common/cpp/audioapi/external/include/vorbis/codec.h +241 -0
  29. package/common/cpp/audioapi/external/include/vorbis/vorbisenc.h +446 -0
  30. package/common/cpp/audioapi/external/include/vorbis/vorbisfile.h +226 -0
  31. package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
  32. package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
  33. package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
  34. package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
  35. package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
  36. package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
  37. package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
  38. package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
  39. package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
  40. package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
  41. package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
  42. package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
  43. package/common/cpp/audioapi/external/x86/libogg.a +0 -0
  44. package/common/cpp/audioapi/external/x86/libopus.a +0 -0
  45. package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
  46. package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
  47. package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
  48. package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
  49. package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
  50. package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
  51. package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
  52. package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
  53. package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
  54. package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
  55. package/common/cpp/audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.c +623 -0
  56. package/common/cpp/audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.h +71 -0
  57. package/common/cpp/audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.c +574 -0
  58. package/common/cpp/audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.h +41 -0
  59. package/common/cpp/test/CMakeLists.txt +7 -0
  60. package/common/cpp/test/RunTests.sh +3 -8
  61. package/ios/audioapi/ios/core/AudioDecoder.mm +62 -51
  62. package/package.json +1 -1
@@ -35,15 +35,39 @@ Pod::Spec.new do |s|
35
35
 
36
36
  s.compiler_flags = "#{folly_flags}"
37
37
 
38
- s.pod_target_xcconfig = {
39
- "USE_HEADERMAP" => "YES",
40
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
41
- "GCC_PREPROCESSOR_DEFINITIONS" => '$(inherited) HAVE_ACCELERATE=1',
42
- "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/common/cpp\" \"$(PODS_TARGET_SRCROOT)/ios\"",
43
- 'OTHER_CFLAGS' => "$(inherited) #{folly_flags} #{fabric_flags} #{version_flag}"
44
- }
38
+ external_dir = "$(PODS_TARGET_SRCROOT)/common/cpp/audioapi/external"
39
+ # lib_dir = "$(PODS_TARGET_SRCROOT)/common/cpp/audioapi/external/$(PLATFORM_NAME)"
40
+ lib_dir = "$(SRCROOT)/../../../packages/react-native-audio-api/common/cpp/audioapi/external/$(PLATFORM_NAME)"
45
41
 
42
+
43
+ s.pod_target_xcconfig = {
44
+ "USE_HEADERMAP" => "YES",
45
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
46
+ "GCC_PREPROCESSOR_DEFINITIONS" => '$(inherited) HAVE_ACCELERATE=1',
47
+ "HEADER_SEARCH_PATHS" => %W[
48
+ $(PODS_TARGET_SRCROOT)/common/cpp
49
+ $(PODS_TARGET_SRCROOT)/ios
50
+ #{external_dir}/include
51
+ #{external_dir}/include/opus
52
+ #{external_dir}/include/vorbis
53
+ ].join(" "),
54
+ 'OTHER_CFLAGS' => "$(inherited) #{folly_flags} #{fabric_flags} #{version_flag}"
55
+ }
56
+
57
+ s.user_target_xcconfig = {
58
+ 'OTHER_LDFLAGS' => %W[
59
+ $(inherited)
60
+ -force_load #{lib_dir}/libopusfile.a
61
+ -force_load #{lib_dir}/libopus.a
62
+ -force_load #{lib_dir}/libogg.a
63
+ -force_load #{lib_dir}/libvorbis.a
64
+ -force_load #{lib_dir}/libvorbisenc.a
65
+ -force_load #{lib_dir}/libvorbisfile.a
66
+ ].join(" ")
67
+ }
46
68
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
47
69
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
48
70
  install_modules_dependencies(s)
49
71
  end
72
+
73
+
@@ -3,8 +3,17 @@ cmake_minimum_required(VERSION 3.12.0)
3
3
  file(GLOB_RECURSE ANDROID_CPP_SOURCES CONFIGURE_DEPENDS "${ANDROID_CPP_DIR}/audioapi/*.cpp")
4
4
  file(GLOB_RECURSE COMMON_CPP_SOURCES CONFIGURE_DEPENDS "${COMMON_CPP_DIR}/audioapi/*.cpp" "${COMMON_CPP_DIR}/audioapi/*.c")
5
5
 
6
+ set(EXTERNAL_DIR ${COMMON_CPP_DIR}/audioapi/external)
7
+ set(ARCH_LIB_DIR ${EXTERNAL_DIR}/${ANDROID_ABI})
8
+ set(INCLUDE_DIR ${EXTERNAL_DIR}/include)
9
+
6
10
  add_library(react-native-audio-api SHARED ${ANDROID_CPP_SOURCES} ${COMMON_CPP_SOURCES})
7
11
 
12
+ foreach(lib IN ITEMS opus opusfile ogg vorbis vorbisenc vorbisfile)
13
+ add_library(${lib} STATIC IMPORTED)
14
+ set_target_properties(${lib} PROPERTIES IMPORTED_LOCATION ${ARCH_LIB_DIR}/lib${lib}.a)
15
+ endforeach()
16
+
8
17
  find_package(ReactAndroid REQUIRED CONFIG)
9
18
  find_package(fbjni REQUIRED CONFIG)
10
19
  find_package(oboe REQUIRED CONFIG)
@@ -14,6 +23,9 @@ target_include_directories(
14
23
  PRIVATE
15
24
  "${COMMON_CPP_DIR}"
16
25
  "${ANDROID_CPP_DIR}"
26
+ "${INCLUDE_DIR}"
27
+ "${INCLUDE_DIR}/opus"
28
+ "${INCLUDE_DIR}/vorbis"
17
29
  "${REACT_NATIVE_DIR}/ReactCommon"
18
30
  "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
19
31
  "${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
@@ -40,4 +52,13 @@ else()
40
52
  )
41
53
  endif()
42
54
 
43
- target_link_libraries(react-native-audio-api ${LINK_LIBRARIES} ${RN_VERSION_LINK_LIBRARIES})
55
+ target_link_libraries(react-native-audio-api
56
+ ${LINK_LIBRARIES}
57
+ ${RN_VERSION_LINK_LIBRARIES}
58
+ opusfile
59
+ opus
60
+ ogg
61
+ vorbis
62
+ vorbisenc
63
+ vorbisfile
64
+ )
@@ -7,59 +7,90 @@
7
7
  #define MINIAUDIO_IMPLEMENTATION
8
8
  #include <audioapi/libs/miniaudio/miniaudio.h>
9
9
 
10
+ #include <audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.h>
11
+ #include <audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.h>
12
+
10
13
  // #include <android/log.h>
11
14
 
12
15
  namespace audioapi {
13
16
 
17
+ // Decoding audio in fixed-size chunks because total frame count can't be
18
+ // determined in advance. Note: ma_decoder_get_length_in_pcm_frames() always
19
+ // returns 0 for Vorbis decoders.
20
+ std::vector<int16_t> AudioDecoder::readAllPcmFrames(
21
+ ma_decoder &decoder,
22
+ int numChannels,
23
+ ma_uint64 &outFramesRead) const {
24
+ std::vector<int16_t> buffer;
25
+ int16_t temp[CHUNK_SIZE * numChannels];
26
+ outFramesRead = 0;
27
+
28
+ while (true) {
29
+ ma_uint64 tempFramesDecoded = 0;
30
+ ma_decoder_read_pcm_frames(&decoder, temp, CHUNK_SIZE, &tempFramesDecoded);
31
+ if (tempFramesDecoded == 0) {
32
+ break;
33
+ }
34
+
35
+ buffer.insert(buffer.end(), temp, temp + tempFramesDecoded * numChannels);
36
+ outFramesRead += tempFramesDecoded;
37
+ }
38
+
39
+ return buffer;
40
+ }
41
+
42
+ std::shared_ptr<AudioBus> AudioDecoder::makeAudioBusFromInt16Buffer(
43
+ const std::vector<int16_t> &buffer,
44
+ int numChannels,
45
+ float sampleRate) const {
46
+ auto outputFrames = buffer.size() / numChannels;
47
+ auto audioBus =
48
+ std::make_shared<AudioBus>(outputFrames, numChannels, sampleRate);
49
+
50
+ for (int ch = 0; ch < numChannels; ++ch) {
51
+ auto channelData = audioBus->getChannel(ch)->getData();
52
+ for (int i = 0; i < outputFrames; ++i) {
53
+ channelData[i] = int16ToFloat(buffer[i * numChannels + ch]);
54
+ }
55
+ }
56
+ return audioBus;
57
+ }
58
+
14
59
  std::shared_ptr<AudioBus> AudioDecoder::decodeWithFilePath(
15
60
  const std::string &path) const {
16
61
  ma_decoder decoder;
17
62
  ma_decoder_config config = ma_decoder_config_init(
18
63
  ma_format_s16, numChannels_, static_cast<int>(sampleRate_));
19
- ma_result result = ma_decoder_init_file(path.c_str(), &config, &decoder);
20
- if (result != MA_SUCCESS) {
64
+ #ifndef AUDIO_API_TEST_SUITE
65
+ ma_decoding_backend_vtable *customBackends[] = {
66
+ ma_decoding_backend_libvorbis, ma_decoding_backend_libopus};
67
+
68
+ config.ppCustomBackendVTables = customBackends;
69
+ config.customBackendCount =
70
+ sizeof(customBackends) / sizeof(customBackends[0]);
71
+ #endif
72
+
73
+ if (ma_decoder_init_file(path.c_str(), &config, &decoder) != MA_SUCCESS) {
21
74
  // __android_log_print(
22
- // ANDROID_LOG_ERROR,
23
- // "AudioDecoder",
24
- // "Failed to initialize decoder for file: %s",
25
- // path.c_str());
75
+ // ANDROID_LOG_ERROR,
76
+ // "AudioDecoder",
77
+ // "Failed to initialize decoder for file: %s",
78
+ // path.c_str());
26
79
  ma_decoder_uninit(&decoder);
27
-
28
80
  return nullptr;
29
81
  }
30
82
 
31
- ma_uint64 totalFrameCount;
32
- ma_decoder_get_length_in_pcm_frames(&decoder, &totalFrameCount);
33
-
34
- std::vector<int16_t> buffer(totalFrameCount * numChannels_);
35
-
36
- ma_uint64 framesDecoded;
37
- ma_decoder_read_pcm_frames(
38
- &decoder, buffer.data(), totalFrameCount, &framesDecoded);
39
-
40
- if (framesDecoded == 0) {
83
+ ma_uint64 framesRead = 0;
84
+ auto buffer = readAllPcmFrames(decoder, numChannels_, framesRead);
85
+ if (framesRead == 0) {
41
86
  // __android_log_print(ANDROID_LOG_ERROR, "AudioDecoder", "Failed to
42
87
  // decode");
43
-
44
88
  ma_decoder_uninit(&decoder);
45
89
  return nullptr;
46
90
  }
47
91
 
48
- auto outputFrames = buffer.size() / numChannels_;
49
- auto audioBus =
50
- std::make_shared<AudioBus>(outputFrames, numChannels_, sampleRate_);
51
-
52
- for (int i = 0; i < numChannels_; ++i) {
53
- auto channelData = audioBus->getChannel(i)->getData();
54
-
55
- for (ma_uint64 j = 0; j < outputFrames; ++j) {
56
- channelData[j] = int16ToFloat(buffer[j * numChannels_ + i]);
57
- }
58
- }
59
-
60
92
  ma_decoder_uninit(&decoder);
61
-
62
- return audioBus;
93
+ return makeAudioBusFromInt16Buffer(buffer, numChannels_, sampleRate_);
63
94
  }
64
95
 
65
96
  std::shared_ptr<AudioBus> AudioDecoder::decodeWithMemoryBlock(
@@ -68,49 +99,36 @@ std::shared_ptr<AudioBus> AudioDecoder::decodeWithMemoryBlock(
68
99
  ma_decoder decoder;
69
100
  ma_decoder_config config = ma_decoder_config_init(
70
101
  ma_format_s16, numChannels_, static_cast<int>(sampleRate_));
71
- ma_result result = ma_decoder_init_memory(data, size, &config, &decoder);
72
- if (result != MA_SUCCESS) {
102
+
103
+ #ifndef AUDIO_API_TEST_SUITE
104
+ ma_decoding_backend_vtable *customBackends[] = {
105
+ ma_decoding_backend_libvorbis, ma_decoding_backend_libopus};
106
+
107
+ config.ppCustomBackendVTables = customBackends;
108
+ config.customBackendCount =
109
+ sizeof(customBackends) / sizeof(customBackends[0]);
110
+ #endif
111
+
112
+ if (ma_decoder_init_memory(data, size, &config, &decoder) != MA_SUCCESS) {
73
113
  // __android_log_print(
74
- // ANDROID_LOG_ERROR,
75
- // "AudioDecoder",
76
- // "Failed to initialize decoder for memory block");
114
+ // ANDROID_LOG_ERROR,
115
+ // "AudioDecoder",
116
+ // "Failed to initialize decoder for memory block");
77
117
  ma_decoder_uninit(&decoder);
78
-
79
118
  return nullptr;
80
119
  }
81
120
 
82
- ma_uint64 totalFrameCount;
83
- ma_decoder_get_length_in_pcm_frames(&decoder, &totalFrameCount);
84
-
85
- std::vector<int16_t> buffer(totalFrameCount * numChannels_);
86
-
87
- ma_uint64 framesDecoded;
88
- ma_decoder_read_pcm_frames(
89
- &decoder, buffer.data(), totalFrameCount, &framesDecoded);
90
-
91
- if (framesDecoded == 0) {
121
+ ma_uint64 framesRead = 0;
122
+ auto buffer = readAllPcmFrames(decoder, numChannels_, framesRead);
123
+ if (framesRead == 0) {
92
124
  // __android_log_print(ANDROID_LOG_ERROR, "AudioDecoder", "Failed to
93
125
  // decode");
94
-
95
126
  ma_decoder_uninit(&decoder);
96
127
  return nullptr;
97
128
  }
98
129
 
99
- auto outputFrames = buffer.size() / numChannels_;
100
- auto audioBus =
101
- std::make_shared<AudioBus>(outputFrames, numChannels_, sampleRate_);
102
-
103
- for (int i = 0; i < numChannels_; ++i) {
104
- auto channelData = audioBus->getChannel(i)->getData();
105
-
106
- for (ma_uint64 j = 0; j < outputFrames; ++j) {
107
- channelData[j] = int16ToFloat(buffer[j * numChannels_ + i]);
108
- }
109
- }
110
-
111
130
  ma_decoder_uninit(&decoder);
112
-
113
- return audioBus;
131
+ return makeAudioBusFromInt16Buffer(buffer, numChannels_, sampleRate_);
114
132
  }
115
133
 
116
134
  std::shared_ptr<AudioBus> AudioDecoder::decodeWithPCMInBase64(
@@ -1,6 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #include <audioapi/libs/audio-stretch/stretch.h>
4
+ #include <audioapi/libs/miniaudio/miniaudio.h>
4
5
  #include <memory>
5
6
  #include <string>
6
7
  #include <vector>
@@ -9,48 +10,72 @@ namespace audioapi {
9
10
 
10
11
  class AudioBus;
11
12
 
13
+ static constexpr int CHUNK_SIZE = 4096;
14
+
12
15
  class AudioDecoder {
13
16
  public:
14
- explicit AudioDecoder(float sampleRate): sampleRate_(sampleRate) {}
17
+ explicit AudioDecoder(float sampleRate) : sampleRate_(sampleRate) {}
15
18
 
16
- [[nodiscard]] std::shared_ptr<AudioBus> decodeWithFilePath(const std::string &path) const;
17
- [[nodiscard]] std::shared_ptr<AudioBus> decodeWithMemoryBlock(const void *data, size_t size) const;
18
- [[nodiscard]] std::shared_ptr<AudioBus> decodeWithPCMInBase64(const std::string &data, float playbackSpeed) const;
19
+ [[nodiscard]] std::shared_ptr<AudioBus> decodeWithFilePath(
20
+ const std::string &path) const;
21
+ [[nodiscard]] std::shared_ptr<AudioBus> decodeWithMemoryBlock(
22
+ const void *data,
23
+ size_t size) const;
24
+ [[nodiscard]] std::shared_ptr<AudioBus> decodeWithPCMInBase64(
25
+ const std::string &data,
26
+ float playbackSpeed) const;
19
27
 
20
28
  private:
21
29
  float sampleRate_;
22
30
  int numChannels_ = 2;
23
31
 
24
- void changePlaybackSpeedIfNeeded(std::vector<int16_t> &buffer, size_t framesDecoded, int numChannels, float playbackSpeed) const {
25
- if (playbackSpeed == 1.0f) {
26
- return;
27
- }
28
-
29
- auto stretcher = stretch_init(static_cast<int>(sampleRate_ / 333.0f), static_cast<int>(sampleRate_ / 55.0f), numChannels, 0x1);
30
-
31
- int maxOutputFrames = stretch_output_capacity(stretcher, static_cast<int>(framesDecoded), 1 / playbackSpeed);
32
- std::vector<int16_t> stretchedBuffer(maxOutputFrames);
33
-
34
- int outputFrames = stretch_samples(
35
- stretcher,
36
- buffer.data(),
37
- static_cast<int>(framesDecoded),
38
- stretchedBuffer.data(),
39
- 1 / playbackSpeed
40
- );
41
-
42
- outputFrames += stretch_flush(stretcher, stretchedBuffer.data() + (outputFrames));
43
- stretchedBuffer.resize(outputFrames);
44
-
45
- buffer = stretchedBuffer;
46
-
47
- stretch_deinit(stretcher);
32
+ std::vector<int16_t> readAllPcmFrames(
33
+ ma_decoder &decoder,
34
+ int numChannels,
35
+ ma_uint64 &outFramesRead) const;
36
+ std::shared_ptr<AudioBus> makeAudioBusFromInt16Buffer(
37
+ const std::vector<int16_t> &buffer,
38
+ int numChannels,
39
+ float sampleRate) const;
40
+
41
+ void changePlaybackSpeedIfNeeded(
42
+ std::vector<int16_t> &buffer,
43
+ size_t framesDecoded,
44
+ int numChannels,
45
+ float playbackSpeed) const {
46
+ if (playbackSpeed == 1.0f) {
47
+ return;
48
+ }
49
+
50
+ auto stretcher = stretch_init(
51
+ static_cast<int>(sampleRate_ / 333.0f),
52
+ static_cast<int>(sampleRate_ / 55.0f),
53
+ numChannels,
54
+ 0x1);
55
+
56
+ int maxOutputFrames = stretch_output_capacity(
57
+ stretcher, static_cast<int>(framesDecoded), 1 / playbackSpeed);
58
+ std::vector<int16_t> stretchedBuffer(maxOutputFrames);
59
+
60
+ int outputFrames = stretch_samples(
61
+ stretcher,
62
+ buffer.data(),
63
+ static_cast<int>(framesDecoded),
64
+ stretchedBuffer.data(),
65
+ 1 / playbackSpeed);
66
+
67
+ outputFrames +=
68
+ stretch_flush(stretcher, stretchedBuffer.data() + (outputFrames));
69
+ stretchedBuffer.resize(outputFrames);
70
+
71
+ buffer = stretchedBuffer;
72
+
73
+ stretch_deinit(stretcher);
48
74
  }
49
75
 
50
76
  [[nodiscard]] static inline int16_t floatToInt16(float sample) {
51
77
  return static_cast<int16_t>(sample * 32768.0f);
52
78
  }
53
-
54
79
  [[nodiscard]] static inline float int16ToFloat(int16_t sample) {
55
80
  return static_cast<float>(sample) / 32768.0f;
56
81
  }
@@ -0,0 +1,26 @@
1
+ #ifndef __CONFIG_TYPES_H__
2
+ #define __CONFIG_TYPES_H__
3
+
4
+ /* these are filled in by configure or cmake*/
5
+ #define INCLUDE_INTTYPES_H 1
6
+ #define INCLUDE_STDINT_H 1
7
+ #define INCLUDE_SYS_TYPES_H 1
8
+
9
+ #if INCLUDE_INTTYPES_H
10
+ #include <inttypes.h>
11
+ #endif
12
+ #if INCLUDE_STDINT_H
13
+ #include <stdint.h>
14
+ #endif
15
+ #if INCLUDE_SYS_TYPES_H
16
+ #include <sys/types.h>
17
+ #endif
18
+
19
+ typedef int16_t ogg_int16_t;
20
+ typedef uint16_t ogg_uint16_t;
21
+ typedef int32_t ogg_int32_t;
22
+ typedef uint32_t ogg_uint32_t;
23
+ typedef int64_t ogg_int64_t;
24
+ typedef uint64_t ogg_uint64_t;
25
+
26
+ #endif
@@ -0,0 +1,26 @@
1
+ #ifndef __CONFIG_TYPES_H__
2
+ #define __CONFIG_TYPES_H__
3
+
4
+ /* these are filled in by configure or cmake*/
5
+ #define INCLUDE_INTTYPES_H @INCLUDE_INTTYPES_H @
6
+ #define INCLUDE_STDINT_H @INCLUDE_STDINT_H @
7
+ #define INCLUDE_SYS_TYPES_H @INCLUDE_SYS_TYPES_H @
8
+
9
+ #if INCLUDE_INTTYPES_H
10
+ #include <inttypes.h>
11
+ #endif
12
+ #if INCLUDE_STDINT_H
13
+ #include <stdint.h>
14
+ #endif
15
+ #if INCLUDE_SYS_TYPES_H
16
+ #include <sys/types.h>
17
+ #endif
18
+
19
+ typedef @SIZE16 @ogg_int16_t;
20
+ typedef @USIZE16 @ogg_uint16_t;
21
+ typedef @SIZE32 @ogg_int32_t;
22
+ typedef @USIZE32 @ogg_uint32_t;
23
+ typedef @SIZE64 @ogg_int64_t;
24
+ typedef @USIZE64 @ogg_uint64_t;
25
+
26
+ #endif