diff --git a/.clang-format b/.clang-format index e5534fd..37ca78b 100644 --- a/.clang-format +++ b/.clang-format @@ -4,9 +4,10 @@ Language: Cpp # Style BasedOnStyle: Microsoft -# No indent for extern block and namespace +# No indent for extern block, namespace, and access specifiers in class IndentExternBlock: NoIndent NamespaceIndentation: None +AccessModifierOffset: -4 # Header files order IncludeIsMainRegex: ".*" # 1. main file diff --git a/cli/cli.h b/cli/cli.h index 3acbbb2..928cd54 100644 --- a/cli/cli.h +++ b/cli/cli.h @@ -6,10 +6,10 @@ class CLI { - public: +public: int Run(int argc, char **argv); - private: +private: Fingerprint *getFingerprintFromMusicFile(const std::string &music_file); Fingerprint *getFingerprintFromStdin(int chunk_seconds, int sample_rate, int channels, int bits_per_sample, bool is_signed); diff --git a/cli/communication/shazam.h b/cli/communication/shazam.h index 4a4f18d..9fe8e51 100644 --- a/cli/communication/shazam.h +++ b/cli/communication/shazam.h @@ -11,10 +11,10 @@ class Shazam { static constexpr char HOST[] = "https://amp.shazam.com/discovery/v5/fr/FR/android/-/tag/"; - public: +public: static std::string Recognize(const Fingerprint *fingerprint); - private: +private: static std::string getShazamHost(); static std::string getUserAgent(); static std::string getRequestContent(const std::string &uri, unsigned int sample_ms); diff --git a/lib/algorithm/frequency.h b/lib/algorithm/frequency.h index 03e2857..fd87b8a 100644 --- a/lib/algorithm/frequency.h +++ b/lib/algorithm/frequency.h @@ -14,7 +14,7 @@ enum class FrequencyBand class FrequencyPeak { - public: +public: FrequencyPeak(std::uint32_t fft_pass_number, std::uint32_t peak_magnitude, std::uint32_t corrected_peak_frequency_bin, std::uint32_t sample_rate); ~FrequencyPeak(); @@ -35,7 +35,7 @@ class FrequencyPeak inline double ComputeAmplitudePCM() const; inline double ComputeElapsedSeconds() const; - private: +private: std::uint32_t fft_pass_number_; std::uint32_t peak_magnitude_; std::uint32_t corrected_peak_frequency_bin_; diff --git a/lib/algorithm/signature.h b/lib/algorithm/signature.h index a0df2ec..f90b780 100644 --- a/lib/algorithm/signature.h +++ b/lib/algorithm/signature.h @@ -32,7 +32,7 @@ __attribute__((packed)); class Signature { - public: +public: Signature(std::uint32_t sample_rate, std::uint32_t num_samples); ~Signature(); void Reset(std::uint32_t sampleRate, std::uint32_t num_samples); @@ -56,10 +56,10 @@ class Signature std::uint32_t SumOfPeaksLength() const; std::string EncodeBase64() const; - private: +private: template std::stringstream &write_little_endian(std::stringstream &stream, const T &&value, - size_t size = sizeof(T)) const + size_t size = sizeof(T)) const { for (size_t i = 0; i < size; ++i) { @@ -68,7 +68,7 @@ class Signature return stream; } - private: +private: std::uint32_t sample_rate_; std::uint32_t num_samples_; std::map> frequency_band_to_peaks_; diff --git a/lib/algorithm/signature_generator.h b/lib/algorithm/signature_generator.h index 94cbaff..cd08510 100644 --- a/lib/algorithm/signature_generator.h +++ b/lib/algorithm/signature_generator.h @@ -10,7 +10,7 @@ constexpr auto MAX_PEAKS = 255u; class SignatureGenerator { - public: +public: SignatureGenerator(); void FeedInput(const LowQualityTrack &input); Signature GetNextSignature(); @@ -25,7 +25,7 @@ class SignatureGenerator max_time_seconds_ = max_time_seconds; } - private: +private: void processInput(const LowQualityTrack &input); void doFFT(const LowQualityTrack &input); void doPeakSpreadingAndRecoginzation(); @@ -33,7 +33,7 @@ class SignatureGenerator void doPeakRecognition(); void resetSignatureGenerater(); - private: +private: LowQualityTrack input_pending_processing_; std::uint32_t sample_processed_; double max_time_seconds_; diff --git a/lib/audio/downsampler.h b/lib/audio/downsampler.h index bae4a27..d38b138 100644 --- a/lib/audio/downsampler.h +++ b/lib/audio/downsampler.h @@ -20,11 +20,11 @@ using DownsampleFunc = void (*)(LowQualityTrack *, const void *, double, std::ui class Downsampler { - public: +public: static LowQualityTrack GetLowQualityPCM(const Wav &wav, std::int32_t start_sec = 0, std::int32_t end_sec = -1); - private: +private: static DownsampleFunc getDownsampleFunc(bool is_signed, std::uint32_t width, std::uint32_t channels); diff --git a/lib/audio/wav.h b/lib/audio/wav.h index d9f60c3..079526b 100644 --- a/lib/audio/wav.h +++ b/lib/audio/wav.h @@ -30,7 +30,7 @@ enum class AudioFormat class Wav { - public: +public: Wav(Wav &&) = default; Wav(const Wav &) = delete; static Wav FromFile(const std::string &wav_file_path); @@ -72,14 +72,14 @@ class Wav return data_; } - private: +private: Wav() = default; static Wav fromPCM(const char *raw_pcm, std::uint32_t raw_pcm_size, AudioFormat audio_format, std::uint32_t sample_rate, std::uint32_t sample_width, std::uint32_t channel_count); void readWavFileBuffer(std::istream &stream); - private: +private: WavHeader header_; FmtSubchunk fmt_; std::string wav_file_path_; diff --git a/lib/utils/ffmpeg.h b/lib/utils/ffmpeg.h index 36c212b..da42533 100644 --- a/lib/utils/ffmpeg.h +++ b/lib/utils/ffmpeg.h @@ -18,11 +18,11 @@ constexpr int EXPECTED_DURATION = 5 * 60; // 5 minutes class FFmpegWrapper { - public: +public: FFmpegWrapper() = delete; static int ConvertToWav(const std::string &input_file, LowQualityTrack *pcm); - private: +private: static std::string getFFmpegPath(); static bool isWindows(); }; diff --git a/lib/utils/fft.h b/lib/utils/fft.h index a19f500..31f4df6 100644 --- a/lib/utils/fft.h +++ b/lib/utils/fft.h @@ -13,7 +13,7 @@ using RealArray = std::vector; class FFT { - public: +public: template static RealArray RFFT(const Iterable &input) { // If input size is 0, return false. diff --git a/lib/utils/ring_buffer.h b/lib/utils/ring_buffer.h index 6599083..82c28fc 100644 --- a/lib/utils/ring_buffer.h +++ b/lib/utils/ring_buffer.h @@ -5,7 +5,7 @@ template class RingBuffer : private std::vector { - public: +public: explicit RingBuffer(std::size_t size, T &&default_value = T()); virtual ~RingBuffer(); @@ -34,7 +34,7 @@ template class RingBuffer : private std::vector return std::vector::end(); } - private: +private: std::uint32_t num_written_; std::uint32_t position_; };