diff --git a/decode.cc b/decode.cc index 5127c48..7011dac 100644 --- a/decode.cc +++ b/decode.cc @@ -15,6 +15,7 @@ namespace DSP { using std::abs; using std::min; using std::cos; using std::sin; #include "blockdc.hh" #include "hilbert.hh" #include "phasor.hh" +#include "bitman.hh" #include "delay.hh" #include "sma.hh" #include "wav.hh" @@ -334,9 +335,7 @@ struct Decoder Mod::hard(tmp, fdom[bin(i+data_off)] / head[bin(i+data_off)]); for (int k = 0; k < Mod::BITS; ++k) { int l = Mod::BITS * (data_cols * j + i) + k; - if (l % 8 == 0) - out[l/8] = 0; - out[l/8] |= (tmp[k] < 0) << (l % 8); + CODE::set_le_bit(out, l, tmp[k] < 0); } } } diff --git a/encode.cc b/encode.cc index 86296fc..188dfb1 100644 --- a/encode.cc +++ b/encode.cc @@ -9,6 +9,7 @@ Copyright 2021 Ahmet Inan #include #include "complex.hh" #include "utils.hh" +#include "bitman.hh" #include "decibel.hh" #include "fft.hh" #include "wav.hh" @@ -150,7 +151,7 @@ struct Encoder value tmp[Mod::BITS]; for (int k = 0; k < Mod::BITS; ++k) { int l = Mod::BITS * (data_cols * j + i) + k; - tmp[k] = 1 - 2 * ((inp[l/8] >> (l % 8)) & 1); + tmp[k] = 1 - 2 * CODE::get_le_bit(inp, l); } fdom[bin(i+data_off)] *= Mod::map(tmp); }