Author Topic: BASSmix beta (mixing & resampling add-on)  (Read 125115 times)

ken

  • Posts: 739
Re: BASSmix beta (mixing & resampling add-on)
« Reply #150 on: 15 May '07 - 21:03 »
Ok, thanks! Muting is a good idea.

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASSmix beta (mixing & resampling add-on)
« Reply #151 on: 15 May '07 - 21:06 »
I've a strange access violation with BASSMIX.DLL when I'm using Bass and Bassmix with Delphi...

Are you using the latest BASSMIX.DLL? If not, please try that. If you still get the crash, to get some clues about it, please let Windows/DrWatson (not Delphi) catch the crash, and upload the drwtsn32.log file to have a look at...

   ftp.un4seen.com/incoming/

I do the BASS_ChannelGetData because I've to do some transformation before the resample...

It looks like you could simplify things a bit by doing that in a DSP function :)

Code: [Select]
     HFile := BASS_StreamCreateFile(False,PChar('in.mp2'),0,0,BASS_STREAM_DECODE or BASS_SAMPLE_LOOP or BASS_SAMPLE_FLOAT);
     BASS_ChannelSetDSP(HFile,@ProcessDSP,0,0);

     HMixPilot := BASS_Mixer_StreamCreate(192000,2,BASS_MIXER_NONSTOP or BASS_SAMPLE_FLOAT);
     if not BASS_Mixer_StreamAddChannel(HMixPilot,HFile,0) then Error('STREAMADDCHANNEL_PILOT');

I do like this:

MP3, CreatStream --->
MP3, CreatStream  --->  BassMix --> Encoder --> ShoutcastStreaming
MP3, CreatStream  --->
 

That works just fine, but I don't want to play on any soundcard, just send to ShoutCast.
I set BASS_Init(0,...   But then I can't get the mixer running then.

As Bernd says, you can only create decoding channels on the "no sound" device, but decoding channels can actually be fed to Shoutcast servers. Instead of playing the mixer, you need to repeatedly call BASS_ChannelGetData on it in a loop. BASSenc should automatically regulate the decoding rate for you, to avoid server buffer overflows.
« Last Edit: 15 May '07 - 21:08 by Ian @ un4seen »

Leonmeijer

  • Posts: 17
Re: BASSmix beta (mixing & resampling add-on)
« Reply #152 on: 3 Jun '07 - 10:50 »
An update is in the BASSmix download, which improves syncing support for source channels. As BASS_Mixer_ChannelGetPosition compensates for the mixer buffer to give accurate source positions, so BASS_Mixer_ChannelSetSync does the same for POS and END syncing. Sources can also be paused now, using the new BASS_MIXER_PAUSE flag.

How can I resume a channel that's added in paused mode? and is it possible to detect weather a source channel is paused?

radio42

  • Posts: 4573
Re: BASSmix beta (mixing & resampling add-on)
« Reply #153 on: 3 Jun '07 - 15:32 »
You simply remove the PUSE flag, like this:
Code: [Select]
BASS_Mixer_ChannelFlags(handle, 0, BASS_MIXER_PAUSE) // remove PAUSE flag

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASSmix beta (mixing & resampling add-on)
« Reply #154 on: 4 Jun '07 - 14:23 »
Yep, and you can check if a source is paused like this...

Code: [Select]
if (BASS_Mixer_ChannelFlags(handle, 0, 0) & BASS_MIXER_PAUSE) { // check PAUSE flag
// it's paused!
}

TommyB

  • Posts: 38
Re: BASSmix beta (mixing & resampling add-on)
« Reply #155 on: 5 Jun '07 - 20:24 »
Hello :)
First of all sorry for my english, and for that that I can't search for an solution. This is because at the moment I have no internet connection at home, so please forgive me, if my problem is well known. I pay for each 30min, and haven't enough time / money to start a big search :)

