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

Renegade

  • Posts: 160
Re: BASS.NET API 2.4.0.3
« Reply #425 on: 28 May '08 - 02:38 »
Pretty please? :D

They really do look very good so the performance hit to start is worth it.

ken

  • Posts: 739
Re: BASS.NET API 2.4.0.3
« Reply #426 on: 28 May '08 - 08:36 »
Bernd,

If you do gradient and it slows down waveform, then make it as an option. WaveForm is so fast today and works great.

Another idea for gradient is if you use a picture as "waveform", then we can just add any small image (height of the waveform but only 1px width) we want.

/Ken

radio42

  • Posts: 4574
Re: BASS.NET API 2.4.0.3
« Reply #427 on: 28 May '08 - 16:21 »
Just to be sure:
You mean something like this (see attachment).
If yes, I guess you can expect a new BASS.NET version tomorrow - I hope :-)

Renegade

  • Posts: 160
Re: BASS.NET API 2.4.0.3
« Reply #428 on: 28 May '08 - 17:27 »
Looking wicked! :D

And yes -- in agreement with Ken (I think I mentioned it before) -- as an option is perfect. Some people won't want the performance hit. Some won't care.

But really, it's looking slick! :)

You rock Bernd!

radio42

  • Posts: 4574
Re: BASS.NET API 2.4.0.4
« Reply #429 on: 29 May '08 - 13:54 »
29.05.2008: Version 2.4.0.4 is out!

BassVideo: updated to support v2.4.0.8
General:
  - WaveFrom:
    . Gradient drawing support (see UseGradient, ColorLeft2, ColorRight2)
    . GetNormalizationGain method added
    . GetCuePoints overloads added supporting seconds
    . AddMarker overloads added supporting seconds
    . AddVolumePoint overloads supporting seconds
  - Tag add-on: a few optimizations (incl. picture reading)
  - Utils: GetNormalizationGain method added

Renegade

  • Posts: 160
Re: BASS.NET API 2.4.0.4
« Reply #430 on: 29 May '08 - 14:32 »
...
  - WaveFrom:
    . Gradient drawing support (see UseGradient, ColorLeft2, ColorRight2)
...

Bernd! You kick ass! Off to buy another license as promised! :D

Renegade

  • Posts: 160
Re: BASS.NET API 2.4.0.4
« Reply #431 on: 29 May '08 - 14:41 »
Just a note: http://www.ten53.de/bass_register.html lists 29 Euro, but the other page has 19 Euro. You might want to update the other one (from the RTF file).


radio42

  • Posts: 4574
Re: BASS.NET API 2.4.0.4
« Reply #432 on: 29 May '08 - 14:53 »
done ;-)

ken

  • Posts: 739
Re: BASS.NET API 2.4.0.4
« Reply #433 on: 29 May '08 - 16:16 »
"GetNormalizationGain" that is a welcomed feature but I don't find anything in the doc.

What I understand so will I get a value that tell me how much I need to gain the audiovolume to match 0dB, or? 

How can I tell the waveform that I gained the audiovolume so the waveform show that gain?

Good work Bernd!

/Ken


radio42

  • Posts: 4574
Re: BASS.NET API 2.4.0.4
« Reply #434 on: 29 May '08 - 17:04 »
Hi Ken,

actually the "GetNormalizationGain" simply delivers the gain factor. The idea is to get a value which might be used e.g. with the BASS_BFX_VOLUME DSP to 'normalize' the volume level of a track, so that the maximum peak value matches 0 dB (or represents the maximum value, which is 32767 for 16-bit and 1.0 for 32-bit).

But today the WaveForm itself always stays the same - meaning it can not be adjusted by any gain factor and such it always displays the original sample values.
I might think about adding this features later on, but then it might only be possible to set a gain factor for the WaveForm as a whole and been straight linear.
But I was also wondering about other DSPs (like EQs) etc. - and it seems to be imposible to adjust the WaveForm or only parts of it to those kind of effects (since almost any DSP might change the WaveForm display if it should display 'what-you-hear').
That's why today I stuck with the original sample data being displayed and not implementing any other WYSIWYG stuff.

ken

  • Posts: 739
Re: BASS.NET API 2.4.0.4
« Reply #435 on: 29 May '08 - 19:36 »
OK then it works as I asumed.

A "gain factor" for the waveform would be very nice to have, and as you said it works on the hole waveform, simply enlage it in height.

Another feature would be drawing a fade. Like some soundeditors, when you do a fade on the sound it shows on the waveform. So I set positions for in/out and gain in/out, then the you draw the that part of the waveform after my inputs.

