Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 20:19 19 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: microcomputer-style game sounds

Author Message
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 341
Posted: 10:46pm 14 Aug 2020
Copy link to clipboard 
Print this post

Here's a simple program that demos some possible game sounds. They remind me a bit of BBC micro or ZX spectrum game sounds.


'change this to skip some
goto 100


100
for h=1 to 2
 chirp 1,5,1200,50,20
next
pause 300

200
for h=1 to 2
 chirp 1,5,600,50,20
next

300
for h=1 to 12
 pause 500
 freq=2800-200*h
 print "single chirp, start frequency ";freq
 chirp 1,5,freq,50,20
next h
play sound 1,B,O,300
pause 1000

400
print "chirps with different t"

for h=1 to 4
 pause 500
 freq=600
 print "single chirp,t=";20*h
 chirp 1,5,freq,50,20*h
next h

pause 1000

500
print "chirps with different d"

for h=1 to 4
 pause 500
 freq=2000
 print "single chirp, d=";50*h
 chirp 1,5,freq,50*h,20
next h

600
 for h=1 to 5
 'pause 500
 freq=1600-200*h
 print "upward chirp, start frequency ";freq
 chirp 1,5,freq,-50,20
next h
play sound 1,B,O,300
pause 1000

700
for h=1 to 5
 pause 500
 freq=1600-200*h
 print "upward chirp, start frequency ";freq
 chirp 1,5,freq,-50,20
next h
play sound 1,B,O,300
pause 1000

800
for h=1 to 5
 pause 500
 freq=1600-200*h
 print "upward chirps repeated, start frequency ";freq
 for h2=1 to 5
   chirp 1,5,freq,-50,20
 next
next h
play sound 1,B,O,300
pause 1000

end

sub chirp sets,reps,f,d,t
for k=1 to sets
 ' if f and d are multiples of 50 (50 cycles per second)
 ' and t is 20 (20ms), a 50th of a second, sound will be smoooth

 ' more generally if f and d are multiples of 1000/t.

 for n=f to f-d*reps step -d
   play sound 1,B,q,n
   pause t
 next n
next
play sound 1,B,O,300

end sub



In a real game it's probably better to use interrupts instead of pause, so the game doesn't have to wait while the sound is playing. But that's more work than I wanted to put into this, at least for now.
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 341
Posted: 05:35am 15 Aug 2020
Copy link to clipboard 
Print this post

Here are some in the ZX Spectrum style where it would make tiny little bits of sound and then have a pause in the sound for a fraction of a second while it did other things.


'play a square wave
sub sq freq, dur
 play sound 1,B,Q,freq
 pause dur
 play stop
end sub

for n=1 to 10
 sq 1000-50*n,3
 pause 100
next

f=1000
for n=1 to 20
 sq f,3
 pause 70
 f=INT(f*1.1)
next

Edited 2020-08-15 15:36 by capsikin
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 341
Posted: 01:20am 20 Aug 2020
Copy link to clipboard 
Print this post

Here's a program to make chirp/zap noises, and let you modify the sounds with the arrow keys.
chirps-ui3.bas.zip

update: I made another version of my interactive chirp program, to give it a blue background, and use 320x200 resolution so the text is bigger. Not sure I like the visual style but I didn't like the previous one that much so I wanted to try something different. Also I made the quit key work.

chirps-ui4.bas.zip

update 2: I've put it on gitlab and made another version. This one has colour, and looks a bit neater.

Link to latest version, as a zip download: https://gitlab.com/caspianmaclean/chirps-ui-cmm2/-/archive/master/chirps-ui-cmm2-master.zip

Gitlab project page
Edited 2020-08-29 20:25 by capsikin
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024