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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • java 转为Calendar_java Calendar和Date()的转化

    java 转为Calendar_java Calendar和Date()的转化在使用过程中发现,publicstaticvoidmain(Stringargs[]){Datedate=newDate();System.out.println(date.getYear();}输出结果为:114而且getYear()方法已经不再建议使用。于是想到Calendar。正确方式为:publicstaticvoidmain(Stringargs[]){Da…

    2022年6月7日
    54
  • pycharm的使用方法_小白远程下载教程

    pycharm的使用方法_小白远程下载教程本文记录使用pycharm过程中遇到的一些问题以及对应的解决方案:怎么下载并且使用Pycharm直接通过jetbrain官网进行下载:官网地址由于pycharm专业版是付费软件,所以需要通过一些手段才能使用,下面给出一个博主的激活成功教程文章(很详细,成功率高)当然我们还是要支持正版!财力支持的同学可以购买正版!!怎么通过pycharm软件下载一些使用插件?在Setting(设置)中找到Pl…

    2022年8月25日
    8
  • 小组成员

    小组成员

    2021年11月18日
    48
  • 直播技术——视频编解码(理论基础)

    直播技术——视频编解码(理论基础)摘自:https://www.cnblogs.com/xkfz007/archive/2012/08/12/2613690.html第1章介绍1.为什么要进行视频压缩?未经压缩的数字视频的数据量巨大存储困难一张DVD只能存储几秒钟的未压缩数字视频。传输困难1兆的带宽传输一秒的数字电视视频需要大约4分钟。2. 为什么可以压

    2022年7月21日
    15
  • jquery动画效果实例_动画js

    jquery动画效果实例_动画js文章目录JS动画实现概述平滑动画无缝连续滚动特效轮播图轮播图淡入淡出效果JS动画实现概述在CSS3中可以通过transition过渡属性可以实现动画JS可以利用CSS3中的transition属性实现元素动画平滑动画利用CSStransition属性实现平滑动画效果<button>开始动画</button><divid=”box”></div><script>varbtn=document.queryS

    2022年10月16日
    1
  • android jsonarray数组转jsonobject异常_Android开发将List转化为JsonArray和JsonObject[通俗易懂]

    android jsonarray数组转jsonobject异常_Android开发将List转化为JsonArray和JsonObject[通俗易懂]释放双眼,带上耳机,听听看~!客户端需要将List转化为JsonArray和JsonObject的方法:首先,List中的Object的属性需要是public:classPerson{publicStringname;publicStringsex;publicintage;}下面假设有ListpersonList=newArrayList();中已经装载好了数据:JSON…

    2022年5月2日
    69

发表回复

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

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