HiFiBerry Dacs & Digi Boards & FasttickerV
Terry Swanborough (61) 152 posts |
Hi I have been given some HiFIberry boards for a project at work I have the following :- They were sitting next to a Raspberry PI running RISCOS so I thought would try to get them running under RISCOS The DAC+ Light just needs I2S at the right speeds to work it needs on other setup. The good news is I have got these cards working all apart from the DAC+ PRO but that uses the It took a while to get them up and running because some other GPIO pins were being used to control other things I am currently copying a WAV file to the RAM disc and the streaming the data from the RAM disc to the I2S FIFO So I went away and had a cup of coffee and then I thought interrupts, so I turned those off and it all works fine, in BASIC or The I2S on the Pi has a 64byte buffer but it seems that when you use two channels it drops to a 32byte buffer I am using wav / pcn cd audio which is 44,100khz 2 channel stereo which needs about 176,000 samples a second. The best way of dealing with this would be to detect the interrupt from the I2S FIFO and then fill the buffer on demand this is where I get a bit vague I have no idea of how to do this under RISCOS. One idea I thought of doing was trying to use fasttickerV is this fast enough to cope with the speed needed? how fast is this timer?. if it was fast enough do other interrupts occur while your in the ticker routine, in an ideal world it would be nice to read data off of a CD to RAM disc and then send this to the I2S FIFO buffer. I have left work for shutdown now until the new year, once I have all the cards working I intend to release the code and hopefully it will be of use to others as a lot of the donkey work regarding card registers and getting the cards up an running it already done. Somebody with more knowledge of the RISCOS internals might be able to make use of this. |
Tristan M. (2946) 1039 posts |
Please, keep going with this! I’m able to set up the RPi, and talk to the DAC+ Pro (clone) via i2c, but had no idea whatsoever on how to do anything on the RISC OS side. If you need someone to test code, please do say so. |
Terry Swanborough (61) 152 posts |
Any DACs that use the same chip set should work but some cards do use GPIO I will finish the code when I get back to work and let you know where I have an idea that might work as reading other threads here it seems that fasttickerV something like OS_ClaimDeviceVector & DMA sound channel 0 OR DMA sound channel 1 |
Jon Abbott (1421) 2651 posts |
You might get away with claiming the Linear Handler after setting a suitable Sample rate and fill your device buffer instead of the SoundDMA buffer. I’m assuming you can poll the device to see if more data can be sent and that it’s not dependent on being filled at exhaustion. You’ll want to pass the call onto the previous claimant once you’ve done your thing, if you want SharedSound to continue working. |
Terry Swanborough (61) 152 posts |
Hi Jon That looks like a good idea. I’m using 44.1khz CD Audio mainly so I’ll release the code with interrupts switched off first just to let people Do you know what the workspace referred to by R2 in Sound_LinearHandler 1 is? |
Jon Abbott (1421) 2651 posts |
As documented, it’s the default value in R0 when your handler is called. |
SeñorNueces (1438) 162 posts |
@Terry Swanborough: Did you release the code somewhere? Risc OS is the only OS on my Pi where I don’t have the Hifiberry working, and I would love to! :) |
Terry Swanborough (61) 152 posts |
HI The software is available from the link below:- Unzip the contents of the zip file copy the file corresponding to your HIFIberry card light / standard etc to your harddisc These programs will play any wav file @44.1Khz in the ram disc on the HIFIberry cards |
SeñorNueces (1438) 162 posts |
@Terry: Are there plans to allow the HiFiBerry to be used as the main sound output for Risc OS? |
Terry Swanborough (61) 152 posts |
Yes that’s the idea I’m currently looking at DMA after Jeffrey Lee gave me some direction I am trying to write a module (never tried that before) and then register the audio with If your reading this Jeffery I looked at the DeviceNumber in the device descriptor and think TIA for the help as this is all very new to me. Terry |
Jeffrey Lee (213) 6048 posts |
I believe 55 is the correct device number for the PCM/I2S controller. https://www.riscosopen.org/viewer/view/mixed/RiscOS/Sources/HAL/BCM2835/hdr/BCM2835?rev=1.31#l557 Different platforms map their IRQ/device numbers differently, so copying a value from e.g. the Iyonix or OMAP sources isn’t likely to work!
No. Bit 31 is used if there are multiple devices in the system which have the same IRQ/device number. Since the PCM/I2S controller is the only thing assigned to device 55, there’s no need to set the bit. As for passing the interrupt on (so that both audio devices can be active at once?) – that’s not supported yet. For SoundDMA to support concurrent output to multiple devices (one input audio stream being split to multiple outputs) there’d probably have to be an extra layer of buffering. You’ve got things to worry about like device-specific buffer size restrictions & data format restrictions (e.g. L/R channel ordering), different sample rates being supported (or even if they both support the same sample rate, there could be clock inaccuracies which will lead to large errors over time), buffer filling being out of sync due to interrupt timing or devices buffering different amounts of data internally, etc. |
Terry Swanborough (61) 152 posts |
Thanks for the info I did read in the ARM peripherals PDF page 113 that PCM used 55 I have a module compiling with the device structures my plan is to try to get basic data Terry |