USBAudio and Mbox2
Pages: 1 2
Ronald May (387) 407 posts |
This device actually accepts the wav stream, but maybe it is the mixer stage that hasn’t been woken up, and the result is no livening of the panel leds and no sound output.
Basically repeated 10 times every 500ms until the 18 bytes in &bootresponse returns with byte 1 at 0×02 else the error message within &bootresponse is used. Somehow I have to find a way to do this in BASIC. |
Colin (478) 2433 posts |
A quick google shows it to be a normal control request where: bmRequestType = 0xc0 and bootresponse is a 18 byte buffer to receive the data. If you know about control requests the first 2 numbers being the wrong way around to the norm may have fooled you. If you rummage around my usb player you’ll find PROCcontrol which should do the job. |
jim lesurf (2082) 1438 posts |
Have you tried Colin/Dave’s programs for probing the device, and my own probe program? If so, what results? Jim |
Ronald May (387) 407 posts |
I have got the MBox 2 waking up with PROCcontrol and the prescribed bytes. I now have to proceed with setting rates as well because I am getting hiss mostly and sometimes a faint music track mixed with the hiss.
I am puzzling over the difference of the send and receive functions in relation to putting these bytes into PROCcontrol. Does ‘type’ change for send? It is good to be over the first hurdle, more will have to be done to check for the device id as a condition for running the routine.
Also I think there is a wimppoll method for getting a delay, rather than counting to one million. |
Colin (478) 2433 posts |
snd_usb_ctl_msg maps to DeviceFS_CallDevice like this
The bmRequestType tells you the type of request and holds the direction
So a bmRequestType of 0xA2 is a class specific request to read data from an endpoint. 0×22 is a Class specific write to an endpoint. bRequest is the equivalent to the action code. For a class 1 audio device a request of 0×81 is a read current value action code (0×01 is write current value) note The names I’m using correspond to the names used in the USB standards – it just avoids confusion to use these names. |
Colin (478) 2433 posts |
If you post a link to the output of usbdescriptors it’ll tell me the capabilities. The reads of endpoints 0×85 and 0×86 in the linux drivers don’t seem to be serving any purpose.
Different capabilities will probably need different alternate/endpoint settings. |
Ronald May (387) 407 posts |
I’ve had no luck by trying to mimic that 48000 setup stuff into PROCcontrol so far. |
Dave Higton (1515) 3526 posts |
Once the firmware has been installed, the device may perhaps look like a standard USB Audio device. If that’s the case, then using my USBAudio module should be far easier than what you’re trying to do. The questions are whether RISC OS sees the device as an audio class device after the fimware installation, and whether the firmware is still in place after a USB Reset (which is what might be necessary to force RISC OS to enumerate the device again). |
Ronald May (387) 407 posts |
Dave, currently, after bringing the box to life with Colins Player, your player will only open with a 24bit |
Colin (478) 2433 posts |
mbox2_setup_48_24_magic is rubbish. temp is just a buffer – the size is not significant as long as its >=3. The first snd_usb_ctl_msg writes the first 3 bytes of it to endpoint 0×85 and temp hasn’t been initialised. The last 3 snd_usb_ctl_msg are reading 3 bytes to srate when it should be writing the sample rate. What you have is a device with 4 interfaces 2 output and 2 input. So what are you trying to do play or record? Interestingly one of the outputs is ac3 – never seen one of them before. You should be able to get that to work as well. What you have is 4 interfaces and each interface can have a choice of alternate settings. So bInterfaceNumber 3 bAlternateSetting 6 is ac3 output. The choices you have are laid out below. What are you trying to do. play or record? I’d have expected my player to work on interface 2 – it picks the first that works. interface 4 and 5 should work with my recorder program.
|
Ronald May (387) 407 posts |
Thanks Colin, I will try some recording later, It looks like it must have 24bit 48000 for playback always. |
Colin (478) 2433 posts |
There isn’t a sample frequency control for any of the PCM outputs. The ac3 output does have a frequency control. Do you have my player working at 48000? For recording for the alternate 2 endpoint’s frequency is determined by byterate, alternate 3 endpoints do have a sample frequency control. There’s no need to use the alternate 3 setting. The alternate 2 setting should record at the byterate used – ie the samplerate used when opening the usb endpoint. So to conclude there is no frequency controls to set – so mbox2_setup_48_24_magic was a waste of time as even if it did what it was trying to do it still wouldn’t do anything as there are no frequency controls. I don’t think reading of bootresponse is relevant
suggests its for reading software from the device which won’t work anyway. |
Colin (478) 2433 posts |
Looking at bInterfaceNumber 2 there are 3 alternate settings 2,3 and 6. This implies that the device has only a subset of a more comprehensive interface where alternate settings 1,4,5,6 exist for this interface. You can speculate that alternate settings 1 to 5 decide the PCM frequency and your device doesn’t have some of these alternate settings so can’t do those frequencies.
That sounds like its working but you are sending 16bit audio to a 24 bit endpoint – the device only does 24bit pcm. |
Ronald May (387) 407 posts |
I found another couple of versions of quirk.c I’ll put up the MBox 2 section as it has more comments. I have been using INKEY 100 as a delay, but though the specified time works in interactive BASIC, in the program it seems to speed up. |
Colin (478) 2433 posts |
IsocPlayer2.zip is a pared down version of IsocPlayer where you have to set all the values explicitly for a particular device – like you do for IsocRecorder. ie it doesn’t find the device automatically. I’ve made an entry at the top of the runimage for the mbox2 device – I’ve filled in the values for the first out interface does it work? Things to try. changing bmAlternateSetting% to 3 or changing xSamplerate% to 44100 and using a 44100 24bit wav. You are trying to play 24bit PCM wav files aren’t you? bInterfaceNumber% = 3 is the other audio out for the device. Note it has xSetFrequency% set to 0 because you can’t set the frequency. You have 2 stereo inputs and 2 stereo outputs all are independent of each other. If mixing is available it’s not done at the usb level. If endianness is an issue I’ll pass on that for now. Regarding quirks.txt I don’t see that it does anything useful except maybe waiting until the device is ready but if it wasn’t ready you wouldn’t have the usb descriptor list. It’s only reading data from the device which isn’t any use to you. mbox2_skip_setting_quirk doesn’t do anything useful as far as I can see. |
Ronald May (387) 407 posts |
Yes, that player is doing everything you intended. I have noticed both old and new versions seem to leave the file open after escaping playing. I only noticed this when trying to move the file after ceasing playing it, and it possibly happens whenever escape is used. This is the first time I’ve had a 24bit device so I have only one 24bit wave file so far. |
Colin (478) 2433 posts |
I’m glad you know what I intended. Does it play 48000 24bit?
I can only think its a difference in the editor you use. I use srcedit – I doubt many other people do. Does running this basic program in a task window print HELLO when you press escape?
If it plays 48000 24bit it will play 48000 16bit in the same endpoint. The 16bit values just need shifting to 24bit values. The assembler should do this for you and you shouldn’t need to change isocplayer2 for it to play 16bit. Changing xSamplerate to 44100 and bAlternateSetting to 3 may play both 44100 24bit and16bit. |
Ronald May (387) 407 posts |
Yes, the problem is not to do with needing 24bit, it is that I have to ‘bump’ it into action, then the hiss changes to audio. All four formats work with the /only/ change needed being 44100 – 48000. in fact I dont think varying the 24bit setting has any effect, and it is possibly getting ignored in playback mode. I’ve found that changing interfaces/endpoints etc leads to needing a reset, so I haven’t done much with that yet, there will be others that do work judging by previous attempts with the hiss/noise following me around. |
Colin (478) 2433 posts |
Try changing line 66 in Runimage from
to
If that doesn’t work does pressing f12 bump it into action when you return to the desktop? I suspect that the buffer is correcting itself after it is emptied. Using window furniture stops the program and allows the buffer to empty.
Is it the same for all four formats? I’m surprised that both 44100 and 48000 work to the same endpoint. The rate of data transfer is determined by the device (it’s an asynchronous endpoint) and I can’t see how it can know which sample rate you are sending. Even adaptive endpoints which use the data rate you send to determine the sample rate tend to only do so in a small window around its programmed samplerate. Are you sure the 44100 wave file isn’t being played slightly fast or the 48000 wave slightly slow?
Is that a computer reset or a device reset? Is it caused by Escape not working as expected if so just put
after line 115
and Space should stop the music. |
jim lesurf (2082) 1438 posts |
Does a simply USB device reset help make it work in the first place? If you’ve tried that I’ve missed the results.
FWIW You may find the port of sox more convenient for tasks like reshuffling, etc, LPCM audio. There is also a program on my software page that will list any ‘extended’ or other chunks in the metadata of a wave file. IIRC Colin and Dave’s players/recorders are like mine and assume plain metadata. But your device may be up to something else for all I know. I’m assuming from what you’ve said the format the device transfers/requires is s24. But class 2 devices may want / include padding bytes so the data is s32le with a zero least-significant byte. |
Colin (478) 2433 posts |
The device is 24bit. There should have been no need to convert the 48000 16bit file my program does 16 – 24bit conversion on the fly. Having a bigger subslotsize for a given bitrate eg 24bit audio played in a 32bit slot is not a class problem it’s just how the device is designed. It can occur in class 1 or class 2 devices. In this case 16 bit files are played in a 24bit slot so need padding out. On another issue, I have a webcam that may interest you Jim. The audio is class 1 on a high speed (USB2) device showing that class 1 isn’t limited to full speed (usb1) devices. |
jim lesurf (2082) 1438 posts |
Hi Colin, Thanks. Afraid I’ve not followed all the previous discussion, so wasn’t clear on the problem. Interesting about the webcam. With that situation would it mean that 192k/16 stereo could be exceeded? Or is that tied Cheers, Jim |
Colin (478) 2433 posts |
Depends on how you interpret the standard. Personally I think it’s been stretched to work on USB2 – I had to modify the usb module to make it work. I can understand why it was done. You upgrade a video interface of a device to USB2 and already have class 1 software for the microphone. So what they’ve done is change the interval that audio data is read from the device to 1 in every 8 frames instead of every frame. USB2 has 8000 frames per sec USB1 1000 frames per sec. If this is proper use then yes class 1 could have higher res audio. |
jim lesurf (2082) 1438 posts |
Interested in the ‘rate cap’ because two devices I have are class 1 and limited by this. In each case the designer would have liked a higher data rate but decided they had In both cases they’ve told me a main reason for this was in essence: “Windows only does class 1 The problem, I guess, is that they can’t tell what hardware the device will Thanks. I’ll duck out and let the thread get back on topic! :-) Jim |
Ronald May (387) 407 posts |
Jim, FWIW I used ffmpeg on linux and got the same ‘Not PCM’ error with both Colin’s and Daves players. I had a quick look at sox and the command line —help didn’t make it clear how to do it, and I didn’t have the HTML help handy. But I wont be doing any converting now that I know 16bit tracks play straight off, and I have moved on. Colin, I timed a track playing at 44100 then 48000 and got close to the same ratio of 48000:44100 so I can definitely say that the speed can be changed /without/ endpoint changes. I did notice the difference in the pitch but now it is verified. Using your xSamplesize% * xSamplerate% * 2 gave silence rather than a hiss that can be bumped, but sometimes silence means a reset is needed so I’ll check again. I tried a variety of sizes there and some lock me out from bumping some dont. On one occasion when it was set at 4096*8 it started straight off by itself, the only time that has happened, and I couldn’t repeat it. When things go completely quiet, It doesn’t necessarily mean any settings are wrong until replugging/resetting the usb box and checking again. The low end noise is there the same on all four formats, It seems to be only there when the audio signals are there. When a track has ended it drops to a quiet hiss which would be normal line/psu noise I think. My rj45 usb extender can quieten that, but I found the necessary ‘bumping’ doesn’t work when it is in use. |
Pages: 1 2