Extract Movie Soundtrack 2.0 source code

Class MainWindow
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Sub Change() Handles Event
Select case me.ListIndex
case 0
AudioCodec="AIFF"
fileextension=".aiff"
case 1
AudioCodec="WAVE"
fileextension=".wav"
case 2
AudioCodec="ULAW"
fileextension=".au"
end Select
End Sub
End ControlInstance
ControlInstance
Sub Change() Handles Event
Select case me.ListIndex
case 0
BitCount=8
case 1
BitCount=16
end Select
End Sub
End ControlInstance
ControlInstance
Sub Change() Handles Event
'rate48khz &hBB800000 48000.00000 in fixed-point
'rate44khz &hAC440000 44100.00000 in fixed-point
'rate32khz &h7D000000 32000.00000 in fixed-point
'rate22050hz &h56220000 22050.00000 in fixed-point
'rate22khz &h56EE8BA3 22254.54545 in fixed-point
'rate16khz &h3E800000 16000.00000 in fixed-point
'rate11khz &h2B7745D1 11127.27273 in fixed-point
'rate11025hz &h2B110000 11025.00000 in fixed-point
'rate8khz &h1F400000 8000.00000 in fixed-point

Select case me.ListIndex
case 0
frequency=&hBB800000
case 1
frequency=&hAC440000
case 2
frequency=&h7D000000
case 3
frequency=&h56220000
case 4
frequency=&h56EE8BA3
case 5
frequency=&h3E800000
case 6
frequency=&h2B7745D1
case 7
frequency=&h2B110000
case 8
frequency=&h1F400000
end Select


End Sub
End ControlInstance
ControlInstance
Sub Change() Handles Event
Select case me.ListIndex
case 0
ChannelCount=1
case 1
ChannelCount=2
end Select
End Sub
End ControlInstance
ControlInstance
Sub Change() Handles Event
Select case me.ListIndex
case 0
Compression="NONE"
case 1
Compression="MAC3"
case 2
Compression="MAC6"
case 3
Compression="ima4"
case 4
Compression="ulaw"
case 5
Compression="alaw"
end Select
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
Process
End Sub
End ControlInstance
ControlInstance
End ControlInstance

// Properties
Dim AudioCodec As string


Dim BitCount As integer


Dim frequency As integer


Dim Compression As string


Dim ChannelCount As integer


Dim filetype As string


Dim fileextension As string



// Event implementations
Sub Open()
Init
End Sub

// Methods
Sub Init()
AudioCodec="AIFF"
BitCount=16
frequency=&hAC440000 // 44000
Compression="NONE"
ChannelCount=2
fileextension=".aiff"
End Sub
Sub Process()
dim m as movie
dim output,input as FolderItem
dim t as QTChapterTrackMBS
dim time, duration as integer
dim q as QTMovieExporterMBS
dim b as Boolean
dim s as string
dim OneChapter as Boolean
dim count as integer
dim bi as BinaryStream

input=GetOpenFolderItem("All files (*.*)")

if input<>nil then
m=input.OpenAsMovie

if m=nil then
MsgBox "Failed to open this movie file! "+input.Name
else
OneChapter=not CheckBox1.Value

if not OneChapter then
t=m.ChapterTrackMBS

if t=nil then
OneChapter=true // no chapters
end if
end if

if OneChapter then
q=new QTMovieExporterMBS

if q.OpenExporter(AudioCodec,"soun") then
q.Progress=1
q.SetSoundFormat BitCount,frequency,OSTypeFromStringMBS(Compression),ChannelCount
output=SpecialFolder.Desktop.Child(input.name+fileextension)

if not q.ConvertMovieToFile(m,output,AudioCodec,"TVOD",0) then
if q.Lasterror<>-2019 Then // no user cancel
MsgBox str(q.Lasterror)+" Failed to write file! "+output.Name
end if
end if
else
MsgBox "Can't open "+AudioCodec+" exporter component!"
end if
else
time=0
count=1

Progress.Visible=true
Progress.value=0
Progress.Maximum=m.DurationFramesMBS/m.TimeScaleMBS
Progress.Refresh

if t.NextInterestingTimeMBS(time, duration) then
while time>=0

output=SpecialFolder.Desktop.Child(Format(count,"00")+" "+t.ChapterText(time)+fileextension)

q=new QTMovieExporterMBS

if q.OpenExporter(AudioCodec,"soun") then
q.SetSoundFormat BitCount,frequency,OSTypeFromStringMBS(Compression),ChannelCount

s=q.ExportToString(m, time, duration)
Progress.value=time/m.TimeScaleMBS
Progress.Refresh
if s<>"" then
bi=output.CreateBinaryFile("All files (*.*)")
if bi<>Nil then
bi.Write s
bi.Close

output.MacType=AudioCodec
output.MacCreator="TVOD"

time=time+1
if false=t.NextInterestingTimeMBS(time, duration) then
exit
end if
count=count+1
else
MsgBox str(q.Lasterror)+" Failed to write file! "+output.Name
exit
end if
else
if q.Lasterror<>-2019 Then // no user cancel
MsgBox str(q.Lasterror)+" Failed to transcode audio data! "+output.Name
end if
exit
end if
else
MsgBox "Can't open "+AudioCodec+" exporter component!"
exit
end if
wend
end if
end if
end if
end if

Progress.Visible=false

End Sub
End Class

Class App
Inherits Application
// Event implementations
Sub EnableMenuItems()
AppleAbout.Enable
End Sub
Sub Open()
RegisterPlugins
End Sub
End Class

Class AboutDialog
Inherits Window
// Controls
ControlInstance
End ControlInstance
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
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()
title=app.longVersion

StaticText1.text=Title
End Sub
End Class





Links
MBS FileMaker tutorial videos