Need help with DTS file conversion!

Started by siggi,

siggi

#25
Sorry Ian,
but I still don't understand!

Using the BASS_DTS_StreamCreateFile directly would mean that the SetStream call is already
present in the DLL?
Because in that case the file gets freed... ???

And what about the incorrect length returned by BASS_ChannelgetLength on a channel created by BASS_DTS_StreamCreateFile?

siggi

News for all helpers!

Today beside of many tests I decided to compare bytesize returned from BASS_ChannelGetLength
with the file size, searching for patrons.
For this I deleted the Ape TAGs written before to some of the DTS files.
I made a lot of calculations but I could not find any patrons.

Later on I started my AudioZip and wth great surprise all length and positions were
suddenly correct...

So it's clear what caused the problem working with BASS_DTS_ChannelCreateFile!

Now I have to discover why BASS_ChannelGetLength includes the TAG size to the bytesize.
It should not and does not happen with other formats.

I read that DTS needs APE TAGs Right?
It can also be that they are not correctly written...
But Tagging and deleting works well even with covers.

This did a big turn!

Next I'll try again converting and splitting DTS.

Ian @ un4seen

Quote from: siggiSorry Ian,
but I still don't understand!

Using the BASS_DTS_StreamCreateFile directly would mean that the SetStream call is already
present in the DLL?
Because in that case the file gets freed... ???

Yes, as you can see here, BASS_DTS_StreamCreateFile is calling SetStream (which associates the file with the stream), while BASS_DTS_StreamCreate (used by the plugin system) isn't:

    https://github.com/pudding-fox/BASS_DTS/blob/37604669600bcdd64478fdbb5718a47a2f6dd299/bass_dts/bass_dts.c#L117

Basically, you shouldn't load the current BASS_DTS version via BASS_PluginLoad. Only use BASS_DTS_StreamCreateFile with DTS files.

Quote from: siggiAnd what about the incorrect length returned by BASS_ChannelgetLength on a channel created by BASS_DTS_StreamCreateFile?

I'm afraid I'm not sure about that. I guess it's one of these calculations that's going wrong, but I'm not familiar enough with it to say which/why:

    https://github.com/pudding-fox/BASS_DTS/blob/37604669600bcdd64478fdbb5718a47a2f6dd299/bass_dts/bass_dts.c#L170
    https://github.com/pudding-fox/BASS_DTS/blob/37604669600bcdd64478fdbb5718a47a2f6dd299/bass_dts/dts_file.c#L252

Quote from: siggiToday beside of many tests I decided to compare bytesize returned from BASS_ChannelGetLength
with the file size, searching for patrons.
For this I deleted the Ape TAGs written before to some of the DTS files.
I made a lot of calculations but I could not find any patrons.

Later on I started my AudioZip and wth great surprise all length and positions were
suddenly correct...

If the "FALSE" in this line is changed to "TRUE" then BASS will read APE tags from the file, which should then mean they get excluded from BASS_DTS's length calculation:

    https://github.com/pudding-fox/BASS_DTS/blob/37604669600bcdd64478fdbb5718a47a2f6dd299/bass_dts/bass_dts.c#L108

Unread tags could indeed explain length calculation problems with some files, but these ones you linked earlier don't seem to have any tags:

    https://github.com/pudding-fox/BASS_DTS/tree/main/Media

Are you suddenly getting the correct length for them too?

siggi

Hi Ian,
Ok I now understand the plugin system better.

I added before myself the Ape TAGs also to files from pudding-fox and later deleted them
with a tagging library that I use for Ape files and wav too without any problem.

Now I get the exact length for each DTS even for that with a pcm/wav header!
That's ok. I still load the BASS_DTS version via BASS_PluginLoad.
As you recommend I will stop doing this.

Quote from: Ian @ un4seenIf the "FALSE" in this line is changed to "TRUE" then BASS will read APE tags from the file, which should then mean they get excluded from BASS_DTS's length calculation:

How could I do this?
I have no access to the DLL and I'm Delphi User.
I opened all links you supplied

Maybe I could use the offset in BASS_DTS_StreamCreateFile with the TAG size,
but then I must read the TAG before creating the stream...

Chris

#29
So here is a New Compile (C++13)  for testing.
I have modified the Suggests from Ian.
1:) adding the missing "file.SetStream" Call so if you are now working with the Plugin System, now the DTS Stream will freeing fine.
2:) Changing the  "bassfunc->file.Open(mem, file, offset, length, flags, FALSE);
  to  "bassfunc->file.Open(mem, file, offset, length, flags, TRUE)
  so that the StreamGetLength Function will APE-Tags excluded from BASS_DTS's length.
So test it and let me now if all now will working.

siggi

Hi Chris,

That sounds great!
I can test it this evening.

So, are you the creator of BASS_DTS?

Chris

#31
No I´m normally a Delphi Coder.(started 1998 with Delphi 4)

It's not a big deal to download the C++ source from git, make the changes of 2 Lines and recompile it.

siggi

Hi Chris,

Party time!
I can't thank you enough for the new DLL!
And the same too for Ian's great help!

I could not have solves this by my own.

Everything playing DTS now works perfect!

I still have some problems with converting DTS to APE and the predicted output sizes
for conversion in general.
But I think I can solve this! Still work left with the DTS support...

Thanks to you all, great job!

Ian @ un4seen

Good to hear those little changes fixed your troubles. I'll try contacting the BASS_DTS developer to get them made official.