I have written an application in VB.Net2005 (NOT using bass.net) which I have used the following:
I have had a bass HMusic (StreamCreateFile) or a HMusic, putting it through a BassFX Tempo stream, read out the data and writes it into a fixed stream (means not affected through file changes and so on). that stream is attached on a BassMix Mixer stream. On the output side I have an asio output which is getting the data from the Mixer stream. Anything works fine, except I want to use the Tempo stream directly (to auto convert mono files to stereo without writing code by myself). Works, too, but:mostly (not every time) if the stream ends (because file end is reached) or I switch to the next file (tempo stream will detached, new file loaded and the new HTempo reattached) it will crash the whole audio processing, including the Asio devices. Application will hang on about each 2nd function call to the bass libraries (like Bass.Free). Well crash is maybe a wrong word, the audio threads doesn't do any work, they are all at 0% cpu load, and my application will hang on some function calls where it have to wait for the bass functions.
Anyone noticed about this problem? If I use my old way (using a stream between Tempo and Mixer) anything works fine. If I use AutoFree and FreeSource on the tempo stream it will work on most cases, too, but not everytime.

Sorry I can't reproduce it better. I hope you can understand my problem. I can't upload my files, uploads are disallowed here -.-

But much thanks already, saved me a lot of time :) Maybe you can help me out with this problem, too

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASSmix beta (mixing & resampling add-on)
« Reply #156 on: 6 Jun '07 - 15:14 »
I have written an application in VB.Net2005 (NOT using bass.net) which I have used the following:
I have had a bass HMusic (StreamCreateFile) or a HMusic, putting it through a BassFX Tempo stream, read out the data and writes it into a fixed stream (means not affected through file changes and so on). that stream is attached on a BassMix Mixer stream.

I'm not entirely sure what you mean by "fixed stream". Does that mean you have a file stream (BASS_StreamCreateFile) feeding a tempo stream (BASS_FX_TempoCreate) feeding a custom stream (BASS_StreamCreate) plugged into a mixer? If so, is there a reason for the custom stream being there, why not plug the tempo stream into the mixer? :)

Anything works fine, except I want to use the Tempo stream directly (to auto convert mono files to stereo without writing code by myself).

Tempo streams won't convert mono to stereo. Maybe you meant that you're using the mixer stream to do that?

Works, too, but:mostly (not every time) if the stream ends (because file end is reached) or I switch to the next file (tempo stream will detached, new file loaded and the new HTempo reattached) it will crash the whole audio processing, including the Asio devices. Application will hang on about each 2nd function call to the bass libraries (like Bass.Free). Well crash is maybe a wrong word, the audio threads doesn't do any work, they are all at 0% cpu load, and my application will hang on some function calls where it have to wait for the bass functions.

That sounds like a couple of threads are in deadlock, waiting for eachother. Which BASS function call(s) is that happening in, and what thread(s) are you making those calls from, eg. from the main thread or a callback or somewhere else?

TommyB

  • Posts: 38
Re: BASSmix beta (mixing & resampling add-on)
« Reply #157 on: 6 Jun '07 - 21:13 »
Well I have had a "fixed stream". Means the stream handle is constant for the application (created on application start, freed at shutdown), unaffected on file changes. I have had a HStream (using Bass.StreamCreateFile) putting it into a HTempo, and on output side (for the file playback 'deck') I have a new HStream (using Bass.StreamCreate) where I feed in the requested data from the tempo stream using the callback. Like you have thought what I've been doing :)
The reason for that was I was starting my application and was really happy to see somethings working :) After that I have implemented not strongly recommended functions like Detach/Pause streams to a HMixer. After that I was able to remove the last (constant) HStream. Thats exactly what I have done. After that the error occours.

By the way: I don't know exactly whats your code is doing. If the Tempo stream converts it from mono to stereo or the mixer.. for me its all the same, but you are right. I want to attach a stream with correct settings (like channel count) to the mixer to auto convert the format. What component will do the work for me... Its your code and I'm happy that it will do it's work :)

