Avatar billede akexpert Nybegynder
03. februar 2002 - 13:15 Der er 19 kommentarer

Musikafspiller...

Hej derude...

Jeg kan ikke finde ud af hvordan man kan lave en musikafspiller, der kan afspille musikfiler, som der derefter kan vælges om filen skal afspilles langsomt, normalt eller hurtigt tempo.. Hvordan kan man gøre det????

Der er 200 points til det RIGTIGE svar!!!


/akExpert
Avatar billede sjh Nybegynder
03. februar 2002 - 22:56 #1
'---------------------------------------- Form1 ----------------------------------------
Option Explicit

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal _
                lpstrCommand As String, ByVal lpstrReturnString As String, ByVal _
                uReturnLength As Long, ByVal hwndCallback As Long) As Long

Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal _
                lpszLongPath As String, ByVal lpszShortPath As String, ByVal _
                cchBuffer As Long) As Long

Public Function mciOpen(Filename As String, TypeDevice As String)
Dim dwReturn As Long
Dim tmp As String * 255
Dim lenShort As Long
Dim shortname As String
  lenShort = GetShortPathName(Filename, tmp, 255)
  shortname = Left$(tmp, lenShort)
  dwReturn = mciSendString("open " & shortname & " type " & TypeDevice & " alias mpeg", 0&, 0&, 0&)
End Function

Public Function mciClose()
Dim dwReturn As Long
  dwReturn = mciSendString("close mpeg", 0&, 0&, 0&)
End Function

Public Function mciPlay()
Dim dwReturn As Long
  dwReturn = mciSendString("play mpeg", 0&, 0&, 0&)
End Function

Public Function mciStop()
Dim dwReturn As Long
  dwReturn = mciSendString("stop mpeg", 0&, 0&, 0&)
End Function

Public Function mciSpeed(Speed As Integer)
Dim dwReturn As Long
  dwReturn = mciSendString("set mpeg speed " & CStr(Speed * 10), 0&, 0&, 0&)
End Function

Private Sub Form_Load()
  mciOpen "E:\Test.mp3", "MPEGVideo"
  mciPlay
  mciSpeed 120 'mciSpeed 1 - 200 (default = 100)
End Sub

Private Sub Form_Unload(Cancel As Integer)
  mciStop
  mciClose
End Sub
'---------------------------------------- Form1 ----------------------------------------
Avatar billede akexpert Nybegynder
08. februar 2002 - 15:33 #2
sjh >> Jeg glemte hvis at sige, at jeg skulle bruge en musikafspiller hvori der er mulighed for at afspille 2 sange på én gang!

/ akExpert
Avatar billede mc.lucifer Praktikant
08. februar 2002 - 15:37 #3
Carot "Gulerod på dansk" har lavet det der program du søger det heder Virtual Turntables Det er faktisk meget godt der har du også en Crossfader, BPM counter hastigheds regulator oma

MC
Avatar billede sjh Nybegynder
08. februar 2002 - 17:37 #4
akexpert> det kan du også, du skal bare lave en ny "Alias"


Public Function mciOpen(Filename As String, TypeDevice As String, sAlias As String)
Dim dwReturn As Long
Dim tmp As String * 255
Dim lenShort As Long
Dim shortname As String
  lenShort = GetShortPathName(Filename, tmp, 255)
  shortname = Left$(tmp, lenShort)
  dwReturn = mciSendString("open " & shortname & " type " & TypeDevice & " alias " & sAlias, 0&, 0&, 0&)
End Function

