Author Topic: BASS_WASAPI and CastInit  (Read 2645 times)

Ian @ un4seen

  • Administrator
  • Posts: 20210
Re: BASS_WASAPI and CastInit
« Reply #25 on: 27 Feb '17 - 13:32 »
Yes, you can have multiple encoders set on the same BASS channel.

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #26 on: 27 Feb '17 - 16:07 »
Thank you.  :D

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #27 on: 6 Mar '17 - 17:24 »
Quote
Maybe a little off topic.
But for AAC do you need driver codex?
And what must I do? I can't stream AAC here. Source is good.


Solved. Channel problem for broadcast. 8 > now 2!
« Last Edit: 7 Mar '17 - 05:18 by Ed1966 »

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #28 on: 18 Mar '17 - 08:35 »
I have some problems casting to ShoutCast server. Sometimes sound seems to be hold for milliseconds and when takes longer some Auto-DJ takes over for few seconds.
Now I think solved this but is this the right solution?

Old situation:
Encoder := BASS_Encode_Start(OutputMixer, ComLine, BASS_ENCODE_FP_16BIT or BASS_ENCODE_NOHEAD
    or BASS_ENCODE_CAST_NOLIMIT, nil, nil);

New situation:
Encoder := BASS_Encode_Start(OutputMixer, ComLine, BASS_ENCODE_FP_16BIT or BASS_ENCODE_NOHEAD
    or BASS_ENCODE_CAST_NOLIMIT or BASS_ENCODE_QUEUE, nil, nil);

You see I add: BASS_ENCODE_QUEUE
And set BASS_CONFIG_ENCODE_QUEUE to ZERO.

So, is this the right way or are there other solutions?

Thanks,
Eduard.



Ian @ un4seen

  • Administrator
  • Posts: 20210
Re: BASS_WASAPI and CastInit
« Reply #29 on: 20 Mar '17 - 15:24 »
Is the server's local playback sometimes stuttering when encoding it? If so, adding the BASS_ENCODE_QUEUE flag could indeed help; it sends the sample data to the encoder asynchronously so that decoding/playback isn't delayed.

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #30 on: 21 Mar '17 - 15:41 »
The stuttering was kind of the problem. Look fine now. Thanks.

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #31 on: 22 Mar '17 - 11:23 »
Do you have some information regarding: BASS_Encode_CastSendMeta
I can not find anything. I want to send cover picture.
Working in Delphi but C is welcome.

Ian @ un4seen

  • Administrator
  • Posts: 20210
Re: BASS_WASAPI and CastInit
« Reply #32 on: 22 Mar '17 - 14:49 »
Note that BASS_Encode_CastSendMeta only works with Shoutcast 2 servers. You can find details on the available metadata options here:

   http://wiki.winamp.com/wiki/SHOUTcast_2_(Ultravox_2.1)_Protocol_Details

For example, you could send a JPEG album cover like this:

Code: [Select]
BASS_Encode_CastSendMeta(encoder, 0x4100, data, length);

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #33 on: 23 Mar '17 - 05:36 »
Thank you. Found this one for use with Delphi so I can figure it out.

const
  BASS_METADATA_BIN_ALBUMART_JPG = 16640

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #34 on: 1 Apr '17 - 11:46 »
There are some stuttering even with buffer enabled. Not al the time but when I do some work in Jukebox. WASAPI is Threaded?
Can I give this Thread some flag to give full rights? If you understand. Maybe is IDLE when I select songs or whatever?

Ian @ un4seen

  • Administrator
  • Posts: 20210
Re: BASS_WASAPI and CastInit
« Reply #35 on: 3 Apr '17 - 15:13 »
Is your WASAPIPROC callback function (or DSPPROC/etc) doing anything that has to wait for another thread, eg. perhaps UI updates? If so, that stuff should be moved out of the callback function. For example, a callback function could post a message to the main thread, and the message handler does the UI update.

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #36 on: 5 Apr '17 - 07:55 »
For Loopback I use (delphi)
Code: [Select]
function WasapiProcPush(buffer:Pointer; length:DWORD; user:Pointer): DWORD; stdcall;
begin
  { Pass data to push stream }
  BASS_StreamPutData(LocalInputChannel, buffer, length);
  Result := BASS_ChannelGetData(LocalOutputMixer, buffer, length);
