Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: Trev 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
-
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
-
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
-
Weren't the old Future Composer tunes using the paula chip to synthesize waveforms without any samples?
-
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.
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.
-
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.
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 (http://uade.ton.tut.fi/) 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.
-
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.
-
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.
-
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.
-
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.
-
@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 :-)
-
>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.
-
@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.
-
@boing
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.
-
@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.
-
@Piru
Hey, here's a silly idea for you. According to the HW manual, one channel can directly modulate the volume of another.
Suppose we encoded 16-bit data into a simple float-like format with a signed 8-bit mantissa and an unsigned 6 bit exponent.
We could split it into 2 buffers. The first buffer contains the 6 bit exponent data, being read for channel 0. This is then used to modulate the volume of channel 1, which is reading the 8-bit data.
Both channels are using the exact same period, so you get to reproduce 14-bit data again.
If both chip ram buffers are being read via DMA (as you would expect) you can do this at a low overhead in terms of CPU interrupts etc.
Encoding from normal 16-bit data to the required format could be achieved using a simple LUT - you can even do calibration for non-linearity when making this table.
Of course this all hinges on the assumption that the hardware channels would be perfectly in sync and remain so.
-
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.
Actually what you've described is a means to produce vibrato - rapidly modulating the pitch.
The whole idea of FM synthesis is to make the wavefrom itself change. It's the same thing as pitch modulation but applied on much smaller time scales. In the case of the Amiga you would have to alter the sample rate for every sample.
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.
SID used analogue oscillators and an alalogue filter so yes it's a hybrid technology. I'm surprised it wasn't used in synths at the time - it is now!
As for ADSR you don't need hardware in the Amiga for that, you can calculate the evvelope in software and write the values into the volume register.
>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.
I reckon Cell could do a killer chipset emulation.
As for the audio the reaon I'm saying it'll be difficult is because if you rely on using different sample rates for playback they'll introduce distortion at diffferent frequencies and this distortion is part of the sound. This wont make much of a difference at high smple rates but you'd be surprised how many mods used 8.3 KHz samples - and played them at lower rates.
At low rates the distrotion is going to be an integral part of the sound so has to be recreated to be accurate. Even these low sample rates wont "fit" properly into 44KHz so you'll need a sampling rate a lot higher to generate even accurate-ish waveforms.
Another way would be to use additive systhesis to add in the distortion, this might actually be *easier* but will require per sample calculation of the correct noise levels / frequency.
Then of course any inaccuracies in the DACs have to be modelled as well as the impact of later analogue components in the audio O/P system.
You may think that you don't want the distortion but it's an integral part of the sound and you'll most likely actually prefer it included.
The early Fairlight CMI samplers were only 8 bit but the users actually preffered their sound to the later 16 bit models.
--
Hmm: I don't think I want to go into this level of complexity but this is giving me ideas for a new kind of Oscillator to add to my synth - I think I may a "Retro Sampler" module to the list...
I'm thinking of using 192KHz as the sampling rate anyway so should be able to do different sample playback rates fairly well.
-
@minator
I've studied FM synthesis in some detail in the past. There is fundamentally nothing different about the vibrato effect and FM other than the ratio of modulator/carrier frequency and the strength of the modulation. Vibrato effects (pitch based - tremelo is volume based) occur when the modulation strength is both very small (modifying the pitch of a note by a few cents) and the frequencty of the modulation is *much* lower than the carrier wave (ie a few Hz).
If you increase the modulation frequency until it is the same order of magnitude as the carrier wave, you start to get your FM synthesis effects.
If you look at the spectrum, you see more and more sidebands beginning to converge around your carrier frequency as your modulator frequency increases.
When your modulator frequency is a rational fraction (or multiple) of your carrier frequency, you get nice waveforms that are rich in harmonics and resemble other commonly encountered waveforms, eg square, sawtooth etc.
As you change that to non rational frequencies you get more complex frequencies that can sound anything from very disharmonic to metallic.
The documentation says that one channel can be used to modulate the period (of which frequency is a function) of another. I see no reason why this could not be used to create a basic 2 operator FM synthesis. As I said it would be a bit more complex, but I don't see a reason it could not be done.
If you have a 22kHz sample waveform (comprising 16-bit period values) derived from a 1kHz tone as your modulation and a 22kHz sample waveform of the same 1kHz tone as normal samplesas your carrier, I see no reason why, with appropriate programming, one could not correctly modulate the other.
-
've studied FM synthesis in some detail in the past. There is fundamentally nothing different about the vibrato effect and FM other than the ratio of modulator/carrier frequency and the strength of the modulation.
I know, as I said it's a question of scale.
The documentation says that one channel can be used to modulate the period (of which frequency is a function) of another. I see no reason why this could not be used to create a basic 2 operator FM synthesis. As I said it would be a bit more complex, but I don't see a reason it could not be done.
Doesn't sound (pun intended) like it would produce very interesting results but who knows... I wonder did anyone ever try?
If they stay in sync the technique could be used to apply PWM to the sample.
--
I'm wonder what would happen if you combined the properties of the C64 and the Amiga by using SID's analogue filter with Paula's digital "oscillators" to generate the waveforms. Could be interesting and definately retro.
...begins thinking about how to write a "Paula boings SID" module
:lol:
-
@leirbag28
This topic has veered pretty far from my initial question. :-) I'm actually writing a PC speaker emulator for m68k/Paula to include in a PC BIOS emulator that's part of a new project I'm working on. So, I'll be setting up a simple sine or square wave, and modifying the appropriate registers based on emulated access to PC I/O ports 42h, 43h, and 61h.
As far as writing music goes, the C64 is great. The C64 Programmer's Reference Manual seems fairly complete. But I'm not into composing right now. Some day. (And I've lost count of the number of SID-capable devices I have lying around.)
@minator
I really dig the distortion and aliasing effects introduced by older Amiga parallel port samplers. Sending the output of a C64 (or other SID thingy) through one of those (maybe not the DSS8, which is a little too smooth--I like the AMAS) and using the Paula for real-time manipulation (if you could swing it) would be cool.
Trev