Author Topic: USB Audio  (Read 4309 times)

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 254
  • -Receive: 49
  • Posts: 1706
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: USB Audio
« Reply #15 on: March 03, 2017, 02:05:40 pm »
Hi

Sorry for jumping into the thread this way.

It can be interesting if you are testing USB Audio devices to list the ones that works with brand, name, model, chipset, hardwareid and include them on the wiki:
http://www.os2world.com/wiki/index.php/Audio_Cards#USB

I'm open for any suggestion to include more working hardware on the wiki. Remember that you can access the wiki with the same user and password of this forum.

Regards

Martin Iturbide
OS2World NewsMaster
... just share the dream.

Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 28
  • Posts: 132
    • View Profile
    • Wim's home page
Re: USB Audio
« Reply #16 on: March 03, 2017, 03:57:45 pm »
Hi Neil,

I bought a Trond USB Audio Adapter, and it works just as Lars said. There is good sound, except for System Sounds.

You might try and convert the system sounds yourself with the IBM Wave Doctor application that I think is part of the IBM Multimedia Presentation Manager Toolkit/2.
\ MMOS2\MMTOOLKT\ NEATSTUF\WVDOC\WVDOC.EXE

Wim
« Last Edit: March 03, 2017, 04:46:18 pm by Wim Brul »

Neil Waldhauer

  • Sr. Member
  • ****
  • Thank You
  • -Given: 6
  • -Receive: 17
  • Posts: 302
    • View Profile
    • Blonde Guy
Re: USB Audio
« Reply #17 on: March 04, 2017, 04:02:43 pm »
I've converted my system sounds to 16-bit, 44.1 KHz. I was going to post the files, but they are over 10 MB zipped.

I used the sox port by Mentore Siesto to convert the files. http://hobbes.nmsu.edu/h-search.php?key=sox&pushbutton=Search

Here is a crude REXX program to convert your files using sox. It shows the options I gave sox to do the work. The documentation for sox is here: http://sox.sourceforge.net/sox.html

Code: [Select]
/* batch file to convert from old style wave files to
   16-bit 44.1 KHz ones. Requires sox to run.
    run from the directory named "sounds"
   */

call SysMkDir '..\SOUND4'

call SysFileTree '*.*', 'wdir.', 'DO'

do i=1 to wdir.0
   soundPointer = pos('sounds', wdir.i)
   say soundPointer wdir.i
   outputFile = overlay('SOUND4', wdir.i, soundPointer)
   call SysMkDir outputFile
   say 'created' outputFile
end
call SysFileTree '*.wav', 'wav.', 'FOS'

do i=1 to wav.0
   soundPointer = pos('sounds', wav.i)
   outputFile = overlay('SOUND4', wav.i, soundPointer)
   'sox' wav.i '-b 16' outputFile 'rate -s -a 44100 dither -s'
   say 'converted' outputFile
end
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Fahrvenugen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 6
  • Posts: 45
    • View Profile
Re: USB Audio
« Reply #18 on: March 04, 2017, 04:55:23 pm »
The CM108 chip in the Trend only appears to support the playback of 16 bit 44.1 and 48kHz PCM data, so the 10 & 20 kHz system audio files sound distorted for that reason, while a frequency converter in the system would fix that, a simpler solution is to replace the system sound files with 16bit 44.1kHz versions.

Good to hear that it is working with the CM108 (as long as the sample rates of the original files are correct).  There is a ton of USB stuff that uses that chipset - from the cheap USB audio dongles that you can find on ebay for $1 to $5, a ton of USB headsets.  I'd also be interested to find out if it works with the Texas Instruments PCM-2900/2902  series chipset which also gets used in a lot of USB audio gear.

Wim Brul

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 28
  • Posts: 132
    • View Profile
    • Wim's home page
Re: USB Audio
« Reply #19 on: March 04, 2017, 06:25:52 pm »
Nice Neil,

I wonder if you would need the following to ensure stereo output:
Code: [Select]
'sox' wav.i '-b 16' outputFile 'channels 2 rate -s -a 44100 dither -s'

Wim

Dave Yeo

  • Hero Member
  • *****
  • Thank You
  • -Given: 8
  • -Receive: 91
  • Posts: 1171
    • View Profile
Re: USB Audio
« Reply #20 on: March 04, 2017, 06:57:26 pm »
You could try compressing the wav files to flac (about 50% compression) or vorbis (10%?) which should still work as system sounds. Easiest is to just right click the wav and use the convert menu.

Lars

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 21
  • Posts: 162
    • View Profile
