summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sound_detector/Makefile.mingw323
-rw-r--r--sound_detector/main.cpp28
-rw-r--r--sound_detector/sound_detector.project9
-rw-r--r--sound_detector/toutf8.c50
-rw-r--r--sound_detector/toutf8.h3
-rw-r--r--sound_detector/toutf8.obin0 -> 1215 bytes
6 files changed, 84 insertions, 9 deletions
diff --git a/sound_detector/Makefile.mingw32 b/sound_detector/Makefile.mingw32
index 00e2207..201c84e 100644
--- a/sound_detector/Makefile.mingw32
+++ b/sound_detector/Makefile.mingw32
@@ -1,7 +1,8 @@
all:
i686-pc-mingw32-gcc -c wingetopt.c -o wingetopt.o
+ i686-pc-mingw32-gcc -c toutf8.c -o toutf8.o
i686-pc-mingw32-g++ -c main.cpp -std=gnu++0x -DBOOST_ALL_NO_LIB -DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -DBOOST_EXCEPTION_DISABLE -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_USE_LIB -DBOOST_THREAD_USE_LIB=1 -DUNICODE -DWIN32 -DWIN32_LEAN_AND_MEAN -D_UNICODE -D_WIN32 -D_WIN32_WINNT=0x0500 -D__USE_W32_SOCKETS -DCURL_STATICLIB -o main.o
- i686-pc-mingw32-g++ -o sound_detector.exe *.o -lwldap32 -liconv -lwldap32 -lws2_32 -lz -lgmp -lz -lboost_system-mt -lboost_date_time-mt -lboost_thread_win32-mt -lboost_chrono-mt -lboost_random-mt -lboost_filesystem-mt -lmswsock -lws2_32 -lgdi32 -lcrypt32 -lz -lportaudio -lwinmm -lm -ldsound -lole32 -lwinmm -lm -luuid -lsetupapi -lole32 -lwinmm -lm -lole32 -luuid -lwinmm -lm -lole32 -luuid -lvorbis -lvorbisenc -logg -Wl,-O1 -s
+ i686-pc-mingw32-g++ -o sound_detector.exe *.o -lwldap32 -liconv -lwldap32 -lws2_32 -lz -lgmp -lz -lboost_system-mt -lboost_date_time-mt -lboost_thread_win32-mt -lboost_chrono-mt -lboost_random-mt -lboost_filesystem-mt -lmswsock -lws2_32 -lgdi32 -lcrypt32 -lz -lportaudio -lwinmm -lm -ldsound -lole32 -lwinmm -lm -luuid -lsetupapi -lole32 -lwinmm -lm -lole32 -luuid -lwinmm -lm -lole32 -luuid -lvorbis -lvorbisenc -logg -liconv -Wl,-O1 -s
upx --best sound_detector.exe
clean:
rm *.o
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);
}
diff --git a/sound_detector/sound_detector.project b/sound_detector/sound_detector.project
index 3b68ebd..319e841 100644
--- a/sound_detector/sound_detector.project
+++ b/sound_detector/sound_detector.project
@@ -9,6 +9,8 @@
<Dependencies/>
<VirtualDirectory Name="src">
<File Name="main.cpp"/>
+ <File Name="toutf8.c"/>
+ <File Name="toutf8.h"/>
</VirtualDirectory>
<Settings Type="Executable">
<GlobalSettings>
@@ -33,9 +35,10 @@
<Library Value="vorbisenc"/>
</Linker>
<ResourceCompiler Options="" Required="no"/>
- <General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="./Debug" Command="./$(ProjectName)" CommandArguments="-d0 -o. -s 5,2 -S 3,5" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes"/>
+ <General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="./Debug" Command="./$(ProjectName)" CommandArguments="-d 4 -o. -s 5,2 -S 3,5" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
- <![CDATA[]]>
+ <![CDATA[
+ ]]>
</Environment>
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
<PostConnectCommands/>
@@ -76,6 +79,8 @@
+
+
]]>
</Environment>
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
diff --git a/sound_detector/toutf8.c b/sound_detector/toutf8.c
new file mode 100644
index 0000000..1601bd1
--- /dev/null
+++ b/sound_detector/toutf8.c
@@ -0,0 +1,50 @@
+// Copyright © 2013 sss
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifdef WIN32
+//iconv
+#include <stdint.h>
+#include <limits.h>
+#include <string.h>
+#include <stdlib.h>
+#include <iconv.h>
+
+char *to_utf8(const char *koi8r)
+{
+ iconv_t id = iconv_open("CP866", "WINDOWS-1251");
+ if((long)id == -1)
+ {
+ printf("failed to create iconv descriptor with error: %s\n", strerror(errno));
+ return NULL;
+ }
+ int len = strlen(koi8r), outlen = 0;
+ len++;
+ outlen = len * 2;
+ char *outbuf = (char*)malloc(len * 2), *op, *ip;
+ op = outbuf;
+ ip = koi8r;
+ int enc_len = iconv(id, &ip, &len, &op, &outlen);
+ if(enc_len == -1)
+ {
+ printf("failed to convert buffer with error: %s\n", strerror(errno));
+ return NULL;
+ }
+ //outbuf[len] = '\0';
+ return outbuf;
+}
+
+
+#endif
diff --git a/sound_detector/toutf8.h b/sound_detector/toutf8.h
new file mode 100644
index 0000000..49d42d7
--- /dev/null
+++ b/sound_detector/toutf8.h
@@ -0,0 +1,3 @@
+#ifdef WIN32
+extern "C" char *to_utf8(const char *koi8r);
+#endif
diff --git a/sound_detector/toutf8.o b/sound_detector/toutf8.o
new file mode 100644
index 0000000..213bd6c
--- /dev/null
+++ b/sound_detector/toutf8.o
Binary files differ