* Usb audio - unsuported sampling rates
@ 2012-07-10 5:25 Gordon Dilan
2012-07-10 6:53 ` Daniel Mack
0 siblings, 1 reply; 7+ messages in thread
From: Gordon Dilan @ 2012-07-10 5:25 UTC (permalink / raw)
To: alsa-devel
Hello,
I'm using an usb mic which(according to it's producer should support up to
48kHz sampling rate). The problem is ALSA allows me to use only 16 kHz for
this device. I do not want to resample the data, I want to sample it at
48kHz in order to be able to record some high pitch sounds 18-20kHz.
I would want to try to do any modifications necessary in order to try
support 48kHz, but I'm not sure where to start.
Some information:
cat /proc/asound/modules
...
1 snd_usb_audio
arecord --list-devices
**** List of CAPTURE Hardware Devices ****
....
card 1: CameraB409241 [USB Camera-B4.09.24.1], device 0: USB Audio [USB
Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
when I try to use: arecord -v -D hw:1,0 -f S16_LE -c 4 -r 48000 gigi.wav
I get this:
Recording WAVE 'gigi.wav' : Signed 16 bit Little Endian, Rate 48000 Hz,
Channels 4
Warning: rate is not accurate (requested = 48000Hz, got = 16000Hz)
please, try the plug plugin
Hardware PCM card 1 'USB Camera-B4.09.24.1' device 0 subdevice 0
Its setup is:
stream : CAPTURE
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 4
rate : 16000
exact rate : 16000 (16000/1)
msbits : 16
buffer_size : 8000
period_size : 2000
period_time : 125000
tstamp_mode : NONE
period_step : 1
avail_min : 2000
period_event : 0
start_threshold : 1
stop_threshold : 8000
silence_threshold: 0
silence_size : 0
boundary : 2097152000
appl_ptr : 0
hw_ptr : 0
Any sampling rate I would try higher or lower than 16kHz, I will always get
16000 kHz.
Some more information:
lsusb
Bus 001 Device 007: ID 1415:2000 Nam Tai E&E Products Ltd. or OmniVision
Technologies, Inc. Sony Playstation Eye
lsusb -t
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
|__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
|__ Port 2: Dev 7, If 0, Class=vend., Driver=ov534, 480M
|__ Port 2: Dev 7, If 1, Class=audio, Driver=snd-usb-audio, 480M
|__ Port 2: Dev 7, If 2, Class=audio, Driver=snd-usb-audio, 480M
At the moment I'm looking inside ALSA's source code to try to see from
where this limitation of 16000kHz for my device appears, but I have to
admit that I'm kind of lost.
Any pointers on what direction should I go to try make my desired rate
supported would be greatly appreciated!
Thank you and best regards,
Gordon
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Usb audio - unsuported sampling rates
2012-07-10 5:25 Usb audio - unsuported sampling rates Gordon Dilan
@ 2012-07-10 6:53 ` Daniel Mack
2012-07-10 18:57 ` Gordon Dilan
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Mack @ 2012-07-10 6:53 UTC (permalink / raw)
To: alsa-devel; +Cc: gordon.dilan
Hi,
On 10.07.2012 07:25, Gordon Dilan wrote:
> I'm using an usb mic which(according to it's producer should support up to
> 48kHz sampling rate). The problem is ALSA allows me to use only 16 kHz for
> this device. I do not want to resample the data, I want to sample it at
> 48kHz in order to be able to record some high pitch sounds 18-20kHz.
>
> I would want to try to do any modifications necessary in order to try
> support 48kHz, but I'm not sure where to start.
[...]
> Some more information:
> lsusb
> Bus 001 Device 007: ID 1415:2000 Nam Tai E&E Products Ltd. or OmniVision
> Technologies, Inc. Sony Playstation Eye
>
> lsusb -t
Please also provide the output of 'lsusb -v'.
> /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
> |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
> |__ Port 2: Dev 7, If 0, Class=vend., Driver=ov534, 480M
> |__ Port 2: Dev 7, If 1, Class=audio, Driver=snd-usb-audio, 480M
> |__ Port 2: Dev 7, If 2, Class=audio, Driver=snd-usb-audio, 480M
>
>
> At the moment I'm looking inside ALSA's source code to try to see from
> where this limitation of 16000kHz for my device appears, but I have to
> admit that I'm kind of lost.
> Any pointers on what direction should I go to try make my desired rate
> supported would be greatly appreciated!
The device is queried for its supported sample rates during probe using
class-specific commands. If it doesn't return all rates that are
actually supported, we need to add a quirk and override this list.
The list of known sample rates is included in
/proc/asound/card1/stream0. What does that show for you?
Daniel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Usb audio - unsuported sampling rates
2012-07-10 6:53 ` Daniel Mack
@ 2012-07-10 18:57 ` Gordon Dilan
2012-07-10 21:33 ` Daniel Mack
0 siblings, 1 reply; 7+ messages in thread
From: Gordon Dilan @ 2012-07-10 18:57 UTC (permalink / raw)
To: Daniel Mack; +Cc: alsa-devel
Hello Daniel,
Thank you very much for your reply !!!
Please see below.
On Tue, Jul 10, 2012 at 9:53 AM, Daniel Mack <zonque@gmail.com> wrote:
> Hi,
>
> On 10.07.2012 07:25, Gordon Dilan wrote:
> > I'm using an usb mic which(according to it's producer should support up
> to
> > 48kHz sampling rate). The problem is ALSA allows me to use only 16 kHz
> for
> > this device. I do not want to resample the data, I want to sample it at
> > 48kHz in order to be able to record some high pitch sounds 18-20kHz.
> >
> > I would want to try to do any modifications necessary in order to try
> > support 48kHz, but I'm not sure where to start.
>
> [...]
>
> > Some more information:
> > lsusb
> > Bus 001 Device 007: ID 1415:2000 Nam Tai E&E Products Ltd. or OmniVision
> > Technologies, Inc. Sony Playstation Eye
> >
> > lsusb -t
>
> Please also provide the output of 'lsusb -v'.
>
I've appended the output at the end of this mail.
Since the output is long, I've also put it on pastebin:
http://pastebin.com/tpY1thht
> > /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
> > |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
> > |__ Port 2: Dev 7, If 0, Class=vend., Driver=ov534, 480M
> > |__ Port 2: Dev 7, If 1, Class=audio, Driver=snd-usb-audio, 480M
> > |__ Port 2: Dev 7, If 2, Class=audio, Driver=snd-usb-audio, 480M
> >
> >
> > At the moment I'm looking inside ALSA's source code to try to see from
> > where this limitation of 16000kHz for my device appears, but I have to
> > admit that I'm kind of lost.
> > Any pointers on what direction should I go to try make my desired rate
> > supported would be greatly appreciated!
>
> The device is queried for its supported sample rates during probe using
> class-specific commands. If it doesn't return all rates that are
> actually supported, we need to add a quirk and override this list.
>
> The list of known sample rates is included in
> /proc/asound/card1/stream0. What does that show for you?
>
>
cat /proc/asound/card1/stream0
OmniVision Technologies, Inc. USB Camera-B4.09.24.1 at
usb-0000:00:1a.0-1.2, hi : USB Audio
Capture:
Status: Stop
Interface 2
Altset 1
Format: S16_LE
Channels: 4
Endpoint: 4 IN (ASYNC)
Rates: 16000
Data packet interval: 1000 us
>
>
> Daniel
>
I mention that while trying to record using arecord I see in
/var/logs/messages: "kernel: [20914.414286] ALSA clock.c:242 current rate
177346 is different from the runtime rate 16000"
The current rate reported here varies for each call of arecord. Eg it can
be: 676371, 508390, 139882 etc. The values reported are too high to be
real.
lsusb -v
Bus 001 Device 008: ID 1415:2000 Nam Tai E&E Products Ltd. or OmniVision
Technologies, Inc. Sony Playstation Eye
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x1415 Nam Tai E&E Products Ltd. or OmniVision
Technologies, Inc.
idProduct 0x2000 Sony Playstation Eye
bcdDevice 2.00
iManufacturer 1 OmniVision Technologies, Inc.
iProduct 2 USB Camera-B4.09.24.1
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 142
bNumInterfaces 3
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 10
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 42
bInCollection 1
baInterfaceNr( 0) 2
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Microphone
bAssocTerminal 2
bNrChannels 4
wChannelConfig 0x0000
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 1
bSourceID 3
iTerminal 0
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 3
bSourceID 1
bControlSize 1
bmaControls( 0) 0x00
bmaControls( 1) 0x02
Volume Control
bmaControls( 2) 0x02
Volume Control
bmaControls( 3) 0x02
Volume Control
bmaControls( 4) 0x02
Volume Control
iFeature 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 2
bDelay 1 frames
wFormatTag 1 PCM
AudioStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 4
bSubframeSize 2
bBitResolution 16
bSamFreqType 1 Discrete
tSamFreq[ 0] 16000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0300 1x 768 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioControl Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0 Undefined
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0000
(Bus Powered)
Once again thank you,
Gordon
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Usb audio - unsuported sampling rates
2012-07-10 18:57 ` Gordon Dilan
@ 2012-07-10 21:33 ` Daniel Mack
2012-07-12 7:44 ` Daniel Mack
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Mack @ 2012-07-10 21:33 UTC (permalink / raw)
To: Gordon Dilan; +Cc: alsa-devel
Hi Gordon,
On 10.07.2012 20:57, Gordon Dilan wrote:
0
> Interface Descriptor:
> bLength 9
> bDescriptorType 4
> bInterfaceNumber 2
> bAlternateSetting 1
> bNumEndpoints 1
> bInterfaceClass 1 Audio
> bInterfaceSubClass 2 Streaming
> bInterfaceProtocol 0
> iInterface 0
> AudioStreaming Interface Descriptor:
> bLength 7
> bDescriptorType 36
> bDescriptorSubtype 1 (AS_GENERAL)
> bTerminalLink 2
> bDelay 1 frames
> wFormatTag 1 PCM
> AudioStreaming Interface Descriptor:
> bLength 11
> bDescriptorType 36
> bDescriptorSubtype 2 (FORMAT_TYPE)
> bFormatType 1 (FORMAT_TYPE_I)
> bNrChannels 4
> bSubframeSize 2
> bBitResolution 16
> bSamFreqType 1 Discrete
> tSamFreq[ 0] 16000
The interface only reports this single sample rate. If the vendor claims
that there are in fact more, it would be good to know which ones.
Then we can add a quirk to parse_audio_format_rates_v1() in
sound/usb/format.c - that shouldn't be too hard.
Daniel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Usb audio - unsuported sampling rates
2012-07-10 21:33 ` Daniel Mack
@ 2012-07-12 7:44 ` Daniel Mack
2012-07-14 9:01 ` Gordon Dilan
0 siblings, 1 reply; 7+ messages in thread
From: Daniel Mack @ 2012-07-12 7:44 UTC (permalink / raw)
To: Gordon Dilan; +Cc: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 1517 bytes --]
On 10.07.2012 23:33, Daniel Mack wrote:
> Hi Gordon,
>
> On 10.07.2012 20:57, Gordon Dilan wrote:
> 0
>> Interface Descriptor:
>> bLength 9
>> bDescriptorType 4
>> bInterfaceNumber 2
>> bAlternateSetting 1
>> bNumEndpoints 1
>> bInterfaceClass 1 Audio
>> bInterfaceSubClass 2 Streaming
>> bInterfaceProtocol 0
>> iInterface 0
>> AudioStreaming Interface Descriptor:
>> bLength 7
>> bDescriptorType 36
>> bDescriptorSubtype 1 (AS_GENERAL)
>> bTerminalLink 2
>> bDelay 1 frames
>> wFormatTag 1 PCM
>> AudioStreaming Interface Descriptor:
>> bLength 11
>> bDescriptorType 36
>> bDescriptorSubtype 2 (FORMAT_TYPE)
>> bFormatType 1 (FORMAT_TYPE_I)
>> bNrChannels 4
>> bSubframeSize 2
>> bBitResolution 16
>> bSamFreqType 1 Discrete
>> tSamFreq[ 0] 16000
>
> The interface only reports this single sample rate. If the vendor claims
> that there are in fact more, it would be good to know which ones.
>
> Then we can add a quirk to parse_audio_format_rates_v1() in
> sound/usb/format.c - that shouldn't be too hard.
Something like the patch below could help. Can you try this?
Daniel
[-- Attachment #2: playstation-eye-samplerates.diff --]
[-- Type: text/x-patch, Size: 622 bytes --]
diff --git a/sound/usb/format.c b/sound/usb/format.c
index ddfef57..ce64a5b 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -158,6 +158,17 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
return -1;
}
+ /*
+ * Sony's "Playstation Eye" microphone only reports one sample rate,
+ * but can in fact handle more.
+ */
+ if (chip->usb_id == USB_ID(0x1415, 0x2000) && fp->altsetting == 1) {
+ fp->rates = SNDRV_PCM_RATE_CONTINUOUS;
+ fp->rate_min = 16000;
+ fp->rate_min = 48000;
+ return 0;
+ }
+
if (nr_rates) {
/*
* build the rate table and bitmap flags
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: Usb audio - unsuported sampling rates
2012-07-12 7:44 ` Daniel Mack
@ 2012-07-14 9:01 ` Gordon Dilan
2016-02-12 13:59 ` Jacobson
0 siblings, 1 reply; 7+ messages in thread
From: Gordon Dilan @ 2012-07-14 9:01 UTC (permalink / raw)
To: Daniel Mack; +Cc: alsa-devel
Hello Daniel,
Thank you very much for your help and sorry for the late answer. I was
without internet access for the last few days.
I have tried the patch that you sent me(with a minor modification:
fp->rate_max(instead of min) = 48000; ).
If I try to record using 48kHz and then playback, it will playback in "fast
speed", voices being recorded as "chipmunks".
Only at 16000Hz it records at "normal speed".
So it seems that the recording is still done in fact at 16kHz, even though
now the driver appears to support sampling rates between 16000-48000Hz.
Dmesg is also showing me this everytime I try to record using the
microphone(These messages appeared even without the driver modification):
[ 165.364728] ALSA clock.c:242 current rate 175902 is different from the
runtime rate 48000
[ 171.838509] ALSA clock.c:242 current rate 51816 is different from the
runtime rate 48000
[ 206.950822] ALSA clock.c:242 current rate 281039 is different from the
runtime rate 48000
[ 968.713856] ALSA clock.c:242 current rate 6096811 is different from the
runtime rate 48000
Once again, thank you very much for your support!
Best Regards,
Gordon
On Thu, Jul 12, 2012 at 3:44 AM, Daniel Mack <zonque@gmail.com> wrote:
> On 10.07.2012 23:33, Daniel Mack wrote:
> > Hi Gordon,
> >
> > On 10.07.2012 20:57, Gordon Dilan wrote:
> > 0
> >> Interface Descriptor:
> >> bLength 9
> >> bDescriptorType 4
> >> bInterfaceNumber 2
> >> bAlternateSetting 1
> >> bNumEndpoints 1
> >> bInterfaceClass 1 Audio
> >> bInterfaceSubClass 2 Streaming
> >> bInterfaceProtocol 0
> >> iInterface 0
> >> AudioStreaming Interface Descriptor:
> >> bLength 7
> >> bDescriptorType 36
> >> bDescriptorSubtype 1 (AS_GENERAL)
> >> bTerminalLink 2
> >> bDelay 1 frames
> >> wFormatTag 1 PCM
> >> AudioStreaming Interface Descriptor:
> >> bLength 11
> >> bDescriptorType 36
> >> bDescriptorSubtype 2 (FORMAT_TYPE)
> >> bFormatType 1 (FORMAT_TYPE_I)
> >> bNrChannels 4
> >> bSubframeSize 2
> >> bBitResolution 16
> >> bSamFreqType 1 Discrete
> >> tSamFreq[ 0] 16000
> >
> > The interface only reports this single sample rate. If the vendor claims
> > that there are in fact more, it would be good to know which ones.
> >
> > Then we can add a quirk to parse_audio_format_rates_v1() in
> > sound/usb/format.c - that shouldn't be too hard.
>
> Something like the patch below could help. Can you try this?
>
>
> Daniel
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Usb audio - unsuported sampling rates
2012-07-14 9:01 ` Gordon Dilan
@ 2016-02-12 13:59 ` Jacobson
0 siblings, 0 replies; 7+ messages in thread
From: Jacobson @ 2016-02-12 13:59 UTC (permalink / raw)
To: alsa-devel
Gordon Dilan <gordon.dilan <at> gmail.com> writes:
>
> Hello Daniel,
>
> Thank you very much for your help and sorry for the late answer. I was
> without internet access for the last few days.
>
> I have tried the patch that you sent me(with a minor modification:
> fp->rate_max(instead of min) = 48000; ).
> If I try to record using 48kHz and then playback, it will playback in
"fast
> speed", voices being recorded as "chipmunks".
> Only at 16000Hz it records at "normal speed".
>
Hi Daniel and Gordon,
Sorry for posting on such an old thread. I have recently started using the
PlayStation Eye for audio processing and I have run into the same issue of
ALSA only allowing the device to capture at 16khz sampling rate when it
should be capable of 48khz. Your last post indicates that even with a
patch, the device only sampled at 16khz and just played the samples faster.
I am just wondering if either of you came up with a solution to this
problem? Was it ever possible to record at a 48khz?
Any help or information would be greatly appreciated.
Thanks,
Jacobson.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-02-12 14:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-10 5:25 Usb audio - unsuported sampling rates Gordon Dilan
2012-07-10 6:53 ` Daniel Mack
2012-07-10 18:57 ` Gordon Dilan
2012-07-10 21:33 ` Daniel Mack
2012-07-12 7:44 ` Daniel Mack
2012-07-14 9:01 ` Gordon Dilan
2016-02-12 13:59 ` Jacobson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.