Raw Sound Creation Demo (cross-plattform)

Share your advanced PureBasic knowledge/code with the community.
GBeebe
Enthusiast
Enthusiast
Posts: 263
Joined: Sat Oct 09, 2004 6:52 pm
Location: Franklin, PA - USA
Contact:

Re: Raw Sound Creation Demo (cross-plattform)

Post by GBeebe »

One word: Sweet!

Linux users need to add:

Code: Select all

#WAVE_FORMAT_PCM = 1
because it's not defined.
WilliamL
Addict
Addict
Posts: 1252
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Raw Sound Creation Demo (cross-plattform)

Post by WilliamL »

I changed the song playing routine and it makes more sense now.

Unfortunately, on my Mac, I get an IMA error after the second tone on the 4th line at 'id = CatchSound(#PB_Any,*memory)' (line 224).
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Re: Raw Sound Creation Demo (cross-plattform)

Post by Joakim Christiansen »

WilliamL wrote:Unfortunately, on my Mac, I get an IMA error after the second tone on the 4th line at 'id = CatchSound(#PB_Any,*memory)' (line 224).
Hmm, weird. It may be something silly I've done, I'll see if I can figure it out.
I like logic, hence I dislike humans but love computers.
WilliamL
Addict
Addict
Posts: 1252
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Raw Sound Creation Demo (cross-plattform)

Post by WilliamL »

@JC

It seems to have something to do with how many tones that are played. If I take out the first line of data the song plays that much farther past line 4 position 2. In other words, it only seems to play so many tones before the error (17).
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Re: Raw Sound Creation Demo (cross-plattform)

Post by Joakim Christiansen »

WilliamL wrote:@JC

It seems to have something to do with how many tones that are played. If I take out the first line of data the song plays that much farther past line 4 position 2. In other words, it only seems to play so many tones before the error (17).
Aha, well maybe this helps then:

Code: Select all

Procedure addTone(f,d)
  sound = catchToneEx(1000,100,f,d)
  PlaySound(sound):Delay(400)
  FreeSound(sound)
EndProcedure
There it frees up the sound it created when it is done playing it.
I like logic, hence I dislike humans but love computers.
WilliamL
Addict
Addict
Posts: 1252
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: Raw Sound Creation Demo (cross-plattform)

Post by WilliamL »

Same error at same location and now I'm not so sure the number of tones played it the problem. If I rem out the first two lines of data the IMA appears just 2 notes later than before.

Note that I changed your code...

Code: Select all

;Have fun! ;-)

Procedure addTone(f,d)
    Protected sound
    sound = catchToneEx(1000,100,d,f)
    PlaySound(sound):Delay(d)
    FreeSound(sound)
EndProcedure

addTone(676,460):addTone(804,340):addTone(676,230):addTone(676,110):addTone(902,230):
addTone(676,230):addTone(602,230):addTone(676,460):addTone(1012,340):addTone(676,230):
addTone(676,110):addTone(1071,230):addTone(1012,230):addTone(804,230):addTone(676,230):
addTone(1012,230):addTone(1351,230):addTone(676,110):addTone(602,230):addTone(602,110):
addTone(506,230):addTone(758,230):addTone(676,460):addTone(676,460)
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
Post Reply