Author Topic: BASS.NET API 2.4.12.7  (Read 783433 times)

Serkan Polat

  • Guest
Re: BASS.NET API 2.4.10.3
« Reply #1250 on: 17 Feb '14 - 11:40 »
Hi all,
i got a playback system..
the above code is a small part of the player class, it has vumeters etc etc..
there are 2 different class that uses this class.
1 class loops a playlist . lets say this "schedules"
second class plays music depend on time limitations.. lets say this "announces"

the looping of playlist is working perfect without any problem..

the second class fires player at mornings (opening time of shop), and evenings (closing time of shop)
time between 2 announce is more than 10 hours.. but when this happens i got sometimes "unhandled exception" and sometimes "One or more errors occurred" from bass.net . is there a different garbage collector or a memory handler inside bass.net?
or what i am missing in code?

how can i debug whats going in bass.net? is there any log output feature?




Code: [Select]
void playNex(){
try{
 if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
  {Console.WriteLine("Bass init success");}
else{
 Console.WriteLine("Create error" + Bass.BASS_ErrorGetCode());
}
initSoundCard(selectedSoundCard); //default sound card maybe different

  if (_stream != 0)
  {
   //we have a previous stream, freeing stream
    Bass.BASS_StreamFree(_stream);
    _stream = 0;
  }
 if (trackSync != 0)
  {
    Bass.BASS_ChannelRemoveSync(_stream, trackSync);
  }
_stream = Bass.BASS_StreamCreateFile(Path.Combine(FilesPath, fileName), 0, 0, BASSFlag.BASS_STREAM_PRESCAN | BASSFlag.BASS_SAMPLE_FLOAT);
 Bass.BASS_ChannelSetDevice(_stream, selectedDevice);
 double dur = Bass.BASS_ChannelBytes2Seconds(_stream, Bass.BASS_ChannelGetLength(_stream));
 setvolume(100);
 if (Bass.BASS_ChannelPlay(_stream, false))
{
  _sync = new SYNCPROC(OnTrackSync);
  trackSync = Bass.BASS_ChannelSetSync(_stream, BASSSync.BASS_SYNC_END, 0L, _sync, IntPtr.Zero);
}
else{
 Console.WriteLine("Playback Error,skipping to next:" + Bass.BASS_ErrorGetCode());

 Thread.Sleep(100);
 new Thread(playNext).Start();
}
}
catch(Exception ex){
 //here i got error Playback Exception,skipping to next:One or more errors occurred.
 Console.WriteLine("Playback Exception,skipping to next:" + ex.Message);
 Thread.Sleep(100);
 new Thread(playNext).Start();

 }
}

public void setVolume(int value)
        {
            try
            {
                float vol = value / 100.0f; Bass.BASS_ChannelSetAttribute(_stream, BASSAttribute.BASS_ATTRIB_VOL, vol);
            }
            catch (Exception)
            {

            }
        }


public bool initSoundCard(int value)
{
     if (Bass.BASS_Init(value, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            {
                if (_stream != 0)
                {
                    Bass.BASS_ChannelSetDevice(_stream, value);
                }
                Bass.BASS_SetDevice(value);
                selectedDevice = value;
   }
}


radio42

  • Posts: 4576
Re: BASS.NET API 2.4.10.3
« Reply #1251 on: 17 Feb '14 - 13:58 »
Bass.Net does use any extra memory management or garbage collection - it also never calls any GC.xxx methods.
When you get an Exception the exception should indicate you with an error code and stack trace.
You might also call BASS_ErrorGetCode to retrieve the latest BASS error which happens.

GuzzP770

  • Posts: 12
About Bass_Free
« Reply #1252 on: 18 Feb '14 - 03:15 »
hi guys, i have my media player implementing bass_dshow, bassMIX, and bassFX
I have this weird behavior when I reopening my player form (From my Main form), is there something wrong in my FreeSource method?

triggered in Player's Closing Event (vb.net)
Code: [Select]
Bass.BASS_Stop()
BassDShow.BASS_DSHOW_Free()
Bass.BASS_Free()
« Last Edit: 19 Feb '14 - 11:32 by GuzzP770 »

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.10.3
« Reply #1253 on: 19 Feb '14 - 14:03 »
Guess this should be better asked to the DSHOW guys..as this is not a Bass.Net thing.
However, the Free calls frees the entire libs!

serkanp

  • Posts: 67
hi ,
i need to get the sound output of computer and send it to shoutcast or icecast server?

or let me clear my question,
i have many clients uses my application. but sometimes there are problems on client computer (sometimes windows, sometimes linux)
we need to hear the sound output from remote.. so i want to get the sound output when i need (i will start/stop it automatically, no problem), and stream it to a server and listen it..
how is it possible? can you give an idea for this?

ps: i thought that, maybe i can stream the sound output of computer to icecast and listen in an remote office..


radio42

  • Posts: 4576
Re: BASS.NET API 2.4.10.3
« Reply #1255 on: 19 Feb '14 - 15:13 »
Why don't you use e.g. TeamViewer - which already allows you to 'hear' what the client is playing (at least via his default/primary output)?

However, you can use BASS_WASAPI to 'capture' any local loopback device (which also exists for any regular output device) and use that for streaming.

serkanp

  • Posts: 67
Re: BASS.NET API 2.4.10.3
« Reply #1256 on: 19 Feb '14 - 16:10 »
most of the clients does not allow teamviewer or such connection..
most of them in closed intranets but can connect to my server over 80 http port..

in my manager application, i can see whats going on on client..
also i wrote my own teamviewer service application works over 80 http port.. i prepared a reverse ajax /comet style server side connection to clients..
and the connections are alive always.. i can trigger any client pc and trigger any function on my client application over 80 http..

i can send screenshot and screenshot difference of new frame as rectangle bitmaps with udp stream over http 80..
i can send keyboard press , mouse movements, clicks etc..

but i can not hear voice.. that is not my expertise.. :))
i want to implement this option to my teamviewer app.. so i can hear any audio output of my clients..