Public Function mciClose(sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("close " & sAlias, 0&, 0&, 0&)
End Function

Public Function mciPlay(sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("play " & sAlias, 0&, 0&, 0&)
End Function

Public Function mciStop(sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("stop " & sAlias, 0&, 0&, 0&)
End Function

Public Function mciSpeed(Speed As Integer, sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("set " & sAlias & " speed " & CStr(Speed * 10), 0&, 0&, 0&)
End Function

Private Sub Form_Load()
  mciOpen "E:\Test.mp3", "MPEGVideo", "Musik1"
  mciPlay "Musik1"
  mciSpeed 120, "Musik1" 'mciSpeed 1 - 200 (default = 100)
End Sub

Private Sub Form_Unload(Cancel As Integer)
  mciStop "Musik1"
  mciClose "Musik1"
End Sub
Avatar billede akexpert Nybegynder
13. februar 2002 - 17:19 #5
>>sjh
Avatar billede akexpert Nybegynder
13. februar 2002 - 17:21 #6
>>sjh

Det ser ud til at du har tjeck på Visual Basic. Hvor får du din viden fra???

Jeg det lade sig gøre at stille på volumen, bass, diskant eller mellemtonen, også???????

/akexpert
Avatar billede akexpert Nybegynder
13. februar 2002 - 17:21 #7
Jeg skrev forkert!!:

>>sjh

Det ser ud til at du har tjeck på Visual Basic. Hvor får du din viden fra???

Kan det lade sig gøre at stille på volumen, bass, diskant eller mellemtonen, også???????

/akexpert
Avatar billede sjh Nybegynder
13. februar 2002 - 22:36 #8
Ja volume.


Option Explicit

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal _
                lpstrCommand As String, ByVal lpstrReturnString As String, ByVal _
                uReturnLength As Long, ByVal hwndCallback As Long) As Long

Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal _
                lpszLongPath As String, ByVal lpszShortPath As String, ByVal _
                cchBuffer As Long) As Long

Public Function mciOpen(Filename As String, TypeDevice As String, sAlias As String)
Dim dwReturn As Long
Dim tmp As String * 255
Dim lenShort As Long
Dim shortname As String
  lenShort = GetShortPathName(Filename, tmp, 255)
  shortname = Left$(tmp, lenShort)
  dwReturn = mciSendString("open " & shortname & " type " & TypeDevice & " alias " & sAlias, 0&, 0&, 0&)
End Function

Public Function mciClose(sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("close " & sAlias, 0&, 0&, 0&)
End Function

Public Function mciPlay(sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("play " & sAlias, 0&, 0&, 0&)
End Function

Public Function mciStop(sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("stop " & sAlias, 0&, 0&, 0&)
End Function

Public Function mciSpeed(Speed As Integer, sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("set " & sAlias & " speed " & CStr(Speed * 10), 0&, 0&, 0&)
End Function

Public Function mciSetVolume(Channel As String, VolValue As Long, sAlias As String)
Dim cmdToDo As String
Dim dwReturn As Long

  If LCase(Channel) = "left" Or LCase(Channel) = "right" Then
    cmdToDo = "setaudio " & sAlias & " " & Channel & " Volume to " & CStr(VolValue * 10)
      Else
    cmdToDo = "setaudio " & sAlias & " Volume to " & CStr(VolValue * 10)
  End If
dwReturn = mciSendString(cmdToDo, 0&, 0&, 0&)
End Function

Public Function mciGetVolume(Channel As String, sAlias As String) As Long
Dim dwReturn As Long
Dim Volume  As String * 128
Dim cmdToDo As String

    If LCase(Channel) = "left" Or LCase(Channel) = "right" Then
      cmdToDo = "status " & sAlias & " " & Channel & " Volume"
        Else
      cmdToDo = "status " & sAlias & " Volume"
    End If
  dwReturn = mciSendString(cmdToDo, Volume, 128, 0&)
mciGetVolume = Val(Volume / 10)
End Function

Private Sub Form_Load()
  mciOpen "E:\Test.mp3", "MPEGVideo", "Musik1"
  mciPlay "Musik1"
  mciSpeed 120, "Musik1" 'mciSpeed 1 - 200 (default = 100)

  HScroll1.Max = 100
  HScroll1.Value = 50
End Sub

Private Sub Form_Unload(Cancel As Integer)
  mciStop "Musik1"
  mciClose "Musik1"
End Sub

Private Sub HScroll1_Change()
'mciSetVolume "All / Left / Right", 0-100, "Musik1"
  mciSetVolume "All", HScroll1.Value, "Musik1"

'x = mciGetVolume("All / Left / Right", "Musik1")
  Me.Caption = mciGetVolume("All", "Musik1")
End Sub

Private Sub HScroll1_Scroll()
'mciSetVolume "All / Left / Right", 0-100, "Musik1"
  mciSetVolume "All", HScroll1.Value, "Musik1"

'x = mciGetVolume("All / Left / Right", "Musik1")
  Me.Caption = mciGetVolume("All", "Musik1")
End Sub
Avatar billede akexpert Nybegynder
18. februar 2002 - 19:25 #9
Det var dog utroligt med viden der vælter ud fra sjh!!!

Jeg fik ikke svar på om det også kunne lade sig gøre at stille på diskanten, mellemtonen eller bassen!! Kan det lade sig gøre?? Jeg er kun interesseret om det kan!!!!

/akExpert
Avatar billede sjh Nybegynder
18. februar 2002 - 22:48 #10
Jeg er ikke sikker på om man kan i mcicommand, men ellers kan man bruge windows lydstyrke til bass/diskant som jeg har lavet i programmet her http://hjem.get2net.dk/sjh/eksperten/soundnam.zip
Avatar billede akexpert Nybegynder
19. februar 2002 - 11:07 #11
Kan det så lade sig gøre at finde ud af hvor lang en sang er: minutter, sekunder evt. millisekunder?
Og hvor meget af sangen der er blevet afspillet????

/akExpert
Avatar billede sjh Nybegynder
19. februar 2002 - 15:25 #12
Kan du ikke skrive alt det du skal bruge, så skal jeg se hvad jeg kan gåre. ;-)
Avatar billede akexpert Nybegynder
20. februar 2002 - 18:01 #13
Jeg skal bruge:
2 afspiller (har vi klaret!)
Visning af tid(min, sek, evt. millisek.)
Det er nok alt hvad jeg mangler tror jeg!!

Tilbage til det der med bas og diskant! Kan du ikke skaffe VB-koder, som der kan gøre det samme som det program, som du referer til???

/akExpert
Avatar billede sjh Nybegynder
20. februar 2002 - 20:53 #14
Jo, nu har jeg jo selv lavet programmet så det skulle være muglit. :-)

>>Jeg vender tilbage med: tid(min, sek, evt. millisek.)<<

bas og diskant (lydstyrke)
der står eksempel i modulet.

'------------------ Module1 ------------------

Option Explicit

Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Public Const MMSYSERR_NOERROR = 0
Public Const MAXPNAMELEN = 32
Public Const MIXER_LONG_NAME_CHARS = 64
Public Const MIXER_SHORT_NAME_CHARS = 16
Public Const MIXER_GETLINEINFOF_COMPONENTTYPE = &H3&
Public Const MIXER_GETCONTROLDETAILSF_VALUE = &H0&
Public Const MIXER_GETLINECONTROLSF_ONEBYTYPE = &H2&
Public Const MIXER_SETCONTROLDETAILSF_VALUE = &H0&
Public Const MIXERCONTROL_CT_CLASS_FADER = &H50000000
Public Const MIXERCONTROL_CT_CLASS_SWITCH = &H20000000
Public Const MIXERCONTROL_CT_SC_SWITCH_BOOLEAN = &H0&
Public Const MIXERCONTROL_CT_UNITS_BOOLEAN = &H10000
Public Const MIXERCONTROL_CT_UNITS_UNSIGNED = &H30000
Public Const MIXERCONTROL_CT_CLASS_CUSTOM = &H0&
Public Const MIXERCONTROL_CT_CLASS_LIST = &H70000000
Public Const MIXERCONTROL_CT_CLASS_MASK = &HF0000000
Public Const MIXERCONTROL_CT_CLASS_METER = &H10000000
Public Const MIXERCONTROL_CT_CLASS_NUMBER = &H30000000
Public Const MIXERCONTROL_CT_CLASS_SLIDER = &H40000000
Public Const MIXERCONTROL_CT_CLASS_TIME = &H60000000
Public Const MIXERCONTROL_CT_SC_LIST_MULTIPLE = &H1000000
Public Const MIXERCONTROL_CT_SC_LIST_SINGLE = &H0&
Public Const MIXERCONTROL_CT_SC_METER_POLLED = &H0&
Public Const MIXERCONTROL_CT_SC_SWITCH_BUTTON = &H1000000
Public Const MIXERCONTROL_CT_SC_TIME_MICROSECS = &H0&
Public Const MIXERCONTROL_CT_SC_TIME_MILLISECS = &H1000000
Public Const MIXERCONTROL_CT_SUBCLASS_MASK = &HF000000
Public Const MIXERCONTROL_CT_UNITS_CUSTOM = &H0&
Public Const MIXERCONTROL_CT_UNITS_DECIBELS = &H40000
Public Const MIXERCONTROL_CT_UNITS_MASK = &HFF0000
Public Const MIXERCONTROL_CT_UNITS_PERCENT = &H50000
Public Const MIXERCONTROL_CT_UNITS_SIGNED = &H20000
Public Const MIXERLINE_COMPONENTTYPE_DST_FIRST = &H0&
Public Const MIXERLINE_COMPONENTTYPE_SRC_FIRST = &H1000&
Public Const MIXERLINE_COMPONENTTYPE_SRC_ANALOG = &H1000& + 10
Public Const MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY = &H1000& + 9
Public Const MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC = &H1000& + 5
Public Const MIXERLINE_COMPONENTTYPE_SRC_DIGITAL = &H1000& + 1
Public Const MIXERLINE_COMPONENTTYPE_SRC_LAST = &H1000& + 10
Public Const MIXERLINE_COMPONENTTYPE_SRC_LINE = &H1000& + 2
Public Const MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER = &H1000& + 4
Public Const MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED = &H1000& + 0
Public Const MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT = &H1000& + 8

Public Const MIXERLINE_COMPONENTTYPE_SRC_I25InVol = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 1)
Public Const MIXERLINE_COMPONENTTYPE_SRC_LINEVol = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
Public Const MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
Public Const MIXERLINE_COMPONENTTYPE_SRC_MIDIVol = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 4)
Public Const MIXERLINE_COMPONENTTYPE_SRC_CDVol = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 5)
Public Const MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 6)
Public Const MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 7)
Public Const MIXERLINE_COMPONENTTYPE_SRC_WAVEDSVol = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8)
Public Const MIXERLINE_COMPONENTTYPE_src_AUXVol = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 9)

Public Const MIXERLINE_COMPONENTTYPE_DST_UNDEFINED = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 0)
Public Const MIXERLINE_COMPONENTTYPE_DST_DIGITAL = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 1)
Public Const MIXERLINE_COMPONENTTYPE_DST_LINE = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 2)
Public Const MIXERLINE_COMPONENTTYPE_DST_MONITOR = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 3)
Public Const MIXERLINE_COMPONENTTYPE_DST_SPEAKERS = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 4)
Public Const MIXERLINE_COMPONENTTYPE_DST_HEADPHONES = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 5)
Public Const MIXERLINE_COMPONENTTYPE_DST_TELEPHONE = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 6)
Public Const MIXERLINE_COMPONENTTYPE_DST_WAVEIN = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 7)
Public Const MIXERLINE_COMPONENTTYPE_DST_LAST = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)
Public Const MIXERLINE_COMPONENTTYPE_DST_VOICEIN = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)

Public Const MMIO_READ = &H0
Public Const MMIO_FINDCHUNK = &H10
Public Const MMIO_FINDRIFF = &H20

Public Const MIXERCONTROL_CONTROLTYPE_FADER = (MIXERCONTROL_CT_CLASS_FADER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_BASS = (MIXERCONTROL_CONTROLTYPE_FADER + 2)
Public Const MIXERCONTROL_CONTROLTYPE_BOOLEAN = (MIXERCONTROL_CT_CLASS_SWITCH Or MIXERCONTROL_CT_SC_SWITCH_BOOLEAN Or MIXERCONTROL_CT_UNITS_BOOLEAN)
Public Const MIXERCONTROL_CONTROLTYPE_TREBLE = (MIXERCONTROL_CONTROLTYPE_FADER + 3)
Public Const MIXERCONTROL_CONTROLTYPE_VOLUME = (MIXERCONTROL_CONTROLTYPE_FADER + 1)
Public Const MIXERCONTROL_CONTROLTYPE_MUTE = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 2)
Public Const MIXERCONTROL_CONTROLTYPE_EQUALIZER = (MIXERCONTROL_CONTROLTYPE_FADER + 4)
Public Const MIXERCONTROL_CONTROLTYPE_LOUDNESS = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 4)
Public Const MIXERCONTROL_CONTROLTYPE_SIGNEDMETER = (MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_SIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_PEAKMETER = (MIXERCONTROL_CONTROLTYPE_SIGNEDMETER + 1)
Public Const MIXERCONTROL_CONTROLTYPE_BOOLEANMETER = (MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_BOOLEAN)
Public Const MIXERCONTROL_CONTROLTYPE_BUTTON = (MIXERCONTROL_CT_CLASS_SWITCH Or MIXERCONTROL_CT_SC_SWITCH_BUTTON Or MIXERCONTROL_CT_UNITS_BOOLEAN)
Public Const MIXERCONTROL_CONTROLTYPE_CUSTOM = (MIXERCONTROL_CT_CLASS_CUSTOM Or MIXERCONTROL_CT_UNITS_CUSTOM)
Public Const MIXERCONTROL_CONTROLTYPE_DECIBELS = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_DECIBELS)
Public Const MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT = (MIXERCONTROL_CT_CLASS_LIST Or MIXERCONTROL_CT_SC_LIST_MULTIPLE Or MIXERCONTROL_CT_UNITS_BOOLEAN)
Public Const MIXERCONTROL_CONTROLTYPE_MICROTIME = (MIXERCONTROL_CT_CLASS_TIME Or MIXERCONTROL_CT_SC_TIME_MICROSECS Or MIXERCONTROL_CT_UNITS_UNSIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_MILLITIME = (MIXERCONTROL_CT_CLASS_TIME Or MIXERCONTROL_CT_SC_TIME_MILLISECS Or MIXERCONTROL_CT_UNITS_UNSIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_MIXER = (MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT + 1)
Public Const MIXERCONTROL_CONTROLTYPE_MONO = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 3)
Public Const MIXERCONTROL_CONTROLTYPE_SLIDER = (MIXERCONTROL_CT_CLASS_SLIDER Or MIXERCONTROL_CT_UNITS_SIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_STEREOENH = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 5)
Public Const MIXERCONTROL_CONTROLTYPE_UNSIGNED = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER = (MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_UNSIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_SINGLESELECT = (MIXERCONTROL_CT_CLASS_LIST Or MIXERCONTROL_CT_SC_LIST_SINGLE Or MIXERCONTROL_CT_UNITS_BOOLEAN)
Public Const MIXERCONTROL_CONTROLTYPE_MUX = (MIXERCONTROL_CONTROLTYPE_SINGLESELECT + 1)
Public Const MIXERCONTROL_CONTROLTYPE_PAN = (MIXERCONTROL_CONTROLTYPE_SLIDER + 1)
Public Const MIXERCONTROL_CONTROLTYPE_PERCENT = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_PERCENT)
Public Const MIXERCONTROL_CONTROLTYPE_QSOUNDPAN = (MIXERCONTROL_CONTROLTYPE_SLIDER + 2)
Public Const MIXERCONTROL_CONTROLTYPE_SIGNED = (MIXERCONTROL_CT_CLASS_NUMBER Or MIXERCONTROL_CT_UNITS_SIGNED)
' Mixer line flags
Public Const MIXERLINE_LINEF_ACTIVE = &H1&
Public Const MIXERLINE_LINEF_DISCONNECTED = &H8000&
Public Const MIXERLINE_LINEF_SOURCE = &H80000000
' Mixer line target types
Public Const MIXERLINE_TARGETTYPE_AUX = 5
Public Const MIXERLINE_TARGETTYPE_MIDIIN = 4
Public Const MIXERLINE_TARGETTYPE_MIDIOUT = 3
Public Const MIXERLINE_TARGETTYPE_UNDEFINED = 0
Public Const MIXERLINE_TARGETTYPE_WAVEIN = 2
Public Const MIXERLINE_TARGETTYPE_WAVEOUT = 1

Public Const MIXERR_INVALLINE = 1024 + 0
Public Const MIXERR_BASE = 1024
Public Const MIXERR_INVALCONTROL = 1024 + 1
Public Const MIXERR_INVALVALUE = 1024 + 2
Public Const MIXERR_LASTERROR = 1024 + 2

Type MIXERCAPS
    wMid As Integer
    wPid As Integer
    vDriverVersion As Long
    szPname As String * MAXPNAMELEN
    fdwSupport As Long
    cDestinations As Long
End Type

Type Target
    dwType As Long
    dwDeviceID As Long
    wMid As Integer
    wPid As Integer
    vDriverVersion As Long
    szPname As String * MAXPNAMELEN
End Type

Type MIXERLINE
    cbStruct As Long
    dwDestination As Long
    dwSource As Long
    dwLineID As Long
    fdwLine As Long
    dwUser As Long
    dwComponentType As Long
    cChannels As Long
    cConnections As Long
    cControls As Long
    szShortName As String * MIXER_SHORT_NAME_CHARS
    szName As String * MIXER_LONG_NAME_CHARS
    lpTarget As Target
End Type

Type MIXERLINECONTROLS
    cbStruct As Long
    dwLineID As Long
    dwControl As Long
    cControls As Long
    cbmxctrl As Long
    pamxctrl As Long
End Type

Type MIXERCONTROL
    cbStruct As Long
    dwControlID As Long
    dwControlType As Long
    fdwControl As Long
    cMultipleItems As Long
    szShortName(1 To MIXER_SHORT_NAME_CHARS) As Byte
    szName(1 To MIXER_LONG_NAME_CHARS) As Byte
    Bounds(1 To 6) As Long
    Metrics(1 To 6) As Long
End Type

Type MIXERCONTROLDETAILS
    cbStruct As Long
    dwControlID As Long
    cChannels As Long
    item As Long
    cbDetails As Long
    paDetails As Long
End Type

Type MIXERCONTROLDETAILS_BOOLEAN
    fValue As Long
End Type

Type MIXERCONTROLDETAILS_LISTTEXT
    dwParam1 As Long
    dwParam2 As Long
    szName As String * MIXER_LONG_NAME_CHARS
End Type

Type MIXERCONTROLDETAILS_SIGNED
    lValue As Long
End Type

Type MIXERCONTROLDETAILS_UNSIGNED
    dwValue As Long
End Type

Declare Function mixerClose Lib "winmm.dll" (ByVal hmx As Long) As Long
Declare Function mixerGetControlDetails Lib "winmm.dll" Alias "mixerGetControlDetailsA" (ByVal hmxobj As Long, pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails As Long) As Long
Declare Function mixerGetDevCaps Lib "winmm.dll" Alias "mixerGetDevCapsA" (ByVal uMxId As Long, pmxcaps As MIXERCAPS, ByVal cbmxcaps As Long) As Long
Declare Function mixerGetID Lib "winmm.dll" (ByVal hmxobj As Long, pumxID As Long, ByVal fdwId As Long) As Long
Declare Function mixerGetLineControls Lib "winmm.dll" Alias "mixerGetLineControlsA" (ByVal hmxobj As Long, pmxlc As MIXERLINECONTROLS, ByVal fdwControls As Long) As Long
Declare Function mixerGetLineInfo Lib "winmm.dll" Alias "mixerGetLineInfoA" (ByVal hmxobj As Long, pmxl As MIXERLINE, ByVal fdwInfo As Long) As Long
Declare Function mixerGetNumDevs Lib "winmm.dll" () As Long
Declare Function mixerMessage Lib "winmm.dll" (ByVal hmx As Long, ByVal uMsg As Long, ByVal dwParam1 As Long, ByVal dwParam2 As Long) As Long
Declare Function mixerOpen Lib "winmm.dll" (phmx As Long, ByVal uMxId As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal fdwOpen As Long) As Long
Declare Function mixerSetControlDetails Lib "winmm.dll" (ByVal hmxobj As Long, pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails As Long) As Long
Public Declare Function RegisterDLL Lib "Regist10.dll" Alias "REGISTERDLL" (ByVal DllPath As String, bRegister As Boolean) As Boolean
Declare Function mmioClose Lib "winmm.dll" (ByVal hmmio As Long, ByVal uFlags As Long) As Long
Declare Function mmioDescend Lib "winmm.dll" (ByVal hmmio As Long, lpck As MMCKINFO, lpckParent As MMCKINFO, ByVal uFlags As Long) As Long
Declare Function mmioDescendParent Lib "winmm.dll" Alias "mmioDescend" (ByVal hmmio As Long, lpck As MMCKINFO, ByVal X As Long, ByVal uFlags As Long) As Long
Declare Function mmioOpen Lib "winmm.dll" Alias "mmioOpenA" (ByVal szFileName As String, lpmmioinfo As mmioinfo, ByVal dwOpenFlags As Long) As Long
Declare Function mmioRead Lib "winmm.dll" (ByVal hmmio As Long, ByVal pch As Long, ByVal cch As Long) As Long
Declare Function mmioReadFormat Lib "winmm.dll" Alias "mmioRead" (ByVal hmmio As Long, ByRef pch As waveFormat, ByVal cch As Long) As Long
Declare Function mmioStringToFOURCC Lib "winmm.dll" Alias "mmioStringToFOURCCA" (ByVal sz As String, ByVal uFlags As Long) As Long
Declare Function mmioAscend Lib "winmm.dll" (ByVal hmmio As Long, lpck As MMCKINFO, ByVal uFlags As Long) As Long
Private Declare Function GetFileVersionInfo Lib "Version.dll" Alias "GetFileVersionInfoA" (ByVal lptstrFilename As String, ByVal dwHandle As Long, ByVal dwLen As Long, lpData As Any) As Long
Private Declare Function GetFileVersionInfoSize Lib "Version.dll" Alias "GetFileVersionInfoSizeA" (ByVal lptstrFilename As String, lpdwHandle As Long) As Long
Private Declare Function VerQueryValue Lib "Version.dll" Alias "VerQueryValueA" (pBlock As Any, ByVal lpSubBlock As String, lplpBuffer As Any, puLen As Long) As Long
Private Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, ByVal Source As Long, ByVal length As Long)

