reSound - A sound driver and mixer for the P2
Ahle2
Posts: 1,179
reSound Beta 1
Features:
* Runs in a single cog
* Can mix arbitrary number of input channels (up to 64 atm) into any of the up to 8 output pins
* Can be used to generate surround sound on up to 8 speakers
* Each input can have arbitrary sample frequency and bit depth (example, mix 16 bit CD quality @44100Hz with 8 bit samples from an old school game @12345Hz)
* Each input can use its own sample format: 8 bit signed/unsigned, 16 bit signed/unsigned, little/big endianness
* Can be used to play back single shot samples
* Can be used as a sound buffer with interrupt handling (like in modern operating systems)
* Can be used for continuous waveform playback of any size, bit depth, frequency, volume and mixed arbitrarily into any of the outputs
* Can use any combination of the three points above on the different input channels (example, CD audio quality playback + waveforms + singleshots = game sound engine)
* All parameters can be changed on the fly, frequency, volume, panning, loop size.. etc (the included trackerPlayer example depends on this)
* Different built in sound processing options can be applied, like multimode resonance filter, reverb, distortion... etc (very rudimentary atm)
* This list will grow and change over time.
A link to all the music modules used in the example: https://gofile.io/d/1ZSNg9
A link to a free HiFi tune in wav format to use in the wav playback examples: https://gofile.io/d/5tN9D8
Original first post below...
/Johannes
Features:
* Runs in a single cog
* Can mix arbitrary number of input channels (up to 64 atm) into any of the up to 8 output pins
* Can be used to generate surround sound on up to 8 speakers
* Each input can have arbitrary sample frequency and bit depth (example, mix 16 bit CD quality @44100Hz with 8 bit samples from an old school game @12345Hz)
* Each input can use its own sample format: 8 bit signed/unsigned, 16 bit signed/unsigned, little/big endianness
* Can be used to play back single shot samples
* Can be used as a sound buffer with interrupt handling (like in modern operating systems)
* Can be used for continuous waveform playback of any size, bit depth, frequency, volume and mixed arbitrarily into any of the outputs
* Can use any combination of the three points above on the different input channels (example, CD audio quality playback + waveforms + singleshots = game sound engine)
* All parameters can be changed on the fly, frequency, volume, panning, loop size.. etc (the included trackerPlayer example depends on this)
* Different built in sound processing options can be applied, like multimode resonance filter, reverb, distortion... etc (very rudimentary atm)
* This list will grow and change over time.
A link to all the music modules used in the example: https://gofile.io/d/1ZSNg9
A link to a free HiFi tune in wav format to use in the wav playback examples: https://gofile.io/d/5tN9D8
Original first post below...
Hello folks,
Here comes an alfa preview of my upcoming sound driver for the P2. It includes two examples of usage as well.
Features:
* Runs in a single cog
* Can mix arbitrary number of input channels (until the cog chokes) into any of the output pins
* Can output on up to 8 smart pins for surround sound
* Each input can have arbitrary sample frequency and bit depth (example, mix 16 bit CD quality @44100Hz with 8 bit samples from an old school game @12345Hz)
* Each input can use its own sample format: 8 bit signed/unsigned, 16 bit signed/unsigned, little/big endianness
* Can be used to play back single shot samples
* Can be used as a sound buffer with interrupt handling (like in modern operating systems)
* Can be used for continuous waveform playback of any size, bit depth, frequency, volume and mixed arbitrarily into any of the outputs
* Can use any combination of the three points above on any input channel (example, CD audio quality playback + waveforms + singleshots = game sound engine)
* All parameters can be changed on the fly, frequency, volume, panning, loop size.. etc (the included trackerPlayer example depends on this)
* This list will grow and change over time..
Performance:
* At the moment it can mix 58 sixten bit input channels @44100 Hz in stereo mode on a P2 running @250 MHz
Fun times ahead!
/Johannes
Comments
Tell me, what is the analog output audio quality like? Is it noticeably lower than normal audio gear?
Are you using the 16-bit DAC LSB-PWM-dithering smart pin mode? At 123 ohms? Are you using the pull-down resistor for 2.0V output?
Can you give something like a guide for dummies.
Kind regards, Reinhard.
> Super, Johannes!
>
> Tell me, what is the analog output audio quality like? Is it noticeably lower than normal audio gear?
>
> Are you using the 16-bit DAC LSB-PWM-dithering smart pin mode? At 123 ohms? Are you using the pull-down resistor for 2.0V output?
Default mode is 16- bit DAC LSB-NOISE mode in 2V/123ohm. The driver chooses the better sounding PWM mode if the system clock is a multiple of the wanted mixing frequency.
The P2 noise floor is quite low (better than 80dB it seems, but I haven't done real measurements yet) and the over all audio quality is quite good according to my ears. Waaaay better than the P1. I Will try to get real measurements.
> Hello Johannes, that sounds really interesting. And is probably exactly where I want to go. But how am I supposed to use that, I'm hanging light years away. I guess I need an SD card? Should I then load the unzipped files onto the card?
> Can you give something like a guide for dummies.
> Kind regards, Reinhard.
Compile "main.spin2" using fastspin in any of the example folders. Change left and right pin definitions to suite your needs. In the tracker example, you could uncomment the tune you want to play back. There is no example of playing waveforms or playing stereo wav files from SD card in the examples above. That should be easy though, my first examples focused more on realtime mixing and playing samples with frequency control and the mixing capabilities of the driver. For simple stereo playback from SD you might not even need a driver, just an interrupt routine and a double buffer.
Each word is a sample in memory... then you just need to piece them together with a little delay. You could easily modify the drum beat example to do this.
Have you thought of implementing surround matrixing? That's probably more commonly supported/useful than discrete surround channels.
Although doing it properly would require applying a phase shift to the surround channels. I don't even have a clue of how that would work...
Is there a volume control anywhere on the A/V board setup?
Do you also see a future for audio input sources read from external memory at some later time? Perhaps with your mixing architecture being developed one day it may also enable playback of much larger samples stored in a larger HyperRAM/HyperFlash memory? I am still hoping that we might be able to do that one day and share this memory interface with video access too. Of course there will be latency and jitter introduced into these audio accesses when it is shared with video, and video will need to get priority in its transfers to avoid screen corruption. I'm hoping that intermediate transfer buffers will help audio reach performance levels required, so we don't have to generate new access requests on every single sample for example (which is unlikely to end well), and find a way where we can transfer larger blocks more efficiently. Of course there will be some limits to the number of simultaneous channels etc, but I'm thinking something could be possible there.
Couldn't get the other resound sample demo to work. I am using the A/V board outputting left/right on pins 6/7, and I patched the pins accordingly in main.spin2 of this demo but it didn't seem to work. Probed these pins with my scope, saw no output. Also tried on pins 0,1 which was the original default in the code, still no sound/scope output from this demo. Were only pins 0 and 1 meant to work for this one? Has anyone else got the drum demo working? Mod demo was fine.
It seems in the sample player that the kick drum is not working.
I see you've got the meat hidden in a binary.
Are you using the CORDIC to do any processing?
Is the music compressed or are you synthesizing it? It seems like it's compressed.
Update: I do have the HyperRAM board fitted on pins32.39 which I guess I should yank out in case that is somehow affecting things with this audio demo.
I'm using FlexGUI 4.1.0.
I do get a warning when I build this too though it also showed up for the mod player demo which does work..
This is line 119 with the warning:
long[@RESOUND][149] := hubRegPtr
I find that changing/updating tools is generally a distraction for me and there is too often scope for failure...
Both modules & sample versions working as compiled with fastspin -v 4.1.1 (same as in flexgui v 4.1.1), for pins 6 & 7.
And, I'm getting the kick drum, without issue. The BassU8 sample works as well. Not as much luck with TrumpetS8, but that could be my choice of frequencies.
dgately
> Ha, I got this running with FlexGUI. Really neat!
>
> It seems in the sample player that the kick drum is not working.
>
> I see you've got the meat hidden in a binary.
>
> Are you using the CORDIC to do any processing?
>
> Is the music compressed or are you synthesizing it? It seems like it's compressed.
The CORDIC is not used in any form at the moment. I have a lot of possible skip patterns to fill up, maybe some COORDIC operations will fit in there and be used for different FXs?!
The music is from the Amiga days and is completely sample based. No synthesis or compression at all. Just playing different 8 bit samples with realtime (50 Hz) control of pitch and volume into 4 audio channels. The note data, effects and samples are all in the same file, hence the name, "module". The cool thing is that the Amiga did all this in hardware in 1985 with 4 separate DACs that each could output arbitrary pitch and volume. No mixing involved.
Still good.
It hits on all the notes. Technical use of the 4 channels, musical form, instrumentation, it all fits into a high energy package that leaves a person wanting more.
Hey, maybe we will see a music scene on P2. (let's hope)
> This all looks great Ahle2, can't wait to try it out later.
>
> Do you also see a future for audio input sources read from external memory at some later time? Perhaps with your mixing architecture being developed one day it may also enable playback of much larger samples stored in a larger HyperRAM/HyperFlash memory? I am still hoping that we might be able to do that one day and share this memory interface with video access too. Of course there will be latency and jitter introduced into these audio accesses when it is shared with video, and video will need to get priority in its transfers to avoid screen corruption. I'm hoping that intermediate transfer buffers will help audio reach performance levels required, so we don't have to generate new access requests on every single sample for example (which is unlikely to end well), and find a way where we can transfer larger blocks more efficiently. Of course there will be some limits to the number of simultaneous channels etc, but I'm thinking something could be possible there.
I will look into this at some point. I don't have any experience with hyper RAM though. I willl also look into I2S and spdif.
f I understand the pasm listing correctly, 5 cogs are still idle ;-)
best regards, Reinhard
Having I2S would be great and should be somewhat easier to output compared to SPDIF encoding. With any luck hopefully it also fits within your same mixer COG with some smartpin modes and/or possibly using the streamer to avoid the extra COG(s).
I still really don't know what is wrong in my setup with your reSound drumbeat demo now that I'm using fastspin 4.1.0 to build it. I'll have another go at it tomorrow when I'm more awake. However your mod file tracker demo worked well for me. Good stuff @Ahle2!
> This is a fantastic demo. I had no problem with compiling and downloading. Is the reSound.binary also written in spin or is this pasm ?
> f I understand the pasm listing correctly, 5 cogs are still idle ;-)
>
> best regards, Reinhard
Thanks Reinhard!
It's written in pasm for speed.. I will release the source when it's in better shape!
6 cogs are idle actually. The tracker object code runs in the main cog!