This commit is contained in:
2021-10-14 13:47:35 +02:00
commit 6625a8dfaa
4026 changed files with 844291 additions and 0 deletions
@@ -0,0 +1,319 @@
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 2.6 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkAdjustment" id="adjustment1">
<property name="value">18</property>
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment3">
<property name="value">1</property>
<property name="lower">1</property>
<property name="upper">1</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkListStore" id="model1">
<columns>
<!-- column-name gchararray -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">unspecified</col>
</row>
<row>
<col id="0" translatable="yes">female</col>
</row>
<row>
<col id="0" translatable="yes">male</col>
</row>
<row>
<col id="0" translatable="yes">unknown</col>
</row>
</data>
</object>
<object class="GtkListStore" id="model2">
<columns>
<!-- column-name gchararray -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">8192</col>
</row>
</data>
</object>
<object class="GtkDialog" id="openvibe-acquisition-server-settings">
<property name="border_width">5</property>
<property name="title" translatable="yes">Device configuration</property>
<property name="window_position">center</property>
<property name="type_hint">dialog</property>
<property name="gravity">center</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
<property name="spacing">8</property>
<child>
<object class="GtkLabel" id="label_title">
<property name="visible">True</property>
<property name="label" translatable="yes">OpenAL audio capture</property>
<property name="justify">center</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox">
<property name="visible">True</property>
<property name="border_width">8</property>
<property name="spacing">8</property>
<child>
<object class="GtkHBox" id="hbox">
<property name="visible">True</property>
<property name="spacing">8</property>
<child>
<object class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="n_rows">5</property>
<property name="n_columns">2</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkComboBox" id="combobox_gender">
<property name="visible">True</property>
<property name="model">model1</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_age">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_identifier">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment2</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_sampling_frequency">
<property name="visible">True</property>
<property name="label" translatable="yes">Sampling frequency :</property>
<property name="justify">right</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_number_of_channels">
<property name="visible">True</property>
<property name="label" translatable="yes">Number of channels :</property>
<property name="justify">right</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_gender">
<property name="visible">True</property>
<property name="label" translatable="yes">Gender :</property>
<property name="justify">right</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_age">
<property name="visible">True</property>
<property name="label" translatable="yes">Age :</property>
<property name="justify">right</property>
<property name="single_line_mode">True</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label_identifier">
<property name="visible">True</property>
<property name="label" translatable="yes">Identifier :</property>
<property name="justify">right</property>
<property name="single_line_mode">True</property>
</object>
</child>
<child>
<object class="GtkComboBox" id="combobox_sampling_frequency">
<property name="visible">True</property>
<property name="model">model2</property>
<property name="active">0</property>
<child>
<object class="GtkCellRendererText" id="renderer2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spinbutton_number_of_channels">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">adjustment3</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_change_channel_names">
<property name="label" translatable="yes">Change channel names</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator1">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button_apply">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_cancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-10">button_apply</action-widget>
<action-widget response="-6">button_cancel</action-widget>
</action-widgets>
</object>
</interface>
@@ -0,0 +1,36 @@
#include "ovasCConfigurationOpenALAudioCapture.h"
#if defined TARGET_HAS_ThirdPartyOpenAL
namespace OpenViBE {
namespace AcquisitionServer {
/*_________________________________________________
Insert callback to specific widget here
Example with a button that launch a calibration of the device:
//Callback connected to a dedicated gtk button:
static void button_calibrate_pressed_cb(GtkButton* button, void* data)
{
CConfigurationOpenALAudioCapture* config=static_cast<CConfigurationOpenALAudioCapture*>(data);
config->buttonCalibratePressedCB();
}
//Callback actually called:
void CConfigurationGTecGUSBamp::buttonCalibratePressedCB()
{
// Connect to the hardware, ask for calibration, verify the return code, etc.
}
_________________________________________________*/
// If you added more reference attribute, initialize them here
CConfigurationOpenALAudioCapture::CConfigurationOpenALAudioCapture(IDriverContext& ctx, const char* gtkBuilderFilename)
: CConfigurationBuilder(gtkBuilderFilename), m_driverCtx(ctx) {}
bool CConfigurationOpenALAudioCapture::preConfigure() { return CConfigurationBuilder::preConfigure(); }
bool CConfigurationOpenALAudioCapture::postConfigure() { return CConfigurationBuilder::postConfigure(); }
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif //TARGET_HAS_ThirdPartyOpenAL
@@ -0,0 +1,43 @@
#pragma once
#if defined TARGET_HAS_ThirdPartyOpenAL
#include "../ovasCConfigurationBuilder.h"
#include "ovasIDriver.h"
namespace OpenViBE {
namespace AcquisitionServer {
/**
* \class CConfigurationOpenALAudioCapture
* \author Aurelien Van Langhenhove (CIC-IT Garches)
* \date Mon May 16 16:55:49 2011
* \erief The CConfigurationOpenALAudioCapture handles the configuration dialog specific to the OpenAL audio capture device.
*
* TODO: details
*
* \sa CDriverOpenALAudioCapture
*/
class CConfigurationOpenALAudioCapture final : public CConfigurationBuilder
{
public:
// you may have to add to your constructor some reference parameters
// for example, a connection ID:
//CConfigurationOpenALAudioCapture(IDriverContext& ctx, const char* gtkBuilderFilename, uint32_t& rConnectionId);
CConfigurationOpenALAudioCapture(IDriverContext& ctx, const char* gtkBuilderFilename);
bool preConfigure() override;
bool postConfigure() override;
protected:
IDriverContext& m_driverCtx;
/*
* Insert here all specific attributes, such as a connection ID.
* use references to directly modify the corresponding attribute of the driver
* Example:
*/
// uint32_t& m_connectionID;
};
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif //TARGET_HAS_ThirdPartyOpenAL
@@ -0,0 +1,204 @@
#if defined TARGET_HAS_ThirdPartyOpenAL
#include "ovasCDriverOpenALAudioCapture.h"
#include "ovasCConfigurationOpenALAudioCapture.h"
#include <system/ovCTime.h>
namespace OpenViBE {
namespace AcquisitionServer {
CDriverOpenALAudioCapture::CDriverOpenALAudioCapture(IDriverContext& ctx)
: IDriver(ctx), m_settings("AcquisitionServer_Driver_OpenALAudioCapture", m_driverCtx.getConfigurationManager())
{
m_header.setSamplingFrequency(8192);
m_header.setChannelCount(1);
Device = nullptr;
Context = nullptr;
CaptureDevice = nullptr;
m_settings.add("Header", &m_header);
m_settings.load();
}
CDriverOpenALAudioCapture::~CDriverOpenALAudioCapture() {}
const char* CDriverOpenALAudioCapture::getName() { return "OpenAL audio capture"; }
//___________________________________________________________________//
// //
bool CDriverOpenALAudioCapture::initialize(const uint32_t nSamplePerSentBlock, IDriverCallback& callback)
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Debug << "CDriverOpenALAudioCapture::initialize\n";
if (m_driverCtx.isConnected() || !m_header.isChannelCountSet() || !m_header.isSamplingFrequencySet()) { return false; }
m_sample = new float[nSamplePerSentBlock];
if (!m_sample)
{
delete [] m_sample;
m_sample = nullptr;
return false;
}
Samples = new ALshort[nSamplePerSentBlock];
if (!Samples)
{
delete [] Samples;
Samples = nullptr;
return false;
}
// Open default audio device
Device = alcOpenDevice(nullptr);
if (!Device)
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Warning << "Default audio device opening failed.\n";
return false;
}
// Create an audio context
Context = alcCreateContext(Device, nullptr);
if (!Context)
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Warning << "Audio context creation failed.\n";
return false;
}
// Activate context
if (!alcMakeContextCurrent(Context))
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Warning << "Audio context activation failed.\n";
return false;
}
// Verify if audio capture is supported by the computer
if (alcIsExtensionPresent(Device, "ALC_EXT_CAPTURE") == AL_FALSE)
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Warning << "Default audio device does not support audio capture.\n";
return false;
}
// Open capture device
CaptureDevice = alcCaptureOpenDevice(nullptr, (ALCsizei)m_header.getSamplingFrequency(), AL_FORMAT_MONO16, (ALCsizei)m_header.getSamplingFrequency());
if (!CaptureDevice)
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Warning << "Default capture device opening failed.\n";
return false;
}
// Saves parameters
m_callback = &callback;
m_nSamplePerSentBlock = nSamplePerSentBlock;
return true;
}
bool CDriverOpenALAudioCapture::start()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Debug << "CDriverOpenALAudioCapture::start\n";
if (!m_driverCtx.isConnected() || m_driverCtx.isStarted()) { return false; }
// ...
// request hardware to start
// sending data
// ...
alcCaptureStart(CaptureDevice);
return true;
}
bool CDriverOpenALAudioCapture::loop()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Debug << "CDriverOpenALAudioCapture::loop\n";
if (!m_driverCtx.isConnected()) { return false; }
if (!m_driverCtx.isStarted()) { return true; }
// Activate context
if (!alcMakeContextCurrent(Context)) { m_driverCtx.getLogManager() << Kernel::LogLevel_Warning << "Audio context activation failed.\n"; }
ALCint SamplesAvailable;
do
{
alcGetIntegerv(CaptureDevice, ALC_CAPTURE_SAMPLES, 1, &SamplesAvailable);
if ((uint32_t)SamplesAvailable >= m_nSamplePerSentBlock)
{
alcCaptureSamples(CaptureDevice, &Samples[0], (ALCsizei)m_nSamplePerSentBlock);
for (uint32_t i = 0; i < m_nSamplePerSentBlock; ++i) { m_sample[i] = (float)Samples[i]; }
m_callback->setSamples(m_sample);
m_driverCtx.correctDriftSampleCount(m_driverCtx.getSuggestedDriftCorrectionSampleCount());
}
} while ((uint32_t)SamplesAvailable >= m_nSamplePerSentBlock);
return true;
}
bool CDriverOpenALAudioCapture::stop()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Debug << "CDriverOpenALAudioCapture::start\n";
if (!m_driverCtx.isConnected() || !m_driverCtx.isStarted()) { return false; }
alcCaptureStop(CaptureDevice);
return true;
}
bool CDriverOpenALAudioCapture::uninitialize()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Debug << "CDriverOpenALAudioCapture::start\n";
if (!m_driverCtx.isConnected() || m_driverCtx.isStarted()) { return false; }
// Close capture device
alcCaptureCloseDevice(CaptureDevice);
// Context desactivation
alcMakeContextCurrent(nullptr);
// Context destruction
alcDestroyContext(Context);
// Close device
alcCloseDevice(Device);
delete [] m_sample;
m_sample = nullptr;
delete [] Samples;
Samples = nullptr;
m_callback = nullptr;
return true;
}
//___________________________________________________________________//
// //
bool CDriverOpenALAudioCapture::isConfigurable()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Debug << "CDriverOpenALAudioCapture::isConfigurable\n";
return true;
}
bool CDriverOpenALAudioCapture::configure()
{
m_driverCtx.getLogManager() << Kernel::LogLevel_Debug << "CDriverOpenALAudioCapture::start\n";
// Change this line if you need to specify some references to your driver attribute that need configuration, e.g. the connection ID.
CConfigurationOpenALAudioCapture config(m_driverCtx,
Directories::getDataDir() + "/applications/acquisition-server/interface-OpenALAudioCapture.ui");
if (!config.configure(m_header)) { return false; }
m_settings.save();
return true;
}
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif //TARGET_HAS_ThirdPartyOpenAL
@@ -0,0 +1,81 @@
#pragma once
#if defined TARGET_HAS_ThirdPartyOpenAL
#include "ovasIDriver.h"
#include "../ovasCHeader.h"
#include <openvibe/ov_all.h>
#include "../ovasCSettingsHelper.h"
#include "../ovasCSettingsHelperOperators.h"
#if defined TARGET_OS_Windows
#include <al.h>
#include <alc.h>
#elif defined TARGET_OS_Linux
#include <AL/al.h>
#include <AL/alc.h>
#else
#endif
namespace OpenViBE {
namespace AcquisitionServer {
/**
* \class CDriverOpenALAudioCapture
* \author Aurelien Van Langhenhove (CIC-IT Garches)
* \date Mon May 16 16:55:49 2011
* \erief The CDriverOpenALAudioCapture allows the acquisition server to acquire data from a OpenAL audio capture device.
*
* TODO: details
*
* \sa CConfigurationOpenALAudioCapture
*/
class CDriverOpenALAudioCapture final : public IDriver
{
public:
explicit CDriverOpenALAudioCapture(IDriverContext& ctx);
~CDriverOpenALAudioCapture() override;
const char* getName() override;
bool initialize(const uint32_t nSamplePerSentBlock, IDriverCallback& callback) override;
bool uninitialize() override;
bool start() override;
bool stop() override;
bool loop() override;
bool isConfigurable() override;
bool configure() override;
const IHeader* getHeader() override { return &m_header; }
bool isFlagSet(const EDriverFlag flag) const override { return flag == EDriverFlag::IsUnstable; }
protected:
SettingsHelper m_settings;
IDriverCallback* m_callback = nullptr;
// Replace this generic Header with any specific header you might have written
CHeader m_header;
uint32_t m_nSamplePerSentBlock = 0;
float* m_sample = nullptr;
ALshort* Samples = nullptr;
private:
/*
* Insert here all specific attributes, such as USB port number or device ID.
* Example :
*/
// uint32_t m_connectionID;
ALCdevice* Device = nullptr;
ALCcontext* Context = nullptr;
ALCdevice* CaptureDevice = nullptr;
};
} // namespace AcquisitionServer
} // namespace OpenViBE
#endif //TARGET_HAS_ThirdPartyOpenAL