J
J
John Ashley2017-08-29 22:25:32
linux
John Ashley, 2017-08-29 22:25:32

How to record sound from a computer?

Hello everyone, you are my last hope.
I'm trying to programmatically record the sound that I hear from the computer (internal output). I have already tried all the devices, all combinations in portaudio - the sound is recorded only from the microphone. However, the SoundWire software uses PortAudio to record internal audio. I opened it in IDA - configuration result:

input_parameters.device = Pa_GetDefaultInputDevice();
    input_parameters.channelCount = 2;
    input_parameters.sampleFormat = paInt16;
    const PaDeviceInfo *input_info = Pa_GetDeviceInfo(input_parameters.device);
    input_parameters.suggestedLatency = input_info->defaultLowInputLatency;
    input_parameters.hostApiSpecificStreamInfo = NULL;

Pa_OpenStream(&stream, &input_parameters, NULL, input_info->defaultSampleRate, paFramesPerBufferUnspecified/*на самом деле тут 338u(которая скорее всего ссылка на sampleRate) и 1(флаг либо 1 семпл на 1 вызов), я решил что на результат не повлияет*/, paClipOff, recordCallback, NULL);

Okay, everything is there, in recordCallback this is stupid:
int16_t *in = (int16_t *) inputBuffer;
    for(int i = 0; i < LEN(in); i++) {
        cout << in[i] << ":";
    }
    cout << endl;

Everything seems to be in order, everything should work, but here the sound recording comes from a microphone.
For several days I have been trying to write or find at least one working program that records internal sound (I searched for "sound visualize", "audio capture" in github, stackoverflow). But each one either records sound from a microphone, or JACK is offered, or there is another OS (windows).
Gist: main.cpp

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Skobkin, 2017-08-29
@skobkin

See how sound is captured by OBS Studio. True, it works through PulseAudio.

P
planc, 2017-08-30
@planc

https://trac.ffmpeg.org/wiki/Capture/ALSA#Recordau...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question