Re: USB Audio
« Reply #21 on: March 05, 2017, 03:44:51 pm »
....
Actually, supporting 11.025 kHz or 22.05 kHz can be accomplished by inserting zeros in between the samples (3 zeros for 11.025 kHz and 1 zero for 22.05 kHz) and then convolving with a low pass filter window...

There exist sophisticated algorithm for sample rate conversion but we definitely will not need them on OS/2 IMHO. Though putting zeros into the stream I would consider one of the worst solution. A much better and adequate approach (IMHO) would be inserting the same sample a second time for making 22.05 to 44.1 conversion. A slightly better algorithm would be inserting the mean value of two neighbor samples in between.

You did not read properly. I said to add in zeros and THEN to convolve with a low pass filter window. There is nothing sophisticated about that. And using a proper window (say dolph-chebychev) instead of doing linear interpolation gives a much better result at only very little additional cost.

Andi B.

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 12
  • Posts: 321
    • View Profile
Re: USB Audio
« Reply #22 on: March 06, 2017, 09:29:40 am »
Quote
..add in zeros and THEN to convolve with a low pass filter window..
If I understand correctly then this would lower the output level. My suggestions do not change sound level (less than one LSB max.). Low pass filtering is done after the DAC anyway. Absolutely no need to do anything here in software except if you plan high perfomance audio processing. Which I doubt is of any use for OS/2 and is definitely not doable with any of these USB audio toys. 

The simplest solution (doubling each sample for 22.05 to 44.1 conversion) is better than anything you can get out of these creepy USB toys anyway. Even on good sound cards (which are not available for OS/2) you hardly will find someone who can even measure the difference to more sophisticate algorithm at the analog output. And I bet you will not find anyone in the OS/2 community who can hear the difference in a blind test.
« Last Edit: March 06, 2017, 09:32:12 am by Andi B. »

Neil Waldhauer

  • Sr. Member
  • ****
  • Thank You
  • -Given: 6
  • -Receive: 17
  • Posts: 302
    • View Profile
    • Blonde Guy
Re: USB Audio
« Reply #23 on: March 06, 2017, 07:37:20 pm »
I have tried converting to FLAC and OGG just from the context menu. On my eCS 2.2 b2 system, this does not result in a playable file for either format. I understand more work has been done on these codecs.

I tried modifying the sox command to produce 2 channel files. This seems to fix all problems I had with a few files. I tried playing one of the QT games, and early in the play, I got a trap in the USB driver. (see attached photo of trap screen) Converting the sound file eliminates the trap.

Now I an suspicious that any WAV file might need converting unless it is already 2 channel 16 bit 44.1 KHz.

Modified code with new sox invocation that gives stereo
Code: [Select]
/* batch file to convert from old style wave files to
   stereo 16-bit 44.1 KHz ones. Requires sox to run.
   All sounds in the OS/2 multimedia directory are converted
   A backup named IBMSOUND.ZIP is created.
   */

soundDir = SysBootDrive() || '\MMOS2\SOUNDS'
backupZip = SysBootDrive() || '\MMOS2\IBMSOUND.ZIP'

if stream(backupZip, 'c', 'query exists') <> '' then do
   say "No backup created becuase file already exists:" backupZip
end
else do
   'zip -qr' backupZip soundDir
   if rc <> 0 then do
      say "backup file created:" backupZip
   end
end

call SysFileTree soundDir || '\*.wav', 'wav.', 'FOS'

do i=1 to wav.0
   soundPointer = lastpos('.wav', wav.i)
   outputFile = left(wav.i, soundPointer - 1) || '4.wav'
   'sox "' || wav.i || '" -b 16 -c 2 "' || outputFile || '" rate -s -a 44100 dither -s'
   if rc = 0 then do
      say 'converted' filespec('Name', outputFile)
      'copy "' ||  outputFile || '" "' ||  wav.i || '"'
      if rc <> 0 then do
         say 'Error' rc 'updating' wav.i
      end
      'del' outputFile
   end
end

return
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Lars

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 21
  • Posts: 162
    • View Profile