siggi

#34
Back again,
having still troubles with DTS!

I called too early for party time  :-[ !
The byte length returned from BASSS_Getlength is truely NOT correct for DTS.

This needs a longer explication...

I did not recognize it at first, just seeing the supposed correct play time..
But the play times are not real!

I first was confused after encoding to MP3 and getting their play times longer as those of
the DTS files.
So finally I decided to measure the real play time of each file by using a timer and displaying it
in format H:M:s.ms and comparing it to those from other players too.

The results are very interesting:
AZ = AudioZip(my App)
VLC = Win10 version
BS = BSPlayer Win10 version

        SampRate/Channels               AZ displayed  AZ measured diff./s.ms  VLC    BS
file 1  44100/6 PCM/WAV Header   2:47.021        2:46.640          ok            2:47   2:47
file 2  46000/6                                 6:45.600        6:52.219           6.619       6:52   6:45
file 3  96000/6                                 4:22.048        4:26.250           4.166       4:26   4:22
file 4  44100/6                                 2:18.507        2:37.828          19.321  !!  2:38   2:18
file 5  44100/2                               12:08.084       12:07.625          ok         12:08  12:08

Resuming:
There are no problems with file 1 + 5 ! Some milliseconds Don't matter.
The measured play times are notably different for the other files!
VLC handles them well, displaying and progress bar correct!
BS shows the wrong play times as AZ does, and both keep playing on the complete files after
the progress bar has reached the end!
This behaviour I had not noticed before, took a lot of research and trying to get these detailed dates.

So the channel created by BASS_DTS_StreamCreateFile containes the complete bytes as playback is complete.
The GetLength function does NOT return the correct byte length, as my Progress Bar receives the
length as maxvalue and so the progress indication is not correct! The same for the diplayed play time!

Besides the wrong indication of play time, the problem gets even bigger for converting and splitting DTS.
BASS_EncodeStartLimit can not be used as the calculated limit is wrong! Files got cut!
The Ape codec (mac.exe) gave a valid file when giving half of the byte length as limit.
Giving the full length as limit returns invalid APE files.
BASS_EncodeStart does it well for all codecs but the Ape codec still not works!


I tried all possible modes and flags and even updated BASS, bassenc, and bassmixer to the latest versions.
Tried some new flags too.
No difference between using the plugin system or not, using BASS_DTS_SteamCreateFile or
BASS_StreamCreateFile.

Well, I'm stucked again!
Any suggestions?




siggi


Chris

#37
So, the BASSDTS Developer has Fixed the "Length" Error.
Here is a new Compile. I have tested it with different Files looks good.

siggi

Hey Chris,

You are the best!  :D

I'll test it this afternoon!

siggi

Hi again,
Just tried the new DLL

Yes, the length is now correct for all files!
But, I have new problems now with advancing playback with my progress bar!

Just wrote to pudding_fox and explained it there.
It's really weired as there are only envolved Get/SetPosition functions which worked fine
before the last changes made on Bass_DTS!

There must be more to do, I am more and more confused with that DTS format,
but I'm not a specialist in that audio format!

Pudding should solve that!

Chris

#40
Ok I find the Error why the SetPosition not will work.
but I`m not Shure why the //if (mode == BASS_POS_BYTE) will failed.
I send to Bass_BASS_ChannelSetPosition(chan, ScrollPos, BASS_POS_BYTE )
but here comes
QWORD WINAPI BASS_DTS_SetPosition(void* inst, QWORD position, DWORD mode)The return of the mode is 16777216 ?
old (not working) Code
QWORD WINAPI BASS_DTS_SetPosition(void* inst, QWORD position, DWORD mode) {
    DTS_STREAM* dts_stream = inst;
    if (mode == BASS_POS_BYTE) {
       
        QWORD offset = position / dts_stream->channel_count;
       
        if (offset > dts_stream->dts_file->info.length) {
            offset /= 2;
        }
        if (dts_file_seek(dts_stream->dts_file, offset, DTS_FILE_SEEK_POSITION)) {
            //If the seek succeeded then throw away any already decoded samples.
            if (dts_stream_reset(dts_stream, TRUE)) {
                return position;
            }
        }
    }
    errorn(BASS_ERROR_NOTAVAIL);
}

@ Ian
After removing the "if (mode == BASS_POS_BYTE" it will working fine.
Maybe Bass self will change something in the internal Variable mode ?`



@ Siggi here is a FAST FIX for testing.
Best regards Chris



Ian @ un4seen

Quote from: Chris@ Ian
After removing the "if (mode == BASS_POS_BYTE" it will working fine.
Maybe Bass self will change something in the internal Variable mode ?`

That "mode" check can indeed be removed from BASS_DTS_SetPosition, but the check in BASS_DTS_CanSetPosition needs updating to ignore flags (BASS_POS_FLUSH/INEXACT/etc), like this:

    if ((BYTE)mode == BASS_POS_BYTE) {

Chris

#42
@ Ian great -> ((BYTE)mode == BASS_POS_BYTE) ...  that was it.!!




siggi

Ok, finally the GetLength and SetPosition both work correctly!

Many many thanks to Chris and Ian!

It feels very comfortly to receive dedicated true help!

siggi

Can I mark this thread as solved?
Don't see no option...

diystar

#46
The latest release on github, setposition is not correct.

Chris

#47
can you explained a little bit more what specially  isn't correct?
Are you using inside the SetPosition Call any special Flags?