Guidance
指路人
g.yi.org
software / rapidq / Examples / QObject / Object / qwave.html

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Appendix A: QWAVE  
Documentation component by D.Glodt (c)2000-2002 Appendix A: QWAVE

QWAVE Component

QWAVE is a media component used to play or record wave files.

 

 

QWAVE Properties

Field Type R/W Default




Timer QTIMER RW
Controle the fréquency of évent OnChange. 
Lenght LONG R
Lenght of wave file or record time. 
State INTEGER R VD_CLOSE
State of player,can be WV_PLAY,WV_STOP,WV_PAUSE,WV_RECORD. 
FileOpen BOOLEAN R False
It's at true if a wave file is open to play or record. 
CurrentPos LONG RW
Position of wave file in milliseconds. 
Bits INTEGER RW
Bit number by sample of wave,can be WV_BIT8 ou WV_BIT16. 
Frequence INTEGER RW
Sample frequency of wave,can be WV_KHZ8,WV_KHZ11,WV_KHZ44. 
Mode SHORT RW
Output mode,can be WV_STEREO ou WV_MONO. 
Error STRING R
Text error if OPEN method return FALSE
Volume INTEGER RW 0

QWAVE Methods

Method Type Description Params




Close SUB Close the wave file 0
Open FUNCTION(FileName as string) Open a  wave file and return True if no error. 1
Play SUB Play the wave file. 0
Stop SUB Stop the player. 0
Pause SUB Set the player to mode pause 0
New SUB Create a new wave 0
Record SUB Set the player to record,if the wave is new,his record time is define by the Lenght property. 0
Save FUNCTION(FileName as string) Save the wave file and return True 1
Delete Sub(Pos1 as long,Pos2 as long) Delete some sample data from wave file from position pos1 to pos2 in milliseconds 2

QWAVE Events

Event Type Occurs when... Params




OnChange (position as long) Position of player in mode play or mode record. 1

QWAVE Examples

'**************************************************************************
'* application:player Wave                                               *
'* auteur:D.Glodt                                                         *
'* date:7-4-2001                                                          *
'**************************************************************************
$TYPECHECK ON
$Include "Rapidq.inc"
$include "Object\QWave.inc"

$RESOURCE PLAYBMP as "play.bmp"
$RESOURCE STOPBMP as "Stop.bmp"
$RESOURCE PAUSEBMP as "Pause.bmp"
$RESOURCE RECORDBMP as "record.bmp"
$RESOURCE MIDIICO as "midi.ico"

Declare Sub Play
Declare Sub Stop
Declare Sub Pause
Declare Sub Open
Declare Sub Close
Declare Sub Quitter
Declare Sub SaveAs
Declare Sub New
Declare Sub Record
Declare Sub TrackBarChange
Declare Sub PostimerOnTimer(Position as long)
Declare Sub Mono
Declare Sub Stereo
Declare Sub Bit8
Declare Sub Bit16
Declare Sub Khz8
Declare Sub Khz11
Declare Sub Khz44
Declare Sub DeleteStart
Declare Sub DeleteEnd

Dim OpenDialog as QOpenDialog
OpenDialog.Filter="Fichier Wave|*.wav"
OpenDialog.Caption= "Selectionner une onde"
Dim SaveDialog as QSaveDialog
SaveDialog.Filter="Fichier Wave|*.wav"
SaveDialog.Caption= "Sauver une onde"
Dim Wave as QWave
Wave.OnChange=PostimerOnTimer
Wave.timer.interval=200


