Giter Club home page Giter Club logo

kbd-audio's Introduction

kbd-audio

Actions Status

This is a collection of command-line and GUI tools for capturing and analyzing audio data.

Keytap

The most interesting tool is called keytap - it can guess pressed keyboard keys only by analyzing the audio captured from the computer's microphone.

Check this blog post for more details:

Keytap: description and some random thoughts

Video: short demo of Keytap in action

Try it online:

Keytap2

The keytap2 tool is another interesting tool for recovering text from audio. It does not require training data - instead it uses statistical information about the frequencies of the letters and n-grams in the English language.

A more detailed description of the tool is available here: Keytap2 discussion

Video: short demo of Keytap2 in action

CTF: can you guess the text being typed?

Try it online:

Keytap3

This version introduces significant algorithm improvements and better n-gram statistics compared to keytap2. The attack is now fully automated and does not require any manual intervation during the text recovery process.

Video: short demo of using Keytap3

Video: another example of using Keytap3

GUI for Keytap3

Check if your keyboard is vulnerable to Keytap:

What people say about Keytap

"This works incredibly well.
I hope you realize what you've created (and made available to every person in the world)."
-- ffpip

"I just tried it and it works incredibly well. It kind of makes me want to stop using a mechanical keyboard." -- Karawebnetwork

"This attack and Van Eck phreaking are why Edward Snowden, while typing passwords and other sensitive information, would pull a blanket over himself and his laptop." -- aarchi

"This is what mechanical keyboard users deserve" -- super guy

"fuck.." -- Lluis Franco

Build instructions

Dependencies:

  • SDL2 - used to capture audio and to open GUI windows libsdl

    [Ubuntu]
    $ sudo apt install libsdl2-dev
    
    [Mac OS with brew]
    $ brew install sdl2
    
    [MSYS2]
    $ pacman -S git cmake make mingw-w64-x86_64-dlfcn mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL2
    
  • FFTW3 (optional) - some of the helper tools perform Fourier transformations fftw

Linux, FreeBSD, Mac OS, Windows (MSYS2 + MinGW)

git clone https://github.com/ggerganov/kbd-audio
cd kbd-audio
git submodule update --init
mkdir build && cd build
cmake ..
make

Tools

Short summary of the available tools. If the status of the tool is not stable, expect problems and non-optimal results.

Name Type Status
record text stable
record-full text stable
play text stable
play-full text stable
view-gui gui stable
view-full-gui gui stable
key-detector text stable
keytap text stable
keytap-gui gui stable
keytap2-gui gui stable
keytap3 text stable
keytap3-gui gui stable
- extra -
guess-qp text experiment
guess-qp2 text experiment
keytap3-multi text experiment
scale text experiment
subreak text experiment
key-average-gui gui experiment
keytap2 text experiment

Tool details

  • record-full

    Record audio to a raw binary file on disk

    ./record-full output.kbd [-cN]
    

  • play-full

    Playback a recording captured via the record-full tool

    ./play-full input.kbd [-pN]
    

  • record

    Record audio only while typing. Useful for collecting training data for keytap

    ./record output.kbd [-cN] [-CN]
    

  • play

    Playback a recording created via the record tool

    ./play input.kbd [-pN]
    

  • keytap

    Detect pressed keys via microphone audio capture in real-time. Uses training data captured via the record tool.

    ./keytap input0.kbd [input1.kbd] [input2.kbd] ... [-cN] [-CN] [-pF] [-tF]
    

  • keytap-gui

    Detect pressed keys via microphone audio capture in real-time. Uses training data captured via the record tool. GUI version.

    ./keytap-gui input0.kbd [input1.kbd] [input2.kbd] ... [-cN] [-CN]
    

    Online demo: https://keytap.ggerganov.com


  • keytap2-gui record.kbd n-gram-dir [-pN] [-cN] [-CN]

    Detect pressed keys via microphone audio capture. Uses statistical information (n-gram frequencies) about the language. No training data is required. The 'record.kbd' input file has to be generated via the record-full tool and contains the audio data that will be analyzed. The 'n-gram-dir' folder file has to contain n-gram probability files for the corresponding language.

    ./keytap2-gui record.kbd ../data
    

    Online demo: https://keytap2.ggerganov.com


  • keytap3

    Fully automated recovery of unknown text from audio recordings.

    ./keytap3 input.kbd ../data [-cN] [-CN] [-pF] [-tF] [-FN] [-fN]
    

    Online demo: https://keytap3.ggerganov.com


  • keytap3-gui

    GUI version of the keytap3 tool.

    ./keytap3-gui input.kbd ../data [-cN] [-CN] [-pF] [-tF] [-FN] [-fN]
    

    Online demo: https://keytap3-gui.ggerganov.com


  • view-full-gui

    Visualize waveforms recorded with the record-full tool. Can also playback the audio data.

    ./view-full-gui input.kbd [-pN]
    

    view-full-gui


  • view-gui

    Visualize training data recorded with the record tool. Can also playback the audio data.

    ./view-gui input.kbd [-pN]
    

    view-full-gui


Feedback

Any feedback about the performance of the tools is highly appreciated. Please drop a comment here.

kbd-audio's People

Contributors

ggerganov avatar ggicci avatar herrhotzenplotz avatar nwheeler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kbd-audio's Issues

ReferenceError: SharedArrayBuffer is not defined

Seeing this in the live demo using Firefox 63 on osx 10.14.1:

ReferenceError: SharedArrayBuffer is not defined

