Synchronization of IO

Moderator: flatmax

Post Reply
barney39
Posts: 3
Joined: Fri Sep 15, 2017 9:12 pm

Synchronization of IO

Post by barney39 » Sat Sep 23, 2017 1:22 am

Hi there,
We are doing some very high precision timing where we need to align the recorded input samples to the played output samples (we are not worried about latency or delays in starting the recording playback)- at the moment it seems that every time we start up the audio, the alignment in time between the input and output is different (e.g. if we play a pulse on the output, its position on the input is inconsistent). Is there a way that we can ensure that they both start at exactly the same clock cycle (or with exactly the same offset) every time? Alternatively can we get the time stamps to know when the samples were output/recorded (and from this work out the the offset)?

We are working with ALSA and a c-program on a Raspberry PI 3 with your stereo sound card.

Any help would be much appreciated.

flatmax
Posts: 609
Joined: Sat Jul 23, 2016 11:39 pm

Re: Synchronization of IO

Post by flatmax » Sat Sep 23, 2017 3:18 pm

Hi there,

This is a common problem which is in ALSA land, independent of most sound cards.

In your code which interfaces ALSA, can you confirm that you are linking the playback and capture systems ?
For example in the FullDuplex class in gtkiostream , inside the function FullDuplex::go :

Code: Select all

if ((ret=link())<0)
The intention in calling snd_pcm_link is to ensure that both playback and capture are started at the same point in time.

Matt
Check out our audiophile quality crossovers : https://bit.ly/2kb1nzZ
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

barney39
Posts: 3
Joined: Fri Sep 15, 2017 9:12 pm

Re: Synchronization of IO

Post by barney39 » Fri Sep 29, 2017 7:41 pm

Hi Matt,

Thanks so much for your advice. I hadn't found the snd_pcm_link functionality in the ALSA docs. It sounds like exactly what I need.

However, calling snd_pcm_link returns an error code of -22 (Invalid argument). I am attempting to link the playback/capture pcm devices after opening them both with snd_pcm_open and setting various hw/sw params. So, they are valid and configured pcm devices that are being passed in.

Do you have any idea why I'd get an invalid argument error when calling snd_pcm_link? I am using the RCA channel on the stereo soundcard with an external powered microphone.

Thanks!

flatmax
Posts: 609
Joined: Sat Jul 23, 2016 11:39 pm

Re: Synchronization of IO

Post by flatmax » Wed Oct 04, 2017 6:43 am

Hi there,

Not sure what the problem is. Have you considered cross checking your code against the ALSA::FullDuplex code here :

Code: Select all

http://gtkiostream.flatmax.org/FullDuplex_8H_source.html
thanks
Matt
Check out our audiophile quality crossovers : https://bit.ly/2kb1nzZ
Please review the Zero sound card on Amazon USA : https://www.amazon.com/dp/B075V1VNDD
---
Check out our new forum on github : https://github.com/Audio-Injector

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests