Welcome, Guest. Please login or register.

Author Topic: Programming "Chip Tunes"  (Read 1704 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline TrevTopic starter

  • Zero
  • Hero Member
  • *****
  • Join Date: May 2003
  • Posts: 1550
  • Country: 00
    • Show only replies by Trev
Programming "Chip Tunes"
« on: March 24, 2005, 03:39:12 AM »
Anyone know where to find good documentation on doing low-level FM synthesis (which is what I think chip tunes are--correct me if I'm wrong) on Amigas? Or is the info located somwhere less than obvious inside the NDK, kernel docs, or developer CD? (Or perhaps it's more than obvious, and I'm just blind.)

EDIT: OK. That was a totally boneheaded question. The section on custom chips in the hardware manual explains everything quite well.

Trev
 

Offline Waccoon

  • Hero Member
  • *****
  • Join Date: Apr 2002
  • Posts: 1057
    • Show only replies by Waccoon
Re: Programming "Chip Tunes"
« Reply #1 on: March 24, 2005, 08:16:23 AM »
FM is frequency modulation, where the input of one or more waveforms is used to modify a second waveform.  The Amiga has no hardware support for this, so I don't believe you'll find what you're looking for in the hardware documentation.

"Chip" tunes are just really small waveforms (a few hundred bytes at best) that are looped really fast.  Fast arpegios give that traditional glimble effect.  The source code for a number of old soundtracker players is available, though most are only in assembler.
http://www.pouet.net/prod.php?which=13419
 

Offline TrevTopic starter

  • Zero
  • Hero Member
  • *****
  • Join Date: May 2003
  • Posts: 1550
  • Country: 00
    • Show only replies by Trev
Re: Programming "Chip Tunes"
« Reply #2 on: March 25, 2005, 08:25:09 AM »
Ummm, I always understood frequency modulation to be modulating (i.e. changing) the frequency. :-P Anyhow, I'm just writing a simple set of PC speaker emulation routines, so a small sine wave sample and some appropriate writes to AUDxLC, AUDxLEN, AUDxPER, and DMACON should be all I need. Each of the audio channels can  be used to modulate the next higher channel (except for channel 3, which just gets disabled if you enable modulation).

And for chip tunes, some creative use of sine, square, and triangle waves along with frequency and amplitude modulation would be in order. The synthesis would come from mixing the waves to produce recognizable instruments.

Trev
 

  • Guest
Re: Programming "Chip Tunes"
« Reply #3 on: March 25, 2005, 01:36:09 PM »
Weren't the old Future Composer tunes using the paula chip to synthesize waveforms without any samples?
 

Offline minator

  • Hero Member
  • *****
  • Join Date: Jan 2003
  • Posts: 592
    • Show only replies by minator
    • http://www.blachford.info
Re: Programming "Chip Tunes"
« Reply #4 on: March 25, 2005, 03:31:28 PM »
This is a short but interesting thread, I happen to be deep in the middle of the design phase for a soft synth right now and am reading anything and everything I can find on synthesisers I can find.

...So I read this and started reading about the synths in home "micros".
There's thousands of mods out there of course but there's also music formats for pretty much every computer out there, I've heard a load of SIDs (C64) and SAPs (Atari). Fasinating stuff, they are very basic but it's pretty amazing what some people were able to do with them.

Quote
Weren't the old Future Composer tunes using the paula chip to synthesize waveforms without any samples?


Paula was a sample player so you could get the CPU to generate a waveform and the Paula would play it as a loop, you can get it to play pretty much any waveform.

Doing a proper emulation of Paula could be quite difficult as it gets different tones by altering it's playrate, these days the CPU will do the audio playback by interpolating samples for different tones.  So, a MOD played on a modern sound system is going to sound different from the same thing played on an original Amiga.  The later multi channel mods will be easier to play properly because they also used interpolation - providing the mixing rate is identical...

To properly emulate the Amiga sound system *accurately* will rather ironically, require some pretty high end (read expensive) kit.
 

  • Guest
Re: Programming "Chip Tunes"
« Reply #5 on: March 26, 2005, 12:03:51 AM »
Quote

minator wrote:
This is a short but interesting thread, I happen to be deep in the middle of the design phase for a soft synth right now and am reading anything and everything I can find on synthesisers I can find.

...So I read this and started reading about the synths in home "micros".
There's thousands of mods out there of course but there's also music formats for pretty much every computer out there, I've heard a load of SIDs (C64) and SAPs (Atari). Fasinating stuff, they are very basic but it's pretty amazing what some people were able to do with them.

Quote
Weren't the old Future Composer tunes using the paula chip to synthesize waveforms without any samples?


Paula was a sample player so you could get the CPU to generate a waveform and the Paula would play it as a loop, you can get it to play pretty much any waveform.

Doing a proper emulation of Paula could be quite difficult as it gets different tones by altering it's playrate, these days the CPU will do the audio playback by interpolating samples for different tones.  So, a MOD played on a modern sound system is going to sound different from the same thing played on an original Amiga.  The later multi channel mods will be easier to play properly because they also used interpolation - providing the mixing rate is identical...

To properly emulate the Amiga sound system *accurately* will rather ironically, require some pretty high end (read expensive) kit.


Interesting stuff.

The UADE plugin for Linux/MorphOS is the best thing for playing back Amiga MOD's on a modern system.  It uses the UAE core and the EaglePlayer/Delitracker 68k ASM sources for almost cycle exact replay.  It sounds much better than any other MOD Player i've heard that isn't running on a real Amiga.
 

Offline TrevTopic starter

  • Zero
  • Hero Member
  • *****
  • Join Date: May 2003
  • Posts: 1550
  • Country: 00
    • Show only replies by Trev
Re: Programming "Chip Tunes"
« Reply #6 on: March 26, 2005, 12:12:48 AM »
As far as I know, the Paula only plays samples. I think traditional FM synth chips generate the wave forms in hardware. You then modify the frequency, amplitude, and mix to produce custom tones. In the Amiga, it looks like I'll have to dope the Paula with my own wave forms, but that's really very simple, especially with 8-bit samples.

Newer synths work like the Amiga did, using tables of pre-defined sample wave forms (i.e. an actual piano sample) to produce their sounds. But analog and FM synths are regaining popularity.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Programming "Chip Tunes"
« Reply #7 on: March 26, 2005, 01:02:39 AM »
I might be going mental, but I seem to recall reading someplace in the amiga hardware manuals that paula could be configured in such a way that one channel could modulate the volume or period of another. The latter idea is the basis for FM synthesis AFAIK.

Anyway, one way to create great 'chip' tunes is to use musicline. It actually uses the 'short loop' idea of your normal chip tune, but it has some software filters and other operations that make it a little bit special.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Programming "Chip Tunes"
« Reply #8 on: March 26, 2005, 01:08:03 AM »
From the hardware manual:

"To provide more complex audio effects, you can use one audio channel to modulate another. This increases the range and type of effects that can be produced. You can modulate a channel's frequency or  amplitude , or do both types of modulation on a channel at the same time.

Amplitude  modulation affects the  volume  of the waveform. It is often used to produce vibrato or tremolo effects. Frequency modulation affects the  period  of the waveform. Although the basic waveform itself remains the same, the pitch is increased or decreased by frequency modulation.

The system uses one channel to modulate another when you attach two channels. The attach bits in the ADKCON register control how the data from an audio channel is interpreted (see the table below). Normally, each channel produces sound when it is enabled. If the "attach"  bit for an audio channel is set, that channel ceases to produce sound and its data is used to modulate the sound of the next higher-numbered channel. When a channel is used as a modulator, the words in its data set are no longer
treated as two individual bytes. Instead, they are used as "modulator" words. The data words from the modulator channel are written into the corresponding registers of the modulated channel each time the  period register  of the modulator channel times out."

I read that as meaning one channel can modulate the pitch / amplitude of another. The above use seems to be describing a basic LFO, but if you can perform this modulation at normal audio frequencies, you have the basis of an FM synth.
int p; // A
 

Offline boing

  • Sr. Member
  • ****
  • Join Date: Apr 2002
  • Posts: 293
    • Show only replies by boing
    • http://www.TribeOfHeart.org
Re: Programming "Chip Tunes"
« Reply #9 on: March 26, 2005, 06:18:18 AM »
Neat. Which version and which page?  I think this^ is similar to how some programs provided 14-bit audio. By using volume control you can in effect extend the range of the Amiga's default 8-bit DACs. IIRC, the Amiga had/has 64 volume levels (5 bit volume control).


Prior: I think many here are getting hung up with incorrect terminology.  Karlos and Trev seem to be more on target.

The real Amiga audio system by default was designed for playing samples.  Contrast this to the C64's SID chip that used Attack, Decay, Sustain, Release circuits (hyrbid analog-digital).  Both have advantages. I advocated adding ADSR circuits to the Amiga audio. But oh well.  The Amiga does have a mode that goes beyond sample playing however. See Karlos's posting above.


>Doing a proper emulation of Paula could be quite difficult as it gets
>different tones by altering it's playrate
 
  Altering the sample itself can also affect the tone / pitch / frequency.  For example, set the Amiga to do a 1 second 22KHz digitization.  You can record (from a piano) a C note (for example) or the next C up (an octave up- which is twice the inherent frequency).  The playback rate is still 22KHz, but the second sample has a higher tone because while the record/playback rate (period)  is the same, the second sample recorded a string vibrating at 2X the frequency (it's an octave higher). If you looked at the digital levels you'd see that the number of times the sample level crosses the 0 position is twice that of the first sample.  This is basically what Karlos mentions in the Amiga Hardware Ref. Manual.


>The data words from the modulator channel are written into the corresponding registers
>of the modulated channel each time the period register of the modulator channel times out."

Sadly, that's a tad vague.  :-(  Still the Amiga HRM is like a college education in one book.

>To properly emulate the Amiga sound system *accurately*
>will rather ironically, require some pretty high end (read expensive) kit.

 Same is true of the video hardware. Though the Amiga videographic circuits are relatively incomplete by some modern standards, most graphics chips today lack sprites (it's true), color compression modes... and yes, most lack multiple playfields like the Amiga had.  Instead they rely on brute force and fancy blitters.  Sad but true.

 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Programming "Chip Tunes"
« Reply #10 on: March 26, 2005, 01:18:29 PM »
@boing

That was from the hardware manuals as found on  the Dev CD2.1. Theyr'e HTML format - you shouldn't have much trouble finding it - just start in the audio hardware section :-)
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Programming "Chip Tunes"
« Reply #11 on: March 26, 2005, 01:31:40 PM »
Quote

>The data words from the modulator channel are written into the corresponding registers
>of the modulated channel each time the period register of the modulator channel times out."


I read that as meaning the following:

Suppose channel 0 is the modulator and channel 1 the modulated channel.

Channel 0 has playback period of its own, just as it would if it were playing a sample. Instead of feeding the data to the DAC, here the data is fed to the period register of the other channel and that this happens at the basic playback period of the modulator channel.

The "each time the period register of the modulator channel times out" part just seems to be a needlessly long way of confirming this.

Therefore, if your modulator channel has a period equivalent to 5kHz playback, it will update the period register of the modulated channel 5000 times a second. Note that this isn't yet the basic requirement for FM synthesis as it could be writing the same value to the modulated channels period register 5000 times a second, therefore changing nothing.

One thing which seems to be the case here is that building an FM synth would be quite difficult. Rather than simple frequecny modulation, you would be performing period modulation (period is proportional to the inverse of the frequency) meaning your modulator waveform would have to be appropriately encoded.

The bit about data words rather than bytes just means that the 16-bit elements fetched by the modulator channel now represent a register field rather than a pair of 8-bit samples. The period register has a 16 bit resolution, so you can envisage your modulator waveform as an 8-bit sine wave, converted into a 16-bit period value.

This of course means that you need to start with some fixed wafevorms that you can encode in this fashion.

It looks difficult overall. Difficult, perhaps impractical, but not impossible.
int p; // A
 

Offline leirbag28

Re: Programming "Chip Tunes"
« Reply #12 on: March 26, 2005, 01:47:07 PM »
@Trev

Um...maybe its me but uh............Why don't you just get a Commodore 64?  create tons of Chiptunes on it.

No other computer in the world is as popular as th C=64 for this.  SIDS!!!

Im sure somebody has documentation on that since everyone created SIDS on the C=64.
CD32 is actually the best Amiga ever made by Commodore!...
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Programming "Chip Tunes"
« Reply #13 on: March 26, 2005, 02:10:34 PM »
@boing

Quote
I think this^ is similar to how some programs provided 14-bit audio. By using volume control you can in effect extend the range of the Amiga's default 8-bit DACs. IIRC, the Amiga had/has 64 volume levels (5 bit volume control).


Actually it's not done like this. Rather the both channels are set up to play sampledata, but first channel at full volume 64, and the 2nd at volume 1.

Thus the 1st channel provides higher 8 bits of precision (so it plays most significant 8 bits), and the 2nd channel lower 8 bits (least significant 8 bits). However, due to very low volume level of the 2nd channel, the effective precision is around 6 bits: Thus 8 + 6 = 14.

(Or was it due to 256>>2 == 64... Can't remember anymore :-))

Naturally this is done separately for left and right channels.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: Programming "Chip Tunes"
« Reply #14 on: March 26, 2005, 02:28:35 PM »
@piru

Yep, that's exactly how it's done.

Regarding the precision, AFAIK, the 14-bit resoulution comes from the fact that the overall volume of each channel has only 6-bit resolution. This means that one channel can only be at most 64x louder (ignoring the non-linearity for the moment) than any other.

The 'left shift' of the most significant byte, which is effctively achieved by the channel volume, for the overall sample word is therefore only 6 bit.

The remark about the effective precision of the minor channel (ie when played at minimum volume) is also true as far as I recall.

So it all comes down to playing the most significant 8 bits in the major channel and the next most significant 6 bits in the minor channel and the least significant 2 bits simply are not reproduced.

If the channel volume were 8 bit, you'd be able to reproduce the almost full 16-bit dynamic range with this trick, playing the most significant byte at volume 0xFF and the least significant at 0x01 - assuming the minor channel had sufficient resolution at this volume, of course.

As it goes, the effective volume difference of the major and minor channels are actually more than the 6 bit seperation implies. This is down to the non-linearity of the DAC and the reason that calibrated output routines exist.
int p; // A