Questions about the 'sound' command
Author |
Message |
Lapsus Antepedis
|
Posted: Fri Oct 15, 2004 11:52 am Post subject: Questions about the 'sound' command |
|
|
Hello Everyone!
I am trying to make a DTMF dialer program in turing, but I do not want to use any external .wav files for the tones. Is there a way to convince turing to combine 2 frequencies and play them at the same time? Every time I try it turing plays the second freq. over the first. I would not mind using the .wav files, but I would prefer to make the program a standalone.
(plus I cannot find any tones for the elusive A/B/C/D keys on the touchpad.)
Any Ideas?
-Lapsus |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dan
|
Posted: Fri Oct 15, 2004 1:55 pm Post subject: (No subject) |
|
|
I think you are going to have to use wav files for this. I think i whould be alot of work to get turing to procude the right tone. Also the only way of playing sounds at once using the sound comands in turing and not files whould be using a process witch whould lead to other issues and may still not work depending on the comps sound card, the turing verson and how the comand works. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
beard0
|
Posted: Sat Oct 16, 2004 4:05 pm Post subject: (No subject) |
|
|
As far as making the program standalone, depending on how much you know about .wav files, an option may be to have your program write the needed .wav files on start-up, and delete them once your done. As you are not taking about complicated sound waves, just a frequency, this should be possible, using a modified sin function to get the desired frequency. |
|
|
|
|
|
GlobeTrotter
|
Posted: Sat Oct 16, 2004 5:04 pm Post subject: (No subject) |
|
|
Here's an example, using turing's sounds commands, that produces notes. Its very glitchy, and the piano is not quite right, but it shows you the mathematics of sound if you wanted to produce a note. To produce two notes at the same time, I dont think would be possible.
code: |
var notes : array 1 .. 89 of int
var name : array 1 .. 89 of string
var temp : real := 27.5
var temp1 : int
var count := 0
var mx, my, mb, pastmx : int
var mxspeed : int
loop
count += 1
temp *= 2 ** (1 / 12)
notes (count) := round (temp)
exit when count >= 89
if count mod 12 = 1 then
name (count) := "A"
elsif count mod 12 = 2 then
name (count) := "A#"
elsif count mod 12 = 3 then
name (count) := "B"
elsif count mod 12 = 4 then
name (count) := "C"
elsif count mod 12 = 5 then
name (count) := "C#"
elsif count mod 12 = 6 then
name (count) := "D"
elsif count mod 12 = 7 then
name (count) := "D#"
elsif count mod 12 = 8 then
name (count) := "E"
elsif count mod 12 = 9 then
name (count) := "F"
elsif count mod 12 = 10 then
name (count) := "F#"
elsif count mod 12 = 11 then
name (count) := "G"
elsif count mod 12 = 12 then
name (count) := "G#"
elsif count mod 12 = 0 then
name (count) := "G#"
end if
end loop
for i : 1 .. 88
if name (i) = "A#" or name (i) = "C#" or name (i) = "D#" or name (i) = "F#" or name (i) = "G#" then
drawfillbox (i * (maxx div 88), maxy div 2, i * (maxx div 88) + (maxx div 88), maxy - 150, 21)
else
drawfillbox (i * (maxx div 88), 150, i * (maxx div 88) + (maxx div 88), maxy - 150, 30)
end if
drawbox (i * (maxx div 88), 150, i * (maxx div 88) + (maxx div 88), maxy - 150, 7)
end for
mousewhere (pastmx, my, mb)
loop
mousewhere (mx, my, mb)
mxspeed := abs (mx - pastmx)
if mx > (maxx div 88) and mx < maxx - 2 * (maxx div 88) then
if mb = 1 then
if mx div (maxx div 88) mod 12 = 2 or mx div (maxx div 88) mod 12 = 5 or mx div (maxx div 88) mod 12 = 7 or mx div (maxx div 88) mod 12 = 10 or mx
div (maxx div 88) mod 12 = 0 then
if my > maxy div 2 then
Music.Sound (notes (mx div (maxx div 88)), round (200 / (mxspeed+1)))
locate (1, 1)
put name (mx div (maxx div 88))
end if
else
if mx div (maxx div 88) mod 12 = 2 or mx div (maxx div 88) mod 12 = 5 or mx div (maxx div 88) mod 12 = 7 or mx div (maxx div 88) mod 12 = 10 or mx
div (maxx div 88) mod 12 = 0 then
if mx < (mx div (maxx div 88)) * 88 then
Music.Sound (notes ((mx div (maxx div 88) - 1)), round (200 / (mxspeed+1)))
locate (1, 1)
put name (mx div ((maxx div 88) - 1))
else
Music.Sound (notes ((mx div (maxx div 88) + 1)), round (200 / (mxspeed+1)))
locate (1, 1)
put name (mx div ((maxx div 88) + 1))
end if
else
Music.Sound (notes (mx div (maxx div 88)), round (200 / (mxspeed+1)))
locate (1, 1)
put name (mx div (maxx div 88))
end if
end if
else
locate (1, 1)
put " "
end if
locate (2, 1)
put mxspeed
end if
mousewhere (pastmx, my, mb)
delay (10)
end loop
|
|
|
|
|
|
|
|
|