Re: USB Audio
« Reply #24 on: March 06, 2017, 11:15:40 pm »
Yes, I have also experienced this very same trap and even another one. "Your trap" occurs in a frequently used copy routine where the copy routine tries to copy past the end of the segment (compare SI to DSLIM: that's the "end of segment" condition on an attempt to copy in units of 4 Bytes from DS:SI to ES:DI) and even though I have a full system dump for that trap, the dump is broken in a way that I cannot do a stack trace to find out where the error originates. Too bad.

About the other trap I ran into, I know where and why it occurs but I don't yet know what would be the proper solution to fix the error.

By the way: are you using the USB Audio device attached to an external USB 2.0 hub or are you using it in a system that in principle has EHCI only but also a rate matching hub built-in ? Or is this USB Audio device really a USB 2.0 device  (which I doubt) ?

Posting the device descriptor (copied from USBRES.EXE) would help. If the device is USB 1.x, it's a problem with USBEHCD.SYS having to do special processing when handling USB 1.x isochronous devices. That stuff is not really well tested.


« Last Edit: March 06, 2017, 11:49:31 pm by Lars »

Lars

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 21
  • Posts: 162
    • View Profile
Re: USB Audio
« Reply #25 on: March 06, 2017, 11:25:26 pm »
Quote
..add in zeros and THEN to convolve with a low pass filter window..
If I understand correctly then this would lower the output level. My suggestions do not change sound level (less than one LSB max.). Low pass filtering is done after the DAC anyway. Absolutely no need to do anything here in software except if you plan high perfomance audio processing. Which I doubt is of any use for OS/2 and is definitely not doable with any of these USB audio toys. 

The simplest solution (doubling each sample for 22.05 to 44.1 conversion) is better than anything you can get out of these creepy USB toys anyway. Even on good sound cards (which are not available for OS/2) you hardly will find someone who can even measure the difference to more sophisticate algorithm at the analog output. And I bet you will not find anyone in the OS/2 community who can hear the difference in a blind test.

No, if you properly choose the window coefficients, you will not lower the output level, instead it will properly "fill up" the gaps between the original samples. For example, if you properly choose the window coefficients, a DC signal will still be a DC signal with the "gaps filled in" to the very same level as the original samples. I am not sure if this is dramatic but just repeating the samples will lead to distortion that might not be too good for earphones for example. In other words: it might not only be a question of quality.

Neil Waldhauer

  • Sr. Member
  • ****
  • Thank You
  • -Given: 6
  • -Receive: 17
  • Posts: 302
    • View Profile
    • Blonde Guy
Re: USB Audio
« Reply #26 on: March 07, 2017, 01:09:10 am »
By the way: are you using the USB Audio device attached to an external USB 2.0 hub or are you using it in a system that in principle has EHCI only but also a rate matching hub built-in ? Or is this USB Audio device really a USB 2.0 device  (which I doubt) ?

Posting the device descriptor (copied from USBRES.EXE) would help. If the device is USB 1.x, it's a problem with USBEHCD.SYS having to do special processing when handling USB 1.x isochronous devices. That stuff is not really well tested.

Sadly, I do not know what the hardware looks like. All the ports claim to be USB 3.0, yet USBEHCI can still get a USB 2.0 connection on all ports. The computer is a ThinkCentre M92p tiny form factor. I was using one of the rear ports.

I also do not know how to use USBRES to get a device descriptor.
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Lars

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 21
  • Posts: 162
    • View Profile
Re: USB Audio
« Reply #27 on: March 07, 2017, 07:32:57 am »
Open USBRES.EXE (it's in \ecs\bin folder).
Select the device that is the sound device (should be able to guess from the Product name).
Now, right click on the device, "view device report" will show in the appearing context menu.
Click on the context menu entry.
A window "Device Report View" will pop up. Copy everything in the window (can be fairly long and you will need to scroll) and paste it here.

By the way: what driver version of USBEHCD.SYS are you using ? Seems you are using AN 11.14, correct ? Unfortunately, for that I don't have a map file, therefore I cannot locate the point of the trap (it's not at the same CS:IP as the trap that I had even though the error is similar).
You will need to report the trap on the AN bugtracker.


Thanks !
« Last Edit: March 07, 2017, 07:57:13 am by Lars »

Neil Waldhauer

  • Sr. Member
  • ****
  • Thank You
  • -Given: 6
  • -Receive: 17
  • Posts: 302
    • View Profile
    • Blonde Guy
Re: USB Audio
« Reply #28 on: March 07, 2017, 04:52:04 pm »
I looked at the version, and it appears to be Arca Noae 11.12. I will experiment with 10.215 next.

The device report for the sound device is here.

Code: [Select]
<<< Device Description >>>
 Type            : 01
 USB Rev         : 110
 Class           : Reserved (0)
 Subclass        : Reserved (0)
 Protocol        : Reserved (0)
  Device Information is defined at interface Level
 Max. packetsize : 08
 Vendor  ID      : 0D8C
 Product ID      : 0014
 Device Release# : 0100
 Strings:
  Manufacturer Name : C-Media Electronics Inc.
  Product Name      : USB Audio Device
  Serial number     : Not implemented
 Number of Configurations : 1

 Configuration 0 :
  Lenght     : 253
  Name       : <NONE>
  Value      : 1
  Attributes : 0x80
  Power      : 100 mA
  Interfaces : 4

  Interface 0
   Alt Setting : 0
   Name        : <NONE>
   Class       : Audio
   SubClass    : AudioControl
   Protocol    : Not used(0)
   Endpoints   : 0
     Audiocontrol CS Interface Descriptor
     Length  : 10
     Type    : 0x24
     Subtype : 0x01
    Header :
     Audio Device Class Release Number : 0100
     Max size of AudioControl interface descriptor. : 16205
     Number of AudioStreaming and MIDIStreaming interfaces : 2
      1. Streaming interface on Device Interface 1
      2. Streaming interface on Device Interface 2
     Audiocontrol CS Interface Descriptor
    Input Terminal :
     Length  : 12
     Type    : 0x24
     Subtype : 0x02
     Unique Terminal ID       : 1
     Terminal Type            : 0x0101
     Assoc. Terminal ID       : 0
     Number of Log. Channels  : 2
     Spatial channel location : 0x0003
     Name of Channel          : Not Implemented
     Name of Terminal         : Has Index 12(GetString Error -225)
     Audiocontrol CS Interface Descriptor
    Input Terminal :
     Length  : 12
     Type    : 0x24
     Subtype : 0x02
     Unique Terminal ID       : 2
     Terminal Type            : 0x0201
     Assoc. Terminal ID       : 0
     Number of Log. Channels  : 1
     Spatial channel location : 0x0001
     Name of Channel          : Not Implemented
     Name of Terminal         : Has Index 9(GetString Error -225)
     Audiocontrol CS Interface Descriptor
    Output Terminal :
     Length  : 9
     Type    : 0x24
     Subtype : 0x03
     Unique Terminal ID : 6
     Terminal Type      : 0x0301
     Assoc. Terminal ID : 0
     Source ID          : 9
     Name of Terminal   : Not Implemented
     Audiocontrol CS Interface Descriptor
    Output Terminal :
     Length  : 9
     Type    : 0x24
     Subtype : 0x03
     Unique Terminal ID : 7
     Terminal Type      : 0x0101
     Assoc. Terminal ID : 0
     Source ID          : 8
     Name of Terminal   : Not Implemented
     Audiocontrol CS Interface Descriptor
    Selector Unit :
     Length  : 7
     Type    : 0x24
     Subtype : 0x05
     Unique Unit ID    : 8
     Input pins        : 1
      Pin 0 is Connected to Unit 1
      Pin 1 is Connected to Unit 10
     Name of Selector Unit : Has Index 10(GetString Error -225)
     Audiocontrol CS Interface Descriptor
    Feature Unit :
    Length  : 10
    Type    : 36
    Subtype : 6
    Dumped Data :
     09 0F 01 01 02 02
     00 09
     Unique Unit ID  : 9
     Source ID       : 15
     Size of Control Item  : 1
     ControlMap for Master : 0x01
     ControlMap for Channel 1 : 0x02
     ControlMap for Channel 2 : 0x02
     Name of Feature Unit : Has Index 9(GetString Error -225)
     Audiocontrol CS Interface Descriptor
    Feature Unit :
    Length  : 9
    Type    : 36
    Subtype : 6
    Dumped Data :
     0A 02 01 43 00 00
     09
     Unique Unit ID  : 10
     Source ID       : 2
     Size of Control Item  : 1
     ControlMap for Master : 0x43
     ControlMap for Channel 1 : 0x00
     Name of Feature Unit : Has Index 9(GetString Error -225)
     Audiocontrol CS Interface Descriptor
    Feature Unit :
    Length  : 9
    Type    : 36
    Subtype : 6
    Dumped Data :
     0D 02 01 03 00 00
     0D
     Unique Unit ID  : 13
     Source ID       : 2
     Size of Control Item  : 1
     ControlMap for Master : 0x03
     ControlMap for Channel 1 : 0x00
     Name of Feature Unit : Has Index 13(GetString Error -225)
     Audiocontrol CS Interface Descriptor
    Mixer Unit :
     Length  : 13
     Type    : 0x24
     Subtype : 0x04
     Unique Unit ID    : 15
     Input pins        : 2
      Pin 0 is Connected to Unit 2
      Pin 1 is Connected to Unit 1
      Pin 2 is Connected to Unit 13
     Logical Output channels  : 3
     Spatial channel location : 0x0000
     Name of 1st log. Channel : Not Implemented
     Name of Mixer Unit : Has Index 4(GetString Error -225)

  Interface 1
   Alt Setting : 0
   Name        : <NONE>
   Class       : Audio
   SubClass    : Streaming Audio
   Protocol    : Not used(0)
   Endpoints   : 0

  Interface 1
   Alt Setting : 1
   Name        : <NONE>
   Class       : Audio
   SubClass    : Streaming Audio
   Protocol    : Not used(0)
   Endpoints   : 1
    General Endpoint Information:
     Length  : 7
     Type    : 0x24
     Subtype : 0x01
     Controls:
      - Sampling Frequency
      - Locktime 16323 ms
     Audiostreaming CS Interface Descriptor
     Format Type:
     Length  : 14
     Type    : 0x24
     Subtype : 0x02
      Physical Channels : 2
      Subframe size     : 2
      Bits used         : 16
      Supported Frequencies
       - 48000Hz
       - 44100Hz
       - 66825Hz

   Endpoint 0:
    Address     : 01
    Attributes  : 09
    Packetsize  : 00C8
    Interval    : 1
    General Endpoint Information:
     Length  : 7
     Type    : 0x25
     Subtype : 0x01
     Controls:
      - Sampling Frequency
      - Locktime 16353 ms

  Interface 2
   Alt Setting : 0
   Name        : <NONE>
   Class       : Audio
   SubClass    : Streaming Audio
   Protocol    : Not used(0)
   Endpoints   : 0

  Interface 2
   Alt Setting : 1
   Name        : <NONE>
   Class       : Audio
   SubClass    : Streaming Audio
   Protocol    : Not used(0)
   Endpoints   : 1
    General Endpoint Information:
     Length  : 7
     Type    : 0x24
     Subtype : 0x01
     Controls:
      - Sampling Frequency
      - Pitch
      - Locktime 16378 ms
     Audiostreaming CS Interface Descriptor
     Format Type:
     Length  : 14
     Type    : 0x24
     Subtype : 0x02
      Physical Channels : 1
      Subframe size     : 2
      Bits used         : 16
      Supported Frequencies
       - 48000Hz
       - 44100Hz
       - 8520969Hz

   Endpoint 0:
    Address     : 82
    Attributes  : 0D
    Packetsize  : 0064
    Interval    : 1
    General Endpoint Information:
     Length  : 7
     Type    : 0x25
     Subtype : 0x01
     Controls:
      - Sampling Frequency
      - Locktime 16408 (No Unit)

  Interface 3
   Alt Setting : 0
   Name        : <NONE>
   Class       : Human Interface Device (HID)
   SubClass    : No Subclass
   Protocol    : None
   Endpoints   : 1
   HID Description:
    Length          : 09
    HID Rel. Number : 100
    Country Code    : 0000
    Descriptors     : 1
     Type          : 22
     Length        : 0
     Type          : 07
     Length        : 0

   Endpoint 0:
    Address     : 87
    Attributes  : 03
    Packetsize  : 0004
    Interval    : 2

I have now tried 10.215, and it does not trap while playing the 1-channel 16-bit 44.1 KHz sound file from Blubbels game. It still sounds wrong until converted, but it doesn't trap
« Last Edit: March 07, 2017, 05:17:11 pm by Neil Waldhauer »
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Lars

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 21
  • Posts: 162
    • View Profile
Re: USB Audio
« Reply #29 on: March 07, 2017, 06:58:14 pm »
HI Neil,

thanks for posting the device descriptor. I seem to have the very same (inside), I have the sample rates etc. and for my device it also says
"C-M" which surely stands for C-Media.

Plus: Good news, I think I have fixed the trap you had with 11.12 and even though 10.215 seems to work for you: it's a serialization issue for isochronous buffer handling and it can likely strike again at any time (for isochronous devices).
By the way: I had the same trap with USBEHCD 10.215 and that trap is now gone.

I have now added proper serialization to ALL HC drivers (USBEHCD,USBOHCD,USBUHCD). Additionally Wim has fixed an issue in USBAUDIO.SYS with not properly keeping up the correct sample rate (for any sample rate that is not a multiple of 1000 Hz).

Would you be willing to test a new set of drivers ? If yes let me know where to send the stuff ...
« Last Edit: March 07, 2017, 09:34:40 pm by Lars »