Welcome, Guest. Please login or register.

Author Topic: Simple Amiga audio question.  (Read 17556 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline ThorhamTopic starter

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: Simple Amiga audio question.
« Reply #44 from previous page: June 14, 2010, 06:02:32 PM »
Quote from: bubblebobble;564444
Here is an example of my implementation of ADPCM4.

All files are converted back to .wav so you can easily play them.
Thank you very much :) Much better than I expected, to be honest, especially 4 bit (and also better than IMA, it seems that IMA is for speech). Sounds good :)
Quote from: bubblebobble;564444
If you decide to use this codec, I can pass you the source along.
Although I'm still playing around with lossless encoding ideas, I have a feeling I'm going to get stuck and need lossy anyway, so sharing your source code will certainly be appreciated a lot.
Quote from: bubblebobble;564444
Probably 6bit is quite hi-fi too, but it's a little hazzle to implement since 6 is not a fraction of 8, so you need to decode always 4 samples at once. But if 4 samples turns out to be too poor, 6bit would be doable too.
Decoding 4 samples at once shouldn't be much of a problem to implement here.
 

Offline ThorhamTopic starter

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: Simple Amiga audio question.
« Reply #45 on: August 06, 2010, 05:14:42 PM »
Haven't been busy with this for a while now... I think I'll just write an ADPCM encoder and decoder myself. I'll try lossless encoding once more, and I'm also tempted to soft loop the tracks, although it's quite a chore (sigh).

Anyway, thanks to all who've posted their suggestions and comments :)

One more thought: If one could do software channel separation and sound recognition/reconstruction, I'm sure the entropy of music would be better than 0.5, but just try to write it :roflmao:
« Last Edit: August 06, 2010, 05:18:59 PM by Thorham »
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Simple Amiga audio question.
« Reply #46 on: August 06, 2010, 06:42:10 PM »
Quote from: Thorham;573668
One more thought: If one could do software channel separation and sound recognition/reconstruction, I'm sure the entropy of music would be better than 0.5, but just try to write it :roflmao:


If by channel you mean left/right, then many encoders already do take advantage of the correlation between left and right to increase compression*.

If by channel you mean frequency band, then basically this is what mp3 and similar systems use.

*the encoder I wrote doesn't do mid/side band analysis. The reason for this is that the method of encoding tries to pick the best n deltas per frame of audio, using both channels anyway. As a consequence, when the channels are correlated; that is to say they have a similar range of delta values (regardless of overall phase difference between the left/right signals) then the encoder picks values equally suitable for each channel. When one channel has much more variation than the other (for instance, a loud sound in one and quiet in the other), then the louder channel dominates the pool of chosen delta values. The result being that the channel with most going on is always given a bigger share of the available "bits" than the other.
int p; // A
 

Offline ThorhamTopic starter

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: Simple Amiga audio question.
« Reply #47 on: August 06, 2010, 07:41:58 PM »
What I mean is this: If you have a tracked piece of music (all music is tracked), then each of the channels will play part of the music, one instrument at a time. The brain can easily separate the channels and recognize the instruments as independent samples, meaning it can convert a piece of music to a tracked format.

With a tracked format you can easily beat 1:2 lossless compression. A MOD recorded to WAV and compressed with, say, FLAC would be much bigger than the original MOD.

This is why I don't believe that the 1:2 ratio is dictated by nature, as bubblebobble claims. People simply don't know how to do it yet, because WAV to tracked format conversion isn't exactly easy to write, especially not without neural algorithms.
« Last Edit: August 06, 2010, 07:44:24 PM by Thorham »
 

Offline Zac67

  • Hero Member
  • *****
  • Join Date: Nov 2004
  • Posts: 2890
    • Show only replies by Zac67
Re: Simple Amiga audio question.
« Reply #48 on: August 06, 2010, 08:06:07 PM »
No need to separate into instruments/voices.
Since any possible sequence of numbers can be found in Pi (can be mathmatically proven) you just have to search Pi's digits for the sequence of your PCM stream and store the index where the sequence starts.

For decompression you just calculate the digits of Pi from that index on and voilĂ : your original stream will play back.

 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Simple Amiga audio question.
« Reply #49 on: August 06, 2010, 09:14:05 PM »
Quote from: Thorham;573688
With a tracked format you can easily beat 1:2 lossless compression. A MOD recorded to WAV and compressed with, say, FLAC would be much bigger than the original MOD.

