gpt4 book ai didi

C++ BASS 库 - 简单的 mp3 样本播放

转载 作者:塔克拉玛干 更新时间:2023-11-03 08:03:14 26 4
gpt4 key购买 nike

我已经查看了 BASS 引用以寻找解决方案,但我没有找到。我的音频只是不想播放,是的,我检查了我的扬声器是否正常工作。这是“代码”:

#include "stdafx.h"
#include "D:\\Libraries\BASS\c\bass.h"
#include <iostream>
#include <cstdlib>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
BASS_Init(-1, 44100, 0, 0, NULL);
BASS_SetVolume(1);
HSAMPLE sample = BASS_SampleLoad(false, "1.mp3", 0, 0, 1, BASS_SAMPLE_MONO);
HCHANNEL channel=BASS_SampleGetChannel(sample, FALSE);
BASS_ChannelPlay(channel, FALSE);
system("pause");
return 0;
}

我尝试了完全不同的初始化设置等。似乎没有任何效果。 '1.mp3' 文件位于我的“应用程序”的调试文件夹中。提前致谢!

最佳答案

播放的样本必须是void*类型。像我一样尝试:

//path to file 
string *filePath = new string("/home/user/Qt-Projects/bass/sample.mp3");

减少类型void*的函数:

const void* getFile(string* file){
return file->data();
}

然后完成:

streamHandle = BASS_StreamCreateFile(false, getFile(filePath), 0, 0, 0);

关于C++ BASS 库 - 简单的 mp3 样本播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26069135/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com