libzplay库

libzplay目前,非开源,只可以在windows上应用;关于MP3文件播放:通常步骤是:获取MP3相关参数->解码->相关平台播放音频接口播放声音;可以播放解码播放MP3的库很多,如果VLC,ffplay,或者directshow,解码库一般可以用lame,播放播放库可以用SDL,或者Windows上的waveout,directsound等很多方法,这里例举

大家好,又见面了,我是你们的朋友全栈君。

libzplay目前,非开源,只可以在windows上应用;

关于MP3文件播放:通常步骤是:获取MP3相关参数 -> 解码-> 相关平台播放音频接口播放声音;

可以播放解码播放MP3的库很多,如果VLC,ffplay,或者directshow,解码库一般可以用lame,播放播放库可以用SDL,或者Windows上的waveout,directsound等很多方法,这里例举了,因为在任何平台上,无论怎么封装库,最后调用的还是平台播放接口;

这里在Windows上推荐的MP3播放器是libzplay;

这里说明一下libzplay库:

很方便的详细简单的讲解libzplay的应用;

libzplay工程非开源,下到的库中说应用说明文档较少,函数注释较少,有些功能靠猜,不过可以通过测试确定,但是功能还是比较强大的,工程中的示例代码较多;

一:

libzplay除了可以播放MP3,还可以播放WAV,PCM等音频文件,从其枚举值中可以看到播放的支持类型:

This is multimedia library for playing mp3, mp2, mp1, ogg, flac, oga, ac3,
aac, wav and pcm files and streams.

关于streams的播放,可以参考dynamic_stream示例,示例中的是获取MP3格式,但是也可以通过接口自定义设置格式;

enum TStreamFormat
{

sfUnknown = 0,
sfMp3 = 1,
sfOgg = 2,
sfWav = 3,
sfPCM = 4,
sfFLAC = 5,
sfFLACOgg = 6,
sfAC3 = 7,
sfAacADTS = 8,
sfWaveIn = 9,
sfAutodetect = 1000
};

二:

这里简单将其说明放到这里:

===========================================================================================
1. ABOUT
===========================================================================================
libZPlay ver. 2.02 (Win32)

Version: 2.02
Date: May, 2010. 

This is multimedia library for playing mp3, mp2, mp1, ogg, flac, oga, ac3,
aac, wav and pcm files and streams. 

This library integrate all decoders/encoders for supported formats.
You don’t need additional libraries. Library is using native
WINAPI functions from kernel32.dll, user32.dll, gdi32.dll and winmm.dll.
All these libraries are standard libraries on all Microsoft Windows.
There is no need for MFC or .NET support.
Just pure WINAPI. 

Library will play music directly to soundcard.
Simple and easy. No need for additional programming.
You can play music using only 3 lines of code (create class, open file and start playing).
Simple, simple, simple … 

With version 2.00 you can record music from your soundcard.
Read more in libzplay.chm documentation file.

libZPlay library is combination of multiple decoding/encoding libraries.
Read topic 8. COPYRIGHT for more informations.

 
===========================================================================================
2. Supported formats
=========================================================================================== 
 
– MP3  -> mp3, mp2, mp1  MPEG-1, MPEG-2, MPEG 2.5 – Layer I, Layer II, Layer III.
          Read topic 9: MP3 and AAC LICENSE  

– OGG  -> ogg – VORBIS OGG 
 
– AC3  -> A/52 aka. ac3

– AAC  -> HE, LC, MAIN and LTP profile, MPEG2 and MPEG-4 AAC decoder.
          Read topic 9: MP3 and AAC LICENSE

– FLAC -> flac, oga – Native FLAC and OGG flac 
 
– WAVE -> wav – PCM WAVE with RIFF header, uncompressed, 8, 16 bit per sample 
 
– PCM  -> any file – Raw PCM audio format, uncomressed, 8 16 bit per sample  

 
===========================================================================================
3. Supported languages
===========================================================================================

Library is customized for:

– Standard C/C++ (native) 
– Visual C++ .NET (VC.NET wrapper class) 
– Visual Basic .NET (VB.NET wrapper class) 
– C# (C#.NET wrapper class) 
– Delphi (Delphi wrapper class) 
– and any other language which can use exported __stdcall functions from dll library 
 
 
===========================================================================================
4. Features
===========================================================================================

