Codebase of 0.9.5 26.06.2024 found on my OneDrive
This commit is contained in:
52
not_functional/Flac.cpp
Normal file
52
not_functional/Flac.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include <renderd7/music/Flac.hpp>
|
||||
#ifdef RENDERD7_MUSICDEC
|
||||
#define DR_FLAC_IMPLEMENTATION
|
||||
#include <renderd7/external/dr_flac.h>
|
||||
|
||||
int rd7i_check_flac(const std::string &path) {
|
||||
int err = -1;
|
||||
drflac* flac = drflac_open_file(path.c_str(), NULL);
|
||||
|
||||
if(flac != NULL)
|
||||
err = 0;
|
||||
|
||||
drflac_close(flac);
|
||||
return err;
|
||||
}
|
||||
|
||||
namespace RenderD7 {
|
||||
int FlacDecoder::_init(const std::string &path, MusicMeta& meta) {
|
||||
meta.path(path);
|
||||
if(path.find_last_of('/') != path.npos)
|
||||
meta.name(path.substr(path.find_last_of('/')));
|
||||
else
|
||||
meta.name(path);
|
||||
flac = drflac_open_file(path.c_str(), NULL);
|
||||
return flac == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
unsigned int FlacDecoder::_getSampleRate() { return flac->sampleRate; }
|
||||
|
||||
unsigned char FlacDecoder::_getChannels() { return flac->channels; }
|
||||
|
||||
size_t FlacDecoder::_getBufSize() { return buf_size; }
|
||||
|
||||
unsigned long long FlacDecoder::_decode(signed short*buf_addr) {
|
||||
unsigned long long bsf = (unsigned long long)buf_size/(unsigned long long)flac->channels;
|
||||
|
||||
unsigned long long samples_read = drflac_read_pcm_frames_s16(flac, bsf, buf_addr);
|
||||
samples_read *= (unsigned long long)flac->channels;
|
||||
|
||||
return samples_read;
|
||||
}
|
||||
|
||||
void FlacDecoder::_deinit() {
|
||||
drflac_close(flac);
|
||||
}
|
||||
|
||||
size_t FlacDecoder::_getFileSamples() {
|
||||
return flac->totalPCMFrameCount * (size_t)flac->channels;
|
||||
}
|
||||
|
||||
} // namespace RenderD7
|
||||
#endif
|
26
not_functional/Flac.hpp
Normal file
26
not_functional/Flac.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/music/Music.hpp>
|
||||
#include <fstream>
|
||||
|
||||
#include <renderd7/external/dr_flac.h>
|
||||
|
||||
namespace RenderD7 {
|
||||
class FlacDecoder : public MusicDecoder {
|
||||
public:
|
||||
FlacDecoder() {}
|
||||
~FlacDecoder() {}
|
||||
|
||||
int _init(const std::string& pat, MusicMeta& meta) override;
|
||||
unsigned int _getSampleRate() override;
|
||||
unsigned char _getChannels() override;
|
||||
size_t _getBufSize() override;
|
||||
unsigned long long _decode(signed short* buf_addr) override;
|
||||
void _deinit() override;
|
||||
size_t _getFileSamples() override;
|
||||
|
||||
private:
|
||||
drflac* flac;
|
||||
const size_t buf_size = 16 * 1024;
|
||||
};
|
||||
}
|
40
not_functional/MUSIC.md
Normal file
40
not_functional/MUSIC.md
Normal file
@ -0,0 +1,40 @@
|
||||
# Copy of removed Music.cpp file loaders
|
||||
```
|
||||
#include <renderd7/music/Flac.hpp>
|
||||
#include <renderd7/music/Wav.hpp>
|
||||
// "RIFF"
|
||||
/*case 0x46464952:
|
||||
// "riff"
|
||||
case 0x66666972:
|
||||
// "RIFX"
|
||||
case 0x58464952:
|
||||
// "RF64"
|
||||
case 0x34364652:
|
||||
// "FORM"
|
||||
case 0x4D524F46:
|
||||
decoder = new WavDecoder();
|
||||
if (init(path, rd7i_mp_internal_data.meta)) {
|
||||
MusicDecoder::CleanUp();
|
||||
return;
|
||||
}
|
||||
break;*/
|
||||
// Flac
|
||||
/*case 0x43614c66:
|
||||
decoder = new FlacDecoder();
|
||||
if (init(path, rd7i_mp_internal_data.meta)) {
|
||||
RenderD7::PushMessage(
|
||||
RenderD7::Message("Music Player", "Failed to load FLAC"));
|
||||
MusicDecoder::CleanUp();
|
||||
return;
|
||||
}
|
||||
break;*/
|
||||
|
||||
// The other one
|
||||
/*else if (rd7i_check_flac(path) == 0) {
|
||||
decoder = new FlacDecoder();
|
||||
if (init(path, rd7i_mp_internal_data.meta)) {
|
||||
MusicDecoder::CleanUp();
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
```
|
41
not_functional/Wav.cpp
Normal file
41
not_functional/Wav.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include <renderd7/music/Wav.hpp>
|
||||
|
||||
#ifdef RENDERD7_MUSICDEC
|
||||
#define DR_WAV_IMPLEMENTATION
|
||||
#include <renderd7/external/dr_wav.h>
|
||||
|
||||
namespace RenderD7 {
|
||||
int WavDecoder::_init(const std::string &path, MusicMeta& meta) {
|
||||
meta.path(path);
|
||||
if(path.find_last_of('/') != path.npos)
|
||||
meta.name(path.substr(path.find_last_of('/')));
|
||||
else
|
||||
meta.name(path);
|
||||
return !drwav_init_file(&wav, path.c_str(), NULL);
|
||||
}
|
||||
|
||||
unsigned int WavDecoder::_getSampleRate() { return wav.sampleRate; }
|
||||
|
||||
unsigned char WavDecoder::_getChannels() { return wav.channels; }
|
||||
|
||||
size_t WavDecoder::_getBufSize() { return buf_size; }
|
||||
|
||||
unsigned long long WavDecoder::_decode(signed short*buf_addr) {
|
||||
unsigned long long bsf = (unsigned long long)buf_size/(unsigned long long)wav.channels;
|
||||
|
||||
unsigned long long samples_read = drwav_read_pcm_frames(&wav, bsf, buf_addr);
|
||||
samples_read *= (unsigned long long)wav.channels;
|
||||
|
||||
return samples_read;
|
||||
}
|
||||
|
||||
void WavDecoder::_deinit() {
|
||||
drwav_uninit(&wav);
|
||||
}
|
||||
|
||||
size_t WavDecoder::_getFileSamples() {
|
||||
return wav.totalPCMFrameCount * (size_t)wav.channels;
|
||||
}
|
||||
|
||||
} // namespace RenderD7
|
||||
#endif
|
26
not_functional/Wav.hpp
Normal file
26
not_functional/Wav.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <renderd7/music/Music.hpp>
|
||||
#include <fstream>
|
||||
|
||||
#include <renderd7/external/dr_wav.h>
|
||||
|
||||
namespace RenderD7 {
|
||||
class WavDecoder : public MusicDecoder {
|
||||
public:
|
||||
WavDecoder() {}
|
||||
~WavDecoder() {}
|
||||
|
||||
int _init(const std::string& path, MusicMeta& meta) override;
|
||||
unsigned int _getSampleRate() override;
|
||||
unsigned char _getChannels() override;
|
||||
size_t _getBufSize() override;
|
||||
unsigned long long _decode(signed short* buf_addr) override;
|
||||
void _deinit() override;
|
||||
size_t _getFileSamples() override;
|
||||
|
||||
private:
|
||||
drwav wav;
|
||||
const size_t buf_size = 16 * 1024;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user