0

BASS_StreamCreateFile(path,offset,length,BassFlags) always returns '0'. I am not understanding how to use this function. Need help on the usage of BassFlags.

PS : Using this with the help of WPF Sound Visualization Library.

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
abhi154
  • 43
  • 1
  • 3
  • 10

1 Answers1

0

Since 0 only informs you that there's an error, you should check what kind of error it is:

int BASS_ErrorGetCode();

This gives you the errorcode for the recent error.

Here's the list of possible error codes (= return values):

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! 

(from bass.h)

Also make shure you have initialised BASS properly - BASS_Init() must get called before you create a stream:

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
);

Example:

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

BASS_Init(device, freq, 0, 0, NULL); // Init BASS
ollo
  • 24,797
  • 14
  • 106
  • 155
  • Bass is initialised properly. I just want to know how the BASS_StreamCreateFile() works. I have a working code in C# but the VB code doesn't work. The functions returns 0 always. – abhi154 Mar 05 '13 at 04:45
  • Thats why you should check the *real* error code. `0` tells you only that there's an error. Can you post the your code where you call `BASS_StreamCreateFile()`? – ollo Mar 05 '13 at 17:35