mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Remove experimental support for Replaying C32 files (#1294)
This commit is contained in:
parent
c4df2e66be
commit
828eb67a52
@ -41,7 +41,6 @@ static const fs::path txt_ext{u".TXT"};
|
||||
static const fs::path ppl_ext{u".PPL"};
|
||||
static const fs::path c8_ext{u".C8"};
|
||||
static const fs::path c16_ext{u".C16"};
|
||||
static const fs::path c32_ext{u".C32"};
|
||||
static const fs::path cxx_ext{u".C*"};
|
||||
static const fs::path png_ext{u".PNG"};
|
||||
static const fs::path bmp_ext{u".BMP"};
|
||||
@ -87,8 +86,6 @@ fs::path get_partner_file(fs::path path) {
|
||||
path.replace_extension(c8_ext);
|
||||
if (!fs::file_exists(path))
|
||||
path.replace_extension(c16_ext);
|
||||
if (!fs::file_exists(path))
|
||||
path.replace_extension(c32_ext);
|
||||
} else
|
||||
return {};
|
||||
|
||||
|
@ -76,7 +76,6 @@ class FileManBaseView : public View {
|
||||
{u".BMP", &bitmap_icon_file_image, ui::Color::green()},
|
||||
{u".C8", &bitmap_icon_file_iq, ui::Color::dark_cyan()},
|
||||
{u".C16", &bitmap_icon_file_iq, ui::Color::dark_cyan()},
|
||||
{u".C32", &bitmap_icon_file_iq, ui::Color::dark_cyan()},
|
||||
{u".WAV", &bitmap_icon_file_wav, ui::Color::dark_magenta()},
|
||||
{u".PPL", &bitmap_icon_file_iq, ui::Color::white()}, // PPL is the file extension for playlist app
|
||||
{u"", &bitmap_icon_file, ui::Color::light_grey()} // NB: Must be last.
|
||||
|
@ -31,7 +31,6 @@
|
||||
namespace fs = std::filesystem;
|
||||
static const fs::path c8_ext{u".C8"};
|
||||
static const fs::path c16_ext{u".C16"};
|
||||
static const fs::path c32_ext{u".C32"};
|
||||
|
||||
Optional<File::Error> File::open_fatfs(const std::filesystem::path& filename, BYTE mode) {
|
||||
auto result = f_open(&f, reinterpret_cast<const TCHAR*>(filename.c_str()), mode);
|
||||
@ -515,7 +514,7 @@ bool path_iequal(
|
||||
|
||||
bool is_cxx_capture_file(const path& filename) {
|
||||
auto ext = filename.extension();
|
||||
return path_iequal(c8_ext, ext) || path_iequal(c16_ext, ext) || path_iequal(c32_ext, ext);
|
||||
return path_iequal(c8_ext, ext) || path_iequal(c16_ext, ext);
|
||||
}
|
||||
|
||||
uint8_t capture_file_sample_size(const path& filename) {
|
||||
@ -523,8 +522,6 @@ uint8_t capture_file_sample_size(const path& filename) {
|
||||
return sizeof(complex8_t);
|
||||
if (path_iequal(filename.extension(), c16_ext))
|
||||
return sizeof(complex16_t);
|
||||
if (path_iequal(filename.extension(), c32_ext))
|
||||
return sizeof(complex32_t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
static const fs::path c8_ext = u".C8";
|
||||
static const fs::path c32_ext = u".C32";
|
||||
|
||||
namespace file_convert {
|
||||
|
||||
@ -60,41 +59,21 @@ void c8_to_c16(const void* buffer, File::Size bytes) {
|
||||
}
|
||||
}
|
||||
|
||||
// Convert c32 buffer to c16 buffer.
|
||||
// Same buffer used for input & output; input size is bytes; output size is bytes/2.
|
||||
void c32_to_c16(const void* buffer, File::Size bytes) {
|
||||
complex32_t* src = (complex32_t*)buffer;
|
||||
complex16_t* dest = (complex16_t*)buffer;
|
||||
|
||||
// Shift isn't used here because it would amplify noise at center freq since it's a signed number
|
||||
// i.e. ((-1 >> 16) << 16) = -65536, whereas (-1 / 65536) * 65536 = 0
|
||||
for (File::Size i = 0; i < bytes / sizeof(complex32_t); i++) {
|
||||
auto re_out = src[i].real() / 65536;
|
||||
auto im_out = src[i].imag() / 65536;
|
||||
dest[i] = {(int8_t)re_out, (int8_t)im_out};
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace file_convert */
|
||||
|
||||
// Automatically enables C8/C16 or C32/C16 conversion based on file extension
|
||||
// Automatically enables C8/C16 conversion based on file extension
|
||||
Optional<File::Error> FileConvertReader::open(const std::filesystem::path& filename) {
|
||||
convert_c8_to_c16 = path_iequal(filename.extension(), c8_ext);
|
||||
convert_c32_to_c16 = path_iequal(filename.extension(), c32_ext);
|
||||
return file_.open(filename);
|
||||
}
|
||||
|
||||
// If C8 conversion enabled, half the number of bytes are read from the file & expanded to fill the whole buffer.
|
||||
// If C32 conversion enabled, the full byte count is read from the file, and compressed to half the buffer size.
|
||||
File::Result<File::Size> FileConvertReader::read(void* const buffer, const File::Size bytes) {
|
||||
auto read_result = file_.read(buffer, convert_c8_to_c16 ? bytes / 2 : bytes);
|
||||
if (read_result.is_ok()) {
|
||||
if (convert_c8_to_c16) {
|
||||
file_convert::c8_to_c16(buffer, read_result.value());
|
||||
read_result = read_result.value() * 2;
|
||||
} else if (convert_c32_to_c16) {
|
||||
file_convert::c32_to_c16(buffer, read_result.value());
|
||||
read_result = read_result.value() / 2;
|
||||
}
|
||||
bytes_read_ += read_result.value();
|
||||
}
|
||||
|
@ -32,7 +32,6 @@
|
||||
namespace file_convert {
|
||||
|
||||
void c8_to_c16(const void* buffer, File::Size bytes);
|
||||
void c32_to_c16(const void* buffer, File::Size bytes);
|
||||
void c16_to_c8(const void* buffer, File::Size bytes);
|
||||
|
||||
} /* namespace file_convert */
|
||||
@ -52,7 +51,6 @@ class FileConvertReader : public stream::Reader {
|
||||
const File& file() const& { return file_; }
|
||||
|
||||
bool convert_c8_to_c16{};
|
||||
bool convert_c32_to_c16{};
|
||||
|
||||
protected:
|
||||
File file_{};
|
||||
|
Loading…
Reference in New Issue
Block a user