Skip to content

Commit f7fbb5d

Browse files
author
Maciej Makowski
committed
ci: yarn format
1 parent fa161da commit f7fbb5d

File tree

3 files changed

+50
-47
lines changed

3 files changed

+50
-47
lines changed
Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "AudioDecoder.h"
2-
#include <iostream>
32
#include <fstream>
4-
//#include <curl/curl.h>
3+
#include <iostream>
4+
// #include <curl/curl.h>
55
#include <sndfile.h>
6-
#include <filesystem>
76
#include <chrono>
8-
#include "AudioBus.h"
7+
#include <filesystem>
98
#include "AudioArray.h"
9+
#include "AudioBus.h"
1010

1111
#include <android/log.h>
1212
#define LOG_TAG "AudioDecoder"
@@ -15,40 +15,41 @@
1515

1616
namespace audioapi {
1717

18-
AudioDecoder::AudioDecoder(int sampleRate) : sampleRate_(sampleRate) {}
18+
AudioDecoder::AudioDecoder(int sampleRate) : sampleRate_(sampleRate) {}
1919

20-
AudioBus* AudioDecoder::decode(const std::string& pathOrURL) {
21-
return decodeWithFilePath("/Files/runaway_kanye_west.mp3");
22-
}
20+
AudioBus *AudioDecoder::decode(const std::string &pathOrURL) {
21+
return decodeWithFilePath("/Files/runaway_kanye_west.mp3");
22+
}
2323

24-
AudioBus *AudioDecoder::decodeWithFilePath(const std::string& path) const {
25-
SF_INFO sfInfo;
26-
SNDFILE* sndFile = sf_open(path.c_str(), SFM_READ, &sfInfo);
27-
if (!sndFile) {
28-
LOGE("Error opening audio file: %s", sf_strerror(sndFile));
29-
return nullptr;
30-
}
24+
AudioBus *AudioDecoder::decodeWithFilePath(const std::string &path) const {
25+
SF_INFO sfInfo;
26+
SNDFILE *sndFile = sf_open(path.c_str(), SFM_READ, &sfInfo);
27+
if (!sndFile) {
28+
LOGE("Error opening audio file: %s", sf_strerror(sndFile));
29+
return nullptr;
30+
}
3131

32-
auto* buffer = new float[sfInfo.frames * sfInfo.channels];
33-
sf_readf_float(sndFile, buffer, sfInfo.frames);
34-
sf_close(sndFile);
32+
auto *buffer = new float[sfInfo.frames * sfInfo.channels];
33+
sf_readf_float(sndFile, buffer, sfInfo.frames);
34+
sf_close(sndFile);
3535

36-
if (sfInfo.samplerate != sampleRate_) {
37-
//todo
38-
}
36+
if (sfInfo.samplerate != sampleRate_) {
37+
// todo
38+
}
3939

40-
auto* audioBus = new AudioBus(sampleRate_, static_cast<int>(sfInfo.frames), sfInfo.channels);
40+
auto *audioBus = new AudioBus(
41+
sampleRate_, static_cast<int>(sfInfo.frames), sfInfo.channels);
4142

42-
for (int i = 0; i < sfInfo.channels; ++i) {
43-
float* data = audioBus->getChannel(i)->getData();
43+
for (int i = 0; i < sfInfo.channels; ++i) {
44+
float *data = audioBus->getChannel(i)->getData();
4445

45-
for (int j = 0; j < sfInfo.frames; ++j) {
46-
data[j] = buffer[j * sfInfo.channels + i];
47-
}
48-
}
46+
for (int j = 0; j < sfInfo.frames; ++j) {
47+
data[j] = buffer[j * sfInfo.channels + i];
48+
}
49+
}
4950

50-
delete[] buffer;
51+
delete[] buffer;
5152

52-
return audioBus;
53-
}
53+
return audioBus;
54+
}
5455
} // namespace audioapi
Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
#pragma once
22

3-
#include <string>
43
#include <memory>
4+
#include <string>
55
#include <vector>
6-
//#include <curl/curl.h>
6+
// #include <curl/curl.h>
77
#include <sndfile.h>
88
#include <filesystem>
99

1010
namespace audioapi {
1111

12-
class AudioBus;
12+
class AudioBus;
1313

14-
class AudioDecoder {
15-
public:
16-
explicit AudioDecoder(int sampleRate);
14+
class AudioDecoder {
15+
public:
16+
explicit AudioDecoder(int sampleRate);
1717

18-
AudioBus *decode(const std::string& pathOrURL);
18+
AudioBus *decode(const std::string &pathOrURL);
1919

20-
private:
21-
int sampleRate_;
20+
private:
21+
int sampleRate_;
2222

23-
AudioBus *decodeWithFilePath(const std::string& path) const;
24-
// AudioBus *decodeWithURL(const std::string& url);
25-
// AudioBus *convertBuffer();
23+
AudioBus *decodeWithFilePath(const std::string &path) const;
24+
// AudioBus *decodeWithURL(const std::string& url);
25+
// AudioBus *convertBuffer();
2626

27-
// void downloadFileFromURL(const std::string& url, const std::string& tempFilePath);
28-
// static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp);
29-
};
27+
// void downloadFileFromURL(const std::string& url, const std::string&
28+
// tempFilePath); static size_t WriteCallback(void* contents, size_t
29+
// size, size_t nmemb, void* userp);
30+
};
3031

3132
} // namespace audioapi

packages/react-native-audio-api/common/cpp/wrappers/BaseAudioContextWrapper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class BaseAudioContextWrapper {
4141
float *imag,
4242
bool disableNormalization,
4343
int length);
44-
std::shared_ptr<AudioBufferWrapper> decodeAudioDataSource(const std::string &source);
44+
std::shared_ptr<AudioBufferWrapper> decodeAudioDataSource(
45+
const std::string &source);
4546

4647
protected:
4748
std::shared_ptr<AudioDestinationNodeWrapper> destination_;

0 commit comments

Comments
 (0)