ObjReader Community

WIP => WIP => Topic started by: Patrice Terrier on October 09, 2019, 07:46:04 pm

Title: OR audio (Bass.dll)
Post by: Patrice Terrier on October 09, 2019, 07:46:04 pm
Here is the ZIP file to sync your code with mine.


#playaudio Back_to_Amiga_roots_(1992).mod 50 loop

Audio extension supported: ".mp3.wav.ogg.aif.mo3.it.xm.s3m.mtm.mod.umx."

To ease sync, search the code for:
// 10-09-2019 Bass.dll
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 09, 2019, 10:52:45 pm
Thank you Patrice,

I will study your code tomorrow and will come back with my impressions.
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 10, 2019, 02:05:51 pm
Patrice,

Your mobj.h contains traces of a "concentric rotation flag", which is evidently implemented as rotate[8]. I don't remember very well what it is (probably it was some latest request of yours that I didn't reimplement in my code). Can you send me your renderers.h, globals.h and any other files that might utilize this feature?
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 10, 2019, 03:05:40 pm
Here they are.

See Test.zip for an example of use.
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 10, 2019, 08:43:05 pm
I've got your mods to recompile correctly in my project.

Now I'm waiting for a test model to try out the new playaudio feature. :)
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 10, 2019, 08:54:55 pm
Try the attached audio with this one:
http://www.objreader.com/index.php?topic=22.msg2428#msg2428
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 10, 2019, 09:07:57 pm
Here is a small collection of free audio samples.

You can drop them all on MBox64, to select those that fit your taste ;)
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 10, 2019, 09:10:40 pm
I added the audio #meta to the material file as follows:

Code: [Select]
#wallpaper @background.jpg
#playaudio trongrid.ogg 50 loop
........

and then I put TronGrid.ogg in the Tron model folder, and bass.dll, in the \x64\Release\ folder alongside ObjReader64.exe.

My ObjReader crashes when trying to load the Tron model.

What am I doing wrong?

P.S. And why there is a renderers.zip in the TronGrid archive?
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 10, 2019, 09:17:39 pm
Also, I have a call to gl_LoadBackgrounds() in my void backToStaticBkgnd() in shaders.h. What bReset flag are you using there?
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 10, 2019, 09:18:12 pm
The renderer.zip include with the audio was a mistake.

It looks like there is a problem with stream, i shall have to investigate.
(works well with music)
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 10, 2019, 09:24:56 pm
Please take your time. It all can wait till tomorrow. :)
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 10, 2019, 09:25:26 pm
    case MENU_ANI_BKGND: // MLL 06-01-2019: ani backgrounds
        gP.bAniBkgnd = !gP.bAniBkgnd;
        if (gP.bAniBkgnd) {
            dwStyle = MF_CHECKED;
            resetCurAniShader();
            parseAniShader(L"voronoi.fs"); // default
            if (!gl_LoadAniBackgrounds(GetDlgItem(gP.hMain, IDC_LISTBOX))) {
                CheckMenuItem(gR.hAniMenu, MENU_ANI_BKGND, MF_UNCHECKED);
                EnableMenuItem(gR.hAniMenu, MENU_ANI_BKGND, MF_GRAYED);
                break;
            }
            gP.tCurAniBkgndShader.nShaderID = glsl_LoadShaderFromFile("voronoi.fs");
            rAniStart = GetTickCount64() / 1000.0f;
            StartSync();
        } else {
            dwStyle = MF_UNCHECKED;
            gl_LoadBackgrounds(GetDlgItem(gP.hMain, IDC_LISTBOX), TRUE); // PAT 09-09-2019 use TRUE to restore the current wallpaper rather than "back02.jpg"
            resetCurAniShader();
            //if (!(gP.bGiration | gP.bUseFPS | gP.bAnimateLights | gP.bRotation | gP.bIsLerping))
            //    StopSync(SYNC_OFF);
        }
        CheckMenuItem(gR.hAniMenu, MENU_ANI_BKGND, dwStyle);
        gP.bRedraw = TRUE; // Redraw the OpenGL scene
        break;
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 10, 2019, 09:28:40 pm
No, I need the call to gl_LoadBackgrounds() in the void backToStaticBkgnd() function in shaders.h!

Do you have such a function at all?
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 10, 2019, 09:39:34 pm
Indeed #playaudio trongrid.ogg 50 loop
causes an error in Mobj.h there

        case 't': // Tr
            switch (szBuffer[1]) {
            case 'r': // Tr
                if (pMaterial->alpha == 1.0f) { // 12-06-2015 ML: only if alpha is still default
                    fscanf(pFile, "%f", &pMaterial->alpha);
                    if (pMaterial->alpha > 0.0f) {
                        pMaterial->alpha = 1.0f - pMaterial->alpha; // 12-06-2015 ML: follow OBJ specs
                    }
                    if (pMaterial->alpha == 0.0f) { pMaterial->alpha = 1.0f; } // 02-05-2016
                } else {
                    fgets(szBuffer, sizeof(szBuffer), pFile); // 12-06-2015 ML: ignore
                }
                break;


Because of the use of "Tr" go figure !!!


Quote
No, I need the call to gl_LoadBackgrounds() in the void backToStaticBkgnd() function in shaders.h!

void backToStaticBkgnd() { // MLL 06-10-2019:
    BKSHADER* cs = &gP.tCurAniBkgndShader;

    gP.bAniBkgnd = FALSE;
    CheckMenuItem(gR.hAniMenu, MENU_ANI_BKGND, MF_UNCHECKED);
    if (cs->nShaderID) {
        for (int idx = 0; idx <= 3; idx++) {
            if (cs->samplerMapID[idx]) {
                glActiveTexture(GL_TEXTURE0 + idx);
                glBindTexture(GL_TEXTURE_2D, 0);
                glDisable(GL_TEXTURE_2D);
            }
        }
        resetCurAniShader();
        glActiveTexture(GL_TEXTURE0);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_LIGHT0);
    }
    gl_LoadBackgrounds(GetDlgItem(gP.hMain, IDC_LISTBOX), FALSE);

    gP.bRedraw = TRUE;
    gl_DrawScene();
}

Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 10, 2019, 09:43:17 pm
Thank you Patrice!

