Compare commits
No commits in common. "dacb8d820d721dbc18a441c69ee6c399951dc77e" and "60da6c131aa4115b5a0d72b0441285feced4169a" have entirely different histories.
dacb8d820d
...
60da6c131a
|
@ -51,9 +51,6 @@ Ergodox& Ergodox::init(
|
||||||
return Instance;
|
return Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Instance is a static function variable,
|
|
||||||
// and will be deleted at end of program.
|
|
||||||
Ergodox::~Ergodox() {
|
Ergodox::~Ergodox() {
|
||||||
close();
|
close();
|
||||||
hid_exit();
|
hid_exit();
|
||||||
|
|
|
@ -43,9 +43,9 @@ class FFT_Visualizer {
|
||||||
// Visualizer parameters
|
// Visualizer parameters
|
||||||
///
|
///
|
||||||
|
|
||||||
// Horizontal resolution
|
// How many bars this visualizer will generate
|
||||||
const size_t width;
|
const size_t width;
|
||||||
// Vertical resolution
|
// Resolution of this visualizer's bars.
|
||||||
const size_t height;
|
const size_t height;
|
||||||
// Leftmost frequency in spectrum
|
// Leftmost frequency in spectrum
|
||||||
const double HZ_MIN;
|
const double HZ_MIN;
|
||||||
|
|
46
src/test.cpp
46
src/test.cpp
|
@ -44,25 +44,7 @@ const size_t height = 150;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// buffer size for waveform:
|
uint8_t hid_buf[20];
|
||||||
// (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(
|
Ergodox Dox = Ergodox::init(
|
||||||
0x3297,
|
0x3297,
|
||||||
0x4976,
|
0x4976,
|
||||||
|
@ -70,13 +52,34 @@ int main(int argc, char *argv[]) {
|
||||||
0xFF60
|
0xFF60
|
||||||
);
|
);
|
||||||
|
|
||||||
// Data buffer
|
// buffer size for waveform:
|
||||||
uint8_t hid_buf[12];
|
// (44100 / fps * 10), make 10 bigger for slower scrolling
|
||||||
|
//
|
||||||
|
// Double both buffer sizes if stereo
|
||||||
|
|
||||||
|
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) {
|
while (1) {
|
||||||
|
//b.clear();
|
||||||
buf.update();
|
buf.update();
|
||||||
fft.update(buf);
|
fft.update(buf);
|
||||||
|
//draw_spectrum_bitmap(fft.get_output(), b);
|
||||||
|
//b.save("/tmp/o.bmp");
|
||||||
|
|
||||||
hid_buf[0] = 0x01;
|
hid_buf[0] = 0x01;
|
||||||
hid_buf[1] = 0x02;
|
hid_buf[1] = 0x02;
|
||||||
|
@ -89,6 +92,5 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
Dox.write(hid_buf, 12);
|
Dox.write(hid_buf, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue