Jump to content
IGNORED

sound engine concept


grafixbmp

Recommended Posts

I had been, for a while, trying to build a music engine and sound FX design system that could take up a small space and would not require lots of ram. I don't know if any type has been done just like this but I am hoping (if I can get the code done like I want it to be, or close. I wrote something in note pad to get some thoughts down. I even had it proofread. I hope that I can accomplish this much. wish me luck.

 

 

Well, I have a few thoughts about a music engine that would allow for

 

custom code for sound FX or percussion. The engine has a few small constraints but

 

allows for some moderate flexability.

 

First are the parameters which incorporates tracking and quick instrument

 

switches on the fly. The parameters can change once every frame. You have

 

at your disposal each voice consisting of all 32 frequencies for 8

 

different sound modulations. Each note consists of a frequency for a time

 

and a possible rest.

 

 

Each time the engine begins to play something, it aquires a byte and

 

splits it into nibbles (4-bit groups), one being the sustain for a note

 

and the other being a rest after the note. Each song has a timing

 

multiplier of 0 to 15. These are real time multiplied with each sustain and rest for

 

each note in the song. As this happens, the multiplier for the song is

 

counted down by a decrement and when it reaches 0 then the rest value is

 

decremented by one. If it isn't 0 then it continues by decrementing the

 

multiplier and does it again. If, however, the rest equals 0 then a new

 

byte is fetched.

 

For every sustain/rest byte that is fetched, so too is another byte which

 

is broken by 5 bits and 3 bits. The 5 bits show the note's frequency

 

value and the 3 bits show the modulation of the voice. These are set for

 

each sustain and rest byte. This happens for each voice and this data

 

makes up a track table. A song can play these in any order the creator

 

wishes. I may just keep the code stable under the 255 page boundary.

 

This would allow for tracks to be a maximum of 256 bytes as well as song

 

arrangements.

 

The timing multiplier also sets the rate of timing for possible

 

percussion. Each track is synced to its own percussion track. Percussion

 

is read as 2 bits from a byte it has loaded. The program only has to load

 

a byte for a rate that is a ratio of the song's timing multiplier based

 

upon 4 rounds in a single byte load and cut of the byte.

 

For each 2 bits, a "no play" or 1 of 3 possible sounds is generated for

 

one frame. Other methods could be created for the percussion portion of

 

the engine, but the idea seems quite workable. The percussion is quite

 

often played with the second channel, usually the bass line. The bass and

 

percussion may work better in code by alternating naturally in time,

 

thereby using the same location in RAM. The first channel is different.

 

The first channel can be randomly called based upon a single byte in RAM.

 

The gameplay itself controls what this byte is. It is checked every

 

frame, and if 0 is found, the song will continue playing as if no

 

interruptions occurred, but if any other value is found the routine is

 

overridden with another routine that plays one of any number of sounds in

 

its own special routine once every frame for a set time and then returns

 

control of the sound channel to the song again right at the proper place

 

in the continuing song.

 

I hope that is all hammered out properly, but if there are anythings I

 

missed, I would like to know, please. I want this to cover as many bases

 

as possible and still be spaceworthy for song data.

 

As a track plays and then reaches the end, the song track list drops down

 

and loads 2 track sections for both voices along with a percussion list

 

and begins to play. An indicator in the whole list will show where the

 

end is and the next place in the arrangement is jumped over to back at the start of the list and the

 

cycle continues.

 

 

I sure hope that I can atleast get one channel done soon.

Edited by grafixbmp
Link to comment
Share on other sites

I was wondering what a list of the amount of RAM would be like for an efficient, good sound engine? I came up with a number but was wondering what others thought first before I tell mine. I ain't sure if it is more or less but I only know of 2 sound engines but of thoes 2 seem to be about raw sound data strait that was under a page boundary and one that went over that limit.

 

My goal was to develope an engine which gives extended length songs while keeping the overall data needed for the songs non-bloated with a tracking system which keeps notes and rest down to 2 bytes per voice. With the extras of percussion and sound FX added this draws more RAM usage but hey, that alright, I hope.

Edited by grafixbmp
Link to comment
Share on other sites

I thought I would create a timing list for the timming multiplier. In retrospect this multiplier value also acts sorta like a tempo value too. The listing consist of each multiplier and the range of 15 possible lengths of each.

 

