yeah I'm pretty sure thats allowed. The rule against storing sounds as data is referring to storing sound data as data. Ie, you can't convert the DataChunk section of a WAV file to DATA statements, then simply write it back out along with a HeaderChunk and FormatChunk to create a perfectly original copy of the WAV file. :)
Creating the wave data by a mathematical statement ISN'T storing sound data. :) I did it the same way you did, writing out a sin wave. My code:
The sound has a click at the end that I never got around to ironing out. However sadly though, I am now withdrawing from this competition. I've been trying to work on my other main project (which I'm also under some time constraint to produce, though much longer :)) at the same time and although my entry is coming along nicely, I won't have time to finish it. :(
@StevieG: asking nicely.. :) Could you please change your CODE tags to CODEBOX cause thats making a huge amount of scrollage in this thread. :)
+BlackD
Creating the wave data by a mathematical statement ISN'T storing sound data. :) I did it the same way you did, writing out a sin wave. My code:
exists=OpenFile("test.wav") If exists Then CloseFile exists:DeleteFile("test.wav") wave=WriteFile("test.wav") ;Choose our settings Length = 1 SampleRate = 44100 NumChannels = 1 BitsPerSample = 16 frequency=120 volume=25 ;Do Some calcs NumSamples = SampleRate * Length SubChunkSize = (NumSamples * NumChannels * BitsPerSample / 8) + 36 ;Write RIFF Chunk Descriptor WriteByte wave,82 WriteByte wave,73 WriteByte wave,70 WriteByte wave,70 WriteInt wave,SubChunkSize WriteByte wave,87 WriteByte wave,65 WriteByte wave,86 WriteByte wave,69 ;Write FMT subchunk WriteByte wave,102 WriteByte wave,109 WriteByte wave,116 WriteByte wave,32 WriteInt wave,16 WriteByte wave,1 WriteByte wave,0 WriteByte wave,NumChannels WriteByte wave,0 WriteInt wave,Samplerate WriteInt wave,Samplerate * Numchannels * BitsPerSample / 8 WriteByte wave,NumChannels * BitsPerSample / 2 WriteByte wave,0 WriteByte wave,BitsPerSample WriteByte wave,0 ;Write DATA subchunk WriteByte wave,100 WriteByte wave,97 WriteByte wave,116 WriteByte wave,97 WriteInt wave,NumSamples * NumChannels * BitsPerSample / 8 For i = 0 To NumSamples*2 sample#=volume*Sin(Pi*frequency*i/(NumSamples/frequency)) WriteByte wave,sample# Next CloseFile wave Print "Test.Wav created" Print "Press ESC to quit or any key to play." wave=LoadSound("test.wav") While Not KeyHit(1) If KeyHit(28) Then t=MilliSecs() channel=PlaySound(wave) End If If MilliSecs() > (t+900) And ChannelPlaying(channel) Then StopChannel(channel) Wend End
The sound has a click at the end that I never got around to ironing out. However sadly though, I am now withdrawing from this competition. I've been trying to work on my other main project (which I'm also under some time constraint to produce, though much longer :)) at the same time and although my entry is coming along nicely, I won't have time to finish it. :(
@StevieG: asking nicely.. :) Could you please change your CODE tags to CODEBOX cause thats making a huge amount of scrollage in this thread. :)
+BlackD