Playing raw audio/PCM
Patrick M (2888) 126 posts |
Hello, Sorry if this is a question that’s already answered somewhere. At the moment I’m getting interested in writing programs that create sound. Is there any way of doing anything similar in RISC OS? Or maybe I mean to ask, how would you go about playing sound samples in RISC OS? PM |
Bryan Hogan (339) 592 posts |
RDSP is probably the best place to start – http://www.amcog-games.co.uk/rdsp.htm |
Andrew Rawnsley (492) 1445 posts |
There’s also PlayIt which is a system resource on most distributions (and is free otherwise). It doesn’t quite do what the original poster asks, as it is more file-based, but it’s a useful way to do background sound streaming of a variety of input source formats. Historically there was DataVox which has been updated to 32bit by Jeff D. Finally, the distribution for SharedUnixLib includes DigitalRenderer which I believe allows a more linux-y approach to audio which might be applicable in this case. I haven’t tried RDSP (in my head, it was more of an audio fx tool), but looking at the website, it may well do what’s needed too. |
Steffen Huber (91) 1953 posts |
You could try the modules suite that DigitalCD uses: http://users.skynet.be/Andre.Timmermans/digitalcd/player/download.htm |
Patrick M (2888) 126 posts |
Thanks for the replies. I didn’t think of RDSP at first, I had the impression that it was intended as more of a music synth, but it seems like it might do what I want. I’ll look into the other methods too. |
Anthony Vaughan Bartram (2454) 458 posts |
Hi Patrick, RDSP does indeed provide a simple way of loading and playing a sample and/or samples. You can also loop samples if desired. Examples are included that demonstrate this including a simple drum loop example. I’m planning an update to RDSP soon and I might be able to add a feature in for you if RDSP does not quite do what you require. If I understand correctly – are you generating a waveform and looking for a way to play the generated sound as a continuous stream? I am currently implementing a queuing feature in RDSP. At present you would have to manually re-trigger the next generated sample fragment by watching a clock – which might lead to dropouts. I suspect if you implementing a stream solution, then the queuing feature that I am currently writing would make that much easier. |
Patrick M (2888) 126 posts |
Hi Anthony,
That’s correct. I’m writing a music player/tracker, and the sound output from it is a stream that could potentially be very long, or even endless if it’s playing a song that loops. Patrick |
Anthony Vaughan Bartram (2454) 458 posts |
Hi Patrick, However – if this is a music tracker, then traditionally this involves samples triggered in step-time over a number of channels. Are you writing something similar? RDSP has its own internal managed stream (based on Shared Sound) and you can play up to 16 sounds simultaneously on different musical notes (or micro-tones). The sounds played may be samples or can be generated synthesised sounds modulated to different musical notes. I’m just wondering if you what you are writing would be partly implemented by RDSP and that you may not know that it already implements a stream that may play multiple modulated sounds at once. I’m working on a music demo at the moment which uses RDSP internally based on a simple tracker structure. Alternatively, if you just need the audio streaming part – regarding the queuing feature. I hope to have something available later this month or early December. Regards, Tony |
André Timmermans (100) 655 posts |
Hi Patrick, One possibility is to do like !KinoAmp when playing videos with sound in PCM format: use DiskSample to define a circular buffer in mono/stereo 8-bit/16-bit per sample and push data in it regularly while the module plays the buffer and discards the played part. Another possibility as you mention “Tracker” could be to use TimPlayer. Assuming that your instruments are composed of samples (i.e. not synthesized sounds) you create a new “song” and define its samples by pointing to yours in memory, then play/alter notes using these samples. ExternSmp is a little example loads a wave file in memory, defines 2 samples (left and right) from it and plays them. !FxTest is another example which load an ImpulseTracker file and let you play sample/instruments and alter the paramters of the played notes (volume, panning, pitch, …). All the modules and KinoAmp, the documentation and sources are available from http://www.riscos-digitalcd.net/digitalcd/player/download.htm |
Patrick M (2888) 126 posts |
Hello, Thanks for all the information. Sorry for my delayed reply, I’ve been away for a while and had a lot going on.
I knew RDSP has features like that – if I were starting from scratch I’d probably use those features, but my situation is that I’m looking for ways to implement specific features of a program I’ve been writing for Linux. I’ve been writing a game for Linux in C with the Allegro library, and my plan is that once it’s finished, I’ll try to convert it to run on RISC OS. I think Allegro isn’t available for RISC OS so I’ll need to find alternatives for the various features of allegro that I’ve been using (like using OS_SpriteOp instead of the the various Allegro sprite drawing routines, etc) RDSP’s planned queuing feature sounds like it’d allow me to bring over my music playing code with few modifications. The DiskSample method sounds like it would work well too, but I’m thinking that RDSP would probably be more user friendly overall. And I could use RDSP’s other features for playing sound effects, too. Patrick |
Anthony Vaughan Bartram (2454) 458 posts |
Hi Patrick, I was just wondering if a sound queue of 256 entries per channel would be ok for you? Or whether you needed this to be longer. Thanks, Tony |
Patrick M (2888) 126 posts |
Hi Tony, That sounds like a lot – I’m pretty sure it would be plenty, probably even more than enough for me. Patrick |