QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
INCLUDEPATH += "D:\BASS\c"
LIBS += -L"D:\BASS\c\x64" \
-lbass
INCLUDEPATH += "D:\BASSWASAPI\c"
LIBS += -L"D:\BASSWASAPI\c\x64" \
-lbasswasapi
INCLUDEPATH += "D:\BASSENC\c"
LIBS += -L"D:\BASSENC\c\x64" \
-lbassenc
TARGET = nienazwany
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
audio_capture_bass.cpp
HEADERS += mainwindow.h \
audio_capture_bass.h
FORMS += mainwindow.ui
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
INCLUDEPATH += "D:\BASS\c"
LIBS += -L"D:\BASS\c\x64" \
-lbass
INCLUDEPATH += "D:\BASSWASAPI\c"
LIBS += -L"D:\BASSWASAPI\c\x64" \
-lbasswasapi
INCLUDEPATH += "D:\BASSENC\c"
LIBS += -L"D:\BASSENC\c\x64" \
-lbassenc
TARGET = nienazwany
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
audio_capture_bass.cpp
HEADERS += mainwindow.h \
audio_capture_bass.h
FORMS += mainwindow.ui
To copy to clipboard, switch view to plain text mode
#ifndef AUDIO_CAPTURE_BASS_H
#define AUDIO_CAPTURE_BASS_H
#include <QObject>
#include "bass.h"
#include "basswasapi.h"
#include "bassenc.h"
class Audio_Capture_BASS
: public QObject{
Q_OBJECT
public:
explicit Audio_Capture_BASS
(QObject *parent
= 0);
signals:
public slots:
void start_recording();
void stop_recording();
private:
HSTREAM sound_stream;
static DWORD CALLBACK WasapiProc(void *buffer, DWORD length, void *user);
BASS_WASAPI_INFO info;
};
#endif // AUDIO_CAPTURE_BASS_H
#ifndef AUDIO_CAPTURE_BASS_H
#define AUDIO_CAPTURE_BASS_H
#include <QObject>
#include "bass.h"
#include "basswasapi.h"
#include "bassenc.h"
class Audio_Capture_BASS : public QObject
{
Q_OBJECT
public:
explicit Audio_Capture_BASS(QObject *parent = 0);
signals:
public slots:
void start_recording();
void stop_recording();
private:
HSTREAM sound_stream;
static DWORD CALLBACK WasapiProc(void *buffer, DWORD length, void *user);
BASS_WASAPI_INFO info;
};
#endif // AUDIO_CAPTURE_BASS_H
To copy to clipboard, switch view to plain text mode
#include "audio_capture_bass.h"
Audio_Capture_BASS
::Audio_Capture_BASS(QObject *parent
) : QObject(parent
){
BASS_Init(0, 44100, 0, 0, 0); //initialization of silent BASS device
BASS_WASAPI_Init(-3, 0, 0, 0, 0.5, 0,WasapiProc, this); //initialization of default WASAPI loopback capture device
BASS_WASAPI_GetInfo(&info); //getting info about stream parameters
}
//recording function called by BASS_WASAPI_Init every 0.5 second
DWORD CALLBACK Audio_Capture_BASS::WasapiProc(void *buffer, DWORD length, void *user)
{
Audio_Capture_BASS *self = (Audio_Capture_BASS*)user;
BASS_ChannelGetData(self->sound_stream, buffer, length);
return 1;
}
void Audio_Capture_BASS::start_recording()
{
sound_stream = BASS_StreamCreate(info.freq, info.chans, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE, STREAMPROC_DUMMY, 0); //creating a stream(HSTREAM)
BASS_Encode_Start(sound_stream, "output.wav", BASS_ENCODE_PCM|BASS_ENCODE_FP_16BIT|BASS_ENCODE_AUTOFREE, NULL, NULL); //adding WAV encoder to stream
BASS_WASAPI_Start(); //start WASAPI stream output
}
void Audio_Capture_BASS::stop_recording()
{
BASS_WASAPI_Stop(true); //stopping WASAPI stream output
BASS_StreamFree(sound_stream); //stopping recording stream together with encoder
}
#include "audio_capture_bass.h"
Audio_Capture_BASS::Audio_Capture_BASS(QObject *parent) : QObject(parent)
{
BASS_Init(0, 44100, 0, 0, 0); //initialization of silent BASS device
BASS_WASAPI_Init(-3, 0, 0, 0, 0.5, 0,WasapiProc, this); //initialization of default WASAPI loopback capture device
BASS_WASAPI_GetInfo(&info); //getting info about stream parameters
}
//recording function called by BASS_WASAPI_Init every 0.5 second
DWORD CALLBACK Audio_Capture_BASS::WasapiProc(void *buffer, DWORD length, void *user)
{
Audio_Capture_BASS *self = (Audio_Capture_BASS*)user;
BASS_ChannelGetData(self->sound_stream, buffer, length);
return 1;
}
void Audio_Capture_BASS::start_recording()
{
sound_stream = BASS_StreamCreate(info.freq, info.chans, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE, STREAMPROC_DUMMY, 0); //creating a stream(HSTREAM)
BASS_Encode_Start(sound_stream, "output.wav", BASS_ENCODE_PCM|BASS_ENCODE_FP_16BIT|BASS_ENCODE_AUTOFREE, NULL, NULL); //adding WAV encoder to stream
BASS_WASAPI_Start(); //start WASAPI stream output
}
void Audio_Capture_BASS::stop_recording()
{
BASS_WASAPI_Stop(true); //stopping WASAPI stream output
BASS_StreamFree(sound_stream); //stopping recording stream together with encoder
}
To copy to clipboard, switch view to plain text mode
Bookmarks