Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Sep 21, 2019 4:09 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Sin sweep...
PostPosted: Tue Feb 24, 2009 2:46 pm 
I need to generate an application that simply generates a sin sweep sound.
Ideally it would not be a piece of software that just plays a wav file, but a gui where the user
can dial up or down the frequency of the sin wave and perhaps tweek the amplitude.
Of course it needs to be audible...

What function should I look at in RB for this application?

TIA.


Top
  
Reply with quote  
 Post subject: Re: Sin sweep...
PostPosted: Tue Feb 24, 2009 6:55 pm 
Offline

Joined: Tue Feb 24, 2009 6:48 pm
Posts: 1
Hi,
I need the same thing, a simple sine wave, with varying amplitude and duration. This is for sound, like Morse Code.

Thanks,

Carbon


Top
 Profile  
Reply with quote  
 Post subject: Re: Sin sweep...
PostPosted: Fri Aug 28, 2009 1:59 pm 
Offline

Joined: Sun Apr 30, 2006 8:25 am
Posts: 327
Here a code wich creates a tune (.wav file).
Put the code under a button . Maybe this helps...?
Succes !

dim t as binarystream
dim f as folderitem
f=getfolderitem("tune.wav")
t=f.CreateBinaryFile("")

dim b1 as new memoryblock(3)
b1="RIFF"
t.Write b1

dim n1 as uint32
dim n32 as string
dim sc as integer
dim c as integer
dim cal as integer
dim b as integer
dim r as string
dim cc as integer

n32="32036"
n32=str(bin(val(n32)))
cal=(32-len(n32))
for sc=1 to cal step 1
n32="0"+n32
next
c=len(n32)
r=""
cc=0
for b=1 to c step 8
r=r+right(n32,8)
n32=left(n32,len(n32)-8)
t.Writebyte val("&b"+right(r,8))
next


dim b2 as new memoryblock(3)
b2="WAVE"

t.write b2


dim b3 as new memoryblock(3)
b3="fmt "
t.write b3

n32="16"
n32=str(bin(val(n32)))
cal=(32-len(n32))
for sc=1 to cal step 1
n32="0"+n32
next
c=len(n32)
r=""
cc=0
for b=1 to c step 8
r=r+right(n32,8)
n32=left(n32,len(n32)-8)
t.Writebyte val("&b"+right(r,8))
next

n32="1"
n32=str(bin(val(n32)))
cal=(16-len(n32))
for sc=1 to cal step 1
n32="0"+n32
next
c=len(n32)
r=""
cc=0
for b=1 to c step 8
r=r+right(n32,8)
n32=left(n32,len(n32)-8)
t.Writebyte val("&b"+right(r,8))
next

n32="1"
n32=str(bin(val(n32)))
cal=(16-len(n32))
for sc=1 to cal step 1
n32="0"+n32
next
c=len(n32)
r=""
cc=0
for b=1 to c step 8
r=r+right(n32,8)
n32=left(n32,len(n32)-8)
t.Writebyte val("&b"+right(r,8))
next

n32="8000"
n32=str(bin(val(n32)))
cal=(32-len(n32))
for sc=1 to cal step 1
n32="0"+n32
next
c=len(n32)
r=""
cc=0
for b=1 to c step 8
r=r+right(n32,8)
n32=left(n32,len(n32)-8)
t.Writebyte val("&b"+right(r,8))
next

n32="16000"//32000 1 sec
n32=str(bin(val(n32)))
cal=(32-len(n32))
for sc=1 to cal step 1
n32="0"+n32
next
c=len(n32)
r=""
cc=0
for b=1 to c step 8
r=r+right(n32,8)
n32=left(n32,len(n32)-8)
t.Writebyte val("&b"+right(r,8))
next

n32="2"
n32=str(bin(val(n32)))
cal=(16-len(n32))
for sc=1 to cal step 1
n32="0"+n32
next
c=len(n32)
r=""
cc=0
for b=1 to c step 8
r=r+right(n32,8)
n32=left(n32,len(n32)-8)
t.Writebyte val("&b"+right(r,8))
next

n32="16"
n32=str(bin(val(n32)))
cal=(16-len(n32))
for sc=1 to cal step 1
n32="0"+n32
next
c=len(n32)
r=""
cc=0
for b=1 to c step 8
r=r+right(n32,8)
n32=left(n32,len(n32)-8)
t.Writebyte val("&b"+right(r,8))
next

dim b4 as new memoryblock(3)
b4="data"

t.write b4

n32="32000"
n32=str(bin(val(n32)))
cal=(32-len(n32))
for sc=1 to cal step 1
n32="0"+n32
next
c=len(n32)
r=""
cc=0
for b=1 to c step 8
r=r+right(n32,8)
n32=left(n32,len(n32)-8)
t.Writebyte val("&b"+right(r,8))
next



dim a as integer
dim d as integer
dim z as integer


dim pi as double
pi=3.14
for a=1 to 32000 step 2

z=z+1


//here the wave formule ??

d=a/(80/140)*pi
d=sin(d)*11000



n32=str(d)
n32=str(bin(val(n32)))
cal=(16-len(n32))




for sc=1 to cal step 1
n32="0"+n32
next

c=len(n32)
r=""
cc=0

t.WriteByte val("&b"+right(n32,8))
t.WriteByte val("&b"+left(n32,8))



next

t.close


dim s as new sound
s=f.OpenAsSound
s.play

_________________
Using RB prof edition http://program.comuf.com/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group