Maintaining sound card at a specific frequency
Hi all,
I have a problem with my currently setup. I've filed a bug in the
Alsa tracker a couple of days ago but I hope there might be some simple solution to this that only the Alsa developers know.
https://bugtrack.alsa-project.org/alsa-bug/view.php?id=818
The issue is explained in the bug report, but stated in a more general way, in a multi-PC setup where I'm using ADAT clocking to sync all the PCs together, there needs to be a way for me to lock down the sample rate of my sound card and not let applications change it. In the following setup GSt is sending audio continuously to Pro Tools. The audio goes through the HDSP 9652 sound card, but not through Linux. The HDSP 9652 has a hardware mixer and audio data is just roouted through the hardware. The HDSP 9652 is the master clock for the system. This works fine.
GSt ====> HDSP 9652 ====> Pro Tools
However if I open Mozilla and browse around the Pro Tools side starts telling me that the ADAT clock is invalid. My suspicion is that the web page I went to in Mozilla has some sort of audio content on it and it's not encoded at the frequency I'm running at so Mozilla tries to change the frequency of the card to adjust. This would make sense in a single PC setup bu makes no sense in a multi-PC setup like this one.
It does not matter that the apps I'm using on the left and right are Windows. The problem would be there even if they were Linux.
I guess I'm wondering if there isn't some .asoundrc magic that could be done in my Linux account on this machine that would tell all applications (other than Jack for now) to use some virtual device that handles all frequencies. If that virtual device was the default and the resampling (for Mozilla/games/whatever) was done in software and the sound cards frequency was never changed then I think things would work much better.
Is this possible?
Thanks in advance,
Mark
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoting Mark Knecht <[email protected]>:
Quoted 9 lines
I guess I'm wondering if there isn't some .asoundrc magic that could be done in my Linux account on this machine that would tell all applications (other than Jack for now) to use some virtual device that handles all frequencies. If that virtual device was the default and the resampling (for Mozilla/games/whatever) was done in software and the sound cards frequency was never changed then I think things would work much better.
I think you can use default as the device name in .asoundrc and it will be used as the default device for all apps.
Then just give it a plughw instead of hw
ex.
pcm.default {
type plughw
card card1
device 0
}
ctl.default {
type hw
card 0
}
--
Patrick Shirkey - Boost Hardware Ltd. Http://www.boosthardware.com Http://www.djcj.org/ - The Linux Audio Users guide Http://www.djcj.org/gigs - Gigs Guide Korea
========================================
Being on stage with the band in front of crowds shouting, "Get off! No! We want normal music!", I think that was more like acting than anything I've ever done.
Goldie, 8 Nov, 2002
The Scotsman
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 11 lines · On 17-Jan-2005 Patrick Shirkey wrote:
Quoted 8 lines
I guess I'm wondering if there isn't some .asoundrc magic that could be done in my Linux account on this machine that would tell all applications (other than Jack for now) to use some virtual device that handles all frequencies. If that virtual device was the default and the resampling (for Mozilla/games/whatever) was done in software and the sound cards frequency was never changed then I think things would work much better.
I think you can use default as the device name in .asoundrc and it will be used as the default device for all apps.
IMHO we should think on a good solution for this problem. Some cards have many channels/voices but the sample rate is common for all of them. Currently the only clean way to manage it is a control that locks the sample rate at a given frequency, but it isn't a nice solution because it requires explicit user intervention. In the echoaudio driver I implemented a kludge that automatically locks the sample frequency in order to avoid unwanted rate changes.
--
Giuliano.
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
At Tue, 18 Jan 2005 16:50:36 +0100 (CET),
Quoted 16 lines · Giuliano Pochini
Quoted 11 lines · On 17-Jan-2005 Patrick Shirkey wrote:
Quoted 8 lines
I guess I'm wondering if there isn't some .asoundrc magic that could be done in my Linux account on this machine that would tell all applications (other than Jack for now) to use some virtual device that handles all frequencies. If that virtual device was the default and the resampling (for Mozilla/games/whatever) was done in software and the sound cards frequency was never changed then I think things would work much better.
I think you can use default as the device name in .asoundrc and it will be used as the default device for all apps.
Quoted 8 lines
IMHO we should think on a good solution for this problem. Some cards have many channels/voices but the sample rate is common for all of them. Currently the only clean way to manage it is a control that locks the sample rate at a given frequency, but it isn't a nice solution because it requires explicit user intervention. In the echoaudio driver I implemented a kludge that automatically locks the sample frequency in order to avoid unwanted rate changes.
You can add a control to lock the sample rate (e.g. ICE1712).
Takashi
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 27 lines · Takashi Iwai
At Tue, 18 Jan 2005 16:50:36 +0100 (CET),
Quoted 16 lines · Giuliano Pochini
Quoted 11 lines · On 17-Jan-2005 Patrick Shirkey wrote:
Quoted 8 lines
I guess I'm wondering if there isn't some .asoundrc magic that could be done in my Linux account on this machine that would tell all applications (other than Jack for now) to use some virtual device that handles all frequencies. If that virtual device was the default and the resampling (for Mozilla/games/whatever) was done in software and the sound cards frequency was never changed then I think things would work much better.
I think you can use default as the device name in .asoundrc and it will be used as the default device for all apps.
Quoted 8 lines
IMHO we should think on a good solution for this problem. Some cards have many channels/voices but the sample rate is common for all of them. Currently the only clean way to manage it is a control that locks the sample rate at a given frequency, but it isn't a nice solution because it requires explicit user intervention. In the echoaudio driver I implemented a kludge that automatically locks the sample frequency in order to avoid unwanted rate changes.
Quoted 5 lines
You can add a control to lock the sample rate (e.g. ICE1712).
Takashi
That could be a good solution if it would also set the initial frequency of the card.
Right now I have to manually set the HDSP 9652's frequency to 44.1K every time I boot to get the ADAT network to the right frequency. While other may like 48K for audio work those of us that work alot with samplers are far more bound by the frequency that the samples were recorded. This, in the case of GigaSampler and LinuxSampler, is always 44.1K and the HDSP 9652 always comes up at 48K.
To be clear, I think this problem will effect more people in the future and the solution should be general in format and enforced by the Alsa management team for all cards. The default can be unlocked if you like, and that probably works better for the stand alone workstation.
- Mark
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
At Tue, 18 Jan 2005 09:01:21 -0800,
Quoted 29 lines · Mark Knecht
Quoted 27 lines · Takashi Iwai
At Tue, 18 Jan 2005 16:50:36 +0100 (CET),
Quoted 24 lines · Giuliano Pochini
Quoted 11 lines · On 17-Jan-2005 Patrick Shirkey wrote:
Quoted 8 lines
I guess I'm wondering if there isn't some .asoundrc magic that could be done in my Linux account on this machine that would tell all applications (other than Jack for now) to use some virtual device that handles all frequencies. If that virtual device was the default and the resampling (for Mozilla/games/whatever) was done in software and the sound cards frequency was never changed then I think things would work much better.
I think you can use default as the device name in .asoundrc and it will be used as the default device for all apps.
IMHO we should think on a good solution for this problem. Some cards have many channels/voices but the sample rate is common for all of them. Currently the only clean way to manage it is a control that locks the sample rate at a given frequency, but it isn't a nice solution because it requires explicit user intervention. In the echoaudio driver I implemented a kludge that automatically locks the sample frequency in order to avoid unwanted rate changes.
Quoted 8 lines
Quoted 5 lines
You can add a control to lock the sample rate (e.g. ICE1712).
Takashi
That could be a good solution if it would also set the initial frequency of the card.
The system clock of HDSP can be set via control API. So, it works like:
amixer cset iface=PCM,name="Sample Clock Source" "Internal 48.0 kHz"
If this works like you want, only the locking is missing...
Takashi
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 37 lines · Takashi Iwai
At Tue, 18 Jan 2005 09:01:21 -0800,
Quoted 35 lines · Mark Knecht
Quoted 32 lines · Takashi Iwai
At Tue, 18 Jan 2005 16:50:36 +0100 (CET),
Quoted 16 lines · Giuliano Pochini
Quoted 11 lines · On 17-Jan-2005 Patrick Shirkey wrote:
Quoted 8 lines
I guess I'm wondering if there isn't some .asoundrc magic that could be done in my Linux account on this machine that would tell all applications (other than Jack for now) to use some virtual device that handles all frequencies. If that virtual device was the default and the resampling (for Mozilla/games/whatever) was done in software and the sound cards frequency was never changed then I think things would work much better.
I think you can use default as the device name in .asoundrc and it will be used as the default device for all apps.
Quoted 8 lines
IMHO we should think on a good solution for this problem. Some cards have many channels/voices but the sample rate is common for all of them. Currently the only clean way to manage it is a control that locks the sample rate at a given frequency, but it isn't a nice solution because it requires explicit user intervention. In the echoaudio driver I implemented a kludge that automatically locks the sample frequency in order to avoid unwanted rate changes.
You can add a control to lock the sample rate (e.g. ICE1712).
Takashi
Quoted 9 lines
Quoted 2 lines
That could be a good solution if it would also set the initial frequency of the card.
The system clock of HDSP can be set via control API. So, it works like:
amixer cset iface=PCM,name="Sample Clock Source" "Internal 48.0 kHz"If this works like you want, only the locking is missing...
Unfortunately it set it to Autosync, not 48K. I tried 44.1K also but it jsut stays at Autosync. Here's what I see in the terminal:
[mark@Godzilla mark]$ amixer cset iface=PCM,name="Sample Clock Source" "Internal 48.0 kHz"
numid=11,iface=PCM,name='Sample Clock Source'
; type=ENUMERATED,access=rw---,values=1,items=7
; Item #0 'AutoSync'
; Item #1 'Internal 32.0 kHz'
; Item #2 'Internal 44.1 kHz'
; Item #3 'Internal 48.0 kHz'
; Item #4 'Internal 64.0 kHz'
; Item #5 'Internal 88.2 kHz'
; Item #6 'Internal 96.0 kHz'
: values=0
[mark@Godzilla mark]$
Maybe a different form of the command somehow?
- Mark
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
At Tue, 18 Jan 2005 09:12:44 -0800,
Quoted 46 lines · Mark Knecht
Quoted 44 lines · Takashi Iwai
At Tue, 18 Jan 2005 09:01:21 -0800,
Quoted 29 lines · Mark Knecht
Quoted 27 lines · Takashi Iwai
At Tue, 18 Jan 2005 16:50:36 +0100 (CET),
Quoted 24 lines · Giuliano Pochini
Quoted 11 lines · On 17-Jan-2005 Patrick Shirkey wrote:
Quoted 8 lines
I guess I'm wondering if there isn't some .asoundrc magic that could be done in my Linux account on this machine that would tell all applications (other than Jack for now) to use some virtual device that handles all frequencies. If that virtual device was the default and the resampling (for Mozilla/games/whatever) was done in software and the sound cards frequency was never changed then I think things would work much better.
I think you can use default as the device name in .asoundrc and it will be used as the default device for all apps.
IMHO we should think on a good solution for this problem. Some cards have many channels/voices but the sample rate is common for all of them. Currently the only clean way to manage it is a control that locks the sample rate at a given frequency, but it isn't a nice solution because it requires explicit user intervention. In the echoaudio driver I implemented a kludge that automatically locks the sample frequency in order to avoid unwanted rate changes.
Quoted 8 lines
Quoted 5 lines
You can add a control to lock the sample rate (e.g. ICE1712).
Takashi
That could be a good solution if it would also set the initial frequency of the card.
The system clock of HDSP can be set via control API. So, it works like:
amixer cset iface=PCM,name="Sample Clock Source" "Internal 48.0 kHz"
Quoted 5 lines
Quoted 2 lines
If this works like you want, only the locking is missing...
Unfortunately it set it to Autosync, not 48K. I tried 44.1K also but it jsut stays at Autosync. Here's what I see in the terminal:
Ah, my mistake. Try
amixer cset iface=PCM,name="Sample Clock Source" 3
Takashi
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 10 lines · Takashi Iwai
Quoted 8 lines
IMHO we should think on a good solution for this problem. Some cards have many channels/voices but the sample rate is common for all of them. Currently the only clean way to manage it is a control that locks the sample rate at a given frequency, but it isn't a nice solution because it requires explicit user intervention. In the echoaudio driver I implemented a kludge that automatically locks the sample frequency in order to avoid unwanted rate changes.
You can add a control to lock the sample rate (e.g. ICE1712).
Yep, I know, but it's not part of the pcm API: applications do not lock the sample rate themselves. The user has to do it manually. This is why I choosed an alternate solution. If apps were able to lock the rate it would be very useful. It may need some help from the driver, though.
--
Giuliano.
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
At Tue, 18 Jan 2005 18:31:28 +0100 (CET),
Quoted 14 lines · Giuliano Pochini
Quoted 9 lines · Takashi Iwai
Quoted 8 lines
IMHO we should think on a good solution for this problem. Some cards have many channels/voices but the sample rate is common for all of them. Currently the only clean way to manage it is a control that locks the sample rate at a given frequency, but it isn't a nice solution because it requires explicit user intervention. In the echoaudio driver I implemented a kludge that automatically locks the sample frequency in order to avoid unwanted rate changes.
Quoted 6 lines
Quoted 1 line
You can add a control to lock the sample rate (e.g. ICE1712).
Yep, I know, but it's not part of the pcm API: applications do not lock the sample rate themselves. The user has to do it manually. This is why I choosed an alternate solution. If apps were able to lock the rate it would be very useful. It may need some help from the driver, though.
I think this is above the PCM API since this influences the whole system. It's fine to add a new API call in alsa-lib, just as a wrapper to toggle such a control, though...
Takashi
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 48 lines · Takashi Iwai
At Tue, 18 Jan 2005 09:12:44 -0800,
Quoted 46 lines · Mark Knecht
Quoted 44 lines · Takashi Iwai
At Tue, 18 Jan 2005 09:01:21 -0800,
Quoted 29 lines · Mark Knecht
Quoted 27 lines · Takashi Iwai
At Tue, 18 Jan 2005 16:50:36 +0100 (CET),
Quoted 24 lines · Giuliano Pochini
Quoted 11 lines · On 17-Jan-2005 Patrick Shirkey wrote:
Quoted 8 lines
I guess I'm wondering if there isn't some .asoundrc magic that could be done in my Linux account on this machine that would tell all applications (other than Jack for now) to use some virtual device that handles all frequencies. If that virtual device was the default and the resampling (for Mozilla/games/whatever) was done in software and the sound cards frequency was never changed then I think things would work much better.
I think you can use default as the device name in .asoundrc and it will be used as the default device for all apps.
IMHO we should think on a good solution for this problem. Some cards have many channels/voices but the sample rate is common for all of them. Currently the only clean way to manage it is a control that locks the sample rate at a given frequency, but it isn't a nice solution because it requires explicit user intervention. In the echoaudio driver I implemented a kludge that automatically locks the sample frequency in order to avoid unwanted rate changes.
Quoted 8 lines
Quoted 5 lines
You can add a control to lock the sample rate (e.g. ICE1712).
Takashi
That could be a good solution if it would also set the initial frequency of the card.
The system clock of HDSP can be set via control API. So, it works like:
amixer cset iface=PCM,name="Sample Clock Source" "Internal 48.0 kHz"
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
If this works like you want, only the locking is missing...
Unfortunately it set it to Autosync, not 48K. I tried 44.1K also but it jsut stays at Autosync. Here's what I see in the terminal:
Ah, my mistake. Try
amixer cset iface=PCM,name="Sample Clock Source" 3
Yes, that works fine, so I'll add that to rc.local or someplace like that.
I suppose that there must be some way to do this with the hdspmixer settings? Currently I have to run hdspmixer once to get the card turned on at all. Can I somehow capture the current settings into a file and then execute a bunch of commands to get things set up slightly after boot?
thanks,
Mark
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 13 lines · Giuliano Pochini
Quoted 9 lines · Takashi Iwai
Quoted 8 lines
IMHO we should think on a good solution for this problem. Some cards have many channels/voices but the sample rate is common for all of them. Currently the only clean way to manage it is a control that locks the sample rate at a given frequency, but it isn't a nice solution because it requires explicit user intervention. In the echoaudio driver I implemented a kludge that automatically locks the sample frequency in order to avoid unwanted rate changes.
Quoted 7 lines
Quoted 1 line
You can add a control to lock the sample rate (e.g. ICE1712).
Yep, I know, but it's not part of the pcm API: applications do not lock the sample rate themselves. The user has to do it manually. This is why I choosed an alternate solution. If apps were able to lock the rate it would be very useful. It may need some help from the driver, though.
But that sort of application level control is actually what's causing me problems. Mozilla browses around and changes the frequency of the card, independent of what the overall system architecture requires.
Again, I think you're probably right about this issue for a completely stand-alone system, but for a multi-PC system I think some sort of plughw solution that resamples in software when necessary would work better for me and Mozilla.
thanks,
Mark
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
At Tue, 18 Jan 2005 18:08:50 +0100,
Quoted 2 lines · I wrote:
If this works like you want, only the locking is missing...
The attached is an experimental patch to add this feature. You can lock system clock via
amixer cset iface=PCM,name="System Clock Source Locking" on
It's untested, as usual.
Takashi
Index: alsa-kernel/pci/rme9652/hdsp.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/rme9652/hdsp.c,v retrieving revision 1.81
pci/rme9652/hdsp.c +52 -13
@@ -450,6 +450,7 @@u32 control2_register;/* cached value */ u32 creg_spdif;u32 creg_spdif_stream; +int clock_source_locked;char *card_name;/* digiface/multiface */ HDSP_IO_Type io_type;/* ditto, but for code use */ unsigned short firmware_rev;
@@ -2159,7 +2160,7 @@if (val >6 ) val =6 ; }spin_lock_irq (&hdsp->lock); -if (val !=hdsp_clock_source (hdsp)) { +if (val !=hdsp_clock_source (hdsp) && ! hdsp->clock_source_locked) { change = (hdsp_set_clock_source (hdsp, val) ==0 ) ?1 :0 ; }else { change =0 ;
@@ -2168,6 +2169,34 @@return change; } +static int snd_hdsp_info_clock_source_lock (snd_kcontrol_t *kcontrol,snd_ctl_elem_info_t * uinfo) +{ + uinfo->type =SNDRV_CTL_ELEM_TYPE_BOOLEAN ; + uinfo->count =1 ; + uinfo->value.integer.min =0 ; + uinfo->value.integer.max =1 ; +return 0 ; +} + +static int snd_hdsp_get_clock_source_lock (snd_kcontrol_t * kcontrol,snd_ctl_elem_value_t * ucontrol) +{ +hdsp_t *hdsp =snd_kcontrol_chip (kcontrol); + + ucontrol->value.integer.value[0 ] = hdsp->clock_source_locked; +return 0 ; +} + +static int snd_hdsp_put_clock_source_lock (snd_kcontrol_t * kcontrol,snd_ctl_elem_value_t * ucontrol) +{ +hdsp_t *hdsp =snd_kcontrol_chip (kcontrol); +int change; + + change = (int )ucontrol->value.integer.value[0 ] != hdsp->clock_source_locked; +if (change) + hdsp->clock_source_locked = ucontrol->value.integer.value[0 ]; +return change; +} +#define HDSP_DA_GAIN (xname, xindex) \ { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ .name = xname, \
@@ -3129,6 +3158,13 @@HDSP_SPDIF_NON_AUDIO ("IEC958 Non-audio Bit" ,0 ),/* 'Sample Clock Source' complies with the alsa control naming scheme */ HDSP_CLOCK_SOURCE("Sample Clock Source", 0), +{ + .iface =SNDRV_CTL_ELEM_IFACE_PCM , + .name = "Sample Clock Source Locking", + .info = snd_hdsp_info_clock_source_lock, + .get = snd_hdsp_get_clock_source_lock, + .put = snd_hdsp_put_clock_source_lock, +},HDSP_SYSTEM_CLOCK_MODE ("System Clock Mode" ,0 ),HDSP_PREF_SYNC_REF ("Preferred Sync Reference" ,0 ), HDSP_AUTOSYNC_REF("AutoSync Reference", 0),
@@ -3360,6 +3396,7 @@snd_iprintf (buffer,"System Clock Mode: %s\n" , system_clock_mode);snd_iprintf (buffer,"System Clock Frequency: %d\n" , hdsp->system_sample_rate); +snd_iprintf (buffer,"System Clock Locked: %s\n" , hdsp->clock_source_locked ?"Yes" :"No" );snd_iprintf (buffer,"\n" );
@@ -3882,21 +3919,19 @@spin_unlock_irq (&hdsp->lock);return 0 ; - }else { -spin_unlock_irq (&hdsp->lock); }/* how to make sure that the rate matches an externally-set one ? */ -spin_lock_irq (&hdsp->lock); -if ((err =hdsp_set_rate (hdsp,params_rate (params),0 )) <0 ) { -spin_unlock_irq (&hdsp->lock); -_snd_pcm_hw_param_setempty (params,SNDRV_PCM_HW_PARAM_RATE ); -return err; - }else { -spin_unlock_irq (&hdsp->lock); +if (! hdsp->clock_source_locked) { +if ((err =hdsp_set_rate (hdsp,params_rate (params),0 )) <0 ) { +spin_unlock_irq (&hdsp->lock); +_snd_pcm_hw_param_setempty (params,SNDRV_PCM_HW_PARAM_RATE ); +return err; + } } +spin_unlock_irq (&hdsp->lock);if ((err =hdsp_set_interrupt_interval (hdsp,params_period_size (params))) <0 ) {_snd_pcm_hw_param_setempty (params,SNDRV_PCM_HW_PARAM_PERIOD_SIZE );
@@ -4318,13 +4353,17 @@snd_pcm_hw_constraint_msbits (runtime,0 ,32 ,24 );snd_pcm_hw_constraint_list (runtime,0 ,SNDRV_PCM_HW_PARAM_PERIOD_SIZE , &hdsp_hw_constraints_period_sizes); -if (hdsp->io_type ==H9632 ) { - runtime->hw.channels_min = hdsp->qs_out_channels; - runtime->hw.channels_max = hdsp->ss_out_channels; +if (hdsp->clock_source_locked) { + runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate; + }else if (hdsp->io_type ==H9632 ) { runtime->hw.rate_max =192000 ; runtime->hw.rates =SNDRV_PCM_RATE_KNOT ;snd_pcm_hw_constraint_list (runtime,0 ,SNDRV_PCM_HW_PARAM_RATE , &hdsp_hw_constraints_9632_sample_rates); } +if (hdsp->io_type ==H9632 ) { + runtime->hw.channels_min = hdsp->qs_out_channels; + runtime->hw.channels_max = hdsp->ss_out_channels; + } snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_hdsp_hw_rule_out_channels, hdsp,
Takashi,
Since I'm on a PlanetCCRMA box I don't even have Alsa source code.
It would be quite difficult for me to test this in any short time.
Possibly someone else out there with an HDSP box or card can do this?
Sorry,
Mark
Quoted 140 lines · Takashi Iwai
At Tue, 18 Jan 2005 18:08:50 +0100,
Quoted 2 lines · I wrote:
If this works like you want, only the locking is missing...
The attached is an experimental patch to add this feature. You can lock system clock via
amixer cset iface=PCM,name="System Clock Source Locking" on
It's untested, as usual.
Takashi
Index:
alsa-kernel/pci/rme9652/hdsp.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/rme9652/hdsp.c,v retrieving revision 1.81
diff -u -r1.81hdsp.cpci/rme9652/hdsp.c 18 Jan 2005 17:44:54 -0000 renamed from pci/rme9652/hdsp.c 14 Jan 2005 19:50:48 -0000 1.81 +48
-13@@ -450,6 +450,7 @@ u32 control2_register; /* cached value */ u32 creg_spdif; u32 creg_spdif_stream; + int clock_source_locked; char *card_name; /* digiface/multiface */ HDSP_IO_Type io_type; /* ditto, but for code use */ unsigned short firmware_rev;@@ -2159,7 +2160,7 @@ if (val > 6) val = 6; } spin_lock_irq(&hdsp->lock); - if (val != hdsp_clock_source(hdsp)) { + if (val != hdsp_clock_source(hdsp) && ! hdsp->clock_source_locked) { change = (hdsp_set_clock_source(hdsp, val) == 0) ? 1 : 0; } else { change = 0;@@ -2168,6 +2169,34 @@ return change; } +static int snd_hdsp_info_clock_source_lock(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int snd_hdsp_get_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +{ + hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + + ucontrol->value.integer.value[0] = hdsp->clock_source_locked; + return 0; +} + +static int snd_hdsp_put_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +{ + hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + int change; + + change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked; + if (change) + hdsp->clock_source_locked = ucontrol->value.integer.value[0]; + return change; +} + #define HDSP_DA_GAIN(xname, xindex) \ { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ .name = xname, \@@ -3129,6 +3158,13 @@ HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0), /* 'Sample Clock Source' complies with the alsa control naming scheme */ HDSP_CLOCK_SOURCE("Sample Clock Source", 0), +{ + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = "Sample Clock Source Locking", + .info = snd_hdsp_info_clock_source_lock, + .get = snd_hdsp_get_clock_source_lock, + .put = snd_hdsp_put_clock_source_lock, +}, HDSP_SYSTEM_CLOCK_MODE("System Clock Mode", 0), HDSP_PREF_SYNC_REF("Preferred Sync Reference", 0), HDSP_AUTOSYNC_REF("AutoSync Reference", 0),@@ -3360,6 +3396,7 @@ snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode); snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate); + snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No"); snd_iprintf(buffer, "\n");@@ -3882,21 +3919,19 @@ spin_unlock_irq(&hdsp->lock); return 0; - } else { - spin_unlock_irq(&hdsp->lock); } /* how to make sure that the rate matches an externally-set one ? */ - spin_lock_irq(&hdsp->lock); - if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) { - spin_unlock_irq(&hdsp->lock); - _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE); - return err; - } else { - spin_unlock_irq(&hdsp->lock); + if (! hdsp->clock_source_locked) { + if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) { + spin_unlock_irq(&hdsp->lock); + _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE); + return err; + } } + spin_unlock_irq(&hdsp->lock); if ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) { _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);@@ -4318,13 +4353,17 @@ snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hdsp_hw_constraints_period_sizes); - if (hdsp->io_type == H9632) { - runtime->hw.channels_min = hdsp->qs_out_channels; - runtime->hw.channels_max = hdsp->ss_out_channels; + if (hdsp->clock_source_locked) { + runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate; + } else if (hdsp->io_type == H9632) { runtime->hw.rate_max = 192000;
pci/rme9652/hdsp.c 18 Jan 2005 17:44:54 -0000 line 4369
Quoted 10 lines
pci/rme9652/hdsp.c 18 Jan 2005 17:44:54 -0000 renamed from pci/rme9652/hdsp.c 14 Jan 2005 19:50:48 -0000 1.81 +4
-0runtime->hw.rates = SNDRV_PCM_RATE_KNOT; snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdsp_hw_constraints_9632_sample_rates); } + if (hdsp->io_type == H9632) { + runtime->hw.channels_min = hdsp->qs_out_channels; + runtime->hw.channels_max = hdsp->ss_out_channels; + } snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, snd_hdsp_hw_rule_out_channels, hdsp,
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
At Tue, 18 Jan 2005 09:45:41 -0800,
Quoted 23 lines · Mark Knecht
Quoted 13 lines · Giuliano Pochini
Quoted 9 lines · Takashi Iwai
Quoted 8 lines
IMHO we should think on a good solution for this problem. Some cards have many channels/voices but the sample rate is common for all of them. Currently the only clean way to manage it is a control that locks the sample rate at a given frequency, but it isn't a nice solution because it requires explicit user intervention. In the echoaudio driver I implemented a kludge that automatically locks the sample frequency in order to avoid unwanted rate changes.
Quoted 7 lines
Quoted 1 line
You can add a control to lock the sample rate (e.g. ICE1712).
Yep, I know, but it's not part of the pcm API: applications do not lock the sample rate themselves. The user has to do it manually. This is why I choosed an alternate solution. If apps were able to lock the rate it would be very useful. It may need some help from the driver, though.
Quoted 8 lines
But that sort of application level control is actually what's causing me problems. Mozilla browses around and changes the frequency of the card, independent of what the overall system architecture requires.
Again, I think you're probably right about this issue for a completely stand-alone system, but for a multi-PC system I think some sort of plughw solution that resamples in software when necessary would work better for me and Mozilla.
When the rate is locked in the system (as in my patch), plughw should work as you expected.
Takashi
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 11 lines · Takashi Iwai
Quoted 4 lines
Again, I think you're probably right about this issue for a completely stand-alone system, but for a multi-PC system I think some sort of plughw solution that resamples in software when necessary would work better for me and Mozilla.
When the rate is locked in the system (as in my patch), plughw should work as you expected.
Takashi
Great! I hope we can find someone to test this out and get it into the main Alsa flow. Then when it shows up through the Planet I'd be able to test it out.
Thanks for your help,
Mark
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 8 lines · Mark Knecht
But that sort of application level control is actually what's causing me problems. Mozilla browses around and changes the frequency of the card, independent of what the overall system architecture requires.
Again, I think you're probably right about this issue for a completely stand-alone system, but for a multi-PC system I think some sort of plughw solution that resamples in software when necessary would work better for me and Mozilla.
Mozilla is not the problem, most likely it's Flash which uses OSS to play sounds. Unfortunately Mozilla can't play sounds at all, which means many of my favorite web sites like http://getyourasstomars.com
don't work.
Lee
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 10 lines · Lee Revell
Quoted 8 lines · Mark Knecht
But that sort of application level control is actually what's causing me problems. Mozilla browses around and changes the frequency of the card, independent of what the overall system architecture requires.
Again, I think you're probably right about this issue for a completely stand-alone system, but for a multi-PC system I think some sort of plughw solution that resamples in software when necessary would work better for me and Mozilla.
Quoted 7 lines
Mozilla is not the problem, most likely it's Flash which uses OSS to play sounds. Unfortunately Mozilla can't play sounds at all, which means many of my favorite web sites like http://getyourasstomars.com
don't work.Lee
OK, 'Mozilla' as a term is far too broad, and in my case it's only an example of when this problem can happen. It also has happened when I fire up some Gnome or KDE game, but what's strange is it doesn't happen every time I do it. Don't ask me what that's about.
But, true, Mozilla doesn't play audio. I have Shockwave Flash and Quicktime installed. QT comes from an iTunes installation under Crossover Office I suppose...
thanks,
Mark
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 5 lines · Mark Knecht
However if I open Mozilla and browse around the Pro Tools side starts telling me that the ADAT clock is invalid. My suspicion is that the web page I went to in Mozilla has some sort of audio content on it and it's not encoded at the frequency I'm running at so Mozilla tries to change the frequency of the card to adjust.
If you don't care about sound in Mozilla(/Flash), you could load the snd-dummy driver and redirect the /dev/dsp symlink to that 'card' ("ln -sf /dev/dsp1 /dev/dsp", assuming the card number is 1).
HTH
Clemens
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 10 lines · On 18-Jan-2005 Takashi Iwai wrote:
Quoted 6 lines
Quoted 1 line
You can add a control to lock the sample rate (e.g. ICE1712).
Yep, I know, but it's not part of the pcm API: applications do not lock the sample rate themselves. The user has to do it manually. This is why I choosed an alternate solution. If apps were able to lock the rate it would be very useful. It may need some help from the driver, though.
I think this is above the PCM API since this influences the whole system. It's fine to add a new API call in alsa-lib, just as a wrapper to toggle such a control, though...
My driver workarounds the problem this way:
When opencount==1 the app can change the rate freely. When opencount>1 the app can change the rate only if it has not been set yet.pcm_open() always returns the whole frequency range. There is a rule that does rate_min=rate_max=current_rate when the user cannot change the sample rate.
This solves all common cases:
1- trivial case:
open, set_rate, play, close
2- single app, two substreams:
open(1), open(2), set_rate(1), set_rate(2), ...
open(1), set_rate(1), open(2), set_rate(2), ...3- two apps:
A B
open
set_rate(44)
... open
... set_rate(48) -> sets 44
... play
close ...
set_rate(48) -> sets 48
...Of course this method doesn't solve completely the problem Mark is having, because it doesn't warrant that the rate stays at 48K always.
--
Giuliano.
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
At Wed, 19 Jan 2005 10:07:18 +0100 (MET),
Quoted 11 lines · Clemens Ladisch
Quoted 5 lines · Mark Knecht
However if I open Mozilla and browse around the Pro Tools side starts telling me that the ADAT clock is invalid. My suspicion is that the web page I went to in Mozilla has some sort of audio content on it and it's not encoded at the frequency I'm running at so Mozilla tries to change the frequency of the card to adjust.
If you don't care about sound in Mozilla(/Flash), you could load the snd-dummy driver and redirect the
/dev/dspsymlink to that 'card' ("ln -sf/dev/dsp1/dev/dsp", assuming the card number is 1).
This reminds me that accessing to the PCM device is exclusive on HDSP. So, it might be really better to disable OSS access in this way.
Takashi
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
Quoted 7 lines · Clemens Ladisch
Quoted 5 lines · Mark Knecht
However if I open Mozilla and browse around the Pro Tools side starts telling me that the ADAT clock is invalid. My suspicion is that the web page I went to in Mozilla has some sort of audio content on it and it's not encoded at the frequency I'm running at so Mozilla tries to change the frequency of the card to adjust.
Quoted 8 lines
If you don't care about sound in Mozilla(/Flash), you could load the snd-dummy driver and redirect the
/dev/dspsymlink to that 'card' ("ln -sf/dev/dsp1/dev/dsp", assuming the card number is 1).HTH
Clemens
Clemens,
Hi. No, on the contrary, I do care about Mozilla having audio
access. From this thread I think the set of features people like me would be looking for would be something like this:
1) When Alsa is started the sound card comes up running in a known frequency. Solved with an amixer command in rc.local or some other config file.
2) When Alsa is started the sound card comes up with a default set of mixer values. Not sure how to solve this yet for the HDSP 9652 but I presume another set of amixer commands may do this also.
3) When browsing the web, playing games or doing some other set of "normal everyday user" functions, audio commands from the application will not change the frequency of the card. I presume that this *might* be accomplished with some new default device in my .asoundrc file and using the plughw macro and software resampling, along with some capability like Takashi's modification to lock the sample rate.
4) When a special audio control app like qjackctl initializes Jack then Jack can change the sample rate of the card. This allows me to have the Linux box as the main sample rate controller over the network when it needs to be.
I think the above set of ideas would be pretty much what I'm
looking for, but that still needs to be discussed a bit before anyone starts making major changes.
Thanks!
- Mark
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl
Quoted 25 lines · Patrick Shirkey
Quoting Mark Knecht <[email protected]>:
Quoted 9 lines
I guess I'm wondering if there isn't some .asoundrc magic that could be done in my Linux account on this machine that would tell all applications (other than Jack for now) to use some virtual device that handles all frequencies. If that virtual device was the default and the resampling (for Mozilla/games/whatever) was done in software and the sound cards frequency was never changed then I think things would work much better.
I think you can use default as the device name in .asoundrc and it will be used as the default device for all apps.
Then just give it a plughw instead of hw
ex.
pcm.default {
type plughw
card card1
device 0
}
Quoted 5 lines
ctl.default {
type hw
card 0
}
Patrick,
This was interesting. With this file in place the card was locked
into 48KHz and the controls in hdspconfig wouldn't change it. I wonder why? Did this allow Alsa to lock up the card so that even hdspconf couldn't get to it? If so that's going a bit too far I think.
As soon as I removed the file hdspconf worked again...
Thansk for the ideas. I think they may be part of the solution eventually.
- Mark
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl
I think I understand your issue, but I'm not sure I like your solution. Personally, I don't want the sound frequency adjusted in software or by a cheap soundcard. This transformation introduces noise and/or distortions into the sound. I'm using ALSA to drive a home-theater PC (PVR) setup and want the purest sound output I can get from a PC to my stereo receiver. I wish I had an alternative solution to suggest. Please correct me if I've been misled here...
Russ
Quoted 51 lines
Quoted 7 lines · Clemens Ladisch
Quoted 5 lines · Mark Knecht
However if I open Mozilla and browse around the Pro Tools side starts telling me that the ADAT clock is invalid. My suspicion is that the web page I went to in Mozilla has some sort of audio content on it and it's not encoded at the frequency I'm running at so Mozilla tries to change the frequency of the card to adjust.
Quoted 8 lines
If you don't care about sound in Mozilla(/Flash), you could load the snd-dummy driver and redirect the
/dev/dspsymlink to that 'card' ("ln -sf/dev/dsp1/dev/dsp", assuming the card number is 1).HTH
ClemensClemens,
Hi. No, on the contrary, I do care about Mozilla having audio
access. From this thread I think the set of features people like me would be looking for would be something like this:1) When Alsa is started the sound card comes up running in a known frequency. Solved with an amixer command in rc.local or some other config file.
2) When Alsa is started the sound card comes up with a default set of mixer values. Not sure how to solve this yet for the HDSP 9652 but I presume another set of amixer commands may do this also.
3) When browsing the web, playing games or doing some other set of "normal everyday user" functions, audio commands from the application will not change the frequency of the card. I presume that this *might* be accomplished with some new default device in my .asoundrc file and using the plughw macro and software resampling, along with some capability like Takashi's modification to lock the sample rate.
4) When a special audio control app like qjackctl initializes Jack then Jack can change the sample rate of the card. This allows me to have the Linux box as the main sample rate controller over the network when it needs to be.
I think the above set of ideas would be pretty much what I'm
looking for, but that still needs to be discussed a bit before anyone starts making major changes.Thanks!
- Mark
Quoted 10 lines
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl
Quoted 9 lines · Russ Pridemore
I think I understand your issue, but I'm not sure I like your solution. Personally, I don't want the sound frequency adjusted in software or by a cheap soundcard. This transformation introduces noise and/or distortions into the sound. I'm using ALSA to drive a home-theater PC (PVR) setup and want the purest sound output I can get from a PC to my stereo receiver. I wish I had an alternative solution to suggest. Please correct me if I've been misled here...
Russ
Yeah, I think you're off target. #1 issue is that by default Alsa works whatever way it works today. Nothing changes. That way in a SINGLE PC environment, where you want the best sound quality, the card changes frequency just like it does today. Nothing changes and you still get the best operation for what your usage model is.
My suggestion is for a different usage model and most specifically where you have multiple PCs talking to each other. (I.e. - recording studio, project studio, composer) In this model we can use multiple PCs and not have frequencies bouncing around just becasue a single application ononly one PC decides it wants to operate at a different frequency. In this case I envision that you enable an OPTION and then the system acts I said earlier.
Hope that helps,
Mark
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl