libZPlay include + header (windows 32-bit only)

Anwendungen, Tools, Userlibs und anderes nützliches.
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

libZPlay include + header (windows 32-bit only)

Beitrag von ts-soft »

libZPlay ist eine MultiMedia Library für diverse Soundformate, ähnlich FMOD oder Bass.dll, aber mit günstigerer Lizenz!

Infos: http://libzplay.sourceforge.net/
Benötigtes SDK: http://sourceforge.net/projects/libzpla ... z/download

Aufmerksam wurde ich durch andy7 in diesem Beitrag: http://www.purebasic.fr/german/viewtopi ... 98#p299898

libzplay_header.pbi:

Code: Alles auswählen

Enumeration ;TStreamFormat
  #sfUnknown
  #sfMp3
  #sfOgg
  #sfWav
  #sfPCM
  #sfFLAC
  #sfFLACOgg
  #sfAC3
  #sfAacADTS
  #sfWaveIn
  #sfAutodetect = 1000
EndEnumeration

#WaveOutWaveMapper = $FFFFFFFF
#WaveInWaveMapper = $FFFFFFFF

Enumeration ;TFFTGraphSize
  #FFTGraphMinWidht = 100
  #FFTGraphMinHeight = 60
EndEnumeration

Enumeration ;TMBPDetectionMethos
  #dmPeaks
  #dmAutoCorrelation
EndEnumeration

Enumeration ;TFFTGraphHorizontalScale
  #gsLogarithmic
  #gsLinear
EndEnumeration

Enumeration ;TSeekMethod
  #smFromBeginning = 1
  #smFromEnd = 2
  #smFromCurrendForward = 4
  #smFromCurrentBackward = 8
EndEnumeration

Enumeration ;TTimeFormat
  #tfMillisecond = 1
  #tfSecond = 2
  #tfHMS = 4
  #tfSamples = 8
EndEnumeration

Enumeration ;TWaveOutForma
  #format_invalid = 0
  #format_11khz_8bit_mono = 1
  #format_11khz_8bit_stereo = 2
  #format_11khz_16bit_mono = 4
  #format_11khz_16bit_stereo = 8
  #format_22khz_8bit_mono = 16
  #format_22khz_8bit_stereo = 32
  #format_22khz_16bit_mono = 64
  #format_22khz_16bit_stereo = 128
  #format_44khz_8bit_mono = 256
  #format_44khz_8bit_stereo = 512
  #format_44khz_16bit_mono = 1024
  #format_44khz_16bit_stereo = 2048
EndEnumeration

Enumeration ;TWaveOutFunctionality
  #supportPitchControl = 1
  #supportPlaybackRateControl = 2
  #supportVolumeControl = 4
  #supportSeparateLeftRightVolume = 8
  #supportSync = 16
  #supportSampleAccuratePosition = 32
  #supportDirectSound = 6
EndEnumeration

Enumeration ;TID3Version
  #id3Version1 = 1
  #id3Version2 = 2
EndEnumeration

Enumeration ;TFFTGraphType
  #gtLinesLeftOnTop
  #gtLinesRightOnTop
  #gtAreaLeftOnTop
  #gtAreaRightOnTop
  #gtBarsLeftOnTop
  #gtBarsRightOnTop
  #gtSpectrum
EndEnumeration

Enumeration ;TFFTWindow
  #fwRectangular = 1
  #fwHamming
  #fwHann
  #fwCosine
  #fwLanczos
  #fwBartlett
  #fwTriangular
  #fwGauss
  #fwBartlettHann
  #fwBlackman
  #fwNuttall
  #fwBlackmanHarris
  #fwBlackmanNuttall
  #fwFlatTop
EndEnumeration

Enumeration ;TFFTGraphParamID
  #gpFFTPoints = 1
  #gpGraphType
  #gpWindow
  #gpHorizontalScale
  #gpSubgrid
  #gpTransparency
  #gpFrequencyScaleVisible
  #gpDecibelScaleVisible
  #gpFrequencyGridVisible
  #gpDecibelGridVisible
  #gpBgBitmapVisible
  #gpBgBitmapHandle
  #gpColor1
  #gpColor2
  #gpColor3
  #gpColor4
  #gpColor5
  #gpColor6
  #gpColor7
  #gpColor8
  #gpColor9
  #gpColor10
  #gpColor11
  #gpColor12
  #gpColor13
  #gpColor14
  #gpColor15
  #gpColor16