CREATE Form AS QFORM
    Caption="Wave"
    Width=288
    Height=210
    Center
    BorderStyle=bsSingle
    icoHandle=MIDIICO
    OnClose=Quitter
    CREATE MENU AS QMAINMENU

      CREATE FileMenu AS QMENUITEM
        Caption="&Fichier"
        CREATE Item1 AS QMENUITEM
          Caption="&Nouveau"
          OnClick=New
        END CREATE
        CREATE Item2 AS QMENUITEM
          Caption="&Ouvrir"
          OnClick=Open
        END CREATE
        CREATE Item3 AS QMENUITEM
          Caption="&Fermer"
          OnClick=Close
        END CREATE
        CREATE Item4 AS QMENUITEM
          Caption="&Sauver sous"
          OnClick=SaveAs
        END CREATE
        CREATE Item5 AS QMENUITEM
          Caption="-"
        END CREATE
        CREATE Item6 AS QMENUITEM
          Caption="&Quitter"
          OnClick=Quitter
        END CREATE
      END CREATE
      CREATE EditMenu AS QMENUITEM
        Caption="&Edition"
        CREATE Item11 AS QMENUITEM
          Caption="&Delete from start to position"
          OnClick=DeleteStart
        END CREATE
        CREATE Item12 AS QMENUITEM
          Caption="&Delete from position to end"
          OnClick=DeleteEnd
        END CREATE
      END CREATE
    END CREATE
    CREATE Panel1 AS QPANEL
        Left=0
        Top=0
        Width=281
        Height=160
        BevelOuter=bvNone
        CREATE BtPlay AS QCOOLBTN
            BMPHandle=PLAYBMP
            Left=8
            Top=6
            Width=28
            Height=28
            Flat=true
            Hint="Play"
            ShowHint=true
            GroupIndex=1
            OnClick=Play
        END CREATE
        CREATE BtStop AS QCOOLBTN
            BMPHandle=STOPBMP
            Left=46
            Top=6
            Width=28
            Height=28
            Down=true
            Flat=true
            Hint="Stop"
            ShowHint=true
            GroupIndex=1
            OnClick=Stop
        END CREATE
        CREATE BtPause AS QCOOLBTN
            BMPHandle=PAUSEBMP
            Left=84
            Top=6
            Width=28
            Height=28
            Flat=true
            GroupIndex=1
            Hint="Pause"
            ShowHint=true
            OnClick=Pause
        END CREATE
        CREATE BtRecord AS QCOOLBTN
            BMPHandle=RECORDBMP
            Left=122
            Top=6
            Width=28
            Height=28
            Down=true
            Flat=true
            Hint="Record"
            ShowHint=true
            GroupIndex=1
            OnClick=Record
        END CREATE
        CREATE TrackBar1 AS QTRACKBAR
            TickMarks=tmBoth
            TickStyle=tsNone
            Left=2
            Top=36
            LineSize=0
            Width=272
            Height=21
            OnChange=TrackBarChange
        END CREATE
        CREATE groupe1 AS QGROUPBOX
          Top=70
          Left=2
          Width=70
          Height=60
          Caption="Mode"
          CREATE MonoBt AS QRADIOBUTTON
            Top=15
            Left=5
            width=50
            Caption="Mono"
            OnClick=Mono
          END CREATE
          CREATE StereoBt AS QRADIOBUTTON
            Top=35
            Left=5
            width=50
            Caption="Stereo"
            OnClick=Stereo
          END CREATE
        END CREATE
        CREATE groupe2 AS QGROUPBOX
          Top=70
          Left=82
          Width=70
          Height=60
          Caption="Bits"
          CREATE Bit8Bt AS QRADIOBUTTON
            Top=15
            Left=5
            width=50
            Caption="8bits"
            OnClick=Bit8
          END CREATE
          CREATE Bit16Bt AS QRADIOBUTTON
            Top=35
            Left=5
            width=50
            Caption="16bits"
            OnClick=Bit16
          END CREATE
        END CREATE
        CREATE groupe3 AS QGROUPBOX
          Top=70
          Left=162
          Width=70
          Height=80
          Caption="Freq"
          CREATE Freq8Bt AS QRADIOBUTTON
            Top=15
            Left=5
            width=50
            Caption="8Khz"
            OnClick=Khz8
          END CREATE
          CREATE Freq11Bt AS QRADIOBUTTON
            Top=35
            Left=5
            width=50
            Caption="11Khz"
            OnClick=Khz11
          END CREATE
          CREATE Freq44Bt AS QRADIOBUTTON
            Top=55
            Left=5
            width=50
            Caption="44Khz"
            OnClick=Khz44
          END CREATE
        END CREATE
    END CREATE
END CREATE

Form.ShowModal

Sub Open  
  If OpenDialog.Execute Then
   Wave.close
   if Wave.open(OpenDialog.FileName) then
     TrackBar1.Max=Wave.lenght
     TrackBar1.Position=0
     if wave.mode=WV_MONO then
       MonoBt.checked=true
     else
       StereoBt.checked=true
     end if
     if wave.bits=WV_BIT8 then
       Bit8Bt.checked=true
     else
       Bit16Bt.checked=true
     end if
     if wave.frequence=WV_KHZ8 then
       Freq8Bt.checked=true
     elseif wave.frequence=WV_KHZ11 then
       Freq11Bt.checked=true
     elseif wave.frequence=WV_KHZ44 then
       Freq44Bt.checked=true
     end if
   end if
  end if
End Sub

Sub Close
  Wave.close
End Sub

Sub Play
  if wave.FileOpen=false then BtStop.Down=True
  TrackBar1.Max=Wave.lenght
  Wave.play
End Sub

Sub Stop
  Wave.stop
  TrackBar1.Position=0
End Sub

Sub Pause
  if wave.FileOpen=false then BtStop.Down=True
  Wave.pause
End Sub

Sub TrackBarChange
  Wave.currentPos=TrackBar1.Position
End Sub

Sub PostimerOnTimer(Position as long)
  TrackBar1.Position=Position
  If Wave.state=WV_STOP then
    Wave.stop
    TrackBar1.Position=0
    BtStop.Down=True
  end if
End Sub

Sub Quitter
  Wave.close
  form.close
End Sub

Sub Mono
  wave.mode=WV_MONO
End Sub

Sub Stereo
  wave.mode=WV_STEREO
End Sub

Sub Bit8
  wave.bits=WV_BIT8
End Sub

Sub Bit16
  wave.bits=WV_BIT16
End Sub

Sub Khz8
  wave.frequence=WV_KHZ8
End Sub

Sub Khz11
  wave.frequence=WV_KHZ11
End Sub

Sub Khz44
  wave.frequence=WV_KHZ44
End Sub

Sub New
  wave.close
  wave.new
  if wave.mode=WV_MONO then
    MonoBt.checked=true
  else
    StereoBt.checked=true
  end if
  if wave.bits=WV_BIT8 then
    Bit8Bt.checked=true
  else
    Bit16Bt.checked=true
  end if
  if wave.frequence=WV_KHZ8 then
    Freq8Bt.checked=true
  elseif wave.frequence=WV_KHZ11 then
    Freq11Bt.checked=true
  elseif wave.frequence=WV_KHZ44 then
    Freq44Bt.checked=true
  end if
End Sub

Sub SaveAs
  If SaveDialog.Execute Then
    if wave.save(SaveDialog.FileName) then form.caption="Saved"
  end if
End Sub

Sub Record
  if wave.FileOpen=false then BtStop.Down=True
  wave.lenght=6000
  TrackBar1.Max=Wave.lenght
  wave.record
End Sub

Sub DeleteStart
  wave.Delete(0,wave.currentPos)
End Sub

Sub DeleteEnd
  wave.Delete(wave.currentPos,wave.lenght)
End Sub
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2023-2-4  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-10-20 09:06:34