More than 4 sound channels - how it works?
Does anybody have any insider information on how Jochen Hippel's 7 voice routine or Octamed 8 voice works? Or any source code?
|
Basically it just mixing of the samples, 2 samples -> 1 sample (simplest approach: add both sample bytes and divide by 2). That way you can have 8 virtual channels even though only 4 real channels are available. Check the StarTrekker replayer for an example.
|
I have seen Chris Hülsbeck podcast, he was talking about it, but I do not know where :rolleyes
|
Thanks StingRay but I know that much already!
I need more technical details to actually write such a thing. How do they mix together two samples at arbitrary different periods and volumes, and make it fast enough? |
i'm just guessing here, but perhaps it uses something similar to the way interlace video works? where on frame 1 you have odd lines and frame 2 you have even. perhaps the samples are spliced.
does the audio quality seem more noisy when you cram those two samples into one channel? would love to see it played through a spectrometer to look at the waveforms :) |
Quote:
Quote:
|
Quote:
I could spend all week looking at someone else's source code trying to work it out, I just wondered if anyone here could give me some pointers on the theory, like how to resample in good quality on-the-fly, how to handle independent channel volumes (which naively requires a multiplication, and 8 muls 22k times a second is a lot of work), how to sync with Paula to keep it fed with data at the correct rate. But if you have any links to the source code they'd be appreciated because Google isn't helping much right now. |
Quote:
If your aim is games, by the way, consider devoting three channels to audio, and mixing multiple virtual channels of sound effects into a single fourth channel - sound effects can be resampled in advance, if necessary, since they're generally only required to play at one pitch. Quote:
|
Quote:
StarTrekker_v1.2.lha -> Source/8ChannelReplay.s |
Quote:
Wow... they didn't like writing comments, did they? |
Quote:
After looking at that source code for a while, it looks like they don't bother with volume control, and it appears to be fixed-point arithmetic for the resampling, nearest neighbour. I tried writing a resampler once (although with no intention of speed), I had to add interpolation for it to sound any good, nearest neighbour sounded dreadful. But Octamed et al don't sound bad. |
Octamed Soundstudio did full software mixing with better quality than the old halved channel way. Expensive though I guess ( it barely allowed 8 channels on my original unexpanded 1200.
|
I am curious to know the history of software mixing on 16-bit systems. Who was the first to attempt it etc.
I know that the 7-channel replay routine used by Huelsbeck was written by Jochen "Mad Max" Hippel. He was Thalion's original musician and their Amiga programmer. He's even credited in Turrican 3 which was released long after Jochen "retired". |
I wrote a Protracker replayer for the good old C64: http://csdb.dk/release/?id=112365
The mixing of 4 channels at 7800hz including different periods and volume needs about 50% of the cpu power of an unxepanded C64 running at ~1 Mhz. The other half of the cpu time is needed to output the 8 bit samples using NMI. In theory it should be possible to have at least 8 full featured channels running on a stock Amiga 500 without any problems. Using double bufferd mixing buffers and clever use of tables should do the trick. There's no need for any expensive instructions. Even the Protracker replay logic uses a few rasterlines on the c64 using my approach. |
I would be interested to know how to mix samples effectively. Stingray's suggestion of adding two samples and dividing by 2 seems wrong to me - if I have a loud sample and a quiet sample, then the averaging operation will decrease the volume of the louder sample and correspondingly increase the volume of the quieter sample. How would this be avoided?
D. |
Quote:
|
Quote:
Another solution would be to combine two paula channels to get nearly 14 bit output and clipping or dividing won't matter. I didn't do any 68k coding since the nineties, but I think 8 channels with 14 bit output should be doable. I don't know how high the mixing rate will be, but I could do some calculations. |
Quote:
And mixing 4x6 bit samples into one 8 bit is exactly the same. Then you divided your original samples by 4 before adding them together (as you could have used 8 bit samples). |
Quote:
Use 16 bit arithmetic, add all channels (with 256 8-bit channels you need more than 16 bit) at the end rescale result and now story begins. You can truncate/round 16 bit to 8 bit and output directly to DAC loosing lower 8 bit (thus create problem you already mention) or perform error processing (Error Feedback Rounding) - rest from truncation can be added to next 16 bit sample, this is simplest way and it can sound good - oversampling recommended - higher - better. http://www.google.com/patents/US6801925 If there is plenty of CPU power then formal noiseshaping with dithering can be performed (based on scientific publications - correctly noise shaped and dithered 8 bit system with 4 times oversampling can provide over 120 dB dynamics). This remain me my previous idea. Copper audio with DMA - set Audio DMA period high - few times higher than allowed and push audio samples interleaved by zero with Copper. Suggested 14 bit can work also. And probably some LUT's are unavoidable on Amiga (lack of DSP). |
I did wonder about mixing all channels into 14 bit, I don't see why it would be especially more expensive to do it that way. Of course we could use 16 bit samples as well AND use noiseshaping if we were really enthusiastic.
Use of copper to load Paula is interesting idea too. But is any time lost due to vertical blank? |
All times are GMT +2. The time now is 03:27. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.