English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 04 August 2023, 16:32   #21
Rotareneg
Registered User
 
Rotareneg's Avatar
 
Join Date: Sep 2017
Location: Kansas, USA
Posts: 327
You're not going to get "real" positional audio working on a 68K based Amiga, the math for doing positional audio correctly is complex which is why it was generally done with custom ASICs and DSPs when it first starting being a thing in PC gaming.

The wikipedia articles https://en.wikipedia.org/wiki/Sound_localization and https://en.wikipedia.org/wiki/Head-r...nsfer_function give a brief overview.
Rotareneg is offline  
Old 07 August 2023, 11:03   #22
Olaf Barthel
Registered User
 
Join Date: Aug 2010
Location: Germany
Posts: 532
Quote:
Originally Posted by meynaf View Post
Hi,

I'm wondering if there are standard formulas to compute left and right volumes from sound position.
So we have x,y coordinates of the sound, relative to the player : what to do now ?
For example, simply setting volume=0 for "the other side" doesn't work. If distance=1 left and 10 in front of the player, both ears should hear it.
In addition, while simple stereo can't tell if a sound happens in front of the player or behind, perhaps the former should be a little louder than the latter.

I have routines to do this in my dmcsb project but it finally appears they don't fare very well.
I need a good, yet simple enough system to perform that computation.
Any ideas ?
The AmigaOS 3.2 easter egg was updated for the 3.2.1 release to add synthesized bouncing ball sound effects, with reverb similiar to the original boing ball demo. I tried hard to make this work well, but there's more than one limit to what you can achieve there, considering that audio and video should be mostly in sync and that the sound has to be mixed in real time

The code I came up with uses constant power panning which, if the documentation is correct, was picked by Disney as the method preferred by the audience (could be that this research is as old as the movie "Fantasia").

Here are my brief notes and the links to the material which I made use of:

Code:
Note: for the panning to work the angle should be between -45..45 degrees,
      with 0 being the centre. -45 degrees would be the extreme left, and
      45 degrees the extreme right.

radians = (degree * PI) / 180

pan_left = sqrt(2) / 2.0 * (cos(radians) - sin(radians))
pan_right = sqrt(2) / 2.0 * (cos(radians) + sin(radians))

This "panning law" is called "Constant power panning" which avoids
making the sound in the centre softer than it is at the edges of
the field (with "linear panning"):

https://www.cs.cmu.edu/~music/icm-online/readings/panlaws/index.html
https://dsp.stackexchange.com/questions/13149/digital-panning-effect
In the updated AmigaOS 3.2.1 easter egg lookup tables are used which translate the angle (-45 .. 45 degrees) into the volume of the 8 bit sample, like this:

Code:
int pan_left_table[91];
int pan_right_table[91];
double radians;

/* Create lookup tables for panning for angles of -45..45 degrees.
 * An angle of 0 means dead centre, -45 degrees are the extreme left
 * and 45 degrees the extreme right. The table values cover the range
 * of 0..256 and must be divided by 256 before they are used as
 * an amplitude factor.
 */
for(i = 0 ; i <= 90 ; i++)
{
	radians = ((i - 45) * PI) / 180.0;

	pan_left_table[i]	= floor(256 * sqrt(2.0) / 2.0 * (cos(radians) - sin(radians)) + 0.5);
	pan_right_table[i]	= floor(256 * sqrt(2.0) / 2.0 * (cos(radians) + sin(radians)) + 0.5);
}
Now getting the same kind of effect if the source of the sound is produced behind the listener is a different matter, of course. You could cheat by attenuating that sound and/or by switching the phase of the right and left channels for the sound behind the listener. With stereo headphones, switching the phase produces a more diffuse sound whose source cannot be clearly located.

Last edited by Olaf Barthel; 07 August 2023 at 11:10.
Olaf Barthel is offline  
Old 07 August 2023, 14:43   #23
RogerS
Registered User
 
Join Date: Jul 2023
Location: UK
Posts: 25
Maybe there's something helpful in here regarding simulating a sound coming from behind (provided any of it is actually possible on the Amiga hardware of course)?
https://www.reddit.com/r/edmproducti...unds_like_its/

Quote:
votchii ยท 3 yr. ago
Reduce high frequencies and use a bit of reverb, that's generally how your ear perceives sounds coming from the back.
RogerS is offline  
Old 10 August 2023, 10:30   #24
Olaf Barthel
Registered User
 
Join Date: Aug 2010
Location: Germany
Posts: 532
Quote:
Originally Posted by RogerS View Post
Maybe there's something helpful in here regarding simulating a sound coming from behind (provided any of it is actually possible on the Amiga hardware of course)?
https://www.reddit.com/r/edmproducti...unds_like_its/
Hang on, the AmigaOS 3.2.1 easter egg also uses reverb, but not the kind which is calculated in real time. It is applied to the synthesized sound sample which is a sad compromise. Here are my notes on the implementation:

Code:
 * The following implements digital Schroeder reverberation, using
 * information gleaned from:
 *
 * https://medium.com/the-seekers-project/coding-a-basic-reverb-algorithm-an-introduction-to-audio-programming-d5d90ad58bde
 * https://medium.com/the-seekers-project/coding-a-basic-reverb-algorithm-part-2-an-introduction-to-audio-programming-4db79dd4e325
 * https://github.com/Rishikeshdaoo/Reverberator
 *
 * This involves four comb filters and two all-pass filters with
 * predefined delay and decay intervals. The Schroeder reverberation
 * produces a slightly metallic tinge in the tone of the reverberation.
 * This is fine for our purposes, which attempts to produce a sound like
 * the boing ball demo sound sample.
 *
 * The Schroeder reverberation algorithm is described in a paper by
 * M. R. Schroeder, "Natural sounding artificial reverberation"
 * published in the "Journal of the Audio Engineering Society",
 * July 1962, Volume 10, Number 3.
The metallic tone of the reverb fits because, reportedly, the ball bounce sound effect of the 1985 demo was created by hitting a steel garage door with an aluminum baseball bat. If the metallic tone of the Schroeder reverberation was intentional, it could be because plate reverb (using a steel plate), was a staple of recording studio effects in the 1960'ies. Or at least those studios which did not feature built-in echo chamber such as the ones in which Phil Spector used to record his "wall of sound" productions.
Olaf Barthel 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
Amiga sound cutting out on games pauliekins support.WinUAE 2 28 March 2016 04:24
buggy sound on some DOS games clauddio Retrogaming General Discussion 3 29 September 2012 19:07
Sound lags while recording on certain games bLAZER support.WinUAE 46 05 December 2010 12:51
sound prob on some games using 1.5.3, okay on 1.2 kirk support.WinUAE 5 16 April 2009 07:51
Film Sound FX into Games Dastardly Nostalgia & memories 8 23 June 2004 01:51

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 19:30.

Top

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