And of course 60 would be a full second since each run through happens each frame and multiples as such ( 120 = 2 seconds, etc.). I hope this is acceptable for songs. I also decided to allow each track to have it's own value rather than each song as a whole.

 

Multiplier with 15 note spread length

 

1: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

 

2: 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30

 

3: 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45

 

4: 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60

 

5: 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75

 

6: 6 12 18 24 30 36 42 48 54 60 66 72 78 84 90

 

7: 7 14 21 28 35 42 49 56 63 70 77 84 91 98 105

 

8: 8 16 24 32 40 48 56 64 72 80 88 96 104 112 120

 

9: 9 18 27 36 45 54 63 72 81 90 99 108 117 126 135

 

10: 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150

 

11: 11 22 33 44 55 66 77 88 99 110 121 132 143 154 165

 

12: 12 24 36 48 60 72 84 96 108 120 132 144 156 168 180

 

13: 13 26 39 52 65 78 91 104 117 130 143 156 169 182 195

 

14: 14 28 42 56 70 84 98 112 126 140 154 168 182 196 210

 

15: 15 30 45 60 75 90 105 120 135 150 165 180 195 210 225

 

 

 

This list not only works for the sustains but the rests too.

 

As a bonus, when a new track (the last in the list of the song) starts, the program will find a 0 for the timing multiplier in the second voice's track, then the program knows to restart the song list from the begining. This is true cause a 0 as the timing multiplier doesn't work in the math for multiplying.

 

When both voices arrive at the same time with both of their bytes being all zeroed out for sustain and rest then a new track is loaded from the song list.

 

Its also cool when you want to hit notes at specific lengths by simply altering the timing automaticaly by changing tracks.

 

Ya know, on a strange point, I think in retrospect I may have indirectly got some inspiration for this design for a sound and music engine from the way DVD video discs are organized in the IFO and VOB files. I use to study DVD authoring down to the individual commands which are similar to assembly. lol

Edited by grafixbmp
Link to comment
Share on other sites

Firstly, thanks for taking this into consideration.

 

As a chip musician and TIA musician, I'm always thinking about how to push certain chips to their absolute limits; definitely including the TIA. Your skeleton design seems pretty interesting and well thought out.

 

As for additional features I've seen for a TIA sound engine via other people that would be very helpful to musicians:

 

1.) Both or a single modular channel to switch between different stream modes that can swap between nibble/byte stream mode and regular TIA mode via user will with the ability to change rate/pitch.

 

a.) 8-bit or 4-bit PCM streaming. http://little-scale.blogspot.com/search?up...;max-results=10 < Check out that page and TROGdor's blog here for more information.

 

b.) Custom, perfect-pitched waveform streaming (also shown lower down in little-scale's blog): Squares and enough useful duty cycles, pseudo-triangle, saw, and pseudo-sine.

 

2.) Full control of volume of both channels.

 

3.) Borrowing Paul Slocum's auto-hat concept from Music Kit 2, but adding more modularity as for the ability to change hat patterns after so many measures/frames. ($00 for infinite loop)

 

4.) Channel multiplexing minus PCM streaming and custom waveforms; otherwise turning one channel into two channels making 4 channels of pure TIA instruments. (This can be found in other unreleased sound engines on this particular forum.)

 

~~~~

 

All of these suggestions are based on current technologies and developments.

 

Comments/questions?

Link to comment
Share on other sites

I enjoy working with advanced techniques (experience, next to nothing) lol. but when I designed this engine. I wanted a streamlined engine that required few cycles per frame to render and the data for music took as little space as possible but allowed for long elaborate songs. And many of them. With a lead base and percussion along with sound FX. I had thought about designing a more advance version that incorporated some digitaly sampled audio but just wanted to get this one done before moving on to advanced techniques.

 

As this goes, this engine just sets parameters rather than realtime modulating a voice. But that may come later.

 

As a bonus though, I had thought about seting up some crude volume systems for some leveled control. But not sure of a good way to impiment it yet.

Edited by grafixbmp
Link to comment
Share on other sites

The advanced sound techniques are generally reserved for title screens, since they require precious cycles inside the kernel.

 

For the sound engines I've written, I've found that one size does not fit all. It's better to customize your engine to the particular sound Fx and music required for a particular game.

 

