Fixes to C8 capture support (#1290)

* Use divide vs shift in C16->C8 and C32->C16 conversion
* Color cyan for .C32 files
This commit is contained in:
Mark Thompson 2023-07-22 09:12:35 -05:00 committed by GitHub
parent d6b0173e7a
commit bee2dc17af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -76,6 +76,7 @@ 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.

View File

@ -34,9 +34,11 @@ void c16_to_c8(const void* buffer, File::Size bytes) {
complex16_t* src = (complex16_t*)buffer;
complex8_t* dest = (complex8_t*)buffer;
// Shift isn't used here because it would amplify noise at center freq since it's a signed number
// i.e. ((-1 >> 8) << 8) = -256, whereas (-1 / 256) * 256 = 0
for (File::Size i = 0; i < bytes / sizeof(complex16_t); i++) {
auto re_out = src[i].real() >> 8;
auto im_out = src[i].imag() >> 8;
auto re_out = src[i].real() / 256;
auto im_out = src[i].imag() / 256;
dest[i] = {(int8_t)re_out, (int8_t)im_out};
}
}
@ -64,9 +66,11 @@ 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() >> 16;
auto im_out = src[i].imag() >> 16;
auto re_out = src[i].real() / 65536;
auto im_out = src[i].imag() / 65536;
dest[i] = {(int8_t)re_out, (int8_t)im_out};
}
}