About Sound Recorder 2.1 Source
Class MainWindow
Inherits Window
// Controls
ControlInstance
Sub Action() Handles Event
q.Poll
End Sub
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub Action() Handles Event
update
End Sub
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub Action() Handles Event
Record
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
Stop
OpenTimer.mode=1
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
Settings
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
if openfile<>Nil then
app.OpenDocument openfile
openfile=nil
end if
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
q.Pause
ContinueButton.Enabled=true
PauseButton.Enabled=false
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
q.StartRecord
ContinueButton.Enabled=false
PauseButton.Enabled=true
End Sub
End ControlInstance
// Properties
Protected Dim q as QTGrabberMBS
Protected Dim file as folderitem
Protected Dim Recording as boolean
Protected Dim SetupDone as boolean
Protected Dim openfile as folderitem
// Event implementations
Sub EnableMenuItems()
FileRecordMovie.Enabled=not Recording and SetupDone
FileSoundSettings.Enabled=not Recording
FileStopRecording.Enabled=recording
End Sub
Sub Open()
dim samplesize as integer
dim numchannels as integer
dim compressiontype as String
q=new QTGrabberMBS
q.InitGrabber
q.InitSound
q.prepare(true,false)
q.update
q.SetAudioInputParameters 16,2,"raw "
q.AudioInputRate=44100
LoadPref
q.SoundLevelMeterEnabled=true
End Sub
Sub Close()
if Recording then
RecordButton.Enabled=true
StopButton.Enabled=False
SettingsButton.Enabled=true
PauseButton.Enabled=false
ContinueButton.Enabled=false
q.Stop
QuickTimePollMBS
openfile=file
file=nil
end if
q.Close
End Sub
// Methods
Sub update()
dim s as String
dim min,n,sec,hour as integer
dim samplesize as integer
dim numchannels as integer
dim compressiontype as String
dim t as String
dim rate as integer
dim state,value as integer
dim m as MemoryBlock
if q.Recording then
s="Recording... "+chr(13)
s=s+format(q.StorageSpaceRemaining/1024/1024,"0.0")+" MB free on disc,"+chr(13)
n=q.TimeRemaining
if q.LastError=0 then
sec=n\60
min=sec\60
sec=sec-60*min
hour=min\60
min=min-60*hour
s=s+"Time till reaching limit: "
if hour>5 then
s=s+"over 5 hours"+chr(13)
else
s=s+format(hour,"-00")+":"+format(min,"-00")+":"+format(sec,"-00")+chr(13)
end if
end if
else
s="Playing... "+chr(13)
end if
n=q.GetSoundLevelMeterValue
Level.set n
q.GetAudioInputParameters samplesize,numchannels,compressiontype
rate=q.AudioInputRate
if numchannels=1 then
t="mono"
elseif numchannels=2 then
t="stereo"
else
t=str(numchannels)+" channels"
end if
s=s+"Settings: "+q.AudioDevice+" used to record "+str(samplesize)+" bit "+t+" @ "+str(rate)+" Hz, compressor """+compressiontype+""""
if s<>StaticText1.text then
StaticText1.text=s
end if
End Sub
Protected Sub Record()
dim f as FolderItem
f=GetSaveFolderItem(FileTypes.VideoQuicktime,"new movie.mov")
if f<>nil then
RecordButton.Enabled=false
StopButton.Enabled=true
SettingsButton.Enabled=false
PauseButton.Enabled=true
Recording=True
file=F
q.SetDataOutput f,1
q.StartRecord
q.SoundLevelMeterEnabled=true
end if
End Sub
Protected Sub Stop()
RecordButton.Enabled=true
StopButton.Enabled=False
SettingsButton.Enabled=true
PauseButton.Enabled=false
ContinueButton.Enabled=false
Recording=False
q.Stop
q.StartPreview
q.SoundLevelMeterEnabled=true
QuickTimePollMBS
openfile=file
file=nil
End Sub
Protected Sub Settings()
q.AskAudioSettings
q.SoundLevelMeterEnabled=true
SetupDone=true
RecordButton.Enabled=not Recording
SavePref
End Sub
Protected Sub LoadPref()
dim f as FolderItem
dim s as string
dim b as BinaryStream
f=PreferencesFolder.Child("Sound Recorder Prefs")
if f<>Nil and f.Exists then
b=f.OpenAsBinaryFile(false)
if b<>nil then
s=b.Read(b.Length)
if s<>"" then
q.Settings=S
end if
b.Close
end if
end if
End Sub
Protected Sub SavePref()
dim f as FolderItem
dim b as BinaryStream
f=PreferencesFolder.Child("Sound Recorder Prefs")
if f<>Nil then
b=f.CreateBinaryFile("pref")
if b<>nil then
b.Write q.Settings
b.Close
end if
end if
End Sub
End Class
Class App
Inherits Application
// Event implementations
Sub EnableMenuItems()
FileOpen.Enable
End Sub
Sub OpenDocument(item As FolderItem)
dim m as movie
dim w as MovieWindow
if item<>Nil then
m=item.OpenAsMovie
if m<>Nil then
w=new MovieWindow
w.Run item,m
end if
end if
End Sub
Sub Open()
RegisterPlugins
End Sub
End Class
Class LevelCanvas
Inherits Canvas
// Properties
Protected Dim value as integer
Protected Dim buf as picture
// Event implementations
Sub Open()
buf=NewPicture(Width,Height,32)
End Sub
Sub Paint(g As Graphics)
draw g
End Sub
// Methods
Sub draw(g as graphics)
dim h as Graphics
dim he as integer
he=height-Height*value/255
h=buf.Graphics
h.ForeColor=rgb(200,200,200)
h.FillRect 0,0,Width,he
h.ForeColor=rgb(100,255,100)
h.FillRect 0,he,Width,Height
g.DrawPicture buf,0,0
Exception
End Sub
Sub set(v as integer)
if v<>value then
value=v
redraw
end if
End Sub
Sub redraw()
draw Graphics
End Sub
End Class
Class AboutDialog
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
Sub Paint(g As Graphics) Handles Event
dim f as FolderItem
f=app.ApplicationFileMBS
if f<>Nil then
f.DrawIconMBS g,me.left,me.top
end if
End Sub
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub Open() Handles Event
me.text="Realbasic "+rbVersionString
End Sub
End ControlInstance
ControlInstance
Sub Open() Handles Event
me.text=mbspluginversion
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
close
End Sub
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub MouseUp(X As Integer, Y As Integer) Handles Event
me.TextColor=rgb(0,0,255)
ShowURL "http://www.monkeybreadsoftware.de"
End Sub
Function MouseDown(X As Integer, Y As Integer) As Boolean Handles Event
me.TextColor=rgb(255,0,0)
Return true
End Function
End ControlInstance
// Event implementations
Sub Open()
#if TargetWin32
title="Sound Recorder"
#else
title=app.longVersion
#endif
StaticText1.text=Title
End Sub
End Class
Class MovieWindow
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
Sub Action() Handles Event
dim m as new QTMovieExporterMBS
const showUserSettingsDialog=2
call m.ConvertMovieToFile(mov,nil,"","",showUserSettingsDialog)
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
file.Launch
End Sub
End ControlInstance
// Properties
Protected Dim file as folderitem
Protected Dim mov as movie
// Event implementations
Sub EnableMenuItems()
FileClose.Enable
End Sub
// Methods
Sub Run(f as folderitem, m as movie)
mov=m
file=f
Title=f.DisplayName
player.Movie=m
show
End Sub
End Class
Links
MBS Realbasic PDF Plugins - Nachhilfe in Kell