– supports mp3, ogg, flac, ac3, aac, wav, pcm 
– supports wave-in input (get samples from line-in, microphone, ….)
– supports encoding samples into mp3, ogg, flac, wave and aac streams and files
– UNICODE support for functions using strings ( filename, error messages, ID3 info, … ) 
– read info tags from file ( ID3v1, ID3v2, VORBIS comment, wave RIFF list,
  FLAC VORBIS comment, embeded picture ) 
– easy drawing embeded picture to screen
– REVERSE PLAYING (you can play song backward in real time, “real” backward playing
  without predecoding in PCM) 
– built in equaliter, user can specify own subbands, add subbands, … 
– built in echo and reverb sound processor 
– pitch/rate/tempo change 
– stereo cut effect 
– detect beat-per-minute using 2 methods ( peak detection and autocorrelation) 
– loop playing (you can play just one portion of file, repeat this portion … ) 
– channel mixer (you can mix left and right chanel, convert stereo to mono … ) 
– volume slide control (fade-in and fade-out) 
– internal volume control (without affecting wave out device volume) 
– pulling VU meter data (you can simply create VU meter) 
– pulling FFT data (you can simply build FFT spectrum analyzer) 
– built in FFT spectrum graph, library will draw complete spectrum graph on your window 
– callback mechanism (class will inform you about events like play, stop, fade, …) 
– access to decoded PCM data throug callback message 
– play data from disk files, UNICODE SUPPORT 
– play data from allocated memory 
– play dynamic streams (push small memory chunks into stream while song is playing,
  for download streams) 
– selecting wave output (for multiple waveout devices) 
– easy play, pause, seek … 
– class interface for VC.NET, VB.NET, C# and Delphi. 
 

===========================================================================================
5. ARCHIVE CONTENTS
===========================================================================================

.\
  \C#              – C# support files
  \C++             – C/C++ support files
  \Delphi          – Delphi support files
  \VB.NET          – VB.NET support files
  \VC.NET          – VC.NET support files
  \license         – license informations for libraries included in libZPlay library

  libzplay.dll    – libZPlay (WIN32) library – full version
  libzplay.chm    – complete documentation for libZPlay library

===========================================================================================
6. HOW TO USE LIBZPLAY
===========================================================================================
For more informations read instructions from install.txt in C#, C++, Delphi, VB.NET or
VC.NET folder.

播放示例:

示例1:

player = CreateZPlay();

// open file
if(player->OpenFile( “F:\\t.mp3”, sfAutodetect) == 0)
{

printf(“Error: %s\nPress key to exit.\r\n”, player->GetError());
player->Release();
return  ;
}

player->Play();

示例2:

从sfWaveIn播放枚举值可以看出,应该是支持音频输入设备采集播放的;

这个示例讲解了打开音频设备,播放,但是关于第一个参数的音频名称,可以通过directshow,或者directsound等方法枚举音频设置;

所以这个示例,可以替代portaudio,或者directsound,或者wavein等一些方法,如果不想播放声音,可以设置音量为0;

player = CreateZPlay();

       //设置参数:
       player->SetSettings(sidAccurateLength,1);

// open file
if(player->OpenFile( “virtual-audio-capturer”, sfWaveIn) == 0)
{

printf(“Error: %s\nPress key to exit.\r\n”, player->GetError());
player->Release();
return  ;
}

player->Play();

示例3:

获取MP3解码值,或音频设备采集值;

这个是关心的,但是,在示例代码中没有看到示例程序,也没有看到说明文档;

不过可以根据:MsgWaveBuffer猜测,应该是支持数据获取的;所以这里的示例首先参考回调函数设置的示例,然后设置数据获取;

enum  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
};

ZPlay* player;

int  __stdcall  CallbackFunc(void* instance, void *user_data, TCallbackMessage message, unsigned int param1, unsigned int param2)
{

ZPlay *myinstance = (ZPlay*) instance;

switch(message)
{

case MsgNextSong:
{

printf(“Index: %u  Left: %u\n”, param1, param2); 
}
break;

case  MsgWaveBuffer:
{

                       //在这个参数中,第一个参数是指针,第二个参数是长度;
static FILE * f = fopen(“F:\\tm.pcm”,”w+b”);
fwrite( (unsigned char * )param1, 1, param2, f );
}

}

return 0;
}