radio42

  • Posts: 4574
Re: BASS.NET API 2.4.0.4
« Reply #436 on: 30 May '08 - 08:03 »
Note, that today you can already set a volume curve on the WaveForm (see AddVolumePoint) - but as said it doesn't reflect such 'fading' in the drawing...I'll think about this in a future release.

ken

  • Posts: 739
Re: BASS.NET API 2.4.0.4
« Reply #437 on: 1 Jun '08 - 14:54 »
Working with waveform in 2.4.0.4. When using seconds in AddMarker, I get strange result.

if I do like this it works great:

StartCue, MixCue and EndCue is a TimeSpan

Code: [Select]


               WF2.ClearAllMarker();

                long _cueinStart = WF2.Frame2Bytes(WF2.Position2Frames(StartCue.TotalSeconds));
                long _cueoutMix = WF2.Frame2Bytes(WF2.Position2Frames(MixCue.TotalSeconds));
                long _cueoutEnd = WF2.Frame2Bytes(WF2.Position2Frames(EndCue.TotalSeconds));


                WF2.AddMarker("Start", _cueinStart);
                WF2.AddMarker("Mix", _cueoutMix);
                WF2.AddMarker("End", _cueoutEnd);

                DrawWave();




But if I fo like this (working with seconds directly) I get a different placement of markers.

Code: [Select]

               WF2.ClearAllMarker();


                double _cueinStart = StartCue.TotalSeconds;
                double _cueoutMix = MixCue.TotalSeconds;
                double _cueoutEnd = EndCue.TotalSeconds;
               
                WF2.AddMarker("Start", _cueinStart);
                WF2.AddMarker("Mix", _cueoutMix);
                WF2.AddMarker("End", _cueoutEnd);

                DrawWave();



radio42

  • Posts: 4574
Re: BASS.NET API 2.4.0.4
« Reply #438 on: 1 Jun '08 - 18:45 »
Hi Ken,

I just figured, that the "Position2Frames(double seconds)" methods was not using the SyncPlayback factor in it's conversion.
So here is an update to try:
www.un4seen.com/filez/4/Bass24.Net_pre.zip

All depends what your values (StartCue, MixCue and EndCue) represent: The position of the rendering waveform or the position of the playback stream you have used with SyncPlayback.
I suggest you always do that later: always use position of the playback stream.
Meaning, once you have created a WaveForm and you are now using a regular playback stream with the WaveForm you should call the "SyncPlayback" method with that playback stream.

Any of the conversion methods now do use this SyncFactor to perform it's conversion!
Which would mean a call like this:
 
Code: [Select]
WF2.Frame2Bytes(WF2.Position2Frames(StartCue.TotalSeconds));would convert it twice - as Position2Frames uses it and Frame2Bytes as well.

So the appropriate methods to use now would be:
"Position2Playback" respectively "Position2Rendering"

Assume the following to set a marker:
Code: [Select]
WaveForm _wf = new WaveForm("test.mp3", ...);
_wf.RenderStart(true, BASSFlag.BASS_DEFAULT);
...
int playback = Bass.BASS_StreamCreateFile("test.mp3"...);
_wf.SyncPlayback(playback);

...
long position = Bass.BASS_ChannelGetPosition(playback)
double posSec = Bass.BASS_ChannelBytes2Seconds(_playback, position);

// now both calls should result in the same position in the WaveForm
AddMarker("A", position);
AddMarker("B", posSec);

OKay, here is some explanation of what's happening inside the various methods:

a) AddMarker(name, seconds)/AddMarker(name, position) always call "Position2Rendering" internally to convert the handed over position to the rendering position of the WaveForm. So AddMarker always assumes you are using playback positions - not rendering positions.

b) GetMarker/GetMarkerSec always call "Position2Playback" internally to return the playback position and not the rendering position.

c) Any convertion method (like Position2Frames, Frame2Bytes, etc.) always use the SyncFactor internally - so make sure to never call them cascaded.

ken

  • Posts: 739
Re: BASS.NET API 2.4.0.4
« Reply #439 on: 1 Jun '08 - 19:18 »
Bernd,

I get same result with the update.  I figure the problem.  I open a saved waveform (from file) drawing the markers from values in my database (TimeSpan).  Then I can edit my cuepoits by changing the TimeSpan and redrawing the markers (by the code I posted before).

That works great in both examples (bytes / seconds) if I don't start playing the stream. but if I have played the stream then the AddMarker (by seconds) don't show correct positions. But works great when using bytes in AddMarker.

