Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (degenerate_762), 1,128 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
generate tone with specified pitch, amplitude, and duration #218673
07/29/08 20:27
07/29/08 20:27
Joined: Jun 2008
Posts: 40
pfeldman Offline OP
Newbie
pfeldman  Offline OP
Newbie

Joined: Jun 2008
Posts: 40
I'd like to see a function similar to beep() that (A) works and (2) allows the caller to specify pitch, amplitude, and duration. With a sequence of calls to such a function, simple musical melodies could be generated.

Dr. Phillip M. Feldman

Re: generate tone with specified pitch, amplitude, and duration [Re: pfeldman] #218739
07/30/08 09:22
07/30/08 09:22
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Take a basic sine wave of 440 Hz, play it in a loop, and use snd_tune to adjust it to the frequency you need.

Re: generate tone with specified pitch, amplitude, and duration [Re: jcl] #220910
08/10/08 19:02
08/10/08 19:02
Joined: Jun 2008
Posts: 40
pfeldman Offline OP
Newbie
pfeldman  Offline OP
Newbie

Joined: Jun 2008
Posts: 40
I've looked at the documentation at the following URL:

http://www.xuduo.cn/Tutorial/Manual_en/asnd_tune.htm

It's not clear how this is working. I assume that snd_tune changes the frequency by simply modifying the playback rate. If so, this will also change the duration, which is undesirable. I suppose that I could make the sound longer than what's needed, and then use a combination of snd_tune() and snd_stop() to achieve the effect that I want, but this would be ugly. I'd like to see a cleaner mechanism for producing a sequence of tones.

Thanks!

Re: generate tone with specified pitch, amplitude, and duration [Re: pfeldman] #220911
08/10/08 19:09
08/10/08 19:09
Joined: Oct 2006
Posts: 873
S
Shadow969 Offline
User
Shadow969  Offline
User
S

Joined: Oct 2006
Posts: 873
not sure about the way snd_tune is working, but i used it to achieve the similar effect - in a piano simulator. i took 15 real note sounds of one octave and then changed their pitch with snd_tune, without noticing difference in duration.
i suppose you can make a simple loopable sound of 440 Hz and play it in the loop, use snd_tune to transpose it and snd_stop to stop it (or snd_tune to lower the volume till silence)

Re: generate tone with specified pitch, amplitude, and duration [Re: Shadow969] #220928
08/10/08 20:49
08/10/08 20:49
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
use snd_loop() and when the sound has played long enough, then use snd_stop().
This way you can tune the frequency as you wish without having to worry about playback length.

Re: generate tone with specified pitch, amplitude, and duration [Re: FBL] #221455
08/14/08 03:41
08/14/08 03:41
Joined: Jun 2008
Posts: 40
pfeldman Offline OP
Newbie
pfeldman  Offline OP
Newbie

Joined: Jun 2008
Posts: 40
OK. Both of these sound like workable solutions. If anyone is willing to post a sample of code, that would be even better, but I think that I can take it from here.

Thanks!

Phillip


Moderated by  aztec, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1