Renaming the OGG file to Grid.ogg...
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 10, 2019, 09:48:05 pm
Now it works fine! But the audio and background aren't killed and reset, respectively, on clicking the File->Close all and clear scene menu... ???
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 10, 2019, 09:48:23 pm
Quote
Renaming the OGG file to Grid.ogg...
Yes, but we must protect us against it anyway
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 10, 2019, 09:50:37 pm
Quote
File->Close all and clear scene menu
I never used it until now, easy to fix
add a BassCloseChannel()
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 10, 2019, 09:53:01 pm
Re. protection: who does the appropriate protection, you or me? ;)

Re. fix: should be somewhere at the beginning of the function, I presume?


But the overall effect is very, very good! Thanks a lot for this enhancement! :)
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 10, 2019, 10:00:44 pm
There is another problem

Try to use "Reload model" after that a "Close and clear scene" has been performed.
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 10, 2019, 10:07:28 pm
This isn't a problem but a feature. ;)

Clearing everything also clears the memory about the last model loaded.

Reloading the model is primarily meant for actualizing the most recent changes to its materials, maps, and geo.
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 10, 2019, 11:07:54 pm
I did this to protect the code in mobj.h starting form line 1079
but i am unsure that it is the best way to do it.

    // Load the materials in the MTL file.
    while (fscanf(pFile, "%s", szBuffer) != EOF) {
        CharLowerA(szBuffer);
        if (strcmp(szBuffer, "#playaudio") == 0) {           // 10-10-2019 Bass.dll (we must ignore this meta there)
            s1[0] = 0; s2[0] = 0; s3[0] = 0;
            fgets(szBuffer, sizeof(szBuffer), pFile);
            sscanf(szBuffer, "%s %s %s", s1, s2, s3);
        }
        switch (szBuffer[0]) {
        case 'n': // Ns
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 11, 2019, 12:10:44 am
Alternatively,

........
        case 't': // Tr
            switch (szBuffer[1]) {
            case 'r': // Tr
                if (szBuffer[2] == 32 || szBuffer[2] == 9) { // MLL 10-10-2019: Tr should always be followed by a space or tab
                    if (pMaterial->alpha == 1.0f) { // 12-06-2015 ML: only if alpha is still default
                        fscanf(pFile, "%f", &pMaterial->alpha);
                        if (pMaterial->alpha > 0.0f) {
                            pMaterial->alpha = 1.0f - pMaterial->alpha; // 12-06-2015 ML: follow OBJ specs
                        }
                        if (pMaterial->alpha == 0.0f) { pMaterial->alpha = 1.0f; } // 02-05-2016
                    } else {
                        fgets(szBuffer, sizeof(szBuffer), pFile); // 12-06-2015 ML: ignore
                    }
                }
                break;
........


This way the style of existing code is preserved.

8)

P.S. And I also think that every two-letter case for the other parameters should be supplied with such a sanity check... ::)
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 11, 2019, 09:03:55 am
My friend

Indeed i think that we must protect for all the cases, this i the reason why i made the test before the switch.

To follow what you suggested here:
Re. fix:
Quote
should be somewhere at the beginning of the function, I presume?

and avoiding code duplication for each two letter-case of the other parameters.

I have attached the Version_2_80.zip sync, just to make sure that we are both using the same latest changes.

Shall we release this version as the new official one, to be able to add audio in the new material files?
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 11, 2019, 01:48:23 pm
Patrice,

Thank you for the code!

1. Don't you think that checking only a few scarce enough two-letter abbreviations (Tr, Ns, Ka, Kd, etc.) for just one space byte after them will be much faster than checking every line in the .MTL file for a multibyte #playaudio char sequence, and thus worthy of code duplication?

2. I have added much code to my selectable MSAA/CSAA/FXAA option but it isn't either complete or fully tested yet, nor does it go well with the PP options ATM that are also far too few for a sterling release.

So if all that code is still not used then yes, we can publish another intermediary release that won't be a major one until both AA and PP options are fully complete... ???
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 11, 2019, 03:26:30 pm
Quote
1. Don't you think that checking only a few scarce enough two-letter abbreviations (Tr, Ns, Ka, Kd, etc.) for just one space byte after them will be much faster than checking every line in the .MTL file for a multibyte #playaudio char sequence, and thus worthy of code duplication?

Then please could you make the change for me, because i am currently working on a WinDev demo project that i would like to complete first.
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 11, 2019, 06:20:50 pm
OK I'll do that tomorrow if you don't mind.
Title: Re: OR audio (Bass.dll)
Post by: Michael Lobko-Lobanovsky on October 13, 2019, 08:05:19 am
Patrice,

If you want to release your code as v2.80, please send me the entire set of your files for sync'ing, not just these few. There may be more differences in our code elsewhere. It's been a long time indeed since we merged last.

TIA
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 13, 2019, 09:26:07 am
Here they are, within distinct ZIP files inside of SYNC.zip
Title: Re: OR audio (Bass.dll)
Post by: Patrice Terrier on October 24, 2019, 05:42:29 pm
I plan to release animated backgrounds altogether with audio, in version #2.80, to have only one version to manage, do you have any fixup to apply befeore i publish the new official version?