void CtestMPThreeToPcmDlg::OnBnClickedButton1()
{

// TODO: 在此添加控件通知处理程序代码

// create class instance
player = CreateZPlay();

player->SetSettings(sidAccurateLength,1);

player->SetCallbackFunc(CallbackFunc, /*MsgNextSong*/MsgWaveBuffer, 0);

// open file
//if(player->OpenFile( “F:\\t.mp3”, sfAutodetect) == 0)
if(player->OpenFile( “virtual-audio-capturer”, sfWaveIn) == 0)
{

printf(“Error: %s\nPress key to exit.\r\n”, player->GetError());
player->Release();
return  ;
}

player->Play();

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/127304.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Vue生命周期(11个钩子函数)「建议收藏」

    Vue生命周期生命周期初识生命周期详解(八个钩子函数)生命周期生命周期:Vue是一个构造函数,当执行执行这个函数时,相当于初始化vue实例;在创建实例过程中,需要设置数据监听,编译模板,将实例挂载到DOM上,数据更新能够让DOM也更新,在这个初始化,又会不同阶段默认调用一些函数执行,这些函数就是生命周期的钩子函数;生命周期钩子函数生命周期钩子函数,让够让咱们…

    2022年4月6日
    145
  • Python中常用的第三方库_vscode如何使用第三方库

    Python中常用的第三方库_vscode如何使用第三方库第10章Python第三方库使用1.Python第三方库的获取和安装1.1pip工具安装1.2自定义安装1.3文件安装1.4pip工具使用2.pyinstaller库概述3.pyinstaller库与程序打包4.jieba库概述5.jieba库与中文分词6.wordcloud库概述7.wordcloud库与可视化词云1.Python第三方库的获取和安装Python第三方库依照安装方式灵活性和难易程度有3个方法,这3个方法是:pip工具安装、

    2022年10月14日
    3
  • UML类图总结(浅显易懂实用)

    UML类图总结(浅显易懂实用)UML类图的作用是描述程序中类的信息及各个类之间的关系。所有的面向对象(ObjectOriented)语言都离不开类的概念,理解了程序中类的设计也就理解了程序的一半。但类的具体描述方式在各个类中都不一样,UML类图的提出是为了能够脱离语言的限制,抽象地描述各个类的信息及各个类之间的关系。这是UML类图的作用。一、类的基本表示方式在UML类图中,每一个矩形代表一个类。我们举一个简单的例子:这是一个…

    2022年7月12日
    15
  • 画完三角形再画谢尔宾斯基地毯

    画完三角形再画谢尔宾斯基地毯照样废话不说,看代码看注释importjava.awt.Color;importjava.awt.Dimension;importjava.awt.Graphics;importjava.awt.Toolkit;importjava.awt.event.MouseAdapter;importjava.awt.event.MouseEvent;import…

    2022年7月13日
    16
  • 手机APP如何抓包[通俗易懂]

    手机APP如何抓包[通俗易懂]使用场景程序及其使用第一步:Fiddler抓取手机App的HTTP协议请求数据首先保证手机和Fiddler主机为同一网络Fiddler开启远程设备连接(确认Fiddler代理主机IP和端口号)手机端设置网络代理为Fiddler主机(设为Fiddler代理主机IP地址和端口号)验证:访问传智官网(http://www.itcast.cn)第一步:Fiddler抓取手机App的…

    2022年5月30日
    36
  • 手眼标定之基本原理

    手眼标定之基本原理文章目录一前言二Eye-in-Hand2.1基础知识准备2.2Eye-in-Hand基本原理三跋原文首发于微信公众号【视觉IMAX】。一前言机器人的视觉系统分为固定场景视觉系统和运动的「手-眼」视觉系统。摄像机与机器人的手部末端,构成手眼视觉系统。根据摄像机与机器人相互位置的不同,手眼视觉系统分为Eye-in-Hand系统和Eye-to-Hand系统。Eye-in-Hand…

    2022年6月12日
    43

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号