EndEnumeration

Enumeration ;TCallbackMessage
  #MsgStopAsync = 1
  #MsgPlayAsync = 2
  #MsgEnterLoopAsync = 4
  #MsgExitLoopAsync = 8
  #MsgEnterVolumeSlideAsync = 16
  #MsgExitVolumeSlideAsync = 32
  #MsgStreamBufferDoneAsync = 64
  #MsgStreamNeedMoreDataAsync = 128
  #MsgNextSongAsync = 256
  #MsgStop = 65536
  #MsgPlay = 131072
  #MsgEnterLoop = 262144
  #MsgExitLoop = 524288
  #MsgEnterVolumeSlide = 1048576
  #MsgExitVolumeSlide = 2097152
  #MsgStreamBufferDone = 4194304
  #MsgStreamNeedMoreData = 8388608
  #MsgNextSong = 16777216
  #MsgWaveBuffer = 33554432
EndEnumeration

Prototype TCallbackFunc(*instance, *user_data, message, param1, param2)

Enumeration ;TSettingID
  #sidWaveBufferSize = 1
  #sidAccurateLength
  #sidAccurateSeek
  #sidSamplerate
  #sidChannelNumber
  #sidBitPerSample
  #sidBigEndian
  #sidWaveInBufferSize
EndEnumeration

Structure TStreamHMSTime
  hour.l
  minute.l
  second.l
  millisecond.l
EndStructure

Structure TStreamTime
  sec.l
  ms.l
  samples.l
  hms.TStreamHMSTime
EndStructure

Structure TEchoEffect
  nLeftDelay.l
  nLeftSrcVolume.l
  nLeftEchoVolume.l
  nRightDelay.l
  nRightSrcVolume.l
  nRightEchoVolume.l
EndStructure

Structure TWaveOutInfo
  ManufacturerID.l
  ProductID.l
  DriverVersion.l
  Formats.l
  Channels.l
  Support.l
  ProductName.s
EndStructure

Structure TWaveOutInfoW
  ManufacturerID.l
  ProductID.l
  DriverVersion.l
  Formats.l
  Channels.l
  Support.l
  ProductName.s
EndStructure

Structure TWaveInInfo
  ManufacturerID.l
  ProductID.l
  DriverVersion.l
  Formats.l
  Channels.l
  ProductName.s
EndStructure

Structure TWaveInInfoW
  ManufacturerID.l
  ProductID.l
  DriverVersion.l
  Formats.l
  Channels.l
  ProductName.s
EndStructure

Structure TStreamStatus
  fPlay.l
  fPause.l
  fEcho.l
  fEqualizer.l
  fVocalCut.l
  fSideCut.l
  fChannelMix.l
  fSlideVolume.l
  nLoop.l
  fReverse.l
  nSongIndex.l
  nSongsInQueue.l
EndStructure

Structure TID3Info
  Title.s
  Artist.s
  Album.s
  Year.s
  Comment.s
  TrackNum.s
  Genre.s
EndStructure

Structure TID3Picture
  PicturePresent.l
  CanDrawPicture.l
  MIMEType.s
  PictureType.l
  Description.s
  *PictureData
  PictureDataSize.l
  *hBitmap
  Width.l
  Height.l
  reserved.a[128]
EndStructure

Structure TID3PictureW
  PicturePresent.l
  CanDrawPicture.l
  MIMEType.s
  PictureType.l
  Description.s
  *PictureData
  PictureDataSize.l
  *hBitmap
  Width.l
  Height.l
  reserved.u[128]
EndStructure

Structure TID3InfoEx
  Title.s
  Artist.s
  Album.s
  Year.s
  Comment.s
  TrackNum.s
  Genre.s
  AlbumArtist.s
  Composer.s
  OriginalArtist.s
  Copyright.s
  URL.s
  Encoder.s
  Publisher.s
  BPM.l
  Picture.TID3Picture
  reserved.a[128]
EndStructure

