How to do USB audio
Pages: 1 ... 39 40 41 42 43 44 45 46 47 48 49 50 51 52
jim lesurf (2082) 1330 posts |
I don’t know what your PVR actually records. However when I use my 290e ‘T2’ USB dongle it will record the data packets for a chosen ‘station’ as they arrive. So the result is a series of standard-sized packets. One PID being for audio, one for Video, and two others for the metadata. Timing info tends to be included. Similarly if I record an entire mux I get the packets for each ‘station’ on the mux. However it can be a PITA to make sense of the metadata, etc. You can’t time playback from the data rates as the video is statmuxed so varies as the various stations trade-off the amount they are given. But synch and time is in the metadata packets so the RX can reassemble and play. I can’t recall off-hand as I’ve not been working with the video recently, but I think it is ye olde mpeg for SD and ‘mp4’ for HD. May be mis-remembering though as my main interest tends to be the audio component. Jim |
Chris Dale (2393) 17 posts |
Hi, Having changed !USBRecorder’s Settings file as instructed in the help file and run it, it finds the 2i2 as the Wanted Device but after entering a file name and pressing Return, the window fills up with “GBPB Error: 222 Handle is either illegal or has been closed” until I press Escape. Then a text file with the expected file name containing only the text “RIFF$¬ WAVEfmt €» e data ¬” is written to RAMDisc0.$. I’ve tried increased RAMDisc size to 40MB and entering only 0.25 minutes recording time. Any ideas as to what I’ve done wrong or how to fix this would be appreciated. I’ve also got an ARMini (RO5.18) but if run !USBRecorder I get and error window “App may have gone wrong” and “No writable memory at this address”. Chris |
Steve Pampling (1551) 7904 posts |
Two things, RO5.20 is the known good level for the ARMini, try increasing the next slot before starting !USBRecorder and see how that goes. |
jim lesurf (2082) 1330 posts |
The GBPB error is a sign that the program either can’t read the input from the 2i2 or can’t write the results. Do you have the current version of USBRecorder? And what do you have in your settings file inside it? The 2i2 works OK here on my ARMiniX (was 5.20, now 5.21). I think I also tested it on my Iyonix but I now can’t recall for sure. However: Recently (i.e. after I wrote and made the USB programs available) I found out that there has been a change to the default behaviour of RO regarding wimpslots. With recent versions of RO the slot size will be automatically increased to fit. So programs that run without declaring a satisfactory wimpslot size on, say, RO5.20 or more, will fail on some earlier OS versions because their allocated slot is too small. So Steve’s comment about trying a larger wimpslot for ‘next’ is worth a try. If it works, add a wimpslot command to !Run. FWIW I’ll check this when I get a chance, but I’ve been otherwise occupied. Alas the OS change wasn’t announced so far as I know, so I only found out about it when it came up in discussion later on the forum with Jeffrey Lee. FWIW You can also hack Colin’s recorder to work with the 2i2. The required details can be obtained from using my probe program. Oh, and the 2i2 may need a USB ‘kick’/reset at first, depending on the order in which you connected it and loaded the modules. Jim |
jim lesurf (2082) 1330 posts |
Just checked. I also got the same error unless I did a usbreset for the 2i2 before trying to use it. So if you get the error as reported you need to check/do two things after having loaded the modules and connected the 2i2: 1) open a taskwindow and issue a 2) If it still doesn’t work, add a line to the start of the !Run file inside the USBRecorder app. The program here takes 2664k as a taskwindow slot. So add something like If the above doesn’t work, give more details and I’ll try to diagnose. If I can I’ll produce modified versions to avoid these problems. Afraid the ‘reset’ problem is down to the hardware and USB system. So to avoid it I’ll have to add some kind of ‘kick before 1st use’ to the program(s). Some devices need this, others don’t. No idea why. Whilst on tweak/fixes for the programs: is there an easy way for a program to find out if it is being run in a taskwindow or singletasking? My recorder prints out a running display of the signal levels. But this needs different formatting for the two situations. At present, looks best for singletasking. BTW When using the 2i2 and other devices you may find experimenting with different USB power arrangements affects the background noise level. So if you want best results, experiment with different hubs / psus… Jim |
Chris Dale (2393) 17 posts |
Thanks Jim and Steve. Tried running USBRecorder (V0.52) again today before changing anything and now after *Wanted Device Found = USB02 * and Entering an output file name (test1), instead of GPBP Error I Get: Recording using device USB02 min sec left right [dBFS] Nothing else happens until I press Escape even if I wait for more than the 15 seconds specified recording duration. Tried *usbreset 2: No change. Same result. I don’t know why today’s test was different to yesterday’s. I think that getting decent quality recording for the Iyonix/Armini is a bit step forward and have purchased the 2i2, I’m keen to get it working. ARMini: I can only find OS Update to 5.19 so have done that but I haven’t done anything else with that today yet. Chris D. |
jim lesurf (2082) 1330 posts |
You should get something like… Simple USB Audio Recorder ver 0.52 ================================== Enter duration [mins] => 1 Record for 60 sec [ 60 x 1 sec blocks ] Wanted Maker = *Focusrite* Device = *Scarlett 2i2 USB* Record 96000 samples/sec 2 channels 24 bits per sample 4 bytes/frame Output directory = RAM::RamDisc0.$ Input buffer size set to 768000 Byte conversion req. 4 => 3 bytes per sample skip 1 List of devices by ID = USB13,USB10 Examine USB13 Maker = *Focusrite* Device = *Scarlett 2i2 USB* *** Wanted Device Found = USB13 *** Examine USB10 Maker = *Cambridge Audio * Device = *Cambridge Audio USB Audio 2.0* Done Will record using USB13 Enter output file name => fred/wav Recording using device USB13 Output written to RAM::RamDisc0.$.fred/wav sblock bytes => 0 77 1 0 18 4 2 1 0 OpenIn report: recordhandle = 239 start recording Payload to write = 34560000 min sec left right [dBFS] 0 0 -60.0 -60.0 0 1 -60.0 -60.0 ...snipped... 0 59 -60.0 -60.0 1 0 -60.0 -60.0 record done 60 blocks Time excess = -4 centiseconds * (Ignore the lines for the Cambridge Audio DAC which show up as the program scans to find the 2i2 on my machine.] Using a settings file containing Focusrite Scarlett 2i2 USB 96000 2 24 4 RAM::RamDisc0.$ The value you get for the recording handle looks wrong which makes me feel that you’re still not managing to connect for the transfers. Have you loaded Colin and Dave’s modules? I assume so as you said playout works, but I’m puzzled by the failure to get a handle. Can you please list what you have in your ‘settings’ file inside !USBRecorder? That may have a value the 2i2 doesn’t like, so it is refusing to accept the recording connection. The sblock values seem OK. The only difference seems to be that you’re wanting to make 48k recordings whereas I’m setting to record 96k. But maybe something else is confusing the connection. Can you also list what my USBAudioProbe lists from the 2i2? Failing all else, maybe it is something different about your OS version or the ARMini. You’d have to ask about that on the R-Comp email list I guess as I don’t know anything about the ARMini. However here I can get the 2i2 to record using my Iyonix (RO5.18) as well as on my ARMiniX (now RO5.21). The above is from my ARMiniX. Jim |
Chris Dale (2393) 17 posts |
Thanks Jim. Yes, I loaded !USBModule and !USBAudio. I assume that I have to do this every time before using !USBPlayer or !USBRecorder. I didn’t see any instructions for installing !USBAudio so it’s presently in the same folder as USBRecorder etc. and I just double click it. USBModule is of course lost from RAMDisc each time the Iyonix is shut down. USBRecorder’s settings file is: Focusrite After running USBRecorder, as before a small file is created in RAMDisc which contains only: I tried 96000 but it doesn’t seem to make any difference. Tried running !USBProbe. I get:
[Rates buffer size used/needed = 512] Minimum 0 Maximum 0 Step 0 [Hz] * So there seems to be something wrong there also. Chris D |
Chris Dale (2393) 17 posts |
The copy of the result of running USBProbe in my previous reply seems to have been slightly scrambled. I had snipped out most of the repeating lines but the word ‘Snip’ and some return characters seem to have disappeared but it’s essentially right. |
jim lesurf (2082) 1330 posts |
The result you got from my probe showed that you aren’t actually finding the 2i2. Did you remember to do a Note the module is Afraid my programs all use the USBAudio module. So unless this gives you appropriate results from my Probe, the other programs I wrote almost certainly won’t work. Note that you can use Looks to me like the USBAudio module wasn’t loaded or simply wasn’t working if you’d given the usbreset. Alternatively you may need to run Dave’s probe program to see if your 2i2 is different in some way from the ones I have. Also check you are using the newest versions of Dave/Colin’s modules. BTW you can try hacking Colin’s recorder program by adding a line or two to include the 2i2 in the list it can use. I’ll see if I can find my hacked copy. That bypassesses the USBAudio module so may be worth your trying. Jim |
jim lesurf (2082) 1330 posts |
Have a look inside Colin’s !IsocRecorder program. You should see a series of sections like IF usb$ = "" THEN xName$ = "'Focusrite' 'Scarlett 2i2 USB'" usb$=FNusb_findDeviceByVendor(&1235,&8006,-1) xInterface% = 2 xAlternate% = 1 xEndpoint% = &82 xSamplerate% = 96000 xSamplesize% = 8 : REM 2 channel 4 bytes per channel xChannels% = 2 xBits% = 32 : REM was 24 xControlInterface% = 0 xClockId% = 41 release1% = FALSE ENDIF Add the above to them. It’s the hack which worked here for using the 2i2 with his program. This should record even if Dave’s USBAudio module is absent or doesn’t work for some reason. Remember that you may need to If that works but even my probe returns nonsense then I suspect the USBAudio module isn’t working for some reason. You’ll then to run Dave’s test prog to see what it says. Jim |
Chris Dale (2393) 17 posts |
OK Thanks for that Jim. A further test of !USBProbe and !USBRecorder and they now work. I suspect the problem has been that although I reset what appeared to be the appropriate USB device number, the number seems to change more readily than I would have expected and I may have been resetting the wrong number. I’m now using !USBinfo which makes it easier to keep checking it and do the reset. Yes, sorry !USBAudio was a typo. Meant USBAudio module. Here’s the results from !USBProbe and from !USBRecorder: USB Audio Probe 1.15 ==================== Scans USB to find and report on the details of Audio devices Also checks to see which can play a given wave file Type in sample rate => 48000 number of channels => 2 bits per sample => 24 OK, scan looking for ability to play: rate = 48000 channels = 2 bits/sample = 24 Using USBAudio_EnumerateDevices to find out what is connected ------------------------------------------------------------- List of devices by ID = USB17 Device 1 => USB17 Devices counted = 1 Now examine each device in detail ================================= Device 1 details ------------------ ID [USB17] Maker = *Focusrite* Device = *Scarlett 2i2 USB* Vendor ID = 4661 Product ID = 32790 Number of resolutions available = 3 play using 24 bits per sample using 4 bytes per subframe rec using 24 bits per sample using 4 bytes per subframe [Rates buffer size used/needed = 48] play ch = 2 res = 24 bytes/ch = 4 lpcm number of rates = 4 rates are: 44100 48000 88200 96000 samples/sec *** Match Found! *** Using 4 bytes/sample transfer rec ch = 2 res = 24 bytes/ch = 4 lpcm number of rates = 4 rates are: 44100 48000 88200 96000 samples/sec Now report any devices able to play the file -------------------------------------------- Device USB17 using 4 bytes per sample transferred [req. 3 => 4 bytes/sample] * RAM::RamDisc0.$.test5 48000 2 3 24 USB22 1 1 1 4 24 2 1 ClockID: 41 usb_control: bmRType=0x21 bRequest=0x1 wValue=0x100 wIndex=0x2900 wLength=0x4 buf=0xA7F48 usb_control: bmRType=0xA1 bRequest=0x1 wValue=0x100 wIndex=0x2900 wLength=0x4 buf=0xA7F48 Sample Frequency get: 48000 USB22#nopad;noblock;size384000;samplerate48000;samplesize8;interface1;alternate1;endpoint1: Started Press escape to abort Time: 60.02 Finished (78) Thank you for your help with this. I realise that it’s early days yet for USB Audio. It’ll be great if there’s a fully working app in due course. I’ll have another look at the ARMini later. Chris D |
jim lesurf (2082) 1330 posts |
Glad you’ve now got my programs working. Afraid the need to do a When I get a chance I’ll do new versions of my programs that: 1) deliver a usbreset to the device before trying to use it. 2) actively set a suitable wimpslot size. I want to check a few things first, and will then release new versions. Afraid though that my programs so far are only intended as demos/experiments. I’m useless at writing wimp applications. I may do nicer singletasking fullscreen ones, though, a bit like my !USBScope providing a helpful ‘graphic’ display. That approach suits me because if I’m playing or recording audio I don’t want the machine to do anything else anyway. But something more like !DigitalCD or !PlaySound for USB playout or recording would clearly be preferred by many people. Alas, not something I’m capable of writing! :-/ BTW At present if you’re going to do much recording I’d recommend also using !USBScope at first to get some idea of the levels, etc, before making recordings. Makes it easier to see what is going on. All being well, I’ll transfer some of what !USBScope displays to a new !USBRecorder at some point, though. Jim |
Chris Dale (2393) 17 posts |
OK. Yes, I hope someone with the right skills will take up the challenge. I’d be happy to pay for a suitable app. |
Chris Dale (2393) 17 posts |
After updating my ARMini to RO5.19 and SP6 I tried my Focusrite Scarlett 2i2: !USBProbe: results all 0s; !USBRecorder: No writable memory at this address; !USBPlayer: Internal error: Abort on data transfer; !IsocPlayer and !IsocRecorder: Couldn’t open pipe. USBAudio and !USBModule had been run and USB Device reset done. I guess that the errors are all due to the same cause, whatever that may be. Chris D |
jim lesurf (2082) 1330 posts |
Bigger wimpslot required? Did you check with !USBProbe after doing the usbreset? Note that the reset does tend to change the USB device’s number. May be worth your while asking on the R-Comp list about this. if there is something specific to the ARMini (as disinct from ARMiniX) I probably won’t know about it. I can’t test here on an ARMini. Also, try not plugging in the 2i2’s USB connection until after you’ve installed the modules. That may avoid the device giving the problem that requires a ‘kick’. Jim |
Chris Dale (2393) 17 posts |
Thank you. Tried: adding ‘WimpSlot 3000k’ to !USBRecorder’s Run file; Checking with !USBProbe after doing usbreset; and Plugging in the 2i2’s USB connection after installing the modules. No change so I’ll try the ARMini support mail list. This is more for interest as I can now use my 2i2 with the Iyonix. Chris D. |
Dave Higton (1515) 3399 posts |
One thing: I would advise against doing a USBReset in general. It’s a pretty serious thing to do to a device; and it means the device will probably come up with a new number, which has the potential to cause as much confusion as it solves. I own lots of USB devices, and I have never found the need to reset one. There are just a few unhelpful USB devices out there. Sadly the Focusrite 2i2 seems to be one of them, in more ways than one. |
Chris Johnson (125) 818 posts |
Are you sure that such an old version of RISC OS actually supports all that is needed for usbaudio to function? |
jim lesurf (2082) 1330 posts |
FWIW It doesn’t seem to need the usbreset if it is plugged in after I load the modules. Alas, that then isn’t convenient for other reasons as it means having to unplug it and plug it in again each time I start anew. And IIRC the Behringer equivalent does the same. I’m wondering if the problem will cease once the modules are included in the romset from bootup. Or maybe for some reason it wants to be the ‘last device on the list’… Pest, either way. Is there any alternative to usbreset that might preserve the USB number? I’ll also keep looking for an alternative, but makers simply don’t seem to reply to emails. Hence I’d end up having to buy more to find out they don’t work because they aren’t standard compliant! :-/ |
jim lesurf (2082) 1330 posts |
FWIW the 2i2 works OK with my Iyonix running RO5.18. And I may have misunderstood what Chris Dale said, but I thought he had got it working on his ARMini until he upgraded. Did I misread that? Either way, I suspect this may be a question for R-Comp about the ARMini. It is one of the matters I’ve just flagged there myself. Jim |
Chris Dale (2393) 17 posts |
Sorry if I was not clear. The USB audio apps wouldn’t work on my ARMini before or after upgrading from RO5.18 to RO5.19 and SP6, which was the latest stable release I found on the ARMini downloads. Thanks for flagging this on the ARMini support list. I’ve added my comments. Chris D. |
jim lesurf (2082) 1330 posts |
It occurs to me to check. Do you have a ramdisc on your ARMini? AIUI Colin’s module installation program copies itself to ramdisc before running to install his audio-capable modules. This is to avoid a problem where a machine’s main HD is USB as the process temporarily ‘loses’ connection with USB devices when the old modules are shutdown. So it can’t then load his new ones from the USB HD! Hence you need a ramdisc present for the install to work. Afraid I tend to take this for granted as I use ramdisc a lot for various purposes as a scratchpad, etc. Since the programs work here on my RO5.18 Iyonix and my ARMiniX (RO 5.21 now), otherwise I’m stumped I’m afraid. If you can get Colin’s programs to work, but not mine then his modules are in place OK. And the device is responding. If you can’t get my Probe program to give useful results, but Colin’s programs work, it implies that Dave’s module isn’t happy or present. When testing I recommend only plugging in the 2i2 after you’ve loading Colin and Dave’s modules. That should avoid the need for a usbreset. Beyond this, I’m afraid I have no idea how the ARMini might differ. It may be something about the USB controller. That’s something others would have to deal with as I don’t understand that level. My programs sit on top of Colin/Dave’s modules and let them do the hard work! Jim |
Dave Higton (1515) 3399 posts |
I’m speaking only for the USBAudio module here… I find it impossible to see any difference in the results of plugging in any USB audio device, and loading the USBAudio module, as anything other than a coincidence. The USBAudio module doesn’t have any transactions with any device unless and until a user programme calls any of its SWIs. It doesn’t do anything on module initialisation; it doesn’t respond to any service calls (which it would need to do to find out and keep track of what devices exist); it doesn’t have a Wimp poll loop (it’s not a runnable module). So you can feel free to load the USBAudio module and plug in your USB audio devices in whichever order you like. |
Dave Higton (1515) 3399 posts |
There’s an excellent article in The Register today from my old friend John Watkinson, who does (among other things) an excellent job of debunking the myths that word lengths longer than 16 bits and sampling rates higher than 44.1 kHz make any difference to perceived sound quality. It’s well known that the biggest improvement to sound quality you can get from a piece of audio equipment is to give it a high price tag. http://www.theregister.co.uk/2014/05/13/apple_beats_and_fools_with_money/ |
Pages: 1 ... 39 40 41 42 43 44 45 46 47 48 49 50 51 52