Well a deadlock seems to be the problem, yes. I will try some functions to see where the application hangs on, but anything like StreamCreateFile, same with HMusic or Audio CD Streams will be created. Bass.Free will hang like the BassAsio 'TimeCritical' threads. In my application I have 2 threads that are accessing the Bass/BassAsio/BassMix and so on. The first one (default priority) will initialize (Bass.Init) and shutdown (Bass.Free) the audio system. (It's my splash screen) Simple commands like file changes (now together with detaching stream from HMixer and reattaching it) or applying volume, balance and FX properties will be done from the main applications form thread (Lower Priority because graphic) but if I get serveral of time I will do it from the same thread that calls Bass.Init. Most actions will happen on the BassAsio callback which will start getting the audio data through the whole application (requests data from the HMixer stream, which requests it from the 'file decks' or (not for this case) enabled input channel) and so on

fmcoder

  • Posts: 436
Re: BASSmix beta (mixing & resampling add-on)
« Reply #158 on: 8 Jun '07 - 10:27 »
Ian, sad but true... I still got crashes with bassmix.
There is Dr.Watson log of two crashes in the attach, please take a look.

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASSmix beta (mixing & resampling add-on)
« Reply #159 on: 8 Jun '07 - 15:30 »
By the way: I don't know exactly whats your code is doing. If the Tempo stream converts it from mono to stereo or the mixer.. for me its all the same, but you are right. I want to attach a stream with correct settings (like channel count) to the mixer to auto convert the format. What component will do the work for me... Its your code and I'm happy that it will do it's work :)

If the mixer is stereo, its output will be stereo, regardless of what the sources originally were :) ... How the sources appear in the mix depends on the flags and/or matrixes used for them.

...Most actions will happen on the BassAsio callback...

Please post your ASIOPROC (and any other callbacks that you are using). Note you have to be careful about what you do in a callback. As well as not calling the functions mentioned in the documentation, you should avoid things that may have to wait for other threads.

There is Dr.Watson log of two crashes in the attach, please take a look.

The logs don't seem to match up with the latest BASSmix release (available in first post). Particularly when the crash is in a call from the DLL (not the DLL itself), I generally need to have the same DLL version as in the log to get reliable info out of it. In any case, you could try to reproduce the problem with the latest beta...

   www.un4seen.com/stuff/bassmix.dll

Note that this BASSmix version depends on some new stuff coming in BASS 2.3.0.3, so you will need the beta of that too...

   www.un4seen.com/stuff/bass.dll

fmcoder

  • Posts: 436
Re: BASSmix beta (mixing & resampling add-on)
« Reply #160 on: 9 Jun '07 - 14:26 »
I downloaded the latest bass, but it cannot create a stream - returns error code 37... It's because BASS_STREAM_AUTOFREE flag was used when creating a stream.
When bass 2.3 will be released? Because using two betas (bassmix and bass itself) in my product isn't very good i think.

radio42

  • Posts: 4573
Re: BASSmix beta (mixing & resampling add-on)
« Reply #161 on: 9 Jun '07 - 16:11 »
This error 37 is also 'kind of new in the latest build ;-)
It simply tells you, that you are using a flag at a point where it is not usfull/allowed.

In previous versions of BASS those flag had simply been ignored. But I guess Ian thought it will help more to understand the falgs, if an error will be thrown - so that you would know, that the use of certain flag simply doesn't make sence.

I guess you where using the AUTOFREE flag with the BASS_StreamCreateFile method and have also specified the DECODE flag.
However when using the flag DECODE the following flags are not allowed:
BASS_SAMPLE_SOFTWARE/3D/FX/AUTOFREE as well as he SPEAKER flags.

Beside that I can confirm, that the current 'beta' already fixes a lot of other issues is very stable!

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASSmix beta (mixing & resampling add-on)
« Reply #162 on: 9 Jun '07 - 17:29 »
I downloaded the latest bass, but it cannot create a stream - returns error code 37... It's because BASS_STREAM_AUTOFREE flag was used when creating a stream.

Yep, as Bernd says, it will generate an error when invalid flags are used in combination with the DECODE flag, instead of just ignoring them as previously. I decided to do that because I've seen a few people using the AUTOFREE flag with the DECODE flag (yourself included it seems :)), apparently expecting BASS to auto-free the channel, which it won't do, thus possibly resulting in a leak.