bass_wasapi is windows based .. not platform independent..
and lets say i will use this feature on windows environment, i dont know where to start "capture" any loopback device..
i need code example..


radio42

  • Posts: 4576
Re: BASS.NET API 2.4.10.3
« Reply #1257 on: 19 Feb '14 - 16:46 »
When using Bass.Net you might take a look to the provided C# samples called 'Streaming' resp. 'Encoder' - that is a good starting point...

GuzzP770

  • Posts: 12
Re: BASS.NET API 2.4.10.3
« Reply #1258 on: 20 Feb '14 - 07:31 »
Hi radio42, can you show me a standard-way to implement both bassmix and bassfx, I'm confused, whether I should do BASS_Mixer_StreamAddChannel before BASS_FX_TempoCreate or vice versa ?

serkanp

  • Posts: 67
Re: BASS.NET API 2.4.10.3
« Reply #1259 on: 20 Feb '14 - 07:48 »
When using Bass.Net you might take a look to the provided C# samples called 'Streaming' resp. 'Encoder' - that is a good starting point...

i already implemented streaming and encoder on my streaming server. but i can play mp3 playlist at the moment.
can you show me an example to use loopback device ?

and does streaming of loopback device works on linux mono?

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.10.3
« Reply #1260 on: 20 Feb '14 - 08:38 »
The Bass.Net documentation contains various examples.

To find the related loopback device you might use the "BassWasapi.BASS_WASAPI_GetDeviceInfos()" method.
The returned array of BASS_WASAPI_DEVICEINFO instances can then be used to identify the loopback devices - see the 'IsLoopback' property!


For encoding/recording an Wasapi device e.g. see here:
http://www.bass.radio42.com/help/html/3cc63e6e-272a-36dc-cedb-248d52eeeaf3.htm

I.e. to directly record from Wasapi input. Simply create an instance of the "WasapiHandler" class using an input/loopback device endpoint (see above) you want to record at (this automatically sets the "UseInput" property to true). To retrieve the input sample data use the "InputChannel" channel (e.g. setup an own "DSP" or use it with the "Encoder Framework" - which you have already used I guess).


If you want to use it natively (without the 'WasapiHandler' class) use the "BASS_WASAPI_Init" and "BASS_WASAPI_Start" methods.

GuzzP770

  • Posts: 12
Re: BASS.NET API 2.4.10.3
« Reply #1261 on: 21 Feb '14 - 06:10 »
Hi radio42,
I have applied SYNCPROC to notify me when my source channel Ended,
It works but why I get this svchost32 error?

Code: [Select]
Private Sub EndSync()
        Bass.BASS_ChannelStop(MixChannel)
        Bass.BASS_ChannelStop(SrcChannel)
        Bass.Bass_StreamFree(MixChannel) => ERROR here...
        Bass.Bass_StreamFree(SrcChannel)
    End Sub
