A late Christmas present : The return of the SOUND and ENVELOPE commands...
Pages: 1 2
Anthony Vaughan Bartram (2454) 458 posts |
Still metaphorically wrapping this at the moment…. Should be sharing an ‘alpha’ of the new RISC OS DSP sound module based on shared sound soon ( as I haven’t requested a SWI range yet + I’ve got quite a bit of testing to do & don’t really know what this will run on…). This module enables playing both samples and synthesised sounds from BASIC via SOUND and ENVELOPE commands as well as new custom SWIs / * commands I now have working : 8 channel sound/sample playback (via variable speeds) a (slightly resonant) low pass filter, a delay effect, a modulatable noise generator, PWM, square, triangle and saw-wave oscillators + envelopes to modulate the sound. I’ve linked the code to the SOUND command and am testing/writing the ENVELOPE command integration. Going to add the XOR inter-channel modulation feature soon. I plan to add a compatibility mode to (at least partially) support the SOUND / ENVELOPE commands BBC micro type SN76489 sound that is selectable via a * command/SWI. As by default the ENVELOPE command has a different set of parameters geared toward the new engine. I will supply a selection of BASIC programs to demo the types of sound that this can make. The src code needs tidying and I don’t have a proper package or make file yet (just an obey script). The alpha will be public as this module is free with (src code included). Although I did some POCs in asssembly code, I decided to write this in C (very flat and inlined however). n.b. This post concerns the ‘wavebox-esque’ option in the RISC OS awards. |
Bryan Hogan (339) 592 posts |
This sounds fantastic Anthony. I’m impressed with how far you’ve progressed in the few weeks since your talk at ROUGOL at the end of November. I was always frustrated that Acorn didn’t implement sound and envelope on RISC OS (Arthur) in a backwards compatible way with the Beeb. Finally, 30 years later, we will finally have it! Excellent work :-) |
David Feugey (2125) 2709 posts |
I just say: yeah! |
Patrick M (2888) 126 posts |
Brilliant! |
Rob Heaton (274) 515 posts |
Nice work, I’m looking forward to this too! |
Greg (2474) 144 posts |
I too am interested, glad too see this finally coming to fruition. How does this compare ( processor time ) with the likes of TimPlayer. Is it more efficient ? |
Anthony Vaughan Bartram (2454) 458 posts |
Hi Greg, TimPlayer has different functionality as I understand it is focused on playing tracker files. Although I have used it as a sample player in my games. So it is possible that RDSP will perform better. I’ll have to find a good way to do a performance measurement and would welcome feedback on this. At the moment I’m trying to measure RDSP’s impact on the system by running a separate program and measuring its time to complete (as shared sound runs in the background off an interrupt). |
Anthony Vaughan Bartram (2454) 458 posts |
Thanks for your interest and I’m pleased I’ve finally managed to get this working. The alpha is available from: I have tried this on an ARMX6, Raspberry pi 2, RPCEmu and an Iyonix (although I had to load shared sound manually as it was not in the expected location). Source code and examples are included. There are 7 examples: Please note that this is Alpha quality. No SWIs are included just OS WORD 7, 8 and *commands. Testing::
Release notes: Release status: Alpha Features:
|
Anthony Vaughan Bartram (2454) 458 posts |
In actual fact the RDSP sound command has the following fields: SOUND PFIC,TTVV,FRNN,DDDD
Pending features (planned for next alpha release):
Known Alpha Bugs:
|
Steve Pampling (1551) 8170 posts |
Nice work. Good to see people working on these things. BTW. A few typos in the readme: Typo: significant (missing “i”) Typo: filter (missing “l” ) Typo louder (extraneous “n”) Typo: attack, sustain (missing space) HTH. |
Anthony Vaughan Bartram (2454) 458 posts |
Thanks for checking the ‘readme’ Steve. I’ll get those typos fixed. Don’t suppose I could persuade you to do a code review? (Sorry about the tabulation in DSP.c. I’ll remove the TABs in the next release). Cheers, Tony |
Steve Pampling (1551) 8170 posts |
You’d want a programmer to look over your code and much as I’d like to have those talents… |
Anthony Vaughan Bartram (2454) 458 posts |
Just wondering (once I’ve got the legacy Envelope mode running) if Cybertron Mission’s sound will work? I’m going to try this out later this week. RE: code review – No problems Steve. However, I would be grateful if you have time to try RDSP out please let me know what you ran it on and if it worked. The alpha hasn’t crashed RISC OS for me yet…. But I’m going to try some soak and fuzzed input values to see if it does…. Thanks for your input. Tony |
Anthony Vaughan Bartram (2454) 458 posts |
Actually, David, Patrick, Rob, Greg – please, if you have time, would you try the module and examples supplied? Apologies in advance if anything breaks… :-/ |
rob andrews (112) 200 posts |
Hi Anthony just ran all exapmles on OPMAP5432EVM (home built rom 30 Dec 2016) with only one problem |
Anthony Vaughan Bartram (2454) 458 posts |
Thanks Rob. Much appreciated. Pleased it runs on OPMAP5432EVM It changes the system beep because it hooks OS Word 7 i.e. as used by the SOUND command. I could make the SOUND command integration user selectable (i.e. allow it to be disabled). Or optionally exclude (or re-map) the system beep as a feature – as this uses SOUND channel 1 at a specific frequency. This does mean that you could change the system beep to a custom sample if you wished via RDSP (with a bit of tweaking). |
rob andrews (112) 200 posts |
if it runs on my system it will run on any of the Cortex A15 ports titanium or rapido, have tested on Pi3 on problems, can’t test the game as i have no 256 colour mode availble on EVM |
Anthony Vaughan Bartram (2454) 458 posts |
Thanks Rob. However, I may accept a default behaviour of SOUND 1,1,100,100 i.e. a positive value for envelope. Just realised that this will not conflict with any of the current sound options that I’ve specified. |
Anthony Vaughan Bartram (2454) 458 posts |
Just for fun, I’ve tried a more effective demonstration of the XOR effect. Sounds a bit guitar like to me. 10 PRINT “Delay effect, pulse wave modulation filter and XOR channel modulation”15 PRINT “Version 2: A bit of Sci-fi and Guitar” 20 *RSTART 30 *RDELAY 50 100 40 *RFXMIX 2 1 50 *RFX 8 60 ENVELOPE 1,&10,&40,&16,2,50,50,-2,-4,-8,40,40,40,40 65 REPEAT 70 SOUND &11,0140,RND ( 364 ) ,100:SOUND &412,&0140,RND ( 364 ) ,100 80 A%=INKEY ( 100 ) 90 UNTIL FALSE |
Anthony Vaughan Bartram (2454) 458 posts |
Just spotted a missing &. Sounds very different with that fixed: 70 SOUND &11,&0140,RND ( 364 ) ,100:SOUND &412,&0140,RND ( 364 ) ,100 |
rob andrews (112) 200 posts |
game loads on Pi3 but no sound and some of the keys don’t work the left & right a& Z work but just lay him down then he dies tried some of the other games and they work with sound. BTW the Pi3 is running the beta rom from two days ago with all the latest changes. |
Greg (2474) 144 posts |
Anthony I have ran the demos on my Iyonix and can confirm they play happily with AMPlayer playing an MP3. So thats good 3CHORDS : Plays very quiet until I press ESCAPE then plays much louder and appears perfect BANG : Appears to play OK. Not what I thought of as a bang but that is probably just my interpretation so is probably doing exactly as it is supposed to be doing BBC : No problems DRUMS : Plays extremely quick STAR-COMMAND : No Problems WAVES : No problems XOR-PWM : No problems So far impressed I also played some of the WAVs using PlaySound whilst playing the demos and found that :- BANG BBC STAR-COMMANDIntroduced crackling into the effect they were trying to achieve. Also played some MP3s using PlaySound and did not get any crackling. Hope this helps. I am looking forward to the progress towards a finished product. Well done |
Anthony Vaughan Bartram (2454) 458 posts |
Thanks Greg. My planned timescale is to finish this prior to the South West show in February. I think the crackling when PlaySound plays the WAVs may be partly caused by RDSP using the full dynamic range (available volume) and it clipping. The fast drums might have been caused by a key-press as I’m only using A%=INKEY() to set the tempo. Given the testing performed so far, I think RDSP is running sufficiently fast that I could increase the channels to 16. Unfortunately, with 16 channels I’m going to be causing users a problem if I constantly ask them to reduce volume levels based on multiple channels playing together. Therefore I will add a Dynamic Range Compressor (and maybe make it configurable). This will be quite small (as amplification is effectively just a multiply and a divide). Specifically – a downward compressor with threshold, ratio and attack and release. |
Jeffrey Lee (213) 6048 posts |
For profiling fast code like this (i.e. anything where the monotonic timer won’t be fast enough) I’d recommend either using a HAL timer (most timers will be 32 bits wide and 1MHz or faster) or using the performance counters built into the CPU (I think any ARMv5+ system is guaranteed to have performance counters, not sure about earlier systems. For most cases the cycle counter will be all you need, and unlike the HAL timers they can be configured to be directly accessible from user mode. However you would have to check the relevant manuals to make sure you’re using the right setup/access instructions for the CPU – on ARMv7+ this should all be standardised but for ARMv6 and below the required operations may differ by either architecture or CPU). Whatever method you’re using, it may also make sense to disable interrupts while profiling the code, so that you’re not measuring the cost of someone else’s interrupt handler. And forcing the CPU speed to its slowest may also help with accuracy (e.g. HAL timers) |
Anthony Vaughan Bartram (2454) 458 posts |
Thanks Jeffrey. I’ll try out performance counters once I’ve added my ASM veneer. |
Pages: 1 2