Author Topic: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)  (Read 878 times)

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #30 on: June 30, 2018, 08:35:57 pm »
The tone editor works for me and the simulator allows me to write my maps, so you could start with those.

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #31 on: June 30, 2018, 09:08:05 pm »
I'm trying a different Mac emulator. Basilisk II maybe just doesn't work I DON'T KNOW

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #32 on: June 30, 2018, 09:41:50 pm »
Interesting.

Tone editor can play the files as expected.
There is this error, though.

https://i.imgur.com/jqELbKK.png?1

https://i.imgur.com/GKgDmPb.png?1

I really don't think there is anything wrong the files. The issue is most likely my code.
It crashes when I use PCM-GFS handle but gives Error 303 when I use PCM-Memory handle after GFS_Load.

I did find out the Sega tools expect the file to have the extension AIFF, I wonder if SBL is the same? No big deal, I can just not-shorten it to AIF, doesn't change anything.
« Last Edit: June 30, 2018, 09:48:02 pm by ponut64 »

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #33 on: June 30, 2018, 10:19:05 pm »
It depends, if you just want to play sound effects and it fits in the sound ram, I could just share with you my implementation.
For streaming, I never tried it besides work ram stream.

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #34 on: June 30, 2018, 10:31:57 pm »
Well, I need* both. Looking at what you have done (assuming it uses SBL PCM!) couldn't hurt, because I can't fathom why this code is not working when compared against Rockin'Bs sound player.
I would hope that I don't need to straight-up copy something, so I say, hold the thought for now.
In time, I expect to get something working. Got to be simple.

/e:
Interesting.
STM handle does not return an error, yet it plays no sound. Very odd.
This time, I have registered the interrupt.
Code: [Select]
void	my_vlank(void){
PCM_VblIn();
//Put gouraud shade table in place
    slGouraudTblCopy();
}
//and in main
slIntFunction(my_vlank);
« Last Edit: June 30, 2018, 11:25:46 pm by ponut64 »

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #35 on: July 02, 2018, 03:00:59 am »
An update:

There's actually a "Pitch" value in SGL sound effects that you can manipulate to play the sound back at different rates.
I did see this before I looked at the Rockin'Bs code, but I hadn't figured out how to manipulate it. I don't think I ever would have, it's really complex.
This unfortunately does not comply directly with a sample rate.

Fortunately Rockin'B has some code that can take an input sample rate, and convert that to an output pitch for SGL sound.
This is pretty dang useful, but it uses double-precision values so the Saturn cannot compute it itself (plus, where would you even know the sample rate?)

To get around that, I just used an online C compiler. With that, I can generate a table of common sample rates and convert those to pitch rates.

Code: [Select]
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define PCM_toPitch(OCT, FNS)   ((FNS & 0x03FF) | ((OCT & 0xF) << 11))
#define PCM_toOCT(pitch)        ((pitch & 0x7800) >> 11)
#define PCM_TIMES   1.000577789
// SOURCE: The Rockin' B, Rockin' B Saturn Libraries, RB_PCM.C, line 766
unsigned short PCM_computePitch(double sampleRate)
{
    double c, s;
    int OCT, FNS;
   
    // Fn = Fo * 2^(n/1200)

    // compute necessary slowdown / speedup
    // assuming a base frequency of 44100 Hz
    // Fn / Fo = 2^(n/1200)
    // with Fo = 44100 Hz, the saturn base sample frequency
    s = sampleRate / 44100.0;
//    printf("s = %f\n", s);
   
    // compute the pitch to this(cents)
//    n = log(s) / log(PCM_TIMES);
    // log2(Fn / Fo) * 1200 = n
    c = (log(s) / log(2)); // * 1200.0;
//    printf("c1 = %f\n", c);
    if(c >= 0) {
        // compute OCT
        OCT = (int)c;
        // compute FNS
        c -= (double)OCT;
       
    } else {
        // compute OCT
        OCT = (int)c;
        if(c < OCT)
            OCT -= 1;
        // compute FNS
        c = c - ((double)OCT);
            // respect to new base frequency
//        s = sampleRate / (44100.0 / (1 - OCT));
            // n is now >= 0
//        c = (log(s) / log(2));
    }
   
    OCT &= 0xF;
//    printf("OCT = %x\n", OCT);
    // compute FNS
    c *= 1200.0;
//    printf("c2 = %f\n", c);
        // remove OCT from cents,
        // it's a seperate value
        // the argument needs to be in range 0 <= a < 1200
//    printf("(c / 1200.0) = %f\n", (c / 1200.0));
//    printf("(double)((int)(c / 1200.0)) = %f\n", (double)((int)(c / 1200.0)));
//    printf("pow arg = %f\n", (c / 1200.0) - (double)((int)(c / 1200.0)));
//    printf("pow() = %f\n", pow(2, (c / 1200.0) - (double)((int)(c / 1200.0))));
    FNS = ((int)(1024.0 * (pow(2, (c / 1200.0) ) - 1.0))) & 0x3FF;
//    printf("FNS = %i\n", FNS);
// interpret
//    return ((int)(1024.0 * (pow(2, c/1200.0) - 1.0))) & (0x3FF + (0xF << 11));
   
    return PCM_toPitch(OCT, FNS);
}