Declare Sub CopyStructFromPtr Lib "kernel32" _
              Alias "RtlMoveMemory" _
              (struct As Any, _
              ByVal ptr As Long, ByVal cb As Long)
             
Declare Sub CopyPtrFromStruct Lib "kernel32" _
              Alias "RtlMoveMemory" _
              (ByVal ptr As Long, _
              struct As Any, _
              ByVal cb As Long)
             
Declare Function GlobalAlloc Lib "kernel32" _
              (ByVal wFlags As Long, _
              ByVal dwBytes As Long) As Long
             
Declare Function GlobalLock Lib "kernel32" _
              (ByVal hmem As Long) As Long
             
Declare Function GlobalFree Lib "kernel32" _
              (ByVal hmem As Long) As Long

' variables for managing wave file
Public formatA As waveFormat
Dim hmmioOut As Long
Dim mmckinfoParentIn As MMCKINFO
Dim mmckinfoSubchunkIn As MMCKINFO
Dim bufferIn As Long
Dim hmem As Long
Public numSamples As Long
Public drawFrom As Long
Public drawTo As Long
Public fFileLoaded As Boolean

Type waveFormat
  wFormatTag As Integer
  nChannels As Integer
  nSamplesPerSec As Long
  nAvgBytesPerSec As Long
  nBlockAlign As Integer
  wBitsPerSample As Integer
  cbSize As Integer