I do my playback with SyncPlayback, like this:

Code: [Select]

                    Bass.BASS_StreamFree(_stream);
                    // create the stream
                    _stream = Bass.BASS_StreamCreateFile(FileName, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN);
                    if (_stream != 0)
                    {
                        // used in RMS
                        _30mslength = (int)Bass.BASS_ChannelSeconds2Bytes(_stream, 0.03); // 30ms window
                        // latency from milliseconds to bytes
                        _deviceLatencyBytes = (int)Bass.BASS_ChannelSeconds2Bytes(_stream, _deviceLatencyMS / 1000.0);


                        if (WF2 != null && WF2.IsRendered)
                        {
                            // make sure playback and wave form are in sync, since
                            // we rended with 16-bit but play here with 32-bit
                            WF2.SyncPlayback(_stream);

                            Bass.BASS_ChannelSetPosition(_stream, StartCue.TotalSeconds);

                            long _mixcueSync = WF2.GetMarker("Mix");
                            Bass.BASS_ChannelRemoveSync(_stream, _syncerMixCue);
                            _syncerMixCue = Bass.BASS_ChannelSetSync(_stream, BASSSync.BASS_SYNC_POS, _mixcueSync, _MixCueSync, IntPtr.Zero);

                            long _endcueSync = WF2.GetMarker("End");
                            Bass.BASS_ChannelRemoveSync(_stream, _syncerEndCue);
                            _syncerEndCue = Bass.BASS_ChannelSetSync(_stream, BASSSync.BASS_SYNC_POS, _endcueSync, _EndCueSync, IntPtr.Zero);

                        }
                    }

                    if (FadeIn.TotalMilliseconds > 0)
                        Bass.BASS_ChannelSetAttribute(_stream, BASSAttribute.BASS_ATTRIB_VOL, 0);

                    if (FadeIn.TotalMilliseconds>0)
                        Bass.BASS_ChannelSlideAttribute(_stream, BASSAttribute.BASS_ATTRIB_VOL, 1f, (int)FadeIn.TotalMilliseconds);

                    Bass.BASS_ChannelPlay(_stream, false);


ken

  • Posts: 739
Re: BASS.NET API 2.4.0.4
« Reply #440 on: 1 Jun '08 - 19:24 »
Bernd,

I wrote to soon... With the update AddMarkers (bytes) give me uncorrect positions aslo (but only after I start/stop the stream for playback.  Strange...

/Ken

ken

  • Posts: 739
Re: BASS.NET API 2.4.0.4
« Reply #441 on: 1 Jun '08 - 19:28 »
Hi again...

If I comment and don't use
Code: [Select]
WF2.SyncPlayback(_stream);  then Add.Marker works good, with bytes and seconds.

But then
Code: [Select]
WF2.GetBytePositionFromX don't works as it should...

radio42

  • Posts: 4574
Re: BASS.NET API 2.4.0.4
« Reply #442 on: 1 Jun '08 - 20:00 »
I can't really believe it, as in my tests here it is working just fine.
So what are the values in your DB and/or saved WaveForm - rendered or playback positions?

And have you tried the code I posted before? Did they give you different positions?

ken

  • Posts: 739
Re: BASS.NET API 2.4.0.4
« Reply #443 on: 1 Jun '08 - 20:41 »
The strange this is that it works perfect until I start playing the stream. After that the positions for the markers don't render at the positions the should, and it's a big change in position.

My steps are.

1. I open a mp3 and render the waveform, collectiong cuepoints and saving the waveform to file.
2. Then I open the saved waveform and sets the markers. (as the code I posted)
3. move the markers by altering my cue
4. load the audio and start play. (as the code I posted)


Here is how I render the waveform the first time.

Code: [Select]

           Bass.BASS_StreamFree(_stream);
            _stream = Bass.BASS_StreamCreateFile(_fileName, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN);
           
            if (_stream != 0)
            {
                _FileDuration = TimeSpan.FromSeconds(Bass.BASS_ChannelBytes2Seconds(_stream, Bass.BASS_ChannelGetLength(_stream)));
            }
            // unzoom...(display the whole wave form)
            _zoomStart = -1;
            _zoomStartBytes = -1;
            _zoomEnd = -1;
            _zoomed = false;
           

             WF2 = new WaveForm(FileName, new WAVEFORMPROC(MyWaveFormCallback), null);
            WF2.FrameResolution = 0.01f; // 10ms are nice
            WF2.CallbackFrequency = 2000; // every 30 seconds rendered (3000*10ms=30sec)
         
            WF2.DrawWaveForm = WaveForm.WAVEFORMDRAWTYPE.Stereo;
            WF2.DrawMarker = WaveForm.MARKERDRAWTYPE.Line | WaveForm.MARKERDRAWTYPE.Name | WaveForm.MARKERDRAWTYPE.NamePositionAlternate;
            WF2.MarkerLength = 0.75f;
           
           
            WF2.RenderStart(true, BASSFlag.BASS_DEFAULT);



And in the callback on "finised" I get the cuepoints and save them to my database.

Code: [Select]

               long _cueinStart = 0;
                long _cueoutStart = 0;
                long _cueinEnd = 0;
                long _cueoutEnd = 0;
                long _cueinMix = 0;
                long _cueoutMix = 0;

               WF2.GetCuePoints(ref _cueinStart, ref _cueoutStart, -30f);
                WF2.GetCuePoints(ref _cueinMix, ref _cueoutMix, -15f);
                WF2.GetCuePoints(ref _cueinEnd, ref _cueoutEnd, -92f);

                WF2.AddMarker("Start", _cueinStart);
                WF2.AddMarker("Mix", _cueoutMix);
                WF2.AddMarker("End", _cueoutEnd);

                //Convert to milliseconds for the database.
                double _startCue = (double)(WF2.Frame2Seconds(WF2.Position2Frames(_cueinStart))) * 1000;
                double _endCue = (double)(WF2.Frame2Seconds(WF2.Position2Frames(_cueoutEnd))) * 1000;
                double _mixCue = (double)(WF2.Frame2Seconds(WF2.Position2Frames(_cueoutMix))) * 1000;



radio42

  • Posts: 4574
Re: BASS.NET API 2.4.0.4
« Reply #444 on: 1 Jun '08 - 20:57 »
OKi, that explains all ;-)

