Create sound of specific pitch

Blitz3D Forums/Blitz3D Beginners Area/Create sound of specific pitch

Just wondering if there is any way of simply creating and playing a sound of a specific pitch without having to load a *.wav file.

Via DirectX?

I would like to play a tune as per piano and set sound to respond to key inputs.

Help and Thanks

Jules

Not through blitz as far as I'm aware. You could create a nice simple wav of a sine wave a a specific pitch.

I was doing something like this with a tracker I was writing for blitz... this code might help:
.frequencies
;      C     C#   D    D#     E     F    F#      G    G#     A     A#     B
Data 065.4,069.3,073.4,077.8,082.4,087.3,092.5,098.0,103.8,110.0,116.5,123.5
Data 130.8,138.6,146.8,155.6,164.8,174.6,185.0,196.0,207.7,220.0,233.1,246.9
Data 261.6,277.2,293.7,311.1,329.6,349.2,370.0,392.0,415.3,440.0,466.2,493.9
Data 523.3,554.4,587.3,622.3,659.3,698.5,740.0,784.0,830.6,880.0,932.3,987.8

;root note is 34 - A2

; notes go from C0 to B7

Restore frequencies
Dim frequency#(95)
For n=0 To 47
Read freq#
frequency(n)=freq/440
frequency(n+48)=(freq*16)/440
Next


This will leave you with a multiplier for your frequencies depending on what note you want to play. The root note being A2 (note 34) which would give you a multiplier of 1.

I would guess tapping into a midi-bank might be the way to go for this

You could also load on single wav and use the Robs frequencies table to shift the pitch. Currently there is no known way to create a sound without to use the Loadsound Command. Well, maybe you could use the PC-Speaker Beep Library.

YAY! Speccy sound effects here we come!!!

Dear all of above,

Thanks for your help and advice.

I think I will go the path of creating a single wav file of known pitch and using Rob's frequency table to shift the pitch. Seems the easiest way.

Thanks again

Jules

I messed up this ( http://www.blitzbasic.com/Community/posts.php?topic=35456 ) topic with some related stuff.