End Type

Type mmioinfo
  dwFlags As Long
  fccIOProc As Long
  pIOProc As Long
  wErrorRet As Long
  htask As Long
  cchBuffer As Long
  pchBuffer As String
  pchNext As String
  pchEndRead As String
  pchEndWrite As String
  lBufOffset As Long
  lDiskOffset As Long
  adwInfo(4) As Long
  dwReserved1 As Long
  dwReserved2 As Long
  hmmio As Long
End Type

Type MMCKINFO
    ckid As Long
    ckSize As Long
    fccType As Long
    dwDataOffset As Long
    dwFlags As Long
End Type

Private Type VS_FIXEDFILEINFO
    dwSignature As Long
    dwStrucVersionl As Integer
    dwStrucVersionh As Integer
    dwFileVersionMSl As Integer
    dwFileVersionMSh As Integer
    dwFileVersionLSl As Integer
    dwFileVersionLSh As Integer
    dwProductVersionMSl As Integer
    dwProductVersionMSh As Integer
    dwProductVersionLSl As Integer
    dwProductVersionLSh As Integer
    dwFileFlagsMask As Long
    dwFileFlags As Long
    dwFileOS As Long
    dwFileType As Long
    dwFileSubtype As Long
    dwFileDateMS As Long
    dwFileDateLS As Long
End Type

Dim volR As Long
Dim volL As Long
Dim volume As Long
Dim mute As MIXERCONTROL
Dim unmute As MIXERCONTROL
Dim ONOFF As MIXERCONTROL
Dim hmixer As Long            ' mixer handle
Dim VolCtrl As MIXERCONTROL    ' master volume control
Dim WavCtrl As MIXERCONTROL    ' wave output volume control
Dim CDVol As MIXERCONTROL      ' CD Volume
Dim LineVol As MIXERCONTROL    ' Line/In Volume
Dim MICROPHONE As MIXERCONTROL ' Microphone Volume
Dim PCSPEAKER As MIXERCONTROL    ' PcSpeaker Volume
Dim AUXVol As MIXERCONTROL    ' Auxillary Volume
Dim TELEPHONE As MIXERCONTROL    ' TAD-In Volume
Dim MIDIVol As MIXERCONTROL    ' Midi Volume
Dim I25InVol As MIXERCONTROL  ' I25In Volume
Dim Treble As MIXERCONTROL
Dim Bass As MIXERCONTROL
Dim rc As Long                ' return code
Dim ok As Boolean              ' boolean return code

Function GetMixerControl(ByVal hmixer As Long, _
                        ByVal componentType As Long, _
                        ByVal ctrlType As Long, _
                        ByRef mxc As MIXERCONTROL) As Boolean
                       
' This function attempts to obtain a mixer control. Returns True if successful.
  Dim mxlc As MIXERLINECONTROLS
  Dim mxl As MIXERLINE
  Dim hmem As Long
  Dim rc As Long
     
  mxl.cbStruct = Len(mxl)
  mxl.dwComponentType = componentType
  ' Obtain a line corresponding to the component type
  rc = mixerGetLineInfo(hmixer, mxl, MIXER_GETLINEINFOF_COMPONENTTYPE)
  If (MMSYSERR_NOERROR = rc) Then
      mxlc.cbStruct = Len(mxlc)
      mxlc.dwLineID = mxl.dwLineID
      mxlc.dwControl = ctrlType
      mxlc.cControls = 1
      mxlc.cbmxctrl = Len(mxc)
      ' Allocate a buffer for the control
      hmem = GlobalAlloc(&H40, Len(mxc))
      mxlc.pamxctrl = GlobalLock(hmem)
      mxc.cbStruct = Len(mxc)
      ' Get the control
      rc = mixerGetLineControls(hmixer, mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE)
      If (MMSYSERR_NOERROR = rc) Then
          GetMixerControl = True
          ' Copy the control into the destination structure
          CopyStructFromPtr mxc, mxlc.pamxctrl, Len(mxc)
      Else
          GetMixerControl = False
      End If
      GlobalFree (hmem)
      Exit Function
  End If
  GetMixerControl = False
End Function

Function SetVolumeControl(ByVal hmixer As Long, mxc As MIXERCONTROL, ByVal volume As Long) As Boolean
  Dim mxcd As MIXERCONTROLDETAILS
  Dim Vol As MIXERCONTROLDETAILS_UNSIGNED
  mxcd.cbStruct = Len(mxcd)
  mxcd.dwControlID = mxc.dwControlID
  mxcd.cChannels = 1
  mxcd.item = 0
  mxcd.cbDetails = Len(Vol)
  hmem = GlobalAlloc(&H40, Len(Vol))
  mxcd.paDetails = GlobalLock(hmem)
  Vol.dwValue = volume
  ' Copy the data into the control value buffer
  CopyPtrFromStruct mxcd.paDetails, Vol, Len(Vol)
  rc = mixerSetControlDetails(hmixer, mxcd, MIXER_SETCONTROLDETAILSF_VALUE)
  GlobalFree (hmem)
  If (MMSYSERR_NOERROR = rc) Then
      SetVolumeControl = True
  Else
      SetVolumeControl = False
  End If
End Function