Structure TID3InfoExW
  Title.s
  Artist.s
  Album.s
  Year.s
  Comment.s
  TrackNum.s
  Genre.s
  AlbumArtist.s
  Composer.s
  OriginalArtist.s
  Copyright.s
  URL.s
  Encoder.s
  Publisher.s
  BPM.l
  Picture.TID3PictureW
  reserved.u[128]
EndStructure

Structure TID3InfoW
  Title.s
  Artist.s
  Album.s
  Year.s
  Comment.s
  TrackNum.s
  Genre.s
EndStructure

Structure TStreamInfo
  SamplingRate.l
  ChannelNumber.l
  VBR.l
  Bitrate.l
  Length.TStreamTime
  Description.s
EndStructure

Structure TStreamInfoW
  SamplingRate.l
  ChannelNumber.l
  VBR.l
  Bitrate.l
  Length.TStreamTime
  Description.s
EndStructure

Structure TStreamLoadInfo
  NumberOfBuffers.l
  NumberOfBytes.l
EndStructure

libzplay_include.pbi:

Code: Alles auswählen

XIncludeFile "libzplay_header.pbi"

Import "libzplay.lib"
  CreateZPlay()
  zplay_AddFile(hZPlay, sFileName.p-Ascii, nFormat)
  zplay_AddFileW(hZPlay, sFileName.p-Unicode, nFormat)
  zplay_Close(hZPlay)
  zplay_CreateZPlay()
  zplay_DestroyZPlay(hZPlay)
  zplay_DetectBPM(hZPlay, nMethod)
  zplay_DetectFileBPM(hZPlay, pchFileName.p-Ascii, nFormat, nMethod)
  zplay_DetectFileBPMW(hZPlay, pchFileName.p-Unicode, nFormat, nMethod)
  zplay_DrawBitmapToHDC(hZPlay, *hDC, x, y, width, height, *hBitmap)
  zplay_DrawBitmapToHWND(hZPlay, *hwnd, x, y, width, height, *hBitmap)
  zplay_DrawFFTGraphOnHDC(hZPlay, *hDC, nX, nY, nWidth, nHeight)
  zplay_DrawFFTGraphOnHWND(hZPlay, *hwnd, nX, nY, nWidth, nHeight)
  zplay_EnableEcho(hZPlay, fEnable)
  zplay_EnableEqualizer(hZPlay, fEnable)
  zplay_EnumerateWaveOut(hZPlay)
  zplay_GetBitrate(hZPlay, fAverage)
  zplay_GetDynamicStreamLoad(hZPlay, *pStreamLoadInfo.TStreamLoadInfo)
  zplay_GetEchoParam(hZPlay, nNumberOfEffects, *pEchoEffect)
  zplay_GetEqualizerBandGain(hZPlay, nBandIndex)
  zplay_GetEqualizerParam(hZPlay, *pnBandGain, nNumberOfBands, nPreAmpGain)
  zplay_GetEqualizerPoints(hZPlay, *pnFreqPoint, nNumOfPoints)
  zplay_GetEqualizerPreampGain(hZPlay)
  zplay_GetError(hZPlay)
  zplay_GetErrorW(hZPlay)
  zplay_GetFFTData(hZPlay, nFFTPoints, nFFTWindow, *pnHarmonicNumber, *pnHarmonicFreq, *pnLeftAmplitude , *pnRightAmplitude, *pnLeftPhase, *pnRightPhase)
  zplay_GetFFTGraphParam(hZPlay, nParamID)
  zplay_GetFileFormat(hZPlay, pchFileName.p-Ascii)
  zplay_GetFileFormatW(hZPlay, pchFileName.p-Unicode)
  zplay_GetMasterVolume(hZPlay, *pnLeftVolume, *pnRightVolume)
  zplay_GetPitch(hZPlay)
  zplay_GetPlayerVolume(hZPlay, *pnLeftVolume, *pnRightVolume)
  zplay_GetPosition(hZPlay, *pTime.TStreamTime)
  zplay_GetRate(hZPlay)
  zplay_GetSettings(hZPlay, nSettingID)
  zplay_GetStatus(hZPlay, *pStatus.TStreamStatus)
  zplay_GetStreamInfo(hZPlay, *pInfo.TWaveInInfo)
  zplay_GetStreamInfoW(hZPlay, *pInfo.TWaveInInfoW)
  zplay_GetTempo(hZPlay)
  zplay_GetVUData(hZPlay, *pnLeftChannel, *pnRightChannel)
  zplay_GetVersion(hZPlay)
  zplay_GetWaveOutInfo(hZPlay, nIndex, *pWaveOutInfo.TWaveOutInfo)
  zplay_GetWaveOutInfoW(hZPlay, nIndex, *pWaveOutInfo.TWaveOutInfoW)
  zplay_IsStreamDataFree(hZPlay, *sMemNewData)
  zplay_LoadFileID3(hZPlay, pchFileName.p-Ascii, nFormat, nId3Version, *pId3Info.TID3Info)
  zplay_LoadFileID3Ex(hZPlay, pchFileName.p-Ascii, nFormat, nId3Version, *pId3Info.TID3Info, fDecodeEmbededPicture)
  zplay_LoadFileID3ExW(hZPlay,pchFileName.p-Unicode, nFormat, nId3Version, *pId3Info.TID3InfoW, fDecodeEmbededPicture)
  zplay_LoadFileID3W(hZPlay,pchFileName.p-Unicode, nFormat, nId3Version, *pId3Info.TID3InfoW)
  zplay_LoadID3(hZPlay, nId3Version, *pId3Info.TID3Info)
  zplay_LoadID3Ex(hZPlay, *pId3Info.TID3InfoEx, fDecodeEmbededPicture)
  zplay_LoadID3ExW(hZPlay,*pId3Info.TID3InfoExW, fDecodeEmbededPicture)
  zplay_LoadID3W(hZPlay, nId3Version, *pId3Info.TID3InfoW)
  zplay_MixChannels(hZPlay, fEnable, nLeftPercent, nRightPercent)
  zplay_OpenFile(hZPlay, sFileName.p-Ascii, nFormat)
  zplay_OpenFileW(hZPlay, sFileName.p-Unicode, nFormat)
  zplay_OpenStream(hZPlay, fBuffered, *sMemStream, nStreamSize, nFormat, fDynamic)
  zplay_Pause(hZPlay)
  zplay_Play(hZPlay)
  zplay_PlayLoop(hZPlay, fFormatStartTime, *pStartTime.TStreamTime, fFormatEndTime, *pEndTime.TStreamTime, nNumOfCycles, fContinuePlaying)
  zplay_PushDataToStream(hZPlay, *sMemNewData, nNewDataize)
  zplay_Resume(hZPlay)
  zplay_ReverseMode(hZPlay, fEnable)
  zplay_Seek(hZPlay, fFormat, *pTime, nMoveMethod)
  zplay_SetCallbackFunc(hZPlay, *pCallbackFunc.TCallbackFunc, nMessages, *user_data)
  zplay_SetEchoParam(hZPlay, *pEchoEffect.TEchoEffect, nNumberOfEffects)
  zplay_SetEqualizerBandGain(hZPlay, nBandIndex, nGain)
  zplay_SetEqualizerParam(hZPlay, nPreAmpGain, *pnBandGain, nNumberOfBands)
  zplay_SetEqualizerPoints(hZPlay, *pnFreqPoint, nNumOfPoints)
  zplay_SetEqualizerPreampGain(hZPlay, nGain)
  zplay_SetFFTGraphParam(hZPlay, nParamID, nValue)
  zplay_SetMasterVolume(hZPlay, nLeftVolume, nRightVolume)
  zplay_SetPitch(hZPlay, nPitch)
  zplay_SetPlayerVolume(hZPlay, nLeftVolume, nRightVolume)
  zplay_SetRate(hZPlay, nRate)
  zplay_SetSettings(hZPlay, nSettingID, nValue)
  zplay_SetTempo(hZPlay, nTempo)
  zplay_SetWaveOutDevice(hZPlay, nIndex)
  zplay_SlideVolume(hZPlay, fFormatStart, *pTimeStart.TStreamTime, nStartVolumeLeft, nStartVolumeRight, fFormatEnd, *pTimeEnd.TStreamTime, nEndVolumeLeft, nEndVolumeRight)
  zplay_StereoCut(hZPlay, fEnable, fOutputCenter, fBassToSides)
  zplay_Stop(hZPlay)
