0

BASS_StreamCreateFile(path,offset,length,BassFlags)总是返回' 0'。我不明白如何使用这个功能。在使用 BassFlags 方面需要帮助。

PS:在 WPF 声音可视化库的帮助下使用它。

4

1 回答 1

0

由于0只通知您有错误,您应该检查它是什么类型的错误:

int BASS_ErrorGetCode();

这为您提供了最近错误的错误代码。

以下是可能的错误代码列表(= 返回值):

BASS_ERROR_INIT // BASS_Init has not been successfully called.
BASS_ERROR_NOTAVAIL // Only decoding channels (BASS_STREAM_DECODE) are allowed when using the "no sound" device. The BASS_STREAM_AUTOFREE // flag is also unavailable to decoding channels.
BASS_ERROR_ILLPARAM // The length must be specified when streaming from memory.
BASS_ERROR_FILEOPEN // The file could not be opened.
BASS_ERROR_FILEFORM // The file's format is not recognised/supported.
BASS_ERROR_CODEC    // The file uses a codec that is not available/supported. This can apply to WAV and AIFF files, and also MP3 files when using the "MP3-free" BASS version.
BASS_ERROR_FORMAT   // The sample format is not supported by the device/drivers. If the stream is more than stereo or the BASS_SAMPLE_FLOAT flag is used, it could be that they are not supported.
BASS_ERROR_SPEAKER  // The specified SPEAKER flags are invalid. The device/drivers do not support them, they are attempting to assign a stereo stream to a mono speaker or 3D functionality is enabled.
BASS_ERROR_MEM  // There is insufficient memory.
BASS_ERROR_NO3D // Could not initialize 3D support.
BASS_ERROR_UNKNOWN  // Some other mystery problem! 

(来自bass.h

还请确保您已正确初始化BASS -BASS_Init()必须在创建流之前调用:

BOOL BASS_Init(
    int device, // The device to use... -1 = default device, 0 = no sound, 1 = first real output device
    DWORD freq, // Output sample rate
    DWORD flags, // A combination of flags
    HWND win, // The application's main window... 0 = the current foreground window (use this for console applications)
    GUID *clsid // Class identifier of the object to create, that will be used to initialize DirectSound... NULL = use default
);

例子:

int device = -1; // Default device
int freq = 44100; // Sample rate

BASS_Init(device, freq, 0, 0, NULL); // Init BASS
于 2013-02-08T12:50:55.860 回答