English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 27 September 2013, 19:36   #1
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
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?
Mrs Beanbag is offline  
Old 27 September 2013, 19:55   #2
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,013
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.
StingRay is offline  
Old 27 September 2013, 20:13   #3
Predseda
Puttymoon inhabitant
Predseda's Avatar
 
Join Date: Mar 2007
Location: The City of Townsville
Age: 40
Posts: 4,851
I have seen Chris Hülsbeck podcast, he was talking about it, but I do not know where
Predseda is offline  
Old 27 September 2013, 20:16   #4
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
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?
Mrs Beanbag is offline  
Old 27 September 2013, 21:00   #5
diablothe2nd
Registered User

diablothe2nd's Avatar
 
Join Date: Dec 2011
Location: Northampton, UK
Age: 36
Posts: 1,232
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
diablothe2nd is offline  
Old 27 September 2013, 21:30   #6
StingRay
move.l #$c0ff33,throat

StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,013
Quote:
Originally Posted by Mrs Beanbag View Post
Thanks StingRay but I know that much already!
Why do you ask how 8 channel replayers work then?

Quote:
Originally Posted by Mrs Beanbag View Post
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.
StingRay is offline  
Old 27 September 2013, 21:49   #7
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
Quote:
Originally Posted by StingRay View Post
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.
Mrs Beanbag is offline  
Old 27 September 2013, 22:06   #8
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 577
Quote:
Originally Posted by Mrs Beanbag View Post
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.
robinsonb5 is offline  
Old 27 September 2013, 22:23   #9
TCD
Registered User

TCD's Avatar
 
Join Date: Sep 2006
Location: Germany
Age: 40
Posts: 24,012
Quote:
Originally Posted by Mrs Beanbag View Post
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
TCD is offline  
Old 27 September 2013, 23:43   #10
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
Quote:
Originally Posted by TCD View Post
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 is offline  
Old 29 September 2013, 20:23   #11
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
Quote:
Originally Posted by robinsonb5 View Post
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.
Mrs Beanbag is offline  
Old 30 September 2013, 10:15   #12
musojon74
Registered User

musojon74's Avatar
 
Join Date: Dec 2007
Location: Dereham, United Kingdom
Age: 44
Posts: 470
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.
musojon74 is offline  
Old 30 September 2013, 10:28   #13
alexh
Thalion Webshrine
alexh's Avatar
 
Join Date: Jan 2004
Location: Oxford
Posts: 12,119
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".
alexh is offline  
Old 02 October 2013, 11:01   #14
Thcm
Registered User
 
Join Date: Dec 2011
Location: Gummersbach
Posts: 9
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.
Thcm is offline  
Old 02 October 2013, 13:00   #15
Dunny
Registered User

Dunny's Avatar
 
Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 1,046
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.
Dunny is offline  
Old 02 October 2013, 13:56   #16
demolition
Unregistered User
demolition's Avatar
 
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 38
Posts: 3,690
Quote:
Originally Posted by Dunny View Post
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.
demolition is offline  
Old 02 October 2013, 14:29   #17
Thcm
Registered User
 
Join Date: Dec 2011
Location: Gummersbach
Posts: 9
Quote:
Originally Posted by demolition View Post
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.
Thcm is offline  
Old 02 October 2013, 14:57   #18
demolition
Unregistered User
demolition's Avatar
 
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 38
Posts: 3,690
Quote:
Originally Posted by Thcm View Post
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).
demolition is offline  
Old 02 October 2013, 15:14   #19
pandy71
Registered User
 
Join Date: Jun 2010
Location: PL
Posts: 1,653
Quote:
Originally Posted by Dunny View Post
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).
pandy71 is offline  
Old 02 October 2013, 20:08   #20
Mrs Beanbag
Glastonbridge Software
Mrs Beanbag's Avatar
 
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,202
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?
Mrs Beanbag is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sound channels switched? bLAZER support.WinUAE 21 28 October 2014 08:43
A600: missing sound channels cosam support.Hardware 28 23 May 2010 06:43
More that 4 Sound Channels??? Dragon3d support.WinUAE 8 01 February 2008 17:30
shufflepuck cafe 4 channels sound is crazy turrican3 support.WinUAE 5 08 November 2007 15:41
help sound 4 channels turrican3 support.WinUAE 37 13 April 2007 09:17

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:19.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.24791 seconds with 15 queries