fmcoder

  • Posts: 436
Re: BASSmix beta (mixing & resampling add-on)
« Reply #163 on: 9 Jun '07 - 19:46 »
I used this flag because my app has many settings and "flags" variable contains BASS_SAMPLE_FLOAT and AUTOFREE flags everytime, and depending on settings, it also included speakers or decode flag...
Thanx for explanation.
I made a few tests with new bass and bassmix today, and it not produced any access violations by now, that's good.

Z

  • Posts: 12
Re: BASSmix beta (mixing & resampling add-on)
« Reply #164 on: 26 Jun '07 - 17:44 »
Hi,

I have a problem, but I really don't know where it comes from. Maybe it's something I'm doing wrong.

So I have an application that mix several streams ( 1 to 3 ) using BASSmix. Everything works OK, except on several high end cards where it produces crackling noises ( light on M-Audio FireWire 410, severe on MOTU UltraLite and MOTU 828 Mk2 ). This happens only when 2 or more streams are mixed, and the volume of the streams are left to nominal output. Decreasing the volume of additionnal streams reduces the crackling noises.

Here is how the streams are created :
Quote
BASS_StreamCreateFile(mem,file,offset,length,BASS_STREAM_DECODE | BASS_STREAM_PRESCAN | BASS_SAMPLE_FLOAT );

Here is how the mixer is created :
Quote
BASS_Mixer_StreamCreate ( 44100, 2 , BASS_STREAM_DECODE | BASS_SAMPLE_FLOAT );

Here is how the streams are added :
Quote
BASS_Mixer_StreamAddChannel ( Mixer, Music->Stream, 0 );

The mixer output is in fact sent to a Tempo stream I use to globally control the tempo :
Quote
BASS_FX_TempoCreate( Mixer, NULL );

I'm wondering if somehow the crackling sounds would result from these cards accepting float data ( like they would receive data that is not clipped ).

Any help appreciated.

Update : Well there is data that is not clipped at the output of the mixer and of the tempo stream. But I wrote a DSPPROC to clip it to no avail, so the problem must come from somewhere else.
« Last Edit: 27 Jun '07 - 11:40 by Z »

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASSmix beta (mixing & resampling add-on)
« Reply #165 on: 28 Jun '07 - 14:13 »
Do any of the following make any difference?

  • Lower the soundcard's master and/or "wave" volume in the Windows mixer.
  • Lower the volume (BASS_ChannelSetAttributes) of the tempo stream.
  • Remove the FLOAT flag from the mixer (BASS_Mixer_StreamCreate).
  • Add the SOFTWARE flag to the tempo stream (BASS_FX_TempoCreate).
  • Remove the tempo stream.

TommyB

  • Posts: 38
Re: BASSmix beta (mixing & resampling add-on)
« Reply #166 on: 30 Jun '07 - 20:34 »
argh, found my problem. I have called the 'critical functions' (like start/stop and so on) within the callback... Sorry for that and thanks for help :)

Chrickel

  • Posts: 3
Re: BASSmix beta (mixing & resampling add-on)
« Reply #167 on: 10 Jul '07 - 22:08 »
Hello everybody!

I'm new to bass and bassmix. My project is a multiroom-soundsystem.
I've got a P4 1800 with two 7.1 noname soundcards in it. With a little
VB-program I can already create a mixer-stream, can add a channel from an mp3-file and can mix it to the 4 stereo-outputs of one soundcard.

But:

How can I mix a single channel created from an mp3-file to all 8 stereo channels (which means to all the 4 channels of both soundcards)? The usecase would be that I want to listen to the same song in every room.

BTW: How do I correctly pass a matrix (which is a two dimensional array) as a parameter of BASS_Mixer_ChannelSetMatrix() in Visual Basic? VB wants to have a single value.

Thanks,
Chrickel
« Last Edit: 10 Jul '07 - 23:05 by Chrickel »

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASSmix beta (mixing & resampling add-on)
« Reply #168 on: 12 Jul '07 - 17:21 »
I'm new to bass and bassmix. My project is a multiroom-soundsystem.
I've got a P4 1800 with two 7.1 noname soundcards in it. With a little
VB-program I can already create a mixer-stream, can add a channel from an mp3-file and can mix it to the 4 stereo-outputs of one soundcard.

