Streaming audio from windows output device to linux - linux

I've been able to stream audio from a input device in windows to a Linux machine using LineInCode, plink (Putty) and PulseAudio but unfortunately there isn't an option to choose the Window's output device with LineInCode so I decided to make a program that it does.
A program developed by Matthew van Eerde already do most of the work. You can select an output device and record a wav file. So instead of writing in a file I should send it to the stdout and plink and pacat would do the rest. The audio format "recorded" with his program is type WAVE_FORMAT_EXTENSIBLE (SubFormat) and it should be streamed to the pacat as a PCM. So my question is how do I convert from SubFormat to PCM audio format?
Here's the command with linco:
linco.exe -B 16 -C 2 -R 44100 | plink -v 192.168.11.5 -l armbian -pw 1234 "cat - | pacat --playback"
PS: I've tried to be objective as I could, sorry for the long post. If you have an idea on how to shorten it please let me know how.
Follows the projects link: https://github.com/rsegecin/WLStream

The format recorded in the windows output device is PCM floating 32 bits little endian so pacat needed to be configured to be able to receive this kind of format accordingly. I posted the project in github. There were also the need to configure the output data in binary and use fwrite function because printf wasn't keeping up with data output.
See you there.

Related

Randomly silencing part of input audio in real time

My machine is running Ubuntu 20 LTS. I want to manipulate the input live audio in real-time. I have achieved pitch shifting using sox. The command being -
sox -t pulseaudio default -t pulseaudio null pitch +1000
and then routing the audio from "Monitor of Nullsink" .
What I actually want to do is, silence randomized parts of the input audio, with a range. What I mean is, randomly mute 1-2s of the input audio.
The final goal of this project will be to write a script that manipulates my voice and makes it seems like my network is bad.
There is no restriction in method of achieving. That is we may use any language, make an extension, directly manipulate the input audio with sox, ffmpeg etc. Anything goes.
Found the solution by using trim in sox. The project can be found in
https://github.com/TathagataRoy1278/Bad_Internet_Audio_Modulator

Linux: how to dump audio output PCM bit stream like tcpdump

I am trying to do some audio debugging on my Linux system.
I learned how to record the sound of the current playing media but how can I get the PCM data without DAC/ADC?
I mean, just like wireshark or tcpdump tool, is there some sort of alsadump that I can make use of?
I want to do bit-exact comparison of the output PCM data to make sure the audio processing algorithm (which is an executable binary) worked correctly.
Thanks a lot.

Capturing PCM audio data stream into file, and playing stream via ffmpeg, how?

Would like to do following four things (separately), and need a bit of help understanding how to approach this,
Dump audio data (from a serial-over-USB port), encoded as PCM, 16-bit, 8kHz, little-endian, into a file (plain binary data dump, not into any container format). Can this approach be used:
$ cat /dev/ttyUSB0 > somefile.dat
Can I do a ^C to close the file writing, while the dumping is in progress, as per the above command ?
Stream audio data (same as above described kind), directly into ffmpeg for it to play out ? Like this:
$ cat /dev/ttyUSB0 | ffmpeg
or, do I have to specify the device port as a "-source" ? If so, I couldn't figure out the format.
Note that, I've tried this,
$ cat /dev/urandom | aplay
which works as expected, by playing out white-noise..., but trying the following doesn't help:
$ cat /dev/ttyUSB1 | aplay -f S16_LE
Even though, opening /dev/ttyUSB1 using picocom # 115200bps, 8-bit, no parity, I do see gibbrish, indicating presence of audio data, exactly when I expect.
Use the audio data dumped into the file, use as a source in ffmpeg ? If so how, because so far I get the impression that ffmpeg can read a file in standard containers.
Use pre-recorded audio captured in any format (perhaps .mp3 or .wav) to be streamed by ffmpeg, into /dev/ttyUSB0 device. Should I be using this as a "-sink" parameter, or pipe into it or redirect into it ? Also, is it possible that in 2 terminal windows, I use ffmpeg to capture and transmit audio data from/into same device /dev/ttyUSB0, simultaneously ?
My knowledge of digital audio recording/processing formats, codecs is somewhat limited, so not sure if what I am trying to do qualifies as working with 'raw' audio or not ?
If ffmpeg is unable to do what I am hoping to achieve, could gstreamer be the solution ?
PS> If anyone thinks that the answer could be improved, please feel free to suggest specific points. Would be happy to add any detail requested, provided I have the information.

How to capture voice PCM data over a serial port and process?

I have a telephony modem (SIM5320EVB) which gives voice data on ttyUSB0 as PCM with 1600 bytes each 100ms.Iam able to see the data on minicom. How to capture the PCM data in linux (i use ubuntu)and hear it live on the fly or atleast save and play the data? Is there any application available or API? If the approach atleast is suggested I will try developing one..
cat /dev/ttyUSB0 > my_cap_file
# make some noise for 5s for example, then hit ^C
then get Audacity and try to open your file with it, trying different input formats. You should be able to hear the sound you produced if you will guess the right format.
Install sox for the play command and use: play -r 8000 -c 1 -t raw -e signed-integer -b 16 /dev/ttyUSB0. That is: bit rate 8KHz, 1 channel (mono), raw data (PCM), format is signed integer 16 bits wide, and data can be read from ttyUSB0.
That requires sox to be able to play audio on your system; I've had success with pulseaudio for the underlying sound system.
You may need to modify the buffer size for play. By default, it buffers data which creates a small but very noticeable delay.

How to create artificial microphone input in Linux?

I'm working on an audio recognition project.
For testing, I'd like to be able to have a program:
load audio data from a file
provide it to the Linux kernel, as if it were coming from a microphone
have any user-space program sampling the microphone be obtaining data sourced
from my file.
Is that possible in Linux without having to write a new kernel module?
EDIT: i guess that solution won't work .. but see my comment below.
this shoud be simple under linux.
here are the steps:
make a named pipe with mkfifo (mkfifo ~/audio_out.pipe)
cat the audiofile into this pipe (cat test.wav > ~/audio_out.pipe)
get the program you want to listen, to get input from this pipe. maybe you have to make a symlink for programs not flexible enough to read from any device.
I hope I got your question right.

Resources