end;
and STREAMPROC_PUSH:
Code: [Select]
LocalInputChannel := BASS_StreamCreate(INFO.freq, INFO.chans, BASS_SAMPLE_FLOAT or BASS_STREAM_DECODE, STREAMPROC_PUSH, nil);

Seems to be correct? If so than there is some server problem.

Ian @ un4seen

  • Administrator
  • Posts: 20210
Re: BASS_WASAPI and CastInit
« Reply #37 on: 5 Apr '17 - 14:33 »
Please also show what the LocalOutputMixer's BASS_Mixer_StreamCreate call looks like, and the BASS_Encode_Start call. Also confirm what device you are capturing from, and does capturing from a different device make any difference?

In your previous post you mentioned that the problem happens when you "do some work in Jukebox". Is that on the server PC or the client PC? Also, what client are you using and what buffering is it doing? Does the problem happen if you try playing the stream with a different client, eg. XMPlay or Winamp?

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #38 on: 6 Apr '17 - 10:58 »
Code: [Select]
  {  -3 = default loopback input device }
  Result := BASS_WASAPI_Init(-3, 0, 0, 0{Flags}, 0.5, 0, @WasapiProcPush, nil);
Code: [Select]
  { Create stereo mixer }
  LocalOutputMixer := BASS_Mixer_StreamCreate(INFO.freq, 2, BASS_SAMPLE_FLOAT or BASS_STREAM_DECODE);
Code: [Select]
  Encoder := BASS_Encode_Start(LocalOutputMixer, ComLine, BASS_ENCODE_FP_16BIT or BASS_ENCODE_NOHEAD
      or BASS_ENCODE_CAST_NOLIMIT or BASS_ENCODE_QUEUE, nil, nil);

This code should be good, I think.
Now is much better. Think Server setting error. not mine but they have new one.
Sometimes connection (Auto DJ) break but I think it's client Latency. I don't know solution in code so must be sever side.

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #39 on: 23 Apr '17 - 18:13 »
I have one more problem, hope I can ask this after long run here.

Everything is working but the only problem is difference between:
BASS_ENCODE_COUNT_OUT  and  BASS_ENCODE_COUNT_CAST.

With broadcasting client the difference is always 4096 or higher. When it reaches about 12288 the server is lost for few seconds. No sound on the radio.
BASS_ENCODE_COUNT_QUEUE_LIMIT is set to approximately 10000ms, that's enough because after buffer filled to 2000ms there is also server lost for few seconds.

You can see code above in this topic witch i am using. But we talked about that and that was good.
And I use: BASS_ENCODE_FP_16BIT or BASS_ENCODE_NOHEAD  or BASS_ENCODE_CAST_NOLIMIT or BASS_ENCODE_QUEUE (Encoder_Start)

Do you know a solution about this problem?
Is this maybe a BASS_STREAM_DECODE problem in the Loopback. I think I read something about this.

Thank you.
Regards,
Eduard. 
« Last Edit: 24 Apr '17 - 02:07 by Ed1966 »

Ian @ un4seen

  • Administrator
  • Posts: 20210
Re: BASS_WASAPI and CastInit
« Reply #40 on: 24 Apr '17 - 17:32 »
Perhaps the sending to the server is timing-out sometimes. You can detect that by requesting notifications via BASS_Encode_SetNotify. Do you receive any BASS_ENCODE_NOTIFY_CAST_TIMEOUT notifications? If you do, you could try raising the BASS_CONFIG_ENCODE_CAST_TIMEOUT setting via BASS_SetConfig. Please see the BASS_CONFIG_ENCODE_CAST_TIMEOUT documentation for details.

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #41 on: 24 Apr '17 - 19:23 »
I have set notify 'BASS_Encode_SetNotify' but that is not the problem. I receive message if something is wrong.

Using Centova Cast for broadcasting and the Centova server is located in America and I live in the Netherlands. Could this be the problem? Some distance problems?

I have tested all possibilities and can't get the right code, it must be right here  ???

Or have you one more thought?

Chris

  • Posts: 1804