But:

How can I mix a single channel created from an mp3-file to all 8 stereo channels (which means to all the 4 channels of both soundcards)? The usecase would be that I want to listen to the same song in every room.

Do you want to play the same data on both cards? If so, the most efficient way would be to buffer the data from the mixer stream on one device and feed it to a custom stream (BASS_StreamCreate) on the other device. The buffering could be done in a DSPPROC set on the mixer (BASS_ChanneSetDSP), and you would feed that buffered data to the custom stream's STREAMPROC.

This task will probably be made simpler if/when the ChannelPutData suggestion happens :)

BTW: How do I correctly pass a matrix (which is a two dimensional array) as a parameter of BASS_Mixer_ChannelSetMatrix() in Visual Basic? VB wants to have a single value.

I don't use VB myself, so I'm not entirely sure how you would pass a 2 dimension array, but if all else fails, you could make it a 1 dimension array. For example, this 2 dimension array...

   1, 2
   3, 4

...looks the same to BASSmix as this 1 dimension array...

   1, 2, 3, 4

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASSmix beta (mixing & resampling add-on)
« Reply #169 on: 30 Jul '07 - 15:09 »
BASSmix 2.3 "final" is now available on the BASS page!

Note it requires at least BASS 2.3.0.3, as it depends on some new stuff in that.

martin

  • Posts: 34
Re: BASSmix beta (mixing & resampling add-on)
« Reply #170 on: 30 Aug '07 - 13:02 »
Hi!

I have a problem concerning the volume in the output using bassmix.

I want to have a 6-channel-output where I can define what is Left, Right, Center and so on. Thats why I am using a matrix [2,6] and the numeric-up/down. Everything works fine, but the volume is very low. If I am changing the matrix to [2,2] the volume is like without using bassmix, with [2,6] it's perhaps only 10%... can I change this?
hopefully my problem is understandable...

my code is the following:
-----------------------------------------------------------------
                     if (info.chans==2)
                    {
                        _mixerStream =
                        BassMix.BASS_Mixer_StreamCreate(Properties.Settings.Default.samplerate, 2,
                                      (int)BASSStream.BASS_SAMPLE_FLOAT);
                        bool playok =
                            BassMix.BASS_Mixer_StreamAddChannel(_mixerStream, _stream, BASSStream.BASS_MIXER_MATRIX);
                        // define a mixing matrix for the source stream
                        float[,] matrix = new float[2, 6]
                        {
                            {0, 0, 0, 0, 0, 0}, //L (eingang)
                            {0, 0, 0, 0, 0, 0}, //R (eingang)

                        };

                        matrix.SetValue(1, (int)L_updown.Value - 1, 0); //L
                        matrix.SetValue(1, (int)R_updown.Value - 1, 1); //R

                        BassMix.BASS_Mixer_ChannelSetMatrix(_stream, ref matrix[0, 0]); 
                    }

---------------------------

Thanks in advance
Martin

Ian @ un4seen

  • Administrator
  • Posts: 20393
Re: BASSmix beta (mixing & resampling add-on)
« Reply #171 on: 30 Aug '07 - 15:18 »
Is "info.chans" the source's (_stream) number of channels? If so, shouldn't that matrix be 2x2, as you're creating a 2 channel mixer?
« Last Edit: 30 Aug '07 - 15:38 by Ian @ un4seen »

velusip

  • Posts: 37
Re: BASSmix beta (mixing & resampling add-on)
« Reply #172 on: 2 Sep '07 - 02:38 »
...I want to have a 6-channel-output...
Martin

I think he wants to upmix, so the array is just backwards?
  float[,] matrix = new float[6, 2]

martin

  • Posts: 34
Re: BASSmix beta (mixing & resampling add-on)
« Reply #173 on: 2 Sep '07 - 15:01 »
yes, valusip -- now it works...

thank you! and thanks ian (for the same but edited answer...)
martin