3

我已经检查了 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' 文件位于我的“应用程序”的调试文件夹中。提前致谢!

4

1 回答 1

-1

演奏样品必须是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);
于 2018-07-31T10:56:31.790 回答