View Single Post
Old 13 June 2016, 20:08   #14
68k wisdom
meynaf's Avatar
Join Date: Nov 2007
Location: Lyon (France)
Age: 44
Posts: 2,364
Originally Posted by Toni Wilen View Post
After some thinking: forget what I said..
What must I forget ? I don't remember

Originally Posted by Toni Wilen View Post
It would be really easy to make "hardware" emulation of perfect sound card that does not exist in real world. (All needed framework already exists).
If you say it's easy, i sure take it.

Originally Posted by Toni Wilen View Post
There could be simple data structure that describes the sound buffer, one for each buffer:

- Type of buffer (8/16/24bit samples, number of channels)
- Length of buffer
- Address of buffer
- Volume of buffer (or "don't change")
- Playback frequency of buffer (or "don't change")
- Address of next description structure (or 0 = end)
- Other misc bits (For example generate interrupt when buffer has started/ended)

Usage would be very simple:

- Write address of first data descriptor (can be anywhere in RAM) to IO register
- Enable playback

- Register for reading current active descriptor, play position, volume, frequency etc..
- Write registers to change volume or frequency anytime you want.
That's not exactly my need, but it's a lot closer

It looks more like a DT/EP noteplayer interface, which i kinda like to use.

Here's how I see things (actually it's done like that in my programs, even though only Paula-compatible settings are currently supported by my code).

We have three functions.

1. Allocate audio. Two structure addresses are passed in. First says info such as :
- base frequency (like 3546895 if we want to later use Amiga period, or 44100, or whatever - sound pitch will be freq/per afterwards)
- maximum sound size to be played (is $20000 for Paula)
- min, max period values that'll be used (16-bit values are enough here)
- number of channels (up to 32 if possible)
- needed sample data alignment in memory (is 2 for Paula)
- volume range (64 for Paula, but could be 100 for volumes in %, or anything)
- various flags (like filter on/off, must use chipmem, sample sync needed or not, 8/16/24 bits, etc)
- stereo data array saying where each channel would go : $80 don't care, $81 left, $7f right, $00 center, other values being intermediate

Second structure remains blank here. Its address is just noted.

2. Play audio. No parameter : the structure is known from previous step. So the user just fills in the second structure mentioned above then calls this function : the effect is immediate.

The structure says (the user can write or read these) :
0.l sample address (write)
4.l sample length (write)
8.w period (write)
$a.b volume (write)
$b.b sync (read)
$c.l repeat (write)
$10.l replen (write)
Of course this is an array ; one such struct exists for each channel. No need to use a linked list for that, an array is more practical to me.

First the data is played with "sample address" and "sample length" (length is in number of samples, obviously).
Once finished, the "sync" byte is set as true, then the "repeat" and "replen" values are used to continue seamless playing (and when its end is reached, the values set here are used again and the flag set again, and so on).

Writing new address/length pair implies previous sound is immediately stopped and the new one starts to play.

A length of zero immediately stops the sound. Using a replen of zero indicates the sound should automatically stop at the end.

Setting repeat/replen without prior sample is valid and indicates the sample should simply loop until something is changed.

The writes are detected by setting sample length to -1L (which indicates no-op later on).

3. Exit audio. Frees all resources.

A 4th function might eventually set the master volume, if available.

What do you think of this ?
(and was I clear enough ?)

Originally Posted by Toni Wilen View Post
Not going to happen:
- any kind of DSP stuff or similar.
I don't need that anyway.
Oh, well. Bass and treble would be nice to have, but it's clearly not mandatory.

Originally Posted by Toni Wilen View Post
- different playback frequencies at the same time.
If you mean playback frequencies at the host level, then it's really no big deal.

Originally Posted by Toni Wilen View Post
What do you think of this?
Sounds good.
meynaf is offline  
Page generated in 0.10333 seconds with 9 queries