04 February 2016, 17:08 | #201 |
Registered User
Join Date: Mar 2013
Location: Slovenia
Posts: 138
|
Any kind of interpolation is faking the data you don't have - that is, you are guessing what might the data between the sampled points you have be. Of course, you can make good guesses, considering typical band-limited signal, so no big changes possible between samples, etc.
There are many ways how to do 'interpolation'. One is just repeating the existing samples some n-times (this is definitely the worst way). A little better is linear interpolation between samples (this also allows fractional upsampling). The best is of course a properly-designed low-pass filter. (In theory, all these methods are actually a sort of a filter, either a Zero-Order Hold, a weighted moving average, or a (windowed) FIR/IIR). But, just zero stuffing (A0B0...) is *not* enough for proper upsampling without the accompanying filter. |
04 February 2016, 21:27 | #202 | ||
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
Quote:
Quote:
I have used a convolution kernel [0, -27, 0, 155, 256, 155, 0, -27, 0] to good effect for upsampling by a factor of 2. |
||
05 February 2016, 00:40 | #203 | ||||
Registered User
Join Date: Jun 2010
Location: PL?
Posts: 2,909
|
Quote:
In frequency domain there is a subtle difference - spectral replicas are distributed differently. Quote:
Quote:
Quote:
Last edited by pandy71; 05 February 2016 at 00:53. |
||||
06 February 2016, 19:20 | #204 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
|
13 July 2016, 11:02 | #205 |
Registered User
Join Date: May 2016
Location: Rostock/Germany
Posts: 132
|
Faster nearest neighbor resampling
My apologies for hijacking a concluded thread but I thought I might have something worth sharing in terms of nearest-neighbor resampling. Of course, with fast hardware one might think about filtered resampling. On the other hand, to reproduce the "original" Amiga sound on Paula hardware (for good or bad, which depends on the individual point of view), nearest neighbor is the way to go.
I recently got hooked up to 68k Asm again, started tinkering around with my old code and shortly thereafter stumbled upon this thread. Out of my own (historical) knowledge, I first saw the "addx/add" combo for the position update in Jarno Paananen's PS3M. That one is already quite runtime efficient (though not as accurate as Bresenham), even on 68000. Out of my personal experience, I wouldn't recommend step tables. One might save registers but that comes at the cost of the mov from memory which is more costly than two simple adds. That being said, my tinkering led to a routine that doesn't need the second add of the well known "addx/add" combo. My first-stage 8 Bit mixing main loop looks like this (with 68000 cycle annotations): A0=input array D0=fractional position (upper 16 bits), byte position (lower 16 bits), D4=fractional increment (upper 16 bits), byte increments (lower 16 bits), D2=pointer to current volume table (upper 24 bits), where the lower 8 Bits come from each sample and are addressed as "unsigned" A2=output A5=remaining bytes in the output-16 D6=remaining bytes in the input Code:
.mix_fastloop rept 8 move.b (a0,d0.w),d2 ;14 addx.l d4,d0 ;8 move.l d2,a3 ;4 move.b (a0,d0.w),d2 ;14 move.b (a3),d3 ;8 addx.l d4,d0 ;8 move.l d2,a3 ;4 swap d3 ;4 move.b (a3),d3 ;8 move.l d3,(a2)+ ;12 ;=84 cycles for two bytes (42 cyc per byte w/o check) endr lea -16(a5),a5 ; no condition codes changed ;8 move.l a5,d1 ; swap d1 ; if( remaining_output_bytes < 16 ) 0xffff else 0x0000 or.w d6,d1 ; if( remaining_output_bytes < 16 ) -1 else ; remaining_input_bytes lea (A1,D0.l),A3 ; input: processed bytes cmp.w A3,d1 ; if( D1 < A3 ) -> stop bgt.w .mix_fastloop ;48 cycles ; total 8*68+48 / 16 = 37 cycles/byte This part of my mixing loop shown above is the "copy" loop, called for the first mixed channel. It doesn't require clearing of the output array (A2). For additional channels to be mixed with said first channel, just two more instructions are added in my routine instead of move.l d3,(a2)+: Code:
move.l (a2),a6 adda.l d3,a6 move.l a6,(a2)+ This main loop is quite a bit faster than the old code I used (derived from PS3M) on 68000 and also performs nicely on 68060. Downsides: The volume table shown in this sniplet is 8 Bit deep. For low volume channels, this method introduces quantization noise in the mixing stage that would be an annoyance when 14 or 16 Bit output of the mixed channels is desired. Maybe that stuff is of some use to someone. At least, I had fun coding on 68000 again. |
02 March 2024, 13:51 | #206 | |
Registered User
Join Date: Jan 2015
Location: London/UK
Posts: 230
|
Quote:
I think, it will be hard to make a fast mixing routine for games, but at least, we can use OCTAMED/OKTALYZER 8 channels for MENUS and other places where is not in-game. I think, you probably know this amazing fixed frequency sound routine that is quite fast: [ Show youtube player ] I had the idea to use this fixed frequency routine to make music, how? Well, having the sample for each note, you may think is crazy, but, it could be 32byte samples or some sort of small sample, it would not take much memory (and this mixer mixes the samples stored on fast ram, so, not taking chip ram). So, you need to adapt a music tracker to get to use this 3 real channels and other 4 mixed channels, so, you will be able to use it into a game. This mixing routine take very short amount of raster time. We are using it on out Amiga game, but in this configuration: Real channels: - Channel 1. Bass+Drums - Channel 2. Chords. - Channel 3. Main lead. - Channel 4. Main lead echo. Mixed channels interrupt channel 4 to fire the sound effects. So, we can have 4 sound effects mixed on channel 4. That's 7 channels. |
|
02 March 2024, 20:12 | #207 | |
Registered User
Join Date: Jul 2009
Location: Lala Land
Posts: 608
|
Quote:
|
|
02 March 2024, 20:25 | #208 |
Registered User
Join Date: Jan 2015
Location: London/UK
Posts: 230
|
Yes, I am working with my friends @Nandiusc and @DJMetune on an OCS game, all I can say, the game is using this fixed frequency sound mixer and the performance on a 7mhz OCS Amiga is really good.
You will know about the game when the game is ready to show up. |
02 March 2024, 20:55 | #209 | |
Registered User
Join Date: Feb 2018
Location: Poland
Posts: 373
|
Quote:
Actually no need to adapt a tracker. You just need to write the music having the limitations in mind, in any tracker. Any XM compatible tracker will be well suited for this purpose. |
|
03 March 2024, 03:16 | #210 |
J.M.D - Bedroom Musician
Join Date: Apr 2014
Location: los angeles,ca
Posts: 3,662
|
|
03 March 2024, 10:16 | #211 |
Registered User
Join Date: Feb 2018
Location: Poland
Posts: 373
|
There is more to this, but I don't see the issue with a volume.
|
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 |
|
|