Function SetPANControl(ByVal hmixer As Long, mxc As MIXERCONTROL, ByVal volL As Long, ByVal volR As Long) As Boolean
'This function sets the value for a volume control. Returns True if successful
  Dim mxcd As MIXERCONTROLDETAILS
  Dim Vol(1) As MIXERCONTROLDETAILS_UNSIGNED
  mxcd.item = mxc.cMultipleItems
  mxcd.dwControlID = mxc.dwControlID
  mxcd.cbStruct = Len(mxcd)
  mxcd.cbDetails = Len(Vol(1))
  ' Allocate a buffer for the control value buffer
  mxcd.cChannels = 2
  hmem = GlobalAlloc(&H40, Len(Vol(1)))
  mxcd.paDetails = GlobalLock(hmem)
  Vol(1).dwValue = volR
  Vol(0).dwValue = volL
  ' Copy the data into the control value buffer
  CopyPtrFromStruct mxcd.paDetails, Vol(1).dwValue, Len(Vol(0)) * mxcd.cChannels
  CopyPtrFromStruct mxcd.paDetails, Vol(0).dwValue, Len(Vol(1)) * mxcd.cChannels
  ' Set the control value
  rc = mixerSetControlDetails(hmixer, mxcd, MIXER_SETCONTROLDETAILSF_VALUE)
  GlobalFree (hmem)
  If (MMSYSERR_NOERROR = rc) Then
      SetPANControl = True
  Else
      SetPANControl = False
  End If
End Function

Function unSetMuteControl(ByVal hmixer As Long, mxc As MIXERCONTROL, ByVal unmute As Long) As Boolean
  Dim mxcd As MIXERCONTROLDETAILS
  Dim Vol As MIXERCONTROLDETAILS_UNSIGNED
  mxcd.cbStruct = Len(mxcd)
  mxcd.dwControlID = mxc.dwControlID
  mxcd.cChannels = 1
  mxcd.item = 0
  mxcd.cbDetails = Len(Vol)
  hmem = GlobalAlloc(&H40, Len(Vol))
  mxcd.paDetails = GlobalLock(hmem)
  Vol.dwValue = unmute
  CopyPtrFromStruct mxcd.paDetails, Vol, Len(Vol)
  rc = mixerSetControlDetails(hmixer, mxcd, MIXER_SETCONTROLDETAILSF_VALUE)
  GlobalFree (hmem)
  If (MMSYSERR_NOERROR = rc) Then
      unSetMuteControl = True
  Else
      unSetMuteControl = False
  End If
End Function

Function SetMuteControl(ByVal hmixer As Long, mxc As MIXERCONTROL, mute As Boolean) As Boolean
  Dim mxcd As MIXERCONTROLDETAILS
  Dim Vol As MIXERCONTROLDETAILS_UNSIGNED
  mxcd.cbStruct = Len(mxcd)
  mxcd.dwControlID = mxc.dwControlID
  mxcd.cChannels = 1
  mxcd.item = 0
  mxcd.cbDetails = Len(Vol)
  hmem = GlobalAlloc(&H40, Len(Vol))
  mxcd.paDetails = GlobalLock(hmem)
  Vol.dwValue = volume
  CopyPtrFromStruct mxcd.paDetails, Vol, Len(Vol)
  rc = mixerSetControlDetails(hmixer, mxcd, MIXER_SETCONTROLDETAILSF_VALUE)
  GlobalFree (hmem)
  If (MMSYSERR_NOERROR = rc) Then
      SetMuteControl = True
  Else
      SetMuteControl = False
  End If
End Function

Function GetVolumeControlValue(ByVal hmixer As Long, mxc As MIXERCONTROL) As Long
'This function Gets the value for a volume control. Returns True if successful
    Dim mxcd As MIXERCONTROLDETAILS
    Dim Vol As MIXERCONTROLDETAILS_UNSIGNED
    mxcd.cbStruct = Len(mxcd)
    mxcd.dwControlID = mxc.dwControlID
    mxcd.cChannels = 1
    mxcd.item = 0
    mxcd.cbDetails = Len(Vol)
    mxcd.paDetails = 0
    hmem = GlobalAlloc(&H40, Len(Vol))
    mxcd.paDetails = GlobalLock(hmem)
    rc = mixerGetControlDetails(hmixer, mxcd, MIXER_GETCONTROLDETAILSF_VALUE)
    CopyStructFromPtr Vol, mxcd.paDetails, Len(Vol)
    GlobalFree (hmem)
    If (MMSYSERR_NOERROR = rc) Then
      GetVolumeControlValue = Vol.dwValue
    Else
        GetVolumeControlValue = -1
    End If
End Function

'--------------------------- Mixer Function ---------------------------
'Max Value is 65535
'Min Value is 0

'mixOpen
'mixClose

'Me.Caption = GetMarsterValue
'Me.Caption = GetWaveValue
'Me.Caption = GetMidiValue
'Me.Caption = GetCDValue
'Me.Caption = GetLineValue
'Me.Caption = GetMikrofonValue
'Me.Caption = GetPCSpikValue
'Me.Caption = GetBassValue
'Me.Caption = GetTrebleValue

'SetMarsterValue 33150, 33150
'SetWaveValue 33150, 33150
'SetMidiValue 33150, 33150
'SetCDValue 33150, 33150
'SetLineValue 33150, 33150
'SetMikrofonValue 33150
'SetPCSpikValue 33150
'SetBassValue 33150
'SetTrebleValue 33150

'------------------------------ Eksempel ------------------------------
'Private Sub Command1_Click()
'SetMarsterValue 33150, 33150
'Command1.Caption = GetMarsterValue
'End Sub

'Private Sub Form_Load()
'mixOpen
'Command1.Caption = GetMarsterValue
'End Sub

'Private Sub Form_Unload(Cancel As Integer)
'mixClose
'End Sub
'------------------------------ Eksempel ------------------------------

'--------------------------- Mixer Function ---------------------------

Function mixOpen() 'Form_Load
    rc = mixerClose(hmixer)
    rc = mixerOpen(hmixer, 0, 0, 0, 0)
    If ((MMSYSERR_NOERROR <> rc)) Then
        MsgBox "Kan ikke open lydkortsmixer prøv at instalere dit lydkort og prøv igen."
    End
    End If
End Function

Function mixClose() 'Form_QueryUnload or Form_Unload or Form_Terminate
    rc = mixerClose(hmixer)
End Function

Function GetMarsterValue() 'Me.Caption = GetMarsterValue
'Max Value = 65535
    ok = GetMixerControl(hmixer, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, MIXERCONTROL_CONTROLTYPE_VOLUME, VolCtrl)
    If (ok = True) Then
        GetMarsterValue = GetVolumeControlValue(hmixer, VolCtrl)
    Else
        GetMarsterValue = "Error"
    End If
End Function

Function SetMarsterValue(VolLeft, VolRight) 'SetMarsterValue 33150, 33150
If GetMarsterValue <> "Error" Then
    volL = VolLeft
    volR = VolRight
    SetPANControl hmixer, VolCtrl, volL, volR
End If
End Function

