English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. General (https://eab.abime.net/forumdisplay.php?f=37)
-   -   More than 4 sound channels - how it works? (https://eab.abime.net/showthread.php?t=70932)

Mrs Beanbag 27 September 2013 19:36

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?

StingRay 27 September 2013 19:55

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.

Predseda 27 September 2013 20:13

I have seen Chris Hülsbeck podcast, he was talking about it, but I do not know where :rolleyes

Mrs Beanbag 27 September 2013 20:16

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?

diablothe2nd 27 September 2013 21:00

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 :)

StingRay 27 September 2013 21:30

Quote:

Originally Posted by Mrs Beanbag (Post 913571)
Thanks StingRay but I know that much already!

Why do you ask how 8 channel replayers work then?

Quote:

Originally Posted by Mrs Beanbag (Post 913571)
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 gave you a hint where to look! It's not that multichannel replayer sources are hard to find anyway... StarTrekker, DigiBooster ect. pp.

Mrs Beanbag 27 September 2013 21:49

Quote:

Originally Posted by StingRay (Post 913581)
Why do you ask how 8 channel replayers work then?

Because I want to know how they work in detail, not just the most basic operating principle that isn't enough to actually implement one in practice.

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.

robinsonb5 27 September 2013 22:06

Quote:

Originally Posted by Mrs Beanbag (Post 913587)
I just wondered if anyone here could give me some pointers on the theory, like how to resample in good quality on-the-fly,

I've never tried it for audio, but when I wrote the texture-mapping routines for AMRWolf all those years ago I used what amounted to Bresenham's line-drawing algorithm to step through the source pixels without needing mul and div. A similar technique should make "nearest neighbour" resampling fairly easy - but it'll sound crunchy. If you're targetting base-level machines, I don't think you can realistically hope to resample with interpolation.

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:

how to handle independent channel volumes (which naively requires a multiplication, and 8 muls 22k times a second is a lot of work),
Yeah I don't think there's any way of avoiding a multiplication for that.

TCD 27 September 2013 22:23

Quote:

Originally Posted by Mrs Beanbag (Post 913587)
But if you have any links to the source code they'd be appreciated because Google isn't helping much right now.

http://ftp.exotica.org.uk/pub/exotic...rs/startrekker
StarTrekker_v1.2.lha -> Source/8ChannelReplay.s

Mrs Beanbag 27 September 2013 23:43

Quote:

Originally Posted by TCD (Post 913599)
ftp.exotica.org.uk/pub/exotica/software/audio/editors/startrekker
StarTrekker_v1.2.lha -> Source/8ChannelReplay.s

Thank you!

Wow... they didn't like writing comments, did they?

Mrs Beanbag 29 September 2013 20:23

Quote:

Originally Posted by robinsonb5 (Post 913591)
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.

That is a good idea, I'm interested in music but this could be done on one channel for a drum track.

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.

musojon74 30 September 2013 10:15

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.

alexh 30 September 2013 10:28

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".

Thcm 02 October 2013 11:01

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.

Dunny 02 October 2013 13:00

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.

demolition 02 October 2013 13:56

Quote:

Originally Posted by Dunny (Post 914429)
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?

That's the way to do it. You'll have to half the volume of all your samples though so the final level will be the same. To maintain fidelity you would have to use one extra bit prior to the mixing.

Thcm 02 October 2013 14:29

Quote:

Originally Posted by demolition (Post 914436)
That's the way to do it. You'll have to half the volume of all your samples though so the final level will be the same. To maintain fidelity you would have to use one extra bit prior to the mixing.

It might be the fastest solution, but in real world adding more instruments won't halve the volume of both instruments. You'll get better quality using an auto gain algorithm, but this would be too complicated on an A500. With only two voices I would simpy add the samples and clip them. I did many tests on the C64 and even with 3 voices clipping sounds much better than dividing afterwards. For speed reason I mix 4 voices using 6 bit samples to get an 8 bit mixed sample without clipping.

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.

demolition 02 October 2013 14:57

Quote:

Originally Posted by Thcm (Post 914437)
It might be the fastest solution, but in real world adding more instruments won't halve the volume of both instruments. For speed reason I mix 4 voices using 6 bit samples to get an 8 bit mixed sample without clipping.

No, the real world doesn't have a fixed max volume level. :)
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).

pandy71 02 October 2013 15:14

Quote:

Originally Posted by Dunny (Post 914429)
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.

This can't be avoided - however there is workaround:

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).

Mrs Beanbag 02 October 2013 20:08

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.

Page generated in 0.05230 seconds with 11 queries