Author Topic: Object-Oriented approach for BASS ?  (Read 610 times)

aybe

  • Posts: 145
Object-Oriented approach for BASS ?
« on: 28 Sep '11 - 19:20 »
Somewhat I successfully achieved it, to some extent ...
(Typical DJ-ing app. but even cooler since you just right-click your deck
and you change the input/output, no need to interrupt session nor going to settings)

Using a few classes I can play a stream on whatever device channel, on the fly,
The engine takes care of all the rest, like multiple streams on same ASIO channel,
all the boring stuff is done for you, very few lines for usage etc ...

Also, I started OpenGL 3+ programming recently and encountered the same need quite quickly,
since just showing something on the screen using VBO, VAO, and a basic Shader is already considerable amount of code.

Back to my classes, here they are : Device, Channel, Mixer, Stream (Channel class here represents an ASIO channel)

But,

It's been like 1 year or so, now I decided to look at it again.
Regarding BASS.NET help,
- a channel plays a stream.
- on BASS_ChannelPlay, The channel handle... a HCHANNEL / HMUSIC / HSTREAM / HRECORD handle.

I tried to conform to how it is represented in the documentation,
but in the end it became problematic since I have Channel + Stream to manage.

I forgot a very important detail :
- Stream position does not necessarily reflect channel position,
- You can still retrieve stream handle from channel infos, virtually a stream is only created, nothing else

So inside BASS, is a channel a stream or vice-versa or not at all ? Thinking of merging both ...


Thank you.
« Last Edit: 28 Sep '11 - 19:32 by aybe »

radio42

  • Posts: 4576
Re: Object-Oriented approach for BASS ?
« Reply #1 on: 28 Sep '11 - 21:48 »
Yes, sometimes the name 'channel' and 'stream' are mixed/used in the same way.
To bring some light into it:

1) The term 'stream' is used when you create a 'playable' audio item, e.g. from a file location, URL, user defined callback, sample or recording.
Thus you are using functions like e.g. 'BASS_StreamCreateFile' etc.
These function return a 'handle' for such create stream.
Such 'handle' is also called a 'stream' handle or 'channel' handle - and this might be the confusing part.
There are different types of streams you might create:

HCHANNEL : Returned by BASS_SampleGetChannel. 
HSTREAM : Returned by BASS_StreamCreate, BASS_StreamCreateFile, BASS_StreamCreateURL, BASS_StreamCreateFileUser. Also add-on provided functions. 
HMUSIC : Returned by BASS_MusicLoad. 
HRECORD : Returned by BASS_RecordStart. 

As you can see, different names for the same thing resp. different things having the same name!
The above Hxxx names always mean: H=Handle for a certain type.
This is indeed not 100% clean in terms of naming conventions.

So just let us use the name: HANDLE for all of them.


2) Once you created a 'stream' and got a HANDLE and want/need to manipulate it, you are using the 'channel' functions.
As such you are using functions like e.g. 'BASS_ChannelSetPosition'.
As a 'channel' can be a sample playback channel (HCHANNEL), a sample stream (HSTREAM), a MOD music (HMUSIC), or a recording (HRECORD). Each 'Channel' function can be used with one or more of these channel types.


3) And now it gets completely confusing:
As seen above you have 'Channel' functions which operate on a HANDLE.
But the name 'channel' might mean and reference something completely different in other contexts:
E.g.: There are
- 'ASIO Channels': representing distinct hardware I/Os.
- 'Audio Channels': representing the number of audio channels within the sample data (ie. left and right channel)
- etc.

As you can see it is hard to find 'unique' names for different things, if they already got a global meaning in the real world.
As such take it as it is...

aybe

  • Posts: 145
Re: Object-Oriented approach for BASS ?
« Reply #2 on: 30 Sep '11 - 01:25 »
Ok I got it,  ;D

Thank you.