Function GetWaveValue() 'Me.Caption = GetWaveValue
'Max Value = 65535
    ok = GetMixerControl(hmixer, MIXERLINE_COMPONENTTYPE_SRC_WAVEDSVol, MIXERCONTROL_CONTROLTYPE_VOLUME, WavCtrl)
    If (ok = True) Then
        GetWaveValue = GetVolumeControlValue(hmixer, WavCtrl)
    Else
        GetWaveValue = "Error"
    End If
End Function

Function SetWaveValue(VolLeft, VolRight) 'SetWaveValue 33150, 33150
If GetWaveValue <> "Error" Then
    volL = VolLeft
    volR = VolRight
    SetPANControl hmixer, WavCtrl, volL, volR
End If
End Function

Function GetMidiValue() 'Me.Caption = GetMidiValue
'Max Value = 65535
    ok = GetMixerControl(hmixer, MIXERLINE_COMPONENTTYPE_SRC_MIDIVol, MIXERCONTROL_CONTROLTYPE_VOLUME, MIDIVol)
    If (ok = True) Then
        GetMidiValue = GetVolumeControlValue(hmixer, MIDIVol)
    Else
        GetMidiValue = "Error"
    End If
End Function

Function SetMidiValue(VolLeft, VolRight) 'SetMidiValue 33150, 33150
If GetMidiValue <> "Error" Then
    volL = VolLeft
    volR = VolRight
    SetPANControl hmixer, MIDIVol, volL, volR
End If
End Function

Function GetCDValue() 'Me.Caption = GetCDValue
'Max Value = 65535
    ok = GetMixerControl(hmixer, MIXERLINE_COMPONENTTYPE_SRC_CDVol, MIXERCONTROL_CONTROLTYPE_VOLUME, CDVol)
    If (ok = True) Then
        GetCDValue = GetVolumeControlValue(hmixer, CDVol)
    Else
        GetCDValue = "Error"
    End If
End Function

Function SetCDValue(VolLeft, VolRight) 'SetCDValue 33150, 33150
If GetCDValue <> "Error" Then
    volL = VolLeft
    volR = VolRight
    SetPANControl hmixer, CDVol, volL, volR
End If
End Function

Function GetLineValue() 'Me.Caption = GetLineValue
'Max Value = 65535
        ok = GetMixerControl(hmixer, MIXERLINE_COMPONENTTYPE_SRC_LINEVol, MIXERCONTROL_CONTROLTYPE_VOLUME, LineVol)
    If (ok = True) Then
        GetLineValue = GetVolumeControlValue(hmixer, LineVol)
    Else
        GetLineValue = "Error"
    End If
End Function

Function SetLineValue(VolLeft, VolRight) 'SetLineValue 33150, 33150
If GetLineValue <> "Error" Then
    volL = VolLeft
    volR = VolRight
    SetPANControl hmixer, LineVol, volL, volR
End If
End Function

Function GetMikrofonValue() 'Me.Caption = GetMikrofonValue
'Max Value = 65535
        ok = GetMixerControl(hmixer, MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, MIXERCONTROL_CONTROLTYPE_VOLUME, MICROPHONE)
    If (ok = True) Then
        GetMikrofonValue = GetVolumeControlValue(hmixer, MICROPHONE)
    Else
        GetMikrofonValue = "Error"
    End If
End Function

Function SetMikrofonValue(Vol) 'SetMikrofonValue 33150
If GetMikrofonValue <> "Error" Then
    volume = Vol
    SetVolumeControl hmixer, MICROPHONE, volume
End If
End Function

Function GetPCSpikValue() 'Me.Caption = GetPCSpikValue
'Max Value = 65535
        ok = GetMixerControl(hmixer, MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER, MIXERCONTROL_CONTROLTYPE_VOLUME, PCSPEAKER)
    If (ok = True) Then
        GetPCSpikValue = GetVolumeControlValue(hmixer, PCSPEAKER)
    Else
        GetPCSpikValue = "Error"
    End If
End Function

Function SetPCSpikValue(Vol) 'SetPCSpikValue 33150
If GetPCSpikValue <> "Error" Then
    volume = Vol
    SetVolumeControl hmixer, PCSPEAKER, volume
End If
End Function

Function GetBassValue() 'Me.Caption = GetBassValue
'Max Value = 65535
        ok = GetMixerControl(hmixer, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, MIXERCONTROL_CONTROLTYPE_BASS, Bass)
    If (ok = True) Then
        GetBassValue = GetVolumeControlValue(hmixer, Bass)
    Else
        GetBassValue = "Error"
    End If
End Function

Function SetBassValue(Vol) 'SetBassValue 33150
If GetBassValue <> "Error" Then
    volume = Vol
    SetVolumeControl hmixer, Bass, volume
End If
End Function

Function GetTrebleValue() 'Me.Caption = GetTrebleValue
'Max Value = 65535
        ok = GetMixerControl(hmixer, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS, MIXERCONTROL_CONTROLTYPE_TREBLE, Treble)
    If (ok = True) Then
        GetTrebleValue = GetVolumeControlValue(hmixer, Treble)
    Else
        GetTrebleValue = "Error"
    End If
End Function

Function SetTrebleValue(Vol) 'SetTrebleValue 33150
If GetTrebleValue <> "Error" Then
    volume = Vol
    SetVolumeControl hmixer, Treble, volume
End If
End Function
'--------------------------- Mixer Function ---------------------------

'------------------ Module1 ------------------
Avatar billede sjh Nybegynder
22. februar 2002 - 14:23 #15
'-------------------------------------- modMCI.bas (Module) --------------------------------------
Option Explicit

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal _
                lpstrCommand As String, ByVal lpstrReturnString As String, ByVal _
                uReturnLength As Long, ByVal hwndCallback As Long) As Long

Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal _
                lpszLongPath As String, ByVal lpszShortPath As String, ByVal _
                cchBuffer As Long) As Long

Public Enum enuFormat 'FramesToTime
      TimMinSek = 0
      MinSek = 1
End Enum

'Åbn musik filen
Public Function mciOpen(Filename As String, TypeDevice As String, sAlias As String)
Dim dwReturn As Long
Dim tmp As String * 255
Dim lenShort As Long
Dim shortname As String
  lenShort = GetShortPathName(Filename, tmp, 255)
  shortname = Left$(tmp, lenShort)
  dwReturn = mciSendString("open " & shortname & " type " & TypeDevice & " alias " & sAlias, 0&, 0&, 0&)
End Function

