Compare commits

...

3 Commits

Author SHA1 Message Date
Paul Dino Jones b3067e520d Fix latency on pulseaudio backend 2023-11-14 15:31:44 +00:00
Paul Dino Jones b4f459a539 Add basic info for pulseaudio backend into readme 2023-11-13 07:50:10 +00:00
Paul Dino Jones b4ca18c351 Updated config for new pulseaudio backend 2023-11-13 07:46:04 +00:00
4 changed files with 25 additions and 17 deletions

View File

@ -16,12 +16,14 @@ Cross Platform device manager for driving and flight simulators, for use with co
- Includes utility to configure revburner tachometer - Includes utility to configure revburner tachometer
- Can send data to any serial device. So far only tested with arduino. Includes sample arduino sketch for sim lights. - Can send data to any serial device. So far only tested with arduino. Includes sample arduino sketch for sim lights.
- The support for haptic bass shakers is limited and needs the most work. So far the engine rev is a simple sine wave, which I find convincing. The gear shift event works but not convincing enough for me. - The support for haptic bass shakers is limited and needs the most work. So far the engine rev is a simple sine wave, which I find convincing. The gear shift event works but not convincing enough for me.
- Choice of Portaudio or Pulseaudio backend.
## Dependencies ## Dependencies
- libserialport - arduino serial devices - libserialport - arduino serial devices
- hidapi - usb hid devices - hidapi - usb hid devices
- libusb - used by hidapi - libusb - used by hidapi
- portaudio - sound devices (haptic bass shakers) - portaudio - sound devices (haptic bass shakers)
- pulseaudio - sound devices (haptic bass shakers)
- libenet - UDP support (not yet implemented) - libenet - UDP support (not yet implemented)
- libxml2 - libxml2
- argtable2 - argtable2
@ -44,6 +46,11 @@ cmake ..
make make
``` ```
to use the pulseaudio backend use this cmake command
```
cmake -DUSE_PULSEAUDIO=YES ..
```
## Testing ## Testing
### Setting up Your Arduino Device ### Setting up Your Arduino Device

View File

@ -6,11 +6,18 @@ devices = ( { device = "USB";
granularity = 4; granularity = 4;
config = "/home/paul/.config/monocoque/revburner1.xml"; }, config = "/home/paul/.config/monocoque/revburner1.xml"; },
{ device = "Sound"; { device = "Sound";
type = "Engine" type = "Engine";
devid = "98FD:83AC"; }, devid = "alsa_output.usb-Generic_USB2.0_Device_20170726905959-00.analog-stereo";
pan = 1;
volume = 90;
frequency = 27; },
{ device = "Sound"; { device = "Sound";
type = "Gear" type = "Gear"
devid = "98FD:83AC"; }, devid = "alsa_output.usb-Generic_USB2.0_Device_20170726905959-00.analog-stereo";
pan = 1;
duration = .25;
volume = 100;
frequency = 27; },
{ device = "Serial"; { device = "Serial";
type = "ShiftLights"; type = "ShiftLights";
config = "None"; config = "None";

View File

@ -123,7 +123,7 @@ int usb_generic_shaker_init(SoundDevice* sounddevice, pa_threaded_mainloop* main
// recommended settings, i.e. server uses sensible values // recommended settings, i.e. server uses sensible values
pa_buffer_attr buffer_attr; pa_buffer_attr buffer_attr;
buffer_attr.maxlength = (uint32_t) -1; buffer_attr.maxlength = (uint32_t) 32767;
buffer_attr.tlength = (uint32_t) -1; buffer_attr.tlength = (uint32_t) -1;
buffer_attr.prebuf = (uint32_t) -1; buffer_attr.prebuf = (uint32_t) -1;
buffer_attr.minreq = (uint32_t) -1; buffer_attr.minreq = (uint32_t) -1;
@ -131,22 +131,17 @@ int usb_generic_shaker_init(SoundDevice* sounddevice, pa_threaded_mainloop* main
pa_cvolume cv; pa_cvolume cv;
uint16_t pvolume = ceil(((double) volume/100.0d)*65535); uint16_t pvolume = ceil(((double) volume/100.0d)*65535);
// Settings copied as per the chromium browser source // Settings copied as per the chromium browser source
pa_stream_flags_t stream_flags;
stream_flags = PA_STREAM_INTERPOLATE_TIMING |
PA_STREAM_NOT_MONOTONIC | PA_STREAM_AUTO_TIMING_UPDATE |
PA_STREAM_ADJUST_LATENCY;
//stream_flags = PA_STREAM_START_CORKED; pa_stream_flags_t stream_flags;
stream_flags = PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_NOT_MONOTONIC | PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_ADJUST_LATENCY | PA_STREAM_START_CORKED;
// Connect stream to the default audio output sink // Connect stream to the default audio output sink
pa_cvolume_set(&cv, sample_specifications.channels, pvolume); pa_cvolume_set(&cv, sample_specifications.channels, pvolume);
//pa_cvolume_set(&cv, 1, 0);
pa_cvolume_set_balance(&cv, &channel_map, pan); pa_cvolume_set_balance(&cv, &channel_map, pan);
assert(pa_stream_connect_playback(stream, devname, &buffer_attr, stream_flags, &cv, NULL) == 0); assert(pa_stream_connect_playback(stream, devname, &buffer_attr, stream_flags, &cv, NULL) == 0);
// Wait for the stream to be ready // Wait for the stream to be ready
for(;;) { for(;;) {
pa_stream_state_t stream_state = pa_stream_get_state(stream); pa_stream_state_t stream_state = pa_stream_get_state(stream);

View File

@ -203,10 +203,9 @@ int clilooper(SimDevice* devices, int numdevices, Parameters* p, SimData* simdat
for (int x = 0; x < numdevices; x++) for (int x = 0; x < numdevices; x++)
{ {
devices[x].update(&devices[x], simdata); devices[x].update(&devices[x], simdata);
} }
if( poll(&mypoll, 1, 1000.0/DEFAULT_UPDATE_RATE) ) if( poll(&mypoll, 1, 1000.0/update_rate) )
{ {
scanf("%c", &ch); scanf("%c", &ch);
if(ch == 'q') if(ch == 'q')