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

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

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

QMIDI Component

QMIDI is a  media component used to play midi sequences.

 

 

QMIDI Properties

Field Type R/W Default




Timer QTIMER RW
Control the fréquency of event OnChange. 
Lenght LONG R
Lenght of  midi sequence. 
State INTEGER R VD_CLOSE
State of sequencer,can be MD_PLAY,MD_STOP,MD_PAUSE. 
FileOpen BOOLEAN R False
True if  a midi file is open. 
CurrentFrame LONG RW
Position of midi sequence. 
Error STRING R
Text error if the OPEN méthod return FALSE
Volume INTEGER RW 0

QMIDI Methods

Method Type Description Params




Close SUB Close the midi file 0
Open FUNCTION(FileName as string) Open the midi file and return True if no error 1
Play SUB Play the midi sequence 0
Stop SUB Stop the midi sequence 0
Pause SUB Set the player in mode pause 0

QMIDI Events

Event Type Occurs when... Params




OnChange (position as long) Sequence position in mode play  1

QMIDI Examples

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

$RESOURCE PLAYBMP as "play.bmp"
$RESOURCE STOPBMP as "Stop.bmp"
$RESOURCE PAUSEBMP as "Pause.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 TrackBarChange
Declare Sub PostimerOnTimer(Position as long)

Dim OpenDialog as QOpenDialog
OpenDialog.Filter="Fichier midi|*.mid"
OpenDialog.Caption= "Selectionner une séquence"
Dim midi as QMidi
midi.OnChange=PostimerOnTimer
midi.timer.interval=200


CREATE Form AS QFORM
    Caption="Midi"
    Width=288
    Height=110
    Center
    BorderStyle=bsSingle
    icoHandle=MIDIICO
    OnClose=Quitter
    CREATE MENU AS QMAINMENU
      CREATE FileMenu AS QMENUITEM
        Caption="&Fichier"
        CREATE Item1 AS QMENUITEM
          Caption="&Ouvrir"
          OnClick=Open
        END CREATE
        CREATE Item2 AS QMENUITEM
          Caption="&Fermer"
          OnClick=Close
        END CREATE
        CREATE Item3 AS QMENUITEM
          Caption="-"
        END CREATE
        CREATE Item4 AS QMENUITEM
          Caption="&Quitter"
          OnClick=Quitter
        END CREATE
      END CREATE
    END CREATE
    CREATE Panel1 AS QPANEL
        Left=0
        Top=0
        Width=281
        Height=60
        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 TrackBar1 AS QTRACKBAR
            TickMarks=tmBoth
            TickStyle=tsNone
            Left=2
            Top=36
            LineSize=0
            Width=272
            Height=21
            OnChange=TrackBarChange
        END CREATE
    END CREATE
END CREATE

Form.ShowModal

Sub Open  
  If OpenDialog.Execute Then
   midi.close
   if midi.open(OpenDialog.FileName) then
     TrackBar1.Max=midi.lenght
     TrackBar1.Position=0
   end if
  end if
End Sub

Sub Close
  midi.close
End Sub

Sub Play
  midi.play
End Sub

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

Sub Pause
  midi.pause
End Sub

Sub TrackBarChange
  midi.currentFrame=TrackBar1.Position
End Sub

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

Sub Quitter
  midi.close
  form.close
End Sub

掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2024-12-14  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:50:08