'Luk musik filen
Public Function mciClose(sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("close " & sAlias, 0&, 0&, 0&)
End Function

'Luk alle musik filen
Public Function mciCloseAll()
Dim dwReturn As Long
  dwReturn = mciSendString("close all", 0&, 0&, 0&)
End Function

'Afspille musik filen
Public Function mciPlay(sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("play " & sAlias, 0&, 0&, 0&)
End Function

'Pause/Resume musik filen
Public Function mciPause(sAlias As String)
Dim dwReturn As Long
  If mciGetStatusMode(sAlias) = "paused" Then
    dwReturn = mciSendString("Resume " & sAlias, 0&, 0&, 0&)
      ElseIf mciGetStatusMode(sAlias) = "playing" Then
    dwReturn = mciSendString("Pause " & sAlias, 0&, 0&, 0&)
  End If
End Function

'Stop musik filen
Public Function mciStop(sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("stop " & sAlias, 0&, 0&, 0&)
End Function

'Set hastihed på afspillingen
'Speed 1 - 200 (default = 100)
Public Function mciSetSpeed(Speed As Integer, sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("set " & sAlias & " speed " & CStr(Speed * 10), 0&, 0&, 0&)
End Function

'Get hastihed på afspillingen
Public Function mciGetSpeed(sAlias As String) As Long
Dim cmdToDo As String * 128
Dim dwReturn As Long
Dim SpeedVal As String * 128
  dwReturn = mciSendString("status " & sAlias & " speed", SpeedVal, 128, 0&)

  If Not dwReturn = 0 Then
    mciGetSpeed = -1
    Exit Function
  End If

mciGetSpeed = Val(SpeedVal) / 10
End Function

'Set volume vadi
'VolValue 0 - 100
Public Function mciSetVolume(Channel As String, VolValue As Long, sAlias As String)
Dim cmdToDo As String
Dim dwReturn As Long

  If LCase$(Channel) = "left" Or LCase$(Channel) = "right" Then
    cmdToDo = "setaudio " & sAlias & " " & Channel & " Volume to " & CStr(VolValue * 10)
      Else
    cmdToDo = "setaudio " & sAlias & " Volume to " & CStr(VolValue * 10)
  End If
dwReturn = mciSendString(cmdToDo, 0&, 0&, 0&)
End Function

'Hent volume vadi
Public Function mciGetVolume(Channel As String, sAlias As String) As Long
Dim dwReturn As Long
Dim Volume  As String * 128
Dim cmdToDo As String

    If LCase$(Channel) = "left" Or LCase$(Channel) = "right" Then
      cmdToDo = "status " & sAlias & " " & Channel & " Volume"
        Else
      cmdToDo = "status " & sAlias & " Volume"
    End If
  dwReturn = mciSendString(cmdToDo, Volume, 128, 0&)

  If dwReturn = 0 Then
    mciGetVolume = Val(Volume / 10)
  End If
End Function

'Frames Total
Public Function mciTotalframes(sAlias As String) As Long
Dim dwReturn As Long
Dim sFrames As String * 128
  dwReturn = mciSendString("set " & sAlias & " time format frames", 0&, 0&, 0&)
  dwReturn = mciSendString("status " & sAlias & " length", sFrames, 128, 0&)
mciTotalframes = Val(sFrames)
End Function

'Frames Position
Public Function mciPositionframes(sAlias As String) As Long
Dim dwReturn As Long
Dim sFrames As String * 128
  dwReturn = mciSendString("set " & sAlias & " time format frames", 0&, 0&, 0&)
  dwReturn = mciSendString("status " & sAlias & " position", sFrames, 128, 0&)
mciPositionframes = Val(sFrames)
End Function

'Formater Frames til Tim:Min:Sek / Min:Sek
'eksempel:

'Private Sub Timer1_Timer(Index As Integer)
  'lblTTime(Index).Caption = FramesToTime(mciTotalframes("Musik" & CStr(Index)), MinSek, "Musik" & CStr(Index))    'eller TimMinSek
  'lblCTime(Index).Caption = FramesToTime(mciPositionframes("Musik" & CStr(Index)), MinSek, "Musik" & CStr(Index)) 'eller TimMinSek

  'sclPosition(Index).Max = mciTotalframes("Musik" & CStr(Index))
  'sclPosition(Index).Value = mciPositionframes("Musik" & CStr(Index))
'End Sub

Public Function FramesToTime(Frames As Long, eFormat As enuFormat, sAlias As String) As String
Dim lSec As Long
Dim lMin As Long

  lSec = Int(Val(Frames / 1000))
  lMin = Format(Fix(lSec / 60), "00")

  If eFormat = 0 Then
    FramesToTime = Format(Fix(lMin / 60), "00") & ":" & Format(lMin Mod 60, "00") & ":" & Format(lSec Mod 60, "00")
      Else
    FramesToTime = Format(lMin Mod 60, "00") & ":" & Format(lSec Mod 60, "00")
  End If
End Function

'Flytter Position
'eksempel:

'Private Sub sclPosition_Scroll(Index As Integer)
'  Call mciMovePosition(sclPosition(Index).Value, "Musik" & CStr(Index))
'End Sub

Public Function mciMovePosition(Frames As Long, sAlias As String)
Dim dwReturn As Long
  dwReturn = mciSendString("seek " & sAlias & " to " & Frames, 0&, 0&, 0&)
  dwReturn = mciSendString("play " & sAlias, 0&, 0&, 0&)
End Function

'Status Play/Stop/Pause...
'Bliver brugt i mciPause(sAlias As String)
Public Function mciGetStatusMode(sAlias As String) As String
Dim i As Integer
Dim dwReturn As Long
Dim status As String * 128
  dwReturn = mciSendString("status " & sAlias & " mode", status, 128, 0&)
  For i = 1 To Len(status)
    If Mid(status, i, 1) = Right$(status, 1) Then Exit For
    mciGetStatusMode = mciGetStatusMode & Mid(status, i, 1)
  Next i
End Function
'-------------------------------------- modMCI.bas (Module) --------------------------------------
Avatar billede akexpert Nybegynder
01. marts 2002 - 10:46 #16
jeg har ikke prøvet det med tiden endnu! Men jeg har prøvet det med bassen og diskanten. Jeg kan ikke få dem til at virke! Hvad kan være galt? Den giver meddelsen Error!

/akExpert
Avatar billede akexpert Nybegynder
25. marts 2002 - 15:03 #17
sjh>> Har du opgivet??? DU får pointene når jeg har fået svar på mit spørgsmål.. :-)

/akExpert
Avatar billede sjh Nybegynder
05. april 2002 - 22:00 #18
Nej jeg har ikke opgivet, men dit spørgsmål er "Musikafspiller..." og det har ikke noget med "bass/diskant" adgøre, men jeg syntes at du har fået dit svar op til flere gange.
Avatar billede fizz Nybegynder
04. september 2007 - 23:35 #19
giv dog stakkels sjh hans point... han har svaret på spørgsmålet x 9999
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester