Go Back   Home > Forums > >

PC Based Computer music servers, crossovers, and equalization

CamillaDSP - Cross-platform IIR and FIR engine for crossovers, room correction etc.
CamillaDSP - Cross-platform IIR and FIR engine for crossovers, room correction etc.
Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools
Old 9th March 2020, 12:13 PM   #121
phofman is online now phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Well then the capture device is closed, the script says it clear:

Code:
while [ "$(cat /proc/asound/card3/pcm1c/sub0/status)" != "closed" ]
  ....
done
...
echo "Capture device closed. Clock rate control disabled (clk: 1000000)."
Either camilla is not running, or you are querying a different device. If you want to keep the script running all the time, you will have to modify it to accept the closed status (i.e. wrapping the "while not closed" loop with another while true loop with some sleep)
  Reply With Quote
Old 9th March 2020, 12:16 PM   #122
cube75 is offline cube75  Netherlands
diyAudio Member
 
Join Date: Nov 2007
Location: Netherlands
Found that out too...running now

pi@realtimepi:~ $ sh softclock.sh
uptime: 000000s bufsize: 8192 filled: 12% clk: 99000
  Reply With Quote
Old 9th March 2020, 12:23 PM   #123
phofman is online now phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Very good. Please keep us updated how fast the feedback will stabilize.
  Reply With Quote
Old 9th March 2020, 12:54 PM   #124
cube75 is offline cube75  Netherlands
diyAudio Member
 
Join Date: Nov 2007
Location: Netherlands
Well, to my understanding uptime,buftime and clk should update in terminal, right?
However it does not.
  Reply With Quote
Old 9th March 2020, 01:06 PM   #125
HenrikEnquist is offline HenrikEnquist  Sweden
diyAudio Member
 
Join Date: Apr 2016
Location: Lund
Quote:
Originally Posted by phofman View Post
How does the chain actually work? There are two independent devices - capture, playback. Which one has the "clock master" role in your code?

IIUC correctly there are options:

A) each side uses blocking read/write in separate threads, with execution thread in between, reading from some buffers. Then the "xrun" would occur in these buffers, not in the alsa drivers.

B) one side (master) uses blocking operation, the other one non-blocking ("slave"). The thread is timed by the blocking side, hoping the non-blocking side will produce/consume in the same rate.

C, D - other variants I do not know

Please which workflow do you use?
It's close to A but not exactly. I use queues instead of plain buffers between the threads. I launch three threads, one for capture, one for processing and one for playback.


The capture thread uses blocking io to read N samples per channel (given by buffersize setting). When done, it converts them to float, and packages them in a message that is sent in a channel to the processing thread. The channel is basically a queue shared between the treads and can hold more than one message. Once sent it goes back to reading another set of N samples.



The processing thread waits for a message, does the processing and sends the processed data as a message on another channel to the playback thread.


The playback thread waits for a message. Once received the data is converted to the right format for the device, and then written to the device using blocking io. Once all the data has been written, it loops around to wait for the next message.


In practice the capture device is the one deciding the rate. If the playback queue will slowly grow with not yet played data. If it instead runs faster, once in a while the message will be late, meaning that the playback device will run out of data. Once a new message has been received, playback is resumed.
  Reply With Quote
Old 9th March 2020, 01:23 PM   #126
phofman is online now phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Henrik, thanks a lot for the explanation. I like your 3-thread architecture, IMO the most robust and technically sound solution.

IIUC, the buffer fill (/proc) should be read from the playback soundcard, adjusting the loopback device on capture side, just like you said.
  Reply With Quote
Old 9th March 2020, 01:47 PM   #127
phofman is online now phofman  Czech Republic
diyAudio Member
 
Join Date: Apr 2005
Location: Pilsen
Quote:
Originally Posted by cube75 View Post
Well, to my understanding uptime,buftime and clk should update in terminal, right?
However it does not.

Look at the script. The information is echoed only when new = different clkrate is identified:

Code:
# set clock rate of snd-aloop
if [ $clkrate -ne $lastclk ]
then
  amixer -c 3 cset numid=7 $clkrate > /dev/null
  echo "uptime: "$up"s bufsize: "$loopc_bufsize" filled: "$buf_ratio"% clk: "$clkrate
fi
You keep reading from the loopback /proc, right? But as Henrik said - that buffer will be kept empty all the time, because the reading thread in camilladsp has no blocking on the consumer side - there is a nonblocking queue which can grow unlimited.

Try to print the buf_ratio to see the value:
Code:
# fill rate in percent
buf_ratio=$(($loopc_buf_avail*100/$loopc_bufsize))
echo "buf_ratio: $buf_ratio"   # <----
I think you will see values close to zero all the time. It is under 70 constantly and clkrate is always 99000 - no change, no printout.

You need to read buffer fill of the playback soundcard, IMO.
  Reply With Quote
Old 9th March 2020, 02:07 PM   #128
cube75 is offline cube75  Netherlands
diyAudio Member
 
Join Date: Nov 2007
Location: Netherlands
Yes, for Camilladsp the playbackcard should be read, I know.

I tested this morning with brutefir. Still some glitches.
  Reply With Quote
Old 9th March 2020, 03:21 PM   #129
TNT is offline TNT  Sweden
diyAudio Member
 
Join Date: Apr 2003
Location: Sweden
CamillaDSP - Cross-platform IIR and FIR engine for crossovers, room correction etc.
Quote:
Originally Posted by Daihedz View Post
...or by cheating something useful into the data stream.
Please help NO !!

//
__________________
More distortion to the people! Timing . . . . is paramount.
  Reply With Quote
Old 9th March 2020, 08:06 PM   #130
Daihedz is offline Daihedz  Switzerland
diyAudio Member
 
Join Date: Jan 2010
Quote:
Originally Posted by TNT View Post
Please help NO !!

//
Agreed. Maybe it is not necessary to cheat.

There are indeed perfect solutions already implemented into audio programs: The aforementionned playhrt player which I use in my pipe provides a parameter --extra-bytes-per-second which performs exactly what is discussed here. This parameter allows to specify a correction for the differences between the soundcard's and the computer clocks. Maybe a look into the code of playhrt could be interesting: Bitbucket
  Reply With Quote

Reply


CamillaDSP - Cross-platform IIR and FIR engine for crossovers, room correction etc.Hide this!Advertise here!
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The room correction or speaker correction? What can we do with dsp power now availabl Raimonds Full Range 233 28th January 2017 08:51 AM
Introducing OpenDRC, Open Digital Room Correction engine minidsp miniDSP 20 20th January 2016 06:37 PM
What the difference between dsp room correction eq and software correction erez1012 PC Based 0 10th March 2014 08:07 PM
Writing a Cross-Platform, Free Software Modeling Tool and TS-Parameter DB justinzane Software Tools 6 31st December 2013 07:55 AM
FS: DAC, room-correction, active crossovers, amp, speakers! taloyd Swap Meet 4 14th April 2009 04:16 PM


New To Site? Need Help?

All times are GMT. The time now is 04:09 PM.


Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 14.29%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
Copyright ©1999-2021 diyAudio
Wiki