EndImport
Und ein einfaches Beispiel:

Code: Alles auswählen

EnableExplicit

XIncludeFile "libzplay_include.pbi"

Define hZPlay, File.s, Text.s
Define ID3.TID3Info

File = OpenFileRequester("Bitte eine MP3-Datei wählen", "*.mp3", "MP3-Dateien|*.mp3", 0)
If File
  hZPlay = CreateZPlay()
  If hZPlay
    If zplay_OpenFile(hZPlay, File, #sfMp3)
      CompilerIf #PB_Compiler_Unicode
      If zplay_LoadFileID3W(hZPlay, File,#sfMp3, #id3Version2, @ID3)
      CompilerElse
      If zplay_LoadFileID3(hZPlay, File,#sfMp3, #id3Version2, @ID3)
      CompilerEndIf
        zplay_Play(hZPlay)
        Text = "Musiktitel: " +  id3\Title + #LF$
        Text + "vom Album: " + id3\Album + #LF$
        Text + "aus dem Jahre: " + id3\Year + #LF$ + #LF$
        Text + "Drücken sie Okay zum beenden"
        MessageRequester("Test libzplay", Text)
      EndIf
    EndIf
    zplay_Close(hZPlay)
    zplay_DestroyZPlay(hZPlay)
  EndIf
EndIf
Gruß
Thomas
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Angelo
Beiträge: 102
Registriert: 20.02.2010 14:47
Wohnort: Berlin

Re: libZPlay include + header (windows 32-bit only)

Beitrag von Angelo »

Hervorragend! - Vielen Dank!
PB 5.50; Win 7
Angelo
Beiträge: 102
Registriert: 20.02.2010 14:47
Wohnort: Berlin

Re: libZPlay include + header (windows 32-bit only)

Beitrag von Angelo »

@ts-soft:
Es macht richtig Spaß, diese Lib und Deine include-Datei auszuprobieren. Aber eine Sache verwundert mich. In Deiner include-Datei kommt die Structure TStreamInfo vor, die das Feld length enthält. Aber es gibt keine entsprechende zplay-Funktion, die eine Strukturvariable vom Typ TStreamInfo enthält. Kann das beudeten, dass man mithilfe dieser Lib die Länge einer mp3-Datei nicht herausbekommt, oder habe ich da vielleicht etwas übersehen?
PB 5.50; Win 7
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Re: libZPlay include + header (windows 32-bit only)

Beitrag von ts-soft »

Da kann ich Dir nicht helfen, es sind alle Strukturen, die dokumentiert sind, von mir umgesetzt, ohne zu
kontrollieren, ob diese jemals genutzt werden <)

Hier erhältst Du eine aktualisierte Version von Erion, aus dem englischem Forum,
vielleicht hilft das ja weiter (habs mir bisher nicht angesehen, zeitmangel).

Gruß
Thomas
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Angelo
Beiträge: 102
Registriert: 20.02.2010 14:47
Wohnort: Berlin

Re: libZPlay include + header (windows 32-bit only)

Beitrag von Angelo »

Danke für den Link!
PB 5.50; Win 7
Angelo
Beiträge: 102
Registriert: 20.02.2010 14:47
Wohnort: Berlin

Re: libZPlay include + header (windows 32-bit only)

Beitrag von Angelo »

Das Problem bei der Bestimmung der Länge einer Audiodatei konnte ich beheben. In der include-Datei ist ein kleiner Schreibfehler enthalten. Dort steht:

Code: Alles auswählen

zplay_GetStreamInfo(hZPlay, *pInfo.TWaveInInfo)
zplay_GetStreamInfoW(hZPlay, *pInfo.TWaveInInfoW)
Es muss heißen:

Code: Alles auswählen

zplay_GetStreamInfo(hZPlay, *pInfo.TStreamInfo)
zplay_GetStreamInfoW(hZPlay, *pInfo.TStreamInfoW)
PB 5.50; Win 7
schleicher
Beiträge: 214
Registriert: 30.03.2014 19:57
Computerausstattung: Purebasic 5.70
Wohnort: 18314 Löbnitz

Re: libZPlay include + header (windows 32-bit only)

Beitrag von schleicher »

Wie bestimme ich die Länge einer Mp3-Datei in hh:mm:ss mit diesem Tool.
Purebasic 5.51
Antworten