summaryrefslogtreecommitdiff
path: root/sound_detector/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sound_detector/main.cpp')
-rw-r--r--sound_detector/main.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/sound_detector/main.cpp b/sound_detector/main.cpp
index 8d7f331..b2064d8 100644
--- a/sound_detector/main.cpp
+++ b/sound_detector/main.cpp
@@ -16,13 +16,17 @@
+//c++
+#include <cstdint>
+
#ifndef WIN32
#include <unistd.h>
#else
+//getopt
#include "wingetopt.h"
#endif
-#include <cstdint>
+
//c
#include <stdio.h>
@@ -31,6 +35,7 @@
#include <complex.h>
//c++
+#include <limits>
#include <vector>
#include <fstream>
@@ -44,6 +49,9 @@
#include <boost/date_time.hpp>
#include <boost/filesystem.hpp>
+//internal
+#include "toutf8.h"
+
unsigned int precapture = 3, postcapture = 7, min_length = 1, thresold = 0, stop_thresold = 0;
@@ -222,13 +230,13 @@ int stream_callback(const void *input, void *output, unsigned long frameCount, c
int16_t *buf = bufs[0];
lock.lock();
buffer.insert(buffer.end(), buf, buf + frameCount);
- lock.unlock();
//debug
-/* for(unsigned long i = 0; i < frameCount; i++)
+/* for(size_t i = 0; i < buffer.size(); i++)
{
- if(buf[i] > (int)((float)INT16_MAX/100.0*(float)thresold_percent))
- printf("%d ", buf[i]);
- } */
+ if(buffer[i] > (int)((float)INT16_MAX/100.0*(float)thresold_percent))
+ printf("%d ", buffer[i]);
+ } */
+ lock.unlock();
return paContinue;
//debug end
}
@@ -281,8 +289,16 @@ int main(int argc, char **argv)
for(PaDeviceIndex i =0, end = Pa_GetDeviceCount(); i < end; i++)
{
const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
+ //windows
+#ifdef WIN32
+ char *name = to_utf8(info->name);
+ printf("%d. %s, input channels %d, output channels %d, default sample rate %f, lowest input latency %f, highest input latency %f\n",
+ i, name, info->maxInputChannels, info->maxOutputChannels, info->defaultSampleRate, info->defaultLowInputLatency, info->defaultHighInputLatency);
+ free(name);
+#else
printf("%d. %s, input channels %d, output channels %d, default sample rate %f, lowest input latency %f, highest input latency %f\n",
i, info->name, info->maxInputChannels, info->maxOutputChannels, info->defaultSampleRate, info->defaultLowInputLatency, info->defaultHighInputLatency);
+#endif
}
exit(0);
}