Re: BASS_WASAPI and CastInit
« Reply #42 on: 24 Apr '17 - 19:25 »
Icecast or Shoutcast Server ?

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #43 on: 24 Apr '17 - 19:26 »
ShoutCast

Ian @ un4seen

  • Administrator
  • Posts: 20210
Re: BASS_WASAPI and CastInit
« Reply #44 on: 25 Apr '17 - 14:50 »
I have set notify 'BASS_Encode_SetNotify' but that is not the problem. I receive message if something is wrong.

OK, so you are using BASS_Encode_SetNotify and there are no BASS_ENCODE_NOTIFY_CAST_TIMEOUT notifications?

Another thing to check is whether the encoder is started before BASS_Encode_CastInit is called. That could result in BASS_ENCODE_COUNT_OUT being higher than BASS_ENCODE_COUNT_CAST. To avoid that, the encoder should be created in a paused state (BASS_ENCODE_PAUSE), and then unpaused (BASS_Encode_SetPaused) after BASS_Encode_CastInit is called.

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #45 on: 25 Apr '17 - 17:47 »
There are no BASS_ENCODE_NOTIFY_CAST_TIMEOUT notifications!
I can test it tomorrow morning because now the station is busy. DJ is online.

EDIT:
After testing different between OUT and CAST is 90% zero, that's nice. Sometimes 4096/8192 for moment. But always back to zero.

Next situation because Auto-DJ sever side is not yet over.
I notice that buffer (10000ms) sometimes runs full to about 4000-5000ms and start the Auto-DJ at server side.
Do you know how to fix this and/or what is the problem?

Using:
22-05-2014  16:22           653.312 lame.exe
22-05-2014  16:22           519.680 lame_enc.dll
Is this the latest? I don't see newer.

Regards,
Eduard.

« Last Edit: 26 Apr '17 - 08:12 by Ed1966 »

Ian @ un4seen

  • Administrator
  • Posts: 20210
Re: BASS_WASAPI and CastInit
« Reply #46 on: 26 Apr '17 - 16:21 »
Next situation because Auto-DJ sever side is not yet over.
I notice that buffer (10000ms) sometimes runs full to about 4000-5000ms and start the Auto-DJ at server side.
Do you know how to fix this and/or what is the problem?

I'm not entirely sure what you mean. Can you give a bit more info on the problem, eg. what is its effect?

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #47 on: 27 Apr '17 - 09:16 »
Set value for BASS_ENCODE_COUNT_QUEUE_LIMIT at 10000ms (3528000 bytes)
This value is growing:  BASS_ENCODE_COUNT_QUEUE sometimes up to 5000ms.
When this is happening de music is lost and Centova cast switch to Auto-DJ.
Sometimes BASS_ENCODE_COUNT_QUEUE_FAIL value.

Is this my problem, do to Worthless internet stream? I am not the only one.
I broadcast from the Netherlands to Centova server America. Centova casting sent this to host (website) server in Netherlands, and I listen to this stream.

Main fact, is this coding problem or Centova problem?
If you look back in this topic you see nothing strange coding. I only monitor Loopback and sent it out. Try with different test sources.

Using:
{ BASS_ENCODE_TYPE_MP3 }
Result := Format('lame -r -s %d -b %d -', [AFrequency, ABitRate]); (44100, 256)

Maybe you can explain what to do?
If code is right maybe another Casting :(

Regards,
Eduard.



Ian @ un4seen

  • Administrator
  • Posts: 20210
Re: BASS_WASAPI and CastInit
« Reply #48 on: 27 Apr '17 - 14:10 »
Is the BASS_ENCODE_COUNT_QUEUE value rising over time? If so, that means the source data is being provided more quickly than it's being encoded/casted. One possible reason for that could be if the bitrate is too high for the connection. What is your upstream bandwidth? It looks like your encoding bitrate is 256 kbps? You could try reducing that and see if it helps.

Ed1966

  • Posts: 51
Re: BASS_WASAPI and CastInit
« Reply #49 on: 29 Apr '17 - 06:13 »
About 10Mbit upload speed. 
Tenth of  may I receive new internet provider and test everything again.
Thanks for your time for this moment.

Regards,
Eduard.