Perhaps you can do a check and show a 'firefox not supported' message (if that's the issue..)

keytap doesn't collect training data

On FreeBSD keytap immediately goes to the "[+] Predicting" line:

$ work/.build/keytap -c3 -C2
Usage: work/.build/keytap input.kbd [input2.kbd ...] [-cN] [-pF] [-tF]
-cN - select capture device N
-CN - select number N of capture channels to use
-pF - prediction threshold: CC > F
-tF - background threshold: ampl > F*avg_background

Found 4 capture devices:
- Capture device #0: '/dev/dsp'
- Capture device #1: '/dev/dsp3'
- Capture device #2: '/dev/dsp4'
- Capture device #3: '/dev/dsp7'
Attempt to open capture device 3 : '/dev/dsp7' ...
Opened capture device succesfully!
DeviceId: 2
Frequency: 16000
Format: 33056 (4 bytes)
Channels: 2
Samples: 512
Audio Filter: 1
Cutoff frequency: 100 Hz
Capturing audio ..
[+] Collecting training data
[+] Training
Failed to train the following keys:
[+] Ready to predict. Keep pressing keys and the program will guess which key was pressed
based on the captured audio from the microphone.
[+] Predicting


It doesn't seem to collect any training data.

[Idea] Compute key similarity over the log-scale Mel spectrogram

Currently, we compute the cross-correlation between time-domain key waveforms to determine how similar 2 keys are.
Instead, we can compute the similarity metric over the Mel spectrograms of the signals. The Mel spectrogram seems to be the go-to choice for audio representation in modern state-of-the-art speech recognition algorithms, so why not give it a try in keytap.

Here is a sample implementation to compute the log-scaled Mel spectrogram of an audio, that I recently did for the whisper.cpp project:

https://github.com/ggerganov/whisper.cpp/blob/6d654d192a62e6cd9897d6ff683bdc97406827e9/main.cpp#L1962-L2063

Error during make

$ make
[ 2%] Building CXX object CMakeFiles/Core.dir/audio_logger.cpp.o
[ 4%] Linking CXX static library libCore.a
[ 4%] Built target Core
[ 7%] Building CXX object CMakeFiles/ImGui.dir/imgui/imgui.cpp.o
[ 9%] Building CXX object CMakeFiles/ImGui.dir/imgui/imgui_draw.cpp.o
[ 11%] Building CXX object CMakeFiles/ImGui.dir/imgui/imgui_demo.cpp.o
[ 14%] Building CXX object CMakeFiles/ImGui.dir/imgui/imgui_widgets.cpp.o
[ 16%] Building C object CMakeFiles/ImGui.dir/imgui/examples/libs/gl3w/GL/gl3w.c.o
[ 19%] Building CXX object CMakeFiles/ImGui.dir/imgui/examples/imgui_impl_sdl.cpp.o
[ 21%] Building CXX object CMakeFiles/ImGui.dir/imgui/examples/imgui_impl_opengl3.cpp.o
[ 23%] Linking CXX static library libImGui.a
[ 23%] Built target ImGui
[ 26%] Building CXX object CMakeFiles/view-full-gui.dir/view-full-gui.cpp.o
/home/fwt/kbd-audio/view-full-gui.cpp: In function ‘bool generateLowResWaveform(const TWaveformView&, TWaveform&, int)’:
/home/fwt/kbd-audio/view-full-gui.cpp:116:10: error: expected unqualified-id before ‘[’ token
auto [samples, n] = waveform;
^
/home/fwt/kbd-audio/view-full-gui.cpp:118:27: error: ‘n’ was not declared in this scope
TWaveform waveformAbs(n);
^
/home/fwt/kbd-audio/view-full-gui.cpp:120:35: error: ‘samples’ was not declared in this scope
waveformAbs[i] = std::abs(samples[i]);
^
CMakeFiles/view-full-gui.dir/build.make:62: recipe for target 'CMakeFiles/view-full-gui.dir/view-full-gui.cpp.o' failed
make[2]: *** [CMakeFiles/view-full-gui.dir/view-full-gui.cpp.o] Error 1
CMakeFiles/Makefile2:73: recipe for target 'CMakeFiles/view-full-gui.dir/all' failed
make[1]: *** [CMakeFiles/view-full-gui.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

it seems like that this occurs because the compiler can not understand the keyword "auto". However I have upgrade my cmake to 3.13 and CMakeLists.txt : set (CMAKE_CXX_STANDARD 17) is working now.
How to solve this? Should I upgrade my g++ or gcc?

Error 'Buffer size in file (…..) does not match the expected one (5)'

Hello!
I am trying to run keytap on Linux system like that:
sudo ./keytap /dev/input/event13
But every time I got the error:

Buffer size in file (1565157006) does not match the expected one (5)

The first number is always changing, for example:

Buffer size in file (1565157170) does not match the expected one (5)

Please, would you like to provide some information how to select input device (input.kbd)? Because in my Linux installation I have 24 /dev/input/event* devices...

Thank you in advanced.

Failed to initialize OpenGL loader!

Hi , Amazing idea.

i'm running A Kali-Linux and setup process was alright.
but , getting " Failed to initialize OpenGL loader! " while trying to :

Usage: ./view-gui record.kbd

Found 1 playback devices:
- Playback device #0: 'ES1371/ES1373 / Creative Labs CT2518 (Audio PCI 64V/128/5200 / Creative CT4810/CT5803/CT5806 [Sound Blaster PCI]) Analog Stereo'
Opened playback device succesfully!
Frequency: 24000
Format: 32784
Channels: 1
Samples: 1024
[+] Loading recording from 'output.kbd'
Failed to initialize OpenGL loader!

$ glxinfo | grep "OpenGL version"
OpenGL version string: 2.1 Mesa 19.1.2

$ glxinfo | grep rendering
direct rendering: Yes


Not sure what is that i'm missed .

I have question

please, I have a question, the first one is, the kbd tool it's a captures the characters from the keyboard using audio right?
?? or its just capture the captures the characters using some of the keylogger technique and convert the text to audio???.

the second one is if the first question true I mean if the tool can capture the characters from the keyboard using audio how can I use this tool to capture from another device I mean how can i install it in devices 1 and capture from devise 2

Add the ability to import WAV files to RAW recording

Keytap2 allows recovering audio to text from just the audio recording. Allowing importing of recordings made elsewhere would allows recordings made with other equipment (phones, etc.) and then use the tool to record the text.

cmake: Could not find a package configuration file provided by "SDL2"

I had this error when running cmake:

$ cmake ..
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
CMake Warning at CMakeLists.txt:28 (find_package):
  By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "SDL2", but
  CMake did not find one.

  Could not find a package configuration file provided by "SDL2" with any of
  the following names:

    SDL2Config.cmake
    sdl2-config.cmake

  Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set
  "SDL2_DIR" to a directory containing one of the above files.  If "SDL2"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Found FFTW: /usr/lib/x86_64-linux-gnu/libfftw3.so;/usr/lib/x86_64-linux-gnu/libfftw3f.so
CMake Warning at CMakeLists.txt:32 (message):
  Unable to find SDL2 library.  It is either not installed or CMake cannot
  find it.  In the latter case, setting the USE_FINDSDL2 variable might help:

     $ cmake -D USE_FINDSDL2 ..


CMake Error at CMakeLists.txt:37 (message):
  Aborting


-- Configuring incomplete, errors occurred!
See also "/home/ritiek/Downloads/kbd-audio/build/CMakeFiles/CMakeOutput.log".
See also "/home/ritiek/Downloads/kbd-audio/build/CMakeFiles/CMakeError.log".

Installing libsdl2-dev fixed it for me:

$ sudo apt install libsdl2-dev

It may be helpful to note this in README.md

CMake ..

Good day. When I use cmake .. I get the following:

cmake ..
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.

Update the VERSION argument value or use a ... suffix to tell
CMake that the project does not need compatibility with older versions.

CMake Warning at CMakeLists.txt:78 (find_package):
By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "SDL2", but
CMake did not find one.

Could not find a package configuration file provided by "SDL2" with any of
the following names:

SDL2Config.cmake
sdl2-config.cmake

Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set
"SDL2_DIR" to a directory containing one of the above files. If "SDL2"
provides a separate development package or SDK, be sure it has been
installed.

-- Could NOT find FFTW (missing: FFTW_LIBRARIES FFTW_INCLUDE_DIRS)
CMake Warning at CMakeLists.txt:85 (message):
Unable to find SDL2 library. It is either not installed or CMake cannot
find it. In the latter case, setting the USE_FINDSDL2 variable might help:

 $ cmake -D USE_FINDSDL2 ..

CMake Error at CMakeLists.txt:90 (message):
Aborting

-- Configuring incomplete, errors occurred!
See also "/Users/hackgr/Desktop/kbd-audio/build/CMakeFiles/CMakeOutput.log".
See also "/Users/hackgr/Desktop/kbd-audio/build/CMakeFiles/CMakeError.log".

I already tried with brew install sdl2 but I get the following:

brew install SDL2

Warning: No available formula with the name "sdl2".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

Yes you can, in theory, solve without training data it can be solved as a graph problem also.

#1. Wish we can add comments in github main project page.

To what you said: "I am pretty sure it is possible to implement a prediction approach that does not require to collect training data at all. Given that the user types a text in a certain known language (e.g. English), the statistical information about N-grams in that language, combined with the similarity metric of the detected keypresses could be enough to detect the text being typed. Effectively, it boils down to breaking a substitution cypher."

My Answer: I could entirely wrong, I usually am. But yes you can solve as I stated earlier as graph problem.
Use case: Given an arbitrary key, a graph of nearby keys can be constructed for each key on the keyboard.
From these graphs, you can analyze the waveforms and developing a ranking to predict which key was pressed from the peaks.
And then store the waveform rank back into the graph making it a weighted graph and tells you which key was pressed.
Ofcourse applying some sophisticated graph techniques. It becomes a combinatorics problem also.
This could improve the "nearby key" approach.

This is a very interesting problem to solve - and the accuracy could be nearly perfected. I wonder if google listens in to our keystrokes to improve their AD algorithms.

From the graphs you can create better training data too ?

Recall rate

Hey man love the work you done with this. I was wondering can it be used with a microphone plugged into the laptop as opposed to the built in microphone in the laptop? what type of microphone did you use and how did you train the software to recall at a successful rate.

Incompleted Readme file (Is this just typo?)

It is not work correctly.

cd kbd-audio
git submodule update --init
mkdir build && cd build
cmake ..
make

It must changed like this way on my ubuntu enviroment.

cd kbd-audio
git submodule update --init
mkdir build && cd build
cmake .
make

cmake ..

Buen dia. Podrian ayudarme por favor.

Cuando ingreso cmake .. me muestra lo siguiente :

CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.

Update the VERSION argument value or use a ... suffix to tell
CMake that the project does not need compatibility with older versions.

CMake Warning at CMakeLists.txt:79 (find_package):
By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "SDL2", but
CMake did not find one.

Could not find a package configuration file provided by "SDL2" with any of
the following names:

SDL2Config.cmake
sdl2-config.cmake

Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set
"SDL2_DIR" to a directory containing one of the above files. If "SDL2"
provides a separate development package or SDK, be sure it has been
installed.

-- Could NOT find FFTW (missing: FFTW_LIBRARIES FFTW_INCLUDE_DIRS)
CMake Warning at CMakeLists.txt:86 (message):
Unable to find SDL2 library. It is either not installed or CMake cannot
find it. In the latter case, setting the USE_FINDSDL2 variable might help:

 $ cmake -D USE_FINDSDL2 ..

CMake Error at CMakeLists.txt:91 (message):
Aborting

-- Configuring incomplete, errors occurred!
See also "/Users/dariogr/Desktop/kbd-audio/build/CMakeFiles/CMakeOutput.log".
See also "/Users/dariogr/Desktop/kbd-audio/build/CMakeFiles/CMakeError.log".

Suggestion: keyboard audio spoofer/cloak?

Just a wild idea with no technical depth or contribution; feel free to dismiss and close if necessary.

Can this be turned into a keyboard sound generator engine? I don't simply mean a soundboard kind of thing. Of course it would be simple to sample each key to make a virtual keyboard with authentic information-carrying sound output, but would it be even theoretically possible to mask or alter the sounds coming from an actual keyboard in real time?

Let's conveniently ignore the fact that masking the sound would actually require tech similar to Active Noise Cancelling but directed outwards somehow. It may not be realistic, just imagine it exists for now. Would it be feasible to shuffle the audio identities of the keys as they are being pressed on a real keyboard?

It's a big ask, but the payout is the ability to fool eavesdroppers to think you're typing out the same ASCII penis over and over again. Think of the emails going around NSA's intranet.

error al compilar

Amigo buen dia. Cuando ejecuto "make" comienza a cargar del 1 al 100% pero en el 28% me muestra :
/Users/dariogr/Desktop/kbd-audio/keytap-gui.cpp:618:28: warning: variable 'curosum' set but not used [-Wunused-but-set-variable]
double curosum = 0.0;
^
1 warning generated.
Y en el 60% me muestra:

/Users/dariogr/Desktop/kbd-audio/keytap.cpp:499:28: warning: variable 'curosum' set but not used [-Wunused-but-set-variable]
double curosum = 0.0;
^
/Users/dariogr/Desktop/kbd-audio/keytap.cpp:566:99: warning: format specifies type 'long' but the argument has type 'long long' [-Wformat]
printf(" Adding waveform %d - cc = %g, offset = %ld\n", iwaveform, cc, offset);
~~~ ^~~~~~
%lld

Podrías ayudarme por favor. Saludos

keytap2 crashes on ubuntu 18.04


[pjb@L0253344 :0 build]$ ./record record.kbd
Recording 5 frames per key press
Found 1 capture devices:
    - Capture device #0: 'Built-in Audio Analog Stereo'
Opened capture device 2
    Frequency:  24000
    Format:     33056 (4 bytes)
    Channels:   1
    Samples:    512

Last recorded key -  10 '[enter]'. Total times recorded so far -   1. Total data saved: 0.00976562 MB
  C-c C-c
[pjb@L0253344 :0 build]$ ./keytap2 record.kbd 
Usage: ./keytap2 record.kbd
[+] Loading recording from 'record.kbd'
[+] Loaded recording: of 2562 samples (sample size = 4 bytes)
    Size in memory:          0.00977325 MB
    Sample size:             4
    Total number of samples: 2562
    Recording length:        0.10675 seconds
[+] Searching for key presses
[+] Detected a total of 0 potential key presses
[+] Search took 0.000 seconds
[+] Calculating CC similarity map
[+] Calculation took 0.000 seconds
   -1 
--------------------------------------------------------------------------------------------------------------------------------------

[+] Top 10 pairs
Segmentation fault (core dumped)
[pjb@L0253344 :0 build]$ 
[pjb@L0253344 :0 build]$ coredumpctl dump    25539 > keytap2.core
           PID: 25539 (keytap2)
           UID: 1000 (pjb)
           GID: 1000 (pjb)
        Signal: 11 (SEGV)
     Timestamp: Fri 2018-11-30 14:25:40 CET (2min 43s ago)
  Command Line: ./keytap2 record.kbd
    Executable: /home/pjb/src/kbd-audio/build/keytap2
 Control Group: /user.slice/user-1000.slice/session-2.scope
          Unit: session-2.scope
         Slice: user-1000.slice
       Session: 2
     Owner UID: 1000 (pjb)
       Boot ID: 01b5433ca7d64ffebbb9631c12690f2c
    Machine ID: 3c990c4b0b06406caa7241e23025e717
      Hostname: L0253344
       Storage: /var/lib/systemd/coredump/core.keytap2.1000.01b5433ca7d64ffebbb9631c12690f2c.25539.1543584340000000.lz4
       Message: Process 25539 (keytap2) of user 1000 dumped core.
                
                Stack trace of thread 25539:
                #0  0x000055665c312020 n/a (/home/pjb/src/kbd-audio/build/keytap2)

keytap2.core.xz.base64.txt

Windows build

It would be nice to provide info for building the project in Windows environment

Can't kill record-full process

This thing just keeps recording even when killing process by ID, or by killall record-full.

No ctrl+c response, doesn't respond to Linux kill signals.

system_error: thread constructor failed

good day friend

When I want to use ./record output.kbd it shows me the following:

❯ ./record output.kbd
Usage: ./record output.kbd [-cN]
-cN - select capture device N
-CN - number N of capture channels N

Recording 11 frames per key press
Found 1 capture devices:
- Capture device #0: 'Built-in Microphone'
Attempt to open capture device 0 : 'Built-in Microphone' ...
Opened capture device succesfully!
DeviceId: 2
Frequency: 16000
Format: 33056 (4 bytes)
Channels: 2
Samples: 512
Audio Filter: 1
Cutoff frequency: 100 Hz
Capturing audio ..
libc++abi: terminating with uncaught exception of type std::__1::system_error: thread constructor failed
[1] 2348 abort ./record output.kbd

Identification

Does it need to collect many kinds of keybords, such as a keybord used 3 years.
Different keybord may make different sound so as the keybord used very long time.

Not building on ArchLinux

The project isn't building on ArchLinux because of CMake issues (or probably Arch Linux issues)

Steps to reproduce: (just building steps from README + logging)

git clone https://github.com/ggerganov/kbd-audio
cd kbd-audio
git submodule update --init
mkdir build && cd build
cmake .. &> cmake_log
make &>make_log

Now content of cmake_log

CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.31.1") 
CMake Warning (dev) at /usr/share/cmake-3.20/Modules/FindOpenGL.cmake:315 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  CMakeLists.txt:69 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found OpenGL: /usr/lib/libOpenGL.so   
-- Found FFTW: /usr/lib/libfftw3.so;/usr/lib/libfftw3f.so  
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Configuring done
-- Generating done
-- Build files have been written to: /home/julian/Workspace/repos/kbd-audio/build

And make_log

[  3%] Building CXX object CMakeFiles/Core.dir/common.cpp.o
[  6%] Building CXX object CMakeFiles/Core.dir/audio_logger.cpp.o
/home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:8:10: fatal error: SDL.h: No such file or directory
    8 | #include <SDL.h>
      |          ^~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/Core.dir/build.make:90: CMakeFiles/Core.dir/audio_logger.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/Core.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

I have SDL2 installed and even have SDL.h file (in /usr/include) so it should work, but it isn't. As a workaround, I added this to CMakeLists.txt
include_directories(/usr/include/SDL2)
Then cmake_log looks the same, but make_log shows this

[  3%] Building CXX object CMakeFiles/Core.dir/common.cpp.o
[  6%] Building CXX object CMakeFiles/Core.dir/audio_logger.cpp.o
[  9%] Linking CXX static library libCore.a
[  9%] Built target Core
[ 12%] Building CXX object CMakeFiles/Gui.dir/common-gui.cpp.o
[ 15%] Building CXX object CMakeFiles/Gui.dir/imgui/imgui.cpp.o
[ 18%] Building CXX object CMakeFiles/Gui.dir/imgui/imgui_draw.cpp.o
[ 21%] Building CXX object CMakeFiles/Gui.dir/imgui/imgui_demo.cpp.o
[ 24%] Building CXX object CMakeFiles/Gui.dir/imgui/imgui_widgets.cpp.o
[ 27%] Building C object CMakeFiles/Gui.dir/imgui/examples/libs/gl3w/GL/gl3w.c.o
[ 30%] Building CXX object CMakeFiles/Gui.dir/imgui/examples/imgui_impl_sdl.cpp.o
[ 33%] Building CXX object CMakeFiles/Gui.dir/imgui/examples/imgui_impl_opengl3.cpp.o
[ 36%] Linking CXX static library libGui.a
[ 36%] Built target Gui
[ 39%] Building CXX object CMakeFiles/keytap2-gui.dir/keytap2-gui.cpp.o
/home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp: In lambda function:
/home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1755:29: warning: unused variable ‘tStart’ [-Wunused-variable]
 1755 |                 static auto tStart = t_ms();
      |                             ^~~~~~
/home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1810:22: warning: unused variable ‘tEnd’ [-Wunused-variable]
 1810 |                 auto tEnd = t_ms();
      |                      ^~~~
[ 42%] Building CXX object CMakeFiles/keytap2-gui.dir/subbreak2.cpp.o
/home/julian/Workspace/repos/kbd-audio/subbreak2.cpp:337:18: warning: ‘std::vector<int> {anonymous}::subset(int, int)’ defined but not used [-Wunused-function]
  337 | std::vector<int> subset(int k, int n) {
      |                  ^~~~~~
[ 45%] Linking CXX executable keytap2-gui
/usr/bin/ld: CMakeFiles/keytap2-gui.dir/keytap2-gui.cpp.o: in function `prepareAudioOut(stParameters const&)':
/home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1191: undefined reference to `SDL_Init'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1196: undefined reference to `SDL_GetNumAudioDevices'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1199: undefined reference to `SDL_GetAudioDeviceName'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1208: undefined reference to `SDL_memset'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1218: undefined reference to `SDL_memset'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1220: undefined reference to `SDL_GetAudioDeviceName'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1220: undefined reference to `SDL_OpenAudioDevice'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1233: undefined reference to `SDL_PauseAudioDevice'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1192: undefined reference to `SDL_GetError'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1192: undefined reference to `SDL_LogError'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1222: undefined reference to `SDL_GetError'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1222: undefined reference to `SDL_LogError'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1223: undefined reference to `SDL_Quit'
/usr/bin/ld: CMakeFiles/keytap2-gui.dir/keytap2-gui.cpp.o: in function `renderKeyPresses(stStateUI&, std::vector<short, std::allocator<short> > const&, stKeyPressCollection<short>&)':
/home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:660: undefined reference to `SDL_PauseAudioDevice'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:666: undefined reference to `SDL_ClearQueuedAudio'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:668: undefined reference to `SDL_PauseAudioDevice'
/usr/bin/ld: CMakeFiles/keytap2-gui.dir/keytap2-gui.cpp.o: in function `main::{lambda()#6}::operator()() const':
/home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1448: undefined reference to `SDL_PollEvent'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1468: undefined reference to `SDL_GetWindowID'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1448: undefined reference to `SDL_PollEvent'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1475: undefined reference to `SDL_GetWindowSize'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1464: undefined reference to `SDL_free'
/usr/bin/ld: CMakeFiles/keytap2-gui.dir/keytap2-gui.cpp.o: in function `std::_Function_handler<void (int, int), main::{lambda(int, int)#5}>::_M_invoke(std::_Any_data const&, int&&, int&&)':
/home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1354: undefined reference to `SDL_SetWindowSize'
/usr/bin/ld: CMakeFiles/keytap2-gui.dir/keytap2-gui.cpp.o: in function `main':
/home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1262: undefined reference to `SDL_Init'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/keytap2-gui.cpp:1263: undefined reference to `SDL_GetError'
/usr/bin/ld: libCore.a(audio_logger.cpp.o): in function `AudioLogger::install(AudioLogger::Parameters&&)':
/home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:167: undefined reference to `SDL_Init'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:172: undefined reference to `SDL_GetNumAudioDevices'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:175: undefined reference to `SDL_GetAudioDeviceName'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:184: undefined reference to `SDL_memset'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:194: undefined reference to `SDL_memset'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:196: undefined reference to `SDL_GetAudioDeviceName'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:197: undefined reference to `SDL_GetAudioDeviceName'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:197: undefined reference to `SDL_OpenAudioDevice'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:233: undefined reference to `SDL_PauseAudioDevice'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:168: undefined reference to `SDL_GetError'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:168: undefined reference to `SDL_LogError'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:199: undefined reference to `SDL_GetError'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:199: undefined reference to `SDL_LogError'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:200: undefined reference to `SDL_Quit'
/usr/bin/ld: libCore.a(audio_logger.cpp.o): in function `AudioLogger::terminate()':
/home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:263: undefined reference to `SDL_PauseAudioDevice'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:264: undefined reference to `SDL_CloseAudioDevice'
/usr/bin/ld: libCore.a(audio_logger.cpp.o): in function `AudioLogger::pause()':
/home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:383: undefined reference to `SDL_PauseAudioDevice'
/usr/bin/ld: libCore.a(audio_logger.cpp.o): in function `AudioLogger::resume()':
/home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:391: undefined reference to `SDL_PauseAudioDevice'
/usr/bin/ld: libCore.a(audio_logger.cpp.o): in function `AudioLogger::addFrame(float const*)':
/home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:274: undefined reference to `SDL_GetQueuedAudioSize'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:275: undefined reference to `SDL_GetQueuedAudioSize'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/audio_logger.cpp:276: undefined reference to `SDL_ClearQueuedAudio'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_Init(SDL_Window*)':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:170: undefined reference to `SDL_CreateSystemCursor'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:171: undefined reference to `SDL_CreateSystemCursor'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:172: undefined reference to `SDL_CreateSystemCursor'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:173: undefined reference to `SDL_CreateSystemCursor'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:174: undefined reference to `SDL_CreateSystemCursor'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o):/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:175: more undefined references to `SDL_CreateSystemCursor' follow
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_Init(SDL_Window*)':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:181: undefined reference to `SDL_GetCurrentVideoDriver'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_GetClipboardText(void*)':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:71: undefined reference to `SDL_free'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:72: undefined reference to `SDL_GetClipboardText'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_ProcessEvent(SDL_Event const*)':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:117: undefined reference to `SDL_GetModState'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:118: undefined reference to `SDL_GetModState'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:119: undefined reference to `SDL_GetModState'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:123: undefined reference to `SDL_GetModState'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_Shutdown()':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:228: undefined reference to `SDL_free'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:233: undefined reference to `SDL_FreeCursor'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_NewFrame(SDL_Window*)':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:351: undefined reference to `SDL_GetWindowSize'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:352: undefined reference to `SDL_GetWindowFlags'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:354: undefined reference to `SDL_GL_GetDrawableSize'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:361: undefined reference to `SDL_GetPerformanceCounter'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:248: undefined reference to `SDL_GetMouseState'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_UpdateMousePosAndButtons':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:255: undefined reference to `SDL_GetKeyboardFocus'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:275: undefined reference to `SDL_CaptureMouse'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_NewFrame(SDL_Window*)':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:297: undefined reference to `SDL_SetCursor'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_UpdateMouseCursor':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:298: undefined reference to `SDL_ShowCursor'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_NewFrame(SDL_Window*)':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:310: undefined reference to `SDL_GameControllerOpen'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_UpdateGamepads':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:321: undefined reference to `SDL_GameControllerGetButton'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:322: undefined reference to `SDL_GameControllerGetButton'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:323: undefined reference to `SDL_GameControllerGetButton'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:324: undefined reference to `SDL_GameControllerGetButton'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:325: undefined reference to `SDL_GameControllerGetButton'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o):/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:326: more undefined references to `SDL_GameControllerGetButton' follow
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_UpdateGamepads':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:333: undefined reference to `SDL_GameControllerGetAxis'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:334: undefined reference to `SDL_GameControllerGetAxis'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:335: undefined reference to `SDL_GameControllerGetAxis'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:336: undefined reference to `SDL_GameControllerGetAxis'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_UpdateMousePosAndButtons':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:243: undefined reference to `SDL_WarpMouseInWindow'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_NewFrame(SDL_Window*)':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:360: undefined reference to `SDL_GetPerformanceFrequency'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_UpdateMouseCursor':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:292: undefined reference to `SDL_ShowCursor'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_UpdateMousePosAndButtons':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:264: undefined reference to `SDL_GetWindowPosition'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:265: undefined reference to `SDL_GetGlobalMouseState'
/usr/bin/ld: libGui.a(imgui_impl_sdl.cpp.o): in function `ImGui_ImplSDL2_SetClipboardText(void*, char const*)':
/home/julian/Workspace/repos/kbd-audio/imgui/examples/imgui_impl_sdl.cpp:78: undefined reference to `SDL_SetClipboardText'
/usr/bin/ld: libGui.a(common-gui.cpp.o): in function `Gui::init(char const*, int, int, Gui::Objects&)':
/home/julian/Workspace/repos/kbd-audio/common-gui.cpp:46: undefined reference to `SDL_GL_SetAttribute'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/common-gui.cpp:47: undefined reference to `SDL_GL_SetAttribute'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/common-gui.cpp:48: undefined reference to `SDL_GL_SetAttribute'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/common-gui.cpp:49: undefined reference to `SDL_GL_SetAttribute'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/common-gui.cpp:53: undefined reference to `SDL_GL_SetAttribute'
/usr/bin/ld: libGui.a(common-gui.cpp.o):/home/julian/Workspace/repos/kbd-audio/common-gui.cpp:54: more undefined references to `SDL_GL_SetAttribute' follow
/usr/bin/ld: libGui.a(common-gui.cpp.o): in function `Gui::init(char const*, int, int, Gui::Objects&)':
/home/julian/Workspace/repos/kbd-audio/common-gui.cpp:57: undefined reference to `SDL_GetCurrentDisplayMode'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/common-gui.cpp:63: undefined reference to `SDL_CreateWindow'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/common-gui.cpp:66: undefined reference to `SDL_GL_CreateContext'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/common-gui.cpp:67: undefined reference to `SDL_GL_MakeCurrent'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/common-gui.cpp:68: undefined reference to `SDL_GL_SetSwapInterval'
/usr/bin/ld: libGui.a(common-gui.cpp.o): in function `Gui::render(Gui::Objects const&)':
/home/julian/Workspace/repos/kbd-audio/common-gui.cpp:161: undefined reference to `SDL_GL_MakeCurrent'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/common-gui.cpp:166: undefined reference to `SDL_GL_SwapWindow'
/usr/bin/ld: libGui.a(common-gui.cpp.o): in function `Gui::free(Gui::Objects const&)':
/home/julian/Workspace/repos/kbd-audio/common-gui.cpp:176: undefined reference to `SDL_GL_DeleteContext'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/common-gui.cpp:177: undefined reference to `SDL_DestroyWindow'
/usr/bin/ld: /home/julian/Workspace/repos/kbd-audio/common-gui.cpp:178: undefined reference to `SDL_Quit'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/keytap2-gui.dir/build.make:117: keytap2-gui] Error 1
make[1]: *** [CMakeFiles/Makefile2:158: CMakeFiles/keytap2-gui.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

In other words, make can't find .so file.

I found this working. In target_link_libraries I changed ${SDL2_LIBRARIES} to SDL2::SDL2 and now it works.

In case anyone will have this problem, here is my workaround in simple patch.
0001-Workaround-to-compile-on-archlinux.txt

make

root@sys:/home/user/tools/kbd-audio/build# make
make: *** No targets specified and no makefile found. Stop.
what's the problem?
Thanks

Linker error for OpenGL

There's a linker error for the -gui applications regarding GL. I've fixed it by adding a line to CMakeLists.txt. This makes compiling seem to work. I don't do C/CPP/make/cmake though, so please verify this is the issue. It seems related to some of the issues seen in issue #2, as well. I'll submit a PR once I figure out how to.

I used a docker container (debian:testing) with the following dependencies installed:

git build-essential cmake libsdl2-2.0-0 libsdl2-dev libfftw3-3 libfftw3-dev

Edited: Used debian:testing for (required) latest version of cmake.

Feedback

I was a bit surprised by the huge amount of interest that this project generated. I had no idea if keytap works reliably or not, so I am happy to see that people actually like it.

I am still curious to know how reliable it is. For example, I haven't been able to get any good prediction results when using non-mechanical keyboards. Would be interesting to know if this is the case for everyone.

Feel free to share your experience here.

Error trying to compile in linux (arch)

I change the SDL the #include <SDL.h> to #include <SDL2/SDL.h> and seems compile but i got a problem in the linker

Scanning dependencies of target view-full-gui
[ 35%] Building CXX object CMakeFiles/view-full-gui.dir/view-full-gui.cpp.o
[ 38%] Linking CXX executable view-full-gui
/usr/bin/ld: CMakeFiles/view-full-gui.dir/view-full-gui.cpp.o: en la función prepareAudioOut(stParameters const&)': view-full-gui.cpp:(.text+0x2b3): referencia a SDL_Init' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text+0x2c2): referencia a SDL_GetNumAudioDevices' sin definir /usr/bin/ld: view-full-gui.cpp:(.text+0x2ed): referencia a SDL_GetAudioDeviceName' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text+0x31a): referencia a SDL_memset' sin definir /usr/bin/ld: view-full-gui.cpp:(.text+0x361): referencia a SDL_memset' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text+0x373): referencia a SDL_OpenAudioDevice' sin definir /usr/bin/ld: view-full-gui.cpp:(.text+0x3e8): referencia a SDL_PauseAudioDevice' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text+0x411): referencia a SDL_GetError' sin definir /usr/bin/ld: view-full-gui.cpp:(.text+0x424): referencia a SDL_LogError' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text+0x429): referencia a SDL_Quit' sin definir /usr/bin/ld: view-full-gui.cpp:(.text+0x439): referencia a SDL_GetError' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text+0x44c): referencia a SDL_LogError' sin definir /usr/bin/ld: CMakeFiles/view-full-gui.dir/view-full-gui.cpp.o: en la función renderWaveform(stParameters&, std::vector<int, std::allocator > const&)':
view-full-gui.cpp:(.text+0x150f): referencia a SDL_PauseAudioDevice' sin definir /usr/bin/ld: view-full-gui.cpp:(.text+0x1538): referencia a SDL_ClearQueuedAudio' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text+0x1548): referencia a SDL_PauseAudioDevice' sin definir /usr/bin/ld: CMakeFiles/view-full-gui.dir/view-full-gui.cpp.o: en la función std::_Function_handler<bool (), main::{lambda()#2}>::_M_invoke(std::_Any_data const&)':
view-full-gui.cpp:(.text+0x1ac4): referencia a SDL_PollEvent' sin definir /usr/bin/ld: view-full-gui.cpp:(.text+0x1b02): referencia a SDL_PollEvent' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text+0x1b2d): referencia a SDL_GetWindowSize' sin definir /usr/bin/ld: view-full-gui.cpp:(.text+0x21c1): referencia a SDL_PauseAudioDevice' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text+0x22b2): referencia a SDL_GL_MakeCurrent' sin definir /usr/bin/ld: view-full-gui.cpp:(.text+0x2312): referencia a SDL_GL_SwapWindow' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text+0x2468): referencia a SDL_GetWindowID' sin definir /usr/bin/ld: view-full-gui.cpp:(.text+0x24cf): referencia a SDL_ClearQueuedAudio' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text+0x24df): referencia a SDL_PauseAudioDevice' sin definir /usr/bin/ld: CMakeFiles/view-full-gui.dir/view-full-gui.cpp.o: en la función main':
view-full-gui.cpp:(.text.startup+0x7d): referencia a SDL_Init' sin definir /usr/bin/ld: view-full-gui.cpp:(.text.startup+0x1c4): referencia a SDL_GL_SetAttribute' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text.startup+0x1d3): referencia a SDL_GL_SetAttribute' sin definir /usr/bin/ld: view-full-gui.cpp:(.text.startup+0x1e2): referencia a SDL_GL_SetAttribute' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text.startup+0x1ee): referencia a SDL_GL_SetAttribute' sin definir /usr/bin/ld: view-full-gui.cpp:(.text.startup+0x1fd): referencia a SDL_GL_SetAttribute' sin definir
/usr/bin/ld: CMakeFiles/view-full-gui.dir/view-full-gui.cpp.o:view-full-gui.cpp:(.text.startup+0x20c): más referencias a SDL_GL_SetAttribute' sin definir a continuación /usr/bin/ld: CMakeFiles/view-full-gui.dir/view-full-gui.cpp.o: en la función main':
view-full-gui.cpp:(.text.startup+0x227): referencia a SDL_GetCurrentDisplayMode' sin definir /usr/bin/ld: view-full-gui.cpp:(.text.startup+0x250): referencia a SDL_CreateWindow' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text.startup+0x25d): referencia a SDL_GL_CreateContext' sin definir /usr/bin/ld: view-full-gui.cpp:(.text.startup+0x26c): referencia a SDL_GL_SetSwapInterval' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text.startup+0x51e): referencia a SDL_GL_DeleteContext' sin definir /usr/bin/ld: view-full-gui.cpp:(.text.startup+0x528): referencia a SDL_DestroyWindow' sin definir
/usr/bin/ld: view-full-gui.cpp:(.text.startup+0x52d): referencia a SDL_Quit' sin definir /usr/bin/ld: view-full-gui.cpp:(.text.startup+0x56b): referencia a SDL_GetError' sin definir
/usr/bin/ld: libImGui.a(imgui_impl_sdl.cpp.o): en la función ImGui_ImplSDL2_Init(SDL_Window*)': imgui_impl_sdl.cpp:(.text+0x92): referencia a SDL_CreateSystemCursor' sin definir
/usr/bin/ld: imgui_impl_sdl.cpp:(.text+0xa3): referencia a SDL_CreateSystemCursor' sin definir /usr/bin/ld: imgui_impl_sdl.cpp:(.text+0xb4): referencia a SDL_CreateSystemCursor' sin definir
/usr/bin/ld: imgui_impl_sdl.cpp:(.text+0xc5): referencia a SDL_CreateSystemCursor' sin definir /usr/bin/ld: imgui_impl_sdl.cpp:(.text+0xd6): referencia a SDL_CreateSystemCursor' sin definir
/usr/bin/ld: libImGui.a(imgui_impl_sdl.cpp.o):imgui_impl_sdl.cpp:(.text+0xe7): más referencias a SDL_CreateSystemCursor' sin definir a continuación /usr/bin/ld: libImGui.a(imgui_impl_sdl.cpp.o): en la función ImGui_ImplSDL2_GetClipboardText(void*)':
imgui_impl_sdl.cpp:(.text+0x131): referencia a SDL_free' sin definir /usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x136): referencia a SDL_GetClipboardText' sin definir
/usr/bin/ld: libImGui.a(imgui_impl_sdl.cpp.o): en la función ImGui_ImplSDL2_ProcessEvent(SDL_Event*)': imgui_impl_sdl.cpp:(.text+0x220): referencia a SDL_GetModState' sin definir
/usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x22e): referencia a SDL_GetModState' sin definir /usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x23c): referencia a SDL_GetModState' sin definir
/usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x24b): referencia a SDL_GetModState' sin definir /usr/bin/ld: libImGui.a(imgui_impl_sdl.cpp.o): en la función ImGui_ImplSDL2_Shutdown()':
imgui_impl_sdl.cpp:(.text+0x35e): referencia a SDL_free' sin definir /usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x388): referencia a SDL_FreeCursor' sin definir
/usr/bin/ld: libImGui.a(imgui_impl_sdl.cpp.o): en la función ImGui_ImplSDL2_NewFrame(SDL_Window*)': imgui_impl_sdl.cpp:(.text+0x3f1): referencia a SDL_GetWindowSize' sin definir
/usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x403): referencia a SDL_GL_GetDrawableSize' sin definir /usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x485): referencia a SDL_GetPerformanceCounter' sin definir
/usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x4e4): referencia a SDL_GetMouseState' sin definir /usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x546): referencia a SDL_GetKeyboardFocus' sin definir
/usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x560): referencia a SDL_CaptureMouse' sin definir /usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x5fc): referencia a SDL_SetCursor' sin definir
/usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x606): referencia a SDL_ShowCursor' sin definir /usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x628): referencia a SDL_WarpMouseInWindow' sin definir
/usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x63b): referencia a SDL_ShowCursor' sin definir /usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x691): referencia a SDL_GetPerformanceFrequency' sin definir
/usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x6be): referencia a SDL_GetWindowPosition' sin definir /usr/bin/ld: imgui_impl_sdl.cpp:(.text+0x6c9): referencia a SDL_GetGlobalMouseState' sin definir
/usr/bin/ld: libImGui.a(imgui_impl_sdl.cpp.o): en la función ImGui_ImplSDL2_SetClipboardText(void*, char const*)': imgui_impl_sdl.cpp:(.text+0x154): referencia a SDL_SetClipboardText' sin definir
collect2: error: ld devolvió el estado de salida 1
make[2]: *** [CMakeFiles/view-full-gui.dir/build.make:88: view-full-gui] Error 1
make[1]: *** [CMakeFiles/Makefile2:74: CMakeFiles/view-full-gui.dir/all] Error 2

Select audio input

For some reason, on my computer "default" input is broke. I need to manually select either the built-in mic OR the usb mic, then it works.

None of the demos allows input selection, though.

compiling error

Hi

Very interesting project but I have a problem with compiling it
SDL2 and FFTW3 are installed.

root@kali:~/kbd-audio/build# cmake ..
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found FFTW: /usr/lib/arm-linux-gnueabihf/libfftw3.so;/usr/lib/arm-linux-gnueabihf/libfftw3f.so  
-- Configuring done
-- Generating done
-- Build files have been written to: /root/kbd-audio/build
root@kali:~/kbd-audio/build# make 
Scanning dependencies of target Core
[  2%] Building CXX object CMakeFiles/Core.dir/audio_logger.cpp.o
[  5%] Linking CXX static library libCore.a
[  5%] Built target Core
Scanning dependencies of target keytap
[  7%] Building CXX object CMakeFiles/keytap.dir/keytap.cpp.o
[ 10%] Linking CXX executable keytap
[ 10%] Built target keytap
Scanning dependencies of target guess_qp
[ 13%] Building CXX object CMakeFiles/guess_qp.dir/guess_qp.cpp.o
[ 15%] Linking CXX executable guess_qp
[ 15%] Built target guess_qp
Scanning dependencies of target guess_qp2
[ 18%] Building CXX object CMakeFiles/guess_qp2.dir/guess_qp2.cpp.o
[ 21%] Linking CXX executable guess_qp2
[ 21%] Built target guess_qp2
Scanning dependencies of target play-full
[ 23%] Building CXX object CMakeFiles/play-full.dir/play-full.cpp.o
[ 26%] Linking CXX executable play-full
[ 26%] Built target play-full
Scanning dependencies of target subbreak
[ 28%] Building CXX object CMakeFiles/subbreak.dir/subbreak.cpp.o
In file included from /usr/include/c++/8/vector:69,
                 from /root/kbd-audio/subbreak.h:16,
                 from /root/kbd-audio/subbreak.cpp:6:
/usr/include/c++/8/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_fill_insert(std::vector<_Tp, _Alloc>::iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = double; _Alloc = std::allocator<double>]':
/usr/include/c++/8/bits/vector.tcc:478:5: note: parameter passing for argument of type 'std::vector<double>::iterator' {aka '__gnu_cxx::__normal_iterator<double*, std::vector<double> >'} changed in GCC 7.1
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8/vector:64,
                 from /root/kbd-audio/subbreak.h:16,
                 from /root/kbd-audio/subbreak.cpp:6:
/usr/include/c++/8/bits/stl_vector.h: In function 'bool loadFreqMap(const char*, TFreqMap&)':
/usr/include/c++/8/bits/stl_vector.h:847:4: note: parameter passing for argument of type '__gnu_cxx::__normal_iterator<double*, std::vector<double> >' changed in GCC 7.1
    _M_fill_insert(end(), __new_size - size(), __x);
    ^~~~~~~~~~~~~~
[ 31%] Linking CXX executable subbreak
[ 31%] Built target subbreak
Scanning dependencies of target ImGui
[ 34%] Building CXX object CMakeFiles/ImGui.dir/imgui/imgui.cpp.o
[ 36%] Building CXX object CMakeFiles/ImGui.dir/imgui/imgui_draw.cpp.o
[ 39%] Building CXX object CMakeFiles/ImGui.dir/imgui/imgui_demo.cpp.o
[ 42%] Building CXX object CMakeFiles/ImGui.dir/imgui/imgui_widgets.cpp.o
[ 44%] Building C object CMakeFiles/ImGui.dir/imgui/examples/libs/gl3w/GL/gl3w.c.o
[ 47%] Building CXX object CMakeFiles/ImGui.dir/imgui/examples/imgui_impl_sdl.cpp.o
[ 50%] Building CXX object CMakeFiles/ImGui.dir/imgui/examples/imgui_impl_opengl3.cpp.o
[ 52%] Linking CXX static library libImGui.a
[ 52%] Built target ImGui
Scanning dependencies of target key_average_gui
[ 55%] Building CXX object CMakeFiles/key_average_gui.dir/key_average_gui.cpp.o
[ 57%] Linking CXX executable key_average_gui
/usr/bin/ld: libImGui.a(gl3w.c.o): in function `get_proc':
gl3w.c:(.text+0x4): undefined reference to `glXGetProcAddress'
/usr/bin/ld: libImGui.a(gl3w.c.o): in function `load_procs':
gl3w.c:(.text+0xc0): undefined reference to `glXGetProcAddress'
/usr/bin/ld: gl3w.c:(.text+0x100): undefined reference to `glXGetProcAddress'
/usr/bin/ld: gl3w.c:(.text+0x140): undefined reference to `glXGetProcAddress'
/usr/bin/ld: gl3w.c:(.text+0x180): undefined reference to `glXGetProcAddress'
/usr/bin/ld: libImGui.a(gl3w.c.o):gl3w.c:(.text+0x1ae): more undefined references to `glXGetProcAddress' follow
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/key_average_gui.dir/build.make:87: key_average_gui] Error 1
make[1]: *** [CMakeFiles/Makefile2:259: CMakeFiles/key_average_gui.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Not selecting the right capture device

First, thank you for sharing such a great tool!!!!
A minor problem: It detects up to 4 capture devices, but selects the wrong one. Is it possible to add a parameter to select which of the detected capturing devices must be used?

Increase readme infos

Can you provide info about project please:

  • Is it cross-platform ?
  • How can we build it ?

Continue training while demo'ing

Is it possible to continue training after the demo has already started? The explicit training before the demo could even be removed and the demo could just get better over time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.