[Gambas-user] sound in gambas 3
Tobias Boege
taboege at ...626...
Sun Feb 9 17:07:22 CET 2014
On Sat, 08 Feb 2014, Dominique Michel wrote:
> Le Sat, 08 Feb 2014 03:33:34 +0100,
> Beno?t Minisini <gambas at ...1...> a ?crit :
>
> > Le 08/02/2014 02:04, Beno?t Minisini a ?crit :
> > > Le 08/02/2014 01:24, Dominique Michel a ?crit :
> > >> Hi,
> > >>
> > >> I try to do my first gambas program, and I am stuck with the sound.
> > >>
> > >> All I have for now is 2 labels, 2 value boxes and 1 toggle button.
> > >>
> > >> When I press the toggle button, it launch a message box with the 2
> > >> values in the value boxes and some text. 1 is a frequency, the
> > >> other is the amplitude. I want to use these values to make some
> > >> sounds.
> > >>
> > >> When looking for sound functions, I found Play in sdl.sound. Is it
> > >> possible with it, or with another function, to use something like:
> > >>
> > >> Play frequency volume
> > >>
> > >> Another way would be to create an audio file on the fly...
> > >>
> > >> Dominique
> > >>
> > >
> > > You must use gb.media, which is the interface to gstreamer.
> > > GStreamer has a plugin for generating sinusoidal sounds (its name is
> > > "audiotestsrc", look at the GStreamer documentation for the
> > > details).
> > >
> > > Regards,
> > >
> >
> > I made an example of that for you in revision #6140.
>
> Thanks a lot! I see it is possible to use the other properties like
> wave for the waveform. Gambas is amazing and very powerful.
>
> When modifying the volume control to have the label in dB, I see that a
> formula like
>
> SetFreq(Exp(Log(20) + (Log(20000) - Log(20)) *
> sldFrequency1.Value / 1000))
>
> doesn't give an error when sldFrequency = 0, but a formula like
>
> lblVolume1.Text = Format((20 * Log10(fVol / 1000)), "0.00") &
> " dB"
>
> give an error when fVol = 0. I don't understand why it work in the
> first case but not in the second case.
Well... if sldFrequency1.Value = 0, then you get SetFreq(Exp(Log(20) + 0))
which equals 20 (and 20 is not an invalid frequency, is it?). Whereas, if
fVol = 0, you will evaluate Log10(0) which is undefined.
Regards,
Tobi
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list