void main(void){
int Rate = 18900;
int Pitch;
Pitch = PCM_computePitch(Rate);
printf("(%i)", Pitch);
}

On this website: https://www.onlinegdb.com/online_c_compiler

You can modify the sound data like this:
   __jo_internal_pcm[(int)channel].pitch = [pitch number];

Table of simple rates:
Code: [Select]
44.10 KHz     0 Pitch
37.80 KHz     (31451) Pitch
30.72 KHz     (31122) Pitch
22.05 KHz     (30720) Pitch
18.90 KHz     (29403) Pitch
16.00 KHz     (29134) Pitch
11.00 KHz     (27643) Pitch
08.00 KHz     (27086) Pitch

With this, you can play sound at any sample rate using SGL.
And I should be able to continue my efforts and forge some sort of sound-streaming system using it.
Well, since I got the SBL STM library to cooperate, maybe? Probably not...

On another note: Why did I finally give up on SBL PCM-ADPCM library?
Well, I got it to run playback code errorless, meaning it did not report an error playing back the sound.
But it did not play any sound, even on real hardware, with the interrupt registered. So I had nowhere left to go. Code was Errorless, crashless code that doesn't work is the worst. And you know that's what most game bugs are...
« Last Edit: July 03, 2018, 11:44:11 pm by ponut64 »

XL2

  • Sr. Member
  • ****
  • Posts: 341
  • Karma: +72/-1
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #36 on: July 02, 2018, 04:23:40 pm »
Something stupid but worth a try : did you set the volume?
Check in Yabause to see if it's playing any sounds in one of the 32 channels.

For the pitch the tone editor fixes it for you more or less.
For all audio I'm only using SBL and it works fine.
In fact SBL documentation is better than SGL's documentation.

As for ADPCM, I haven't tried it as I'm super busy with other things, so I can't really help you ATM.

ponut64

  • Full Member
  • ***
  • Posts: 175
  • Karma: +13/-0
    • View Profile
Re: Doomsday Phrase: undefined reference to "ADP_DecMono" (and stereo)
« Reply #37 on: July 02, 2018, 04:25:45 pm »
Don't worry, I'm going to move forward with SGL. I did set the volume. Did a "rollback" and checked Yabause sound channels, nothing was playing. This isn't for ADPCM either, I've concluded I don't need that (though I do wonder how the ADP_DecMono / ADP_DecStereo functions work).
I've found a solution so now I just have to organize it. If I come back to needing SBL, well, I'll have to try and use a more isolated program to use it.
Thanks for reading.
« Last Edit: July 02, 2018, 04:36:03 pm by ponut64 »

 

Sitemap 1 2 3 4 5 6 7 8 9 10 
SMF spam blocked by CleanTalk