View Single Post
Old November 25th, 2011, 12:02   #56
paul_nicholls
Registered User
 
Join Date: Sep 2011
Location: Australia, Tasmania
Posts: 180
Quote:
Originally Posted by tykel View Post
Nice example, suitably retro sounding!
Also, sorry for insisting on this, but would this sound take up 100Hz * 0.310s * 1B = 31B? Or am I not getting this?
After thinking about it, I got the formula wrong before...sorry!

Ok, to find out how much a sound takes up in memory (ignoring any headers and other stuff, just raw sound data), you can use this formula (I am pretty sure I didn't stuff up this time ):

Code:
  SoundSize = Round(BytesPerSample * NumberOfChannels * Duration_mSec * SampleRate / 1000)
so I am using 44100Hz as the sampling rate, 8-Bits per sound sample (or 1 byte), and mono sound output (1 channel...stereo would be 2 channels...)

So I get this:

Code:
  SoundSize = Round(BytesPerSample * NumberOfChannels * Duration_mSec * SampleRate / 1000)
  SoundSize = Round(1              * 1                * 310           * 44100      / 1000)
  SoundSize = 13671
  SoundSize = 13.3505859375 KB
Quote:
Originally Posted by tykel View Post
Another thing, wouldn't it be better to use sound instructions rather than ports for modulation, for better orthogonality?
I was only going on the suggestion that someone else did, to use memory mapped sound ports
None of this is set in stone yet...we can use sound instructions for playing sounds AND changing the sound's waveform + ADSR parts too...

Ok, so how about this then:

Code:
...
09 00 00 00	SND0			Stop playing sounds.
0A 00 LL HH	SND1 HHLL		Play 500Hz tone for HHLL miliseconds (uses current sound generator settings; ADSR, etc.).
0B 00 LL HH	SND2 HHLL		Play 1000Hz tone for HHLL miliseconds (uses current sound generator settings; ADSR, etc.).
0C 00 LL HH	SND3 HHLL		Play 1500Hz tone for HHLL milliseconds (uses current sound generator settings; ADSR, etc.).

0D 0X LL HH     SNP                     Play Sound for HHLL miliseconds at the tone specified in address pointed to by Register X (uses current sound generator settings; ADSR, etc.).

0E AD SR VT     SNG                     Sound generator (applies to all sound tones which follow).
                                        A = attack  (0..15)
                                        D = decay   (0..15)
                                        S = sustain (0..15, volume)
                                        R = release (0..15)
                                        V = volume  (0..15)
                                        T = type of sound:
                                          00 = triangle wave
                                          01 = sawtooth wave
                                          02 = pulse wave (is just square for now)
                                          03 = noise
                                          non-valid values default to 0 output

// Jumps
10 00 LL HH	JMP HHLL		Jump to the specified address.
...
Quote:
Originally Posted by tykel View Post
Also, for timing, you can currently use VBLNK if you don't mind waiting for multiples of 16ms
If anyone else is interested in a WAIT instruction, please make your voice heard!
Interesting idea, but I would really prefer a WAIT instruction...more accurate

cheers,
Paul

Last edited by paul_nicholls; November 25th, 2011 at 19:58..
paul_nicholls is offline   Reply With Quote