This is why I don't believe that the 1:2 ratio is dictated by nature, as bubblebobble claims. People simply don't know how to do it yet, because WAV to tracked format conversion isn't exactly easy to write, especially not without neural algorithms.


Ok, now I get you. Theoretically, assuming you could perform the required convolutions to identify the individual components, this might work for a piece of music where each "channel" is played by some easily identified oscillator function (square wave, sine wave, trinagle wave). You could then translate to a format that describes how those oscillators are played over time (pitch, volume, pan) in order to be able to reproduce it using those same oscillator functions. What you have there is something like your SMF (standard MIDI file) format.

However, real music produced on real instruments does not follow this paradigm. An individual instrument can produce a near infinite variation in tonal quality depending on how it is played, never mind the complexities added by production effects.

There are only two real analysis you can do with a recorded waveform in PCM format:

1) Analyse the sample data in the time domain.
2) Perform discrete FFT to convert into the frequency domain and analyse that.

In either case, you can perform an additional analysis based on the known effects of human audio perception and head related transfer function.
int p; // A
 

Offline bubblebobble

  • Jr. Member
  • **
  • Join Date: Dec 2003
  • Posts: 66
    • Show only replies by bubblebobble
    • http://www.hd-rec.de
Re: Simple Amiga audio question.
« Reply #50 on: August 06, 2010, 09:15:00 PM »
@Thorham
This won't work. A MOD is smaller because it uses samples, usually at a low quality (short, low samplerate, bitresolution, mono etc.). In a regular music production (if done using samples), they could easily exceed the memory needed to store the final mixdown. As soon as you start to use analog things like voice recordings, real instruments etc. the amount of information needed to describe this goes immediately up.

Apart from that, mixing the channels is a lossy process and cannot be reverted. What we hear is extemely lossy, even worse than an mp3.

What the human ear is doing is tracking instruments/noises by harmonic frequencies or other frequency distributions that have been learned before. Doing that, they miss a lot of stuff that is actually in the music. You might hear it the next time you listen, but then ignore something else. The ear uses a lot of information available prior to listening to the music.

E.g. put it to the extreme, you could write a codec that stores the entire music that will ever be encoded/decoded using this codec in a database. Then, encoding/decoding comes down to an index lookup, every music score is compressed to an integer.
But, at the end, you have to store the information, in the encoded data or outside from meta knowledge.

The same with predictors in looseles codecs. They represent prior knowledge that is assumed and put into the decoder. Once the data doesnt obey this knowledge, your codec screws up, e.g. on white noise.

The best predictors achieve roughly 1:2. Just accept this. Anything else is lossy.
mp3 or ogg are pretty good by compressing 1:12. They make assumptions how the human ear works.
--
Author of
HD-Rec, Sweeper, Samplemanager, ArTKanoid, Monkeyscript, Toadies, AsteroidsTR, TuiTED, PosTED, TKPlayer, AudioConverter, ScreenCam, PerlinFX, MapEdit, AB3 Includes and many more...
Homepage: http://www.hd-rec.de
 

Offline ThorhamTopic starter

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: Simple Amiga audio question.
« Reply #51 on: August 10, 2010, 04:48:04 PM »
Quote from: bubblebobble;573704
The best predictors achieve roughly 1:2. Just accept this. Anything else is lossy.
I can only accept this if there's hard mathematical proof for this. If this 1:2 ratio is the result of the current best implementations, than it's circumstantial evidence, and not hard proof. If there is hard proof, then it's a fact, until than it's theory.

Anyway, the idea I presented is probably too hard to implement in this day and age anyway, and I just wanted to hear peoples thoughts about it :)
 

Offline XDelusion

  • Alien Breeder
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 5089
    • Show only replies by XDelusion
    • http://starwarslegacy.net/
Re: Simple Amiga audio question.
« Reply #52 on: August 10, 2010, 06:42:38 PM »
I've been away from the Amiga more than I would have liked. In the past, Karlos or somebody explained to me the process of cutting the first two bits off a WAV file in order to make it friendly with the Amiga. Since then I forget what I was told, would someone mind refreshing my memory?

Thank you!
Earth has a lot of things other folks might want... like the whole planet. And maybe these folks would like a few changes made, like more carbon dioxide in the atmosphere and room for their way of life. - William S. Burroughs
 

Offline XDelusion

  • Alien Breeder
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 5089
    • Show only replies by XDelusion
    • http://starwarslegacy.net/
