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


相关推荐

  • TCP和UDP的最完整的区别[通俗易懂]

    TCP和UDP的最完整的区别[通俗易懂]TCP和UDP两种协议的比较汇总

    2022年6月7日
    37
  • csdn-如何让你的标题比其他人的都要大

    csdn-如何让你的标题比其他人的都要大

    2022年2月21日
    47
  • 车载以太网PHY_车载以太网两根线

    车载以太网PHY_车载以太网两根线车载以太网PHY

    2025年5月23日
    0
  • unity协程简介[通俗易懂]

    unity协程简介[通俗易懂]在Unity中,一般的方法都是顺序执行的,一般的方法也都是在一帧中执行完毕的,当我们所写的方法需要耗费一定时间时,便会出现帧率下降,画面卡顿的现象。当我们调用一个方法想要让一个物体缓慢消失时,除了在Update中执行相关操作外,Unity还提供了更加便利的方法,这便是协程。在通常情况下,如果我们想要让一个物体逐渐消失,我们希望方法可以一次调用便可在程序后续执行中实现我们想要的效果。我们希望代码…

    2022年6月20日
    36
  • 软件工程中的需求分析(软件工程需求分析任务)

    第一部分需求规格说明书1.引言1.1编写目的1.2项目背景1.3定义1.4参考资料1.1编写目的目前我校的校园二手交易市场多是利用超级课程表上的“跳蚤市场”以及本校的贴吧进行,两者都形成了一定的规模。但是贴吧上的交易不够规范,而超级课程表改版之后对“跳蚤市场”这一模块也不够重视,对其入口进行了更改,进入不方便了,导致流量减少,目前在上面发布交易信息的人寥寥无几。…

    2022年4月9日
    97
  • OpenStack八大核心组件精讲之—neutron理论知识

    OpenStack八大核心组件精讲之—neutron理论知识OpenStack八大核心组件精讲之—neutron理论知识一、OpenStack网络二、Linux网络虚拟化(一)、Linux虚拟网桥(二)、虚拟局域网(三)、开发虚拟交换机三、openstack网络基础服务1、neutron网络结构2、网络子网与端口3、网络拓扑类型①、Local②、Flat③、VLAN④、VXLAN⑤、GRE⑥、GENEVE⑦、总结4、网络基本架构5、neutron-server6、Neutron遵循OpenStack的设计原则,采用开放性架构,通过插件.代理与网络提供者的配合来实

    2025年6月11日
    1

发表回复

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

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