Compare commits

..

3 Commits

Author SHA1 Message Date
Mark dacb8d820d
Cleanup 2022-06-26 12:49:50 -07:00
Mark 5ea64d3e07
Comments 2022-06-26 12:47:43 -07:00
Mark 267a8a2ad6
Removed bitmap debug 2022-06-26 12:46:28 -07:00
3 changed files with 27 additions and 26 deletions

View File

@ -51,6 +51,9 @@ Ergodox& Ergodox::init(
return Instance;
}
// Instance is a static function variable,
// and will be deleted at end of program.
Ergodox::~Ergodox() {
close();
hid_exit();

View File

@ -43,9 +43,9 @@ class FFT_Visualizer {
// Visualizer parameters
///
// How many bars this visualizer will generate
// Horizontal resolution
const size_t width;
// Resolution of this visualizer's bars.
// Vertical resolution
const size_t height;
// Leftmost frequency in spectrum
const double HZ_MIN;

View File

@ -44,7 +44,25 @@ const size_t height = 150;
int main(int argc, char *argv[]) {
uint8_t hid_buf[20];
// buffer size for waveform:
// (44100 / fps * 10), make 10 bigger for slower scrolling
//
// Double both buffer sizes if stereo
// FFT generator
FFT_Visualizer fft = FFT_Visualizer(
width, height,
100, 10000
);
// Audio buffer
Buffer buf = Buffer(
"/tmp/mpd.fifo",
44100 / 2, // Keep 500ms of data in buffer
fft.compute_buffer_output_size()
);
// HID interface wrapper
Ergodox Dox = Ergodox::init(
0x3297,
0x4976,
@ -52,34 +70,13 @@ int main(int argc, char *argv[]) {
0xFF60
);
// buffer size for waveform:
// (44100 / fps * 10), make 10 bigger for slower scrolling
//
// Double both buffer sizes if stereo
// Data buffer
uint8_t hid_buf[12];
FFT_Visualizer fft = FFT_Visualizer(
width, height,
100, 10000
);
std::vector<size_t> waveform;
waveform.resize(width);
Buffer buf = Buffer(
"/tmp/mpd.fifo",
//"/home/mark/Workbench/sospi/pulse.fifo",
44100 / 2, // Keep 500ms of data in buffer
fft.compute_buffer_output_size()
);
Bitmap b = Bitmap(width, height);
while (1) {
//b.clear();
buf.update();
fft.update(buf);
//draw_spectrum_bitmap(fft.get_output(), b);
//b.save("/tmp/o.bmp");
hid_buf[0] = 0x01;
hid_buf[1] = 0x02;
@ -92,5 +89,6 @@ int main(int argc, char *argv[]) {
Dox.write(hid_buf, 12);
}
return 0;
}