I only require 3 bytes of RAM per channel for music. One byte points to the song/sound effect, another byte points to the current note, and the third byte points to a note length count-down clock.

 

For ROM usage, I've so far been able to make my songs use only one byte per note, by using lookup tables. The definitions of the bit fields will vary depending on the needs of your song, but here is an example implementation:

 

12223333

 

1 = voice

2 = note duration

3 = pitch

 

For each of these 3 fields, I read the value into X, and use that as an index into a ROM table. So there is a table with 8 different note lengths, and the values can be completely independent of each other. This allows me to define a song with whole notes, half notes, dotted eighths, sixteenth notes, and even triplets, in only 3 bits per note. This could be used instead of a multiplier system.

 

The voice bit can map to any 2 AUDC values. If the entire channel only uses one voice, this bit can be freed up for other uses, and the voice setting can be tied directly to the song/sound effect value.

 

The pitch field allows any 16 pitches, which will be sufficient for most songs. I usually reserve the zero value as a rest note.

 

This is probably obvious, but song and note counters should always count down. When I wrote my first sound engine, I got lazy and had the counters counting up, and this ended up wasting about 40 bytes of ROM throughout the code by the time the game was done. I've finally gone back and cleaned that up so the clocks count down.

 

Sound engines can also apply extra processing to improve the quality of the tones. A soft attack (ramping up the volume) and decay (ramping down the volume) will make the notes sound less shrill. This can be applied to all the notes in the song without requiring extra info in the note data. This is particularly easy for the decay. At the last 8 frames of any note, apply the countdown value to the volume, and it will fade to zero.

Edited by TROGDOR
Link to comment
Share on other sites

NICE!! I just knew there was a better way.These methods save so much on the tinyest level and It wouldn't be too difficult to create tracking as well. That could save even more. I like it. Thanks you many times over. With parameters like these, This whole music thing can be squezzed down so small. lol

Link to comment
Share on other sites

Thanks for the additional input. I know how important it is to keep things lean and efficient. I'd also like to mention that a big and beefy (with features) engine would help out the demo scene. (Take a look at the "Doctor" demo from Trilobit. ...I helped with the music there.)

 

http://8bitcollective.com/items/music/Chermside.mp3 < Here's another neat example of TIA PCM by little-scale.

Link to comment
Share on other sites

Btw. Any chance then for some cross-platform TIA-tracker (like it is RMT for Atari 8-bit)? I know that thare are such progs as SID2TIA etc. but maybe some for people who really don't have to know assemler for composing music...

Link to comment
Share on other sites

Some very interesting ideas in your post, Trogdor. At first I was alarmed at the prospect of only being able to toggle between two distortion settings per voice, but if you have a separate and automatic percussion engine that "steals" individual frames as needed, then I suspect most songs will do fine with settings 1 & 7 for one channel, and 4 & 12 for the other (though it might be less successful for TIA arrangements of pre-existing chiptunes -- I definitely needed a pair of 4/12s in places for the Castlevania level 1 music). With a separate lookup table for each distortion setting, you could get 32 timbrally similar pitches.

 

I am a little concerned about giving up fine-grained control of volume. I suppose you could create some sort of volume map (as it were!) in a lookup table, which would cost no more than 1 byte of RAM (4 bits per channel). I like effects that mimic delay through volume reduction, especially at intervals of 3/4 of a beat, as so famously practiced by David Gilmour of Pink Floyd (Another Brick In The Wall Part 1, Run Like Hell) as well as the Edge from U2 and many others. With two voices you can get up to four levels of delay, which sounds really cool and adds a feeling of depth that's normally absent from TIA music.

 

(Of course, I should probably add that I have absolutely no idea how to write a lookup table, in assembly or bB!)

Edited by thegoldenband
Link to comment
Share on other sites

  • 2 months later...

I have mean't to give uber koodos to Richi_S for his wonderful addition to the community with a efficient top notch sound engine. Actualy I read his topic today and enjoyed the recent distortion demos. Then I thought about reading tis one and as I went down though the post, I was in awe at the real brainstorming every poster every member made here cause I realized almost every major idea and thought everyone here came up with, Richi_S placed in his engine. Bravo man! I now want to take the great compsitions thegoldenband created for castlevania and adapt the data to this engine. Now I have a more powerful drive for castlevania, as a thank you to everyone who has contributed for sure.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...