Re: Simple Amiga audio question.
« Reply #53 on: August 16, 2010, 06:41:24 PM »
Please?
Earth has a lot of things other folks might want... like the whole planet. And maybe these folks would like a few changes made, like more carbon dioxide in the atmosphere and room for their way of life. - William S. Burroughs
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Simple Amiga audio question.
« Reply #54 on: August 16, 2010, 07:03:01 PM »
Quote from: XDelusion;574998
Please?


I can't remember. What was the question?
int p; // A
 

Offline XDelusion

  • Alien Breeder
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 5089
    • Show only replies by XDelusion
    • http://starwarslegacy.net/
Re: Simple Amiga audio question.
« Reply #55 on: August 16, 2010, 07:06:31 PM »
This:

Quote from: XDelusion;574211
I've been away from the Amiga more than I would have liked. In the past, Karlos or somebody explained to me the process of cutting the first two bits off a WAV file in order to make it friendly with the Amiga. Since then I forget what I was told, would someone mind refreshing my memory?

Thank you!
Earth has a lot of things other folks might want... like the whole planet. And maybe these folks would like a few changes made, like more carbon dioxide in the atmosphere and room for their way of life. - William S. Burroughs
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Simple Amiga audio question.
« Reply #56 on: August 16, 2010, 07:12:54 PM »
Quote from: XDelusion;575000
This:


Hmm. I'm not sure it was me that told you that, but well, you should be able to load wav files straight into Soundstudio.

The RIFF WAV specification is a bit of a mess as it tried to become a multiformat container for different audio codecs and sort of failed. However, basic 8 and 16-bit linear PCM encodings are fine in Soundstudio.

You can't load 16-bit WAV data as raw because it's byteswapped and basically it will sound awful. 8-bit WAV data is, for legacy reasons, also unsigned, I believe (centred at 128, rather than 0).
int p; // A
 

Offline ThorhamTopic starter

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: Simple Amiga audio question.
« Reply #57 on: August 17, 2010, 12:30:12 AM »
Don't know if it's useful, but here goes ;)
Quote from: XDelusion;574211
I've been away from the Amiga more than I would have liked. In the past, Karlos or somebody explained to me the process of cutting the first two bits off a WAV file in order to make it friendly with the Amiga. Since then I forget what I was told, would someone mind refreshing my memory?

Thank you!
What you have to do is endian convert each sample in the WAV file, because the bytes are swapped:
Code: [Select]

 move.w (a0)+,d0 ;a0 points to sample.
 rol.w #8,d0 ;swap sample bytes.


In case the samples are stored as unsigned integers you can convert them to signed like this:
Code: [Select]

 sub.w #32768,d0 ;d0 contains the sample.


After that you can convert the sample from 16 to 14 bit like this:
Code: [Select]

 asr.w #2,d0 ;d0 contains the sample.

I sure hope I didn't make any stupid mistakes ;)
« Last Edit: August 20, 2010, 03:35:34 PM by Thorham »
 

Offline XDelusion

  • Alien Breeder
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 5089
    • Show only replies by XDelusion
    • http://starwarslegacy.net/
Re: Simple Amiga audio question.
« Reply #58 on: August 17, 2010, 05:46:57 PM »
WOW, OK, maybe nobody did explain this one to me before, seeing as all that looks...

...a bit over my head.

Are these command lines for a program or something? I'm sure if I start typing that stuff in CLI that nothing will happen but errors, so what's this for?

Thankx! :)
Earth has a lot of things other folks might want... like the whole planet. And maybe these folks would like a few changes made, like more carbon dioxide in the atmosphere and room for their way of life. - William S. Burroughs
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16878
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Simple Amiga audio question.
« Reply #59 on: August 18, 2010, 10:19:51 PM »
@XDelusion

Why do you need to convert 16-bit WAV's to 14-bit anyway? Tools like Play16 etc use AHI which does the conversion from 16-bit data to calibrated 14-bit as it plays.

If you just want to use 16-bit sample data in OctaMED, just go right a head and load the WAV into the sample editor. It should be fine.

@Thoram
Quote
I sure hope I didn't make any stupid mistakes ;)


Just the one. The conversion from unsigned to signed should have subtracted 32768, not 128. You'd subtract 128 for 8-bit unsigned sample data.
« Last Edit: August 18, 2010, 10:25:42 PM by Karlos »
int p; // A