« Last Edit: 21 Feb '14 - 06:19 by GuzzP770 »

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.10.3
« Reply #1262 on: 21 Feb '14 - 08:24 »
As stated in the BASS docs - it would not be save to free the stream from within the SYNCPROC directly.
To resolve that, just invoke an extra thread and free your stream in that extra thread.

GuzzP770

  • Posts: 12
Re: BASS.NET API 2.4.10.3
« Reply #1263 on: 21 Feb '14 - 09:16 »
thanks for responding radio42,

I try to use timer this time, everything works except ::
1. I can't do StreamFree too fast after EndSync, why?
2. My App Freeze when trying to play the next song, after playing a 6 channels song (that I mix into stereo output)
3. Eventhou I only put this line in EndSync, I'm still getting the error
Code: [Select]
Bass.BASS_ChannelSetPosition(channel, Convert.ToInt64(0), BASSMode.BASS_POS_BYTES)
Code: [Select]
Private Sub EndSync(ByVal handle As Integer, ByVal channel As Integer, ByVal data As Integer, ByVal user As IntPtr)
        Bass.BASS_ChannelStop(MixChannel)
        Bass.BASS_ChannelStop(SrcChannel)
        NeedNextSongFeed = True
End Sub

...

' Timer interval is 1 second, I make it so because my App Freeze if the timer trigger too fast to Free the streams

Private Sub Timer_PlayList_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer_PlayList.Tick
        If NeedNextSongFeed Then
            If Not NextSongTrigger Then
                NextSongTrigger = True
            Else
                NeedNextSongFeed = False
                PlayList.BtnNext.PerformClick()
                NextSongTrigger = False
            End If
        End If
End Sub

BtnNext_Click ::
~ StreamFree(SrcChannel)
~ StreamFree(MixChannel)
~ recreate them and ChannelPlay the MixChannel as usual


after reading some similiar post, I need to mention that I do using SAMPLE_LOOP Flag
« Last Edit: 21 Feb '14 - 09:57 by GuzzP770 »

serkanp

  • Posts: 67
Re: BASS.NET API 2.4.10.3
« Reply #1264 on: 21 Feb '14 - 11:47 »
thanks for responding radio42,

I try to use timer this time, everything works except ::
1. I can't do StreamFree too fast after EndSync, why?
2. My App Freeze when trying to play the next song, after playing a 6 channels song (that I mix into stereo output)
3. Eventhou I only put this line in EndSync, I'm still getting the error
Code: [Select]
Bass.BASS_ChannelSetPosition(channel, Convert.ToInt64(0), BASSMode.BASS_POS_BYTES)
Code: [Select]
Private Sub EndSync(ByVal handle As Integer, ByVal channel As Integer, ByVal data As Integer, ByVal user As IntPtr)
        Bass.BASS_ChannelStop(MixChannel)
        Bass.BASS_ChannelStop(SrcChannel)
        NeedNextSongFeed = True
End Sub

...

' Timer interval is 1 second, I make it so because my App Freeze if the timer trigger too fast to Free the streams

Private Sub Timer_PlayList_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer_PlayList.Tick
        If NeedNextSongFeed Then
            If Not NextSongTrigger Then
                NextSongTrigger = True
            Else
                NeedNextSongFeed = False
                PlayList.BtnNext.PerformClick()
                NextSongTrigger = False
            End If
        End If
End Sub

BtnNext_Click ::
~ StreamFree(SrcChannel)
~ StreamFree(MixChannel)
~ recreate them and ChannelPlay the MixChannel as usual


after reading some similiar post, I need to mention that I do using SAMPLE_LOOP Flag

use threads instead of timers..
after endsync just call nextsong function with a new thread..
timers are on main thread and could freeze your application , also when the bassfree operation still frees the channel, the timer may start new song at the same time..
so after streamfree finishes successfully, call a new thread.. this will solve it..

GuzzP770

  • Posts: 12
Re: BASS.NET API 2.4.10.3
« Reply #1265 on: 22 Feb '14 - 05:19 »
I found it! my BassFx Declaration was causing all the problems (I used SAMPLE_LOOP Flag), now I only use DECODE Flag to feed MixerChannel

thanks serkanp and radio42 for helping me

even though everything is working now, I found this weird behavior,
My song won't play when Bass_ChannelPlay(MixChannel) is called
and I found that it will play if I call Bass.BASS_ChannelSetPosition(SrcChannel, 0) after ChannelPlay

someone can explain why ?

Latch

  • Posts: 90
