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


相关推荐

  • mysql8.0jar包及驱动

    mysql8.0jar包及驱动<?xmlversion=”1.0″encoding=”UTF-8″?><projectxmlns=”http://maven.apache.org/POM/4.0.0″xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”xsi:schemaLocation=”http://m…

    2022年5月15日
    61
  • java文档注释符号_java的注释符号

    java文档注释符号_java的注释符号1JAVA语法基础1.1标识符标识符可以简单的理解成一个名字。在Java中,我们需要标识代码的很多元素,包括类名、方法、字段、变量、包名等等。我们选择的那个名称就称为标识符,一个正确的标识符需要遵循以下规则:1.标识符可以由字母、数字、下划线(_)、美元符($)组成,但不能包含@、%、空格等其它特殊字符2.不能以数字开头。如:123name就是不合法3.标识符严格区分大小写。如:tmooc和tMooc是两个不同的标识符4.标识符的命名最好能反映出其作用,做到见名知意。

    2022年10月7日
    2
  • web navigator_前端如何传参数为一个对象

    web navigator_前端如何传参数为一个对象Navigator对象一、Navigator对象简介二、Navigator对象集合三、Navigator对象属性1.appCodeName、appName、appVersion(1)属性介绍(2)具体演示2.cookieEnabled、onLine(1)属性介绍(2)具体演示3.platform、userAgent(1)属性介绍(2)具体演示四、Navigator对象方法1.javaEnabled()五、Navigator对象描述一、Navigator对象简介Navigator对象包含有关浏览

    2025年8月29日
    4
  • Fiddler实现手机抓包——小白入门

    Fiddler实现手机抓包——小白入门手机用fiddler抓包电脑最好是笔记本,这样能和手机保持统一局域网内;其他不多说,直接说步骤了。一.对PC(笔记本)参数进行配置  1.配置fiddler允许监听到https(fiddler默认只抓取http格式的)        打开Fiddler菜单项Tools-&gt;TelerikFiddlerOptions-&gt;HTTPS,        勾选Capt…

    2022年4月20日
    133
  • Java 数组声明

    Java 数组声明首先必须声明数组变量,才能在程序中用数组。下面是数组变量的语法:dataType[]arrayRefVar;//首选的方法dataTypearrayRefVar[];//效果相同但不是首选方法Java语言试用new操作符来创建数组dataType[]arrayRefVar=newdataType[arraySize];//定义int[]nums;//创建nums=newint[10];//变量类型变量名字=变量值int[]nums=new

    2022年6月2日
    38
  • git下载与安装教程[通俗易懂]

    git下载与安装教程[通俗易懂]1.下载地址官网:https://git-scm.com/download/win2.安装选中文件编辑器选notepad++编辑器记得要先安装好3.测试安装是否成功鼠标右键桌面,显示如图说明安装成功打开gitbaseHere输入git–version可以查看版本4.配置全局用户和邮箱信息1)打开gitbaseHere,输入如下命令,回车即可gitconfig–globaluser.nam…

    2022年6月3日
    31

发表回复

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

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