So as from your code you save all positions initially in rendered positions (as you are not calling SyncPlayback when calulating the cuepoints).
Meaning all cuepoints calculated reflect positions in a 16-bit stream (as you render in 16-bit).
And such you initial conversions via "Frame2Seconds" or "Position2Frames" do not take any SyncFactor into account.
Also when you initially call "AddMarkers" there is no SyncFactor set and such all positions are saves as rendered position unchanged.

But when you load the saved WaveForm and retrieve the markers again - then you are calling SyncPlayback beforehand!
Meaning now a "GetMarker" will use the SyncFactor and convert the position accordingly.

You can do one of the following:
a) also call "SyncPlayback" before your initially calculate and set any Markers in your 'on finished' callback
b) already perform the rendering in the same resolution as you later will playback the stream

ken

  • Posts: 739
Re: BASS.NET API 2.4.0.4
« Reply #445 on: 1 Jun '08 - 21:01 »
ok I will try that.

But strange is,if I add this code in "play" A and B are not at the same position. Also tested in your "simple" code example.

Code: [Select]

WF2.SyncPlayback(_stream);

                        Bass.BASS_ChannelSetPosition(_stream, 5.0F);

                        long position = Bass.BASS_ChannelGetPosition(_stream);
                        double posSec = Bass.BASS_ChannelBytes2Seconds(_stream, position);

                        // now both calls should result in the same position in the WaveForm
                        WF2.AddMarker("A", position);
                        WF2.AddMarker("B", posSec);


radio42

  • Posts: 4574
Re: BASS.NET API 2.4.0.4
« Reply #446 on: 1 Jun '08 - 21:03 »
I'll double check this!

ken

  • Posts: 739
Re: BASS.NET API 2.4.0.4
« Reply #447 on: 1 Jun '08 - 21:11 »
But this I dont get.

When I load the Waveform from file and do AddMarker, the all markers are at correct positions. All is good.

BUT, after I start playing the stream, and redraw the markers (with same positions) the markers render at very different positions.

Same "bad proportions" as when drawing "A" and "B" from you code.

ken

  • Posts: 739
Re: BASS.NET API 2.4.0.4
« Reply #448 on: 1 Jun '08 - 21:21 »
I tested and doing 16-bit playback (with BASSFlag.BASS_DEFAULT) then all markers work, but...

radio42

  • Posts: 4574
Re: BASS.NET API 2.4.0.4
« Reply #449 on: 1 Jun '08 - 23:59 »
Hi Ken,

you had been totally right! I'm sorry, there had been a little glitch in one conversion routine.
So here is a new update to try:
www.un4seen.com/filez/4/Bass24.Net_pre.zip