Re: BASS.NET API 2.4.10.3
« Reply #1266 on: 8 Mar '14 - 20:12 »
Has anyone here kept copies of older Bass.Net versions?  I'm specifically looking for version 2.4.3 or 2.4.4 or any of the versions that still supported BassVideo.  I still have 2.4.2 and just realized that there were a couple slightly newer versions that still supported it.  If anyone has copy, I'd greatly appreciate it.

aybe

  • Posts: 145
Re: BASS.NET API 2.4.10.3
« Reply #1267 on: 2 May '14 - 15:24 »
Hi !

I've created a NuGet package for BASS.NET : https://www.nuget.org/packages/BassDotNet/
Source code : https://github.com/aybe/BassDotNet

We can say that it is the first audio library available at NuGet :D

Features :
- A helper object that will initialize BASS and load all plugins that are present, for 32-bit as well 64-bit version
- A few classes that simplifies the usage of it, it's a preliminary version so don't expect much for the time being.

I will maintain this package up-to-date with BASS and with time more useful objects will be integrated.

This project is not intended as a replacement for BASS.NET, you can use BASS.NET as usual but along it
there will be objects that facilitates common tasks.

Any remarks/suggestions are welcome !

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.10.3
« Reply #1268 on: 2 May '14 - 16:41 »
@ Aybe:
I have send you a PM.
In short, please remove your stguff from NuGet and GitHub for now!
Bass.Net is a COMMERCIAL product  and I want people to use and install Bass.Net from the installer to also accept and understand the EULA and LICENSE.
This is not the case with your NuGet and GitHub project...
Thanks.
I am also not sure, if Ian wants his libs to be included in such installer packages.

aybe

  • Posts: 145
Re: BASS.NET API 2.4.10.3
« Reply #1269 on: 2 May '14 - 16:55 »
Sorry about that, I've removed them; see my response to your PM.

aybe

  • Posts: 145
Re: BASS.NET API 2.4.10.3
« Reply #1270 on: 2 May '14 - 17:02 »
While I removed it from the Nuget search, it is still available as a direct link.

I have contacted Nuget team to remove it, it will be removed entirely as soon as they take care of it.

aybe

  • Posts: 145
Re: BASS.NET API 2.4.10.3
« Reply #1271 on: 6 May '14 - 17:06 »
@radio42

Sorry for the previous confusion :-[, you're absolutely right I should have asked first.
Actually I've been sort of asking in the forum weeks ago but got no response so
I guess nobody really cared and therefore just forgot about the legal side of all this :
http://www.un4seen.com/forum/?topic=15499.0

I am asking you now : would you like a NuGet package for BASS.NET ?

I crafted a 'clean' package that I have uploaded on your FTP so you can take a look
at what it would look like, (BASS.NET.2.4.10.3.nupkg)

Licensing : the user can view it and has to accept it for installing it,
(the user will also see the license if he installs it through the command line)

Currently it is fully-featured, BASS and all plugins are in it, both 32 and 64 bit versions.

To try it in your environment follow this procedure to setup a local NuGet source:
https://docs.nuget.org/docs/start-here/managing-nuget-packages-using-the-dialog#Package_Sources

You can easily see its content using Nuget Package Explorer: http://npe.codeplex.com/

After testing it I came to the conclusion that it might be bloated for some users,
maybe multiple versions of it could be crafted such as a basic one with only BASS,
an MP3 free one and a fully-featured one, etc ...
Also, forget what I said previously about the helper objects, they're unrelated to BASS
so I will publish a separate library for them.

Hopefully you'll like that one and approve it !

Thank you.

radio42

  • Posts: 4576
Re: BASS.NET API 2.4.10.3
« Reply #1272 on: 6 May '14 - 19:19 »
Hi Aybe,

thanks for effort.
I guess we also need to discuss this with Ian, as BASs is of course HIS baby, while Bass.Net is mine.
Typically I follow Ian, as he is maintaining BASS and is kind of the master of all.
so I'll discuss that with him...

Greets,
Bernd

aybe

  • Posts: 145
Re: BASS.NET API 2.4.10.3
« Reply #1273 on: 6 May '14 - 19:20 »
Alright excellent, thank you !

ken

  • Posts: 739
Re: BASS.NET API 2.4.10.3
« Reply #1274 on: 4 Jun '14 - 15:09 »
Hi!

How does "DrawBeat" work?  I tried set "DrawBeat = WaveForm.BEATDRAWTYPE.TopBottom" before "RenderStart" and also tried in the callback, but I see no beatlines at all ( I can add markers).

Is BassFX integrated in this?  Any code snippets are welcome!

/Ken
« Last Edit: 4 Jun '14 - 15:26 by ken »