0
0

I think it’s not werry hard, but I’m not able to make this function work :/.

Here is a part of my code:

In my library files:

[code:337v7v9h]
function my_callback (Original_buffer : in void;
New_Buffer : in void;
Length : in Integer;
Param : in Integer) return void is
begin
return New_Buffer;
end my_callback;[/code:337v7v9h]
[code:337v7v9h]


— DSP —


type FSOUND_DSPUNIT is new Long_Integer;
— type FSOUND_DSPCALLBACK is access Long_Integer;

type Spectrum_array is array(1..512) of Interfaces.c.C_float;

— type void is null record;
type void is access procedure;
type FSOUND_DSPCALLBACK is access function (Original_buffer : void;
New_Buffer : void;
Length : Integer;
Param : Integer) return void;
null_callback : FSOUND_DSPCALLBACK := null;[/code:337v7v9h]

and in my main function:

[code:337v7v9h]procedure test is
pragma Linker_Options (“-lfmod”);
tampon : float;
tampon2 : boolean;
tampon3 : character := ‘ ‘;
tampon4 : integer;

stream : FSOUND_STREAM;
stream2 : FSOUND_STREAM;
channel : integer;
channel2 : integer;
surround : boolean := false;
sample : FSOUND_SAMPLE;
— my_callback : callback;
— bidon : void;
my_array : Spectrum_Array := (1..512 => 0.0);
dsp, dsp2 : FSOUND_DSPUNIT;

–function my_callback (Original_buffer : in void;
— New_Buffer : in void;
— Length : in Integer;
— Param : in Integer) return void is
–begin
— return New_Buffer;
–end my_callback;
p_mycallback : FSOUND_DSPCALLBACK := my_callback’access;

begin
...
[/code:337v7v9h]

and
[code:337v7v9h]
tampon2 := FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
tampon2 := FSOUND_SetDriver(FSOUND_DRIVER_DEFAULT);
tampon2 := FSOUND_Init(44100, 32, FSOUND_INIT_USEDEFAULTMIDISYNTH);
stream := FSOUND_Stream_OpenFile(“D:\ANIMES – dossier secondaire\OST\Cowboy Bebop (Vitaminless)\15 – Rain.mp3”, FSOUND_LOOP_NORMAL, 0);
channel := FSOUND_Stream_Play(FSOUND_FREE, stream);
tampon2 := FSOUND_SetSurround(channel, surround);
tampon2 := FSOUND_Stream_SetBufferSize(300);
Put_Line(Integer’Image(FSOUND_GetMaxChannels));
[/code:337v7v9h]

and
[code:337v7v9h]
dsp := FSOUND_DSP_CREATE(p_mycallback, 400, 0);
FSOUND_DSP_SetActive(dsp);
dsp2 := FSOUND_DSP_GetFFTUnit;
FSOUND_DSP_SetActive(dsp2);
my_array := FSOUND_DSP_GetSpectrum;
for Index in spectrum_array’range loop
If my_array(Index) /= 0.0 then
put(Integer’Image(Index));
put(“.”);
end if;
end loop;[/code:337v7v9h]

so, If the GetSpectrum function is ok, I must have a lot of value differents of 0.0, no ? Have I forgot an important function or what ?

  • You must to post comments
0
0

Then the algo’s ok… Thank you verry much, I’m going to rewrite this part of my bindings, until that work ^^.

  • You must to post comments
0
0

Ok, It work now. It was a bad import of the buffer’s type. (The void pointer dont exist un Ada, then I use a char* pointer. I know it’s a char* pointer because of the memcpy function used to it in the minifmod source code :) ). Thanks to all who have help me ๐Ÿ˜€

  • You must to post comments
0
0

i’m not quite sure which programming language you are using, but i maybe able to help:
it looks like you are activating the FFT unit directly before you get the spectrum. this can only produce wrong results. i’m not sure if it has to be activated before any sound is played or if it can be “hot-plugged”, but since the fft unit it is just a dsp module it has a response time of up to 25ms when it is enabled while playing sound.
so, activate the fft unit before you start playing your stream/sound, and it should work just fine.
also, create some if’s to check for errors after the various fmod api calls.

  • You must to post comments
0
0

Well, thank for your response.
The langague is ADA95, FMOD isn’t already supported by this langague but I’m actually programming the Imports :P. That’s “like” C++, with, for example:

c++ – ADA95
= :=
// —

etc…

In fact, I’m not sure that I use the DSP Units on the good way.

Here is a new code, created with yours indications:

[code:buvvl6mp]
tampon2 := FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);
tampon2 := FSOUND_SetDriver(FSOUND_DRIVER_DEFAULT);
tampon2 := FSOUND_Init(44100, 32, FSOUND_INIT_USEDEFAULTMIDISYNTH);

        dsp := FSOUND_DSP_CREATE(p_mycallback, 400, 0);
        FSOUND_DSP_SetActive(dsp);
        dsp2 := FSOUND_DSP_GetFFTUnit;
        FSOUND_DSP_SetActive(dsp2);

stream := FSOUND_Stream_OpenFile("D:\ANIMES – dossier secondaire\OST\Cowboy Bebop (Vitaminless)\15 – Rain.mp3", FSOUND_LOOP_NORMAL, 0);
channel := FSOUND_Stream_Play(FSOUND_FREE, stream);
tampon2 := FSOUND_SetSurround(channel, surround);
tampon2 := FSOUND_Stream_SetBufferSize(300);
Put_Line(Integer’Image(FSOUND_GetMaxChannels));[/code:buvvl6mp]

then a big loop scanning the keyboard, and:
[code:buvvl6mp]
when ‘D’ =>
— dsp := FSOUND_DSP_CREATE(p_mycallback, 400, 0);
— FSOUND_DSP_SetActive(dsp);
— dsp2 := FSOUND_DSP_GetFFTUnit;
— FSOUND_DSP_SetActive(dsp2);
my_array := FSOUND_DSP_GetSpectrum;
for Index in spectrum_array’range loop
If my_array(Index) /= 0.0 then
put(Integer’Image(Index));
put(“.”);
end if;
end loop;[/code:buvvl6mp]

You can see that I’ve desactived the 4 firsts code rows because I’ve added they at the start of the program.

But it dosen’t work too. I’ve alway a full of 0.0 array…

I think I must have a bad Import, but the compiler dont think that, and I will be sure that I use the function by the good way.

Else, can you give me a little-little source code, who only open a file, get the Spectrum in a array and close the file ? Then I can compare they by my own…

  • You must to post comments
0
0

brett’s right, i’ve overseen that one.

[quote:31kt4hky]Else, can you give me a little-little source code, who only open a file, get the Spectrum in a array and close the file ? Then I can compare they by my own…[/quote:31kt4hky]

actually, i dont have any such source code :)
i’m currently writing my own fft unit that gets the spectrum for me, but i’m still researching how to do it best.
but i think there is an example shipped with fmod that shows how to get a spectrum.

  • You must to post comments
0
0

[quote="brett":1hqbd8fh]dsp2 := FSOUND_DSP_GetFFTUnit;
FSOUND_DSP_SetActive(dsp2);

where is your TRUE or FALSE parameter here? you’re probably not even activating it. Also why are you creating a DSP unit of your own.[/quote:1hqbd8fh]

I’ve forgot to say that he’s TRUE by default. Try again ๐Ÿ˜‰

  • You must to post comments
0
0

try setting FSOUND_SetMaxHardwareChannels to 0 and specify FSOUND_2D when opening the stream, to ensure it is not played in a hardware channel (thereby bypassing the dsp chain).
assuming you are using windows:
test if some other mp3 or some .wav is working with the spectrum; I read on the forum that when the mp3 file has an unknown header/id3/id3v2 tag, the decoding job is done by directx, which bypasses the dsp chain as well.

  • You must to post comments
0
0

[quote="Bomber-Marc":2n2p3u9h]
tampon : float;
tampon2 : boolean;
tampon3 : character := ‘ ‘;
tampon4 : integer;
[/quote:2n2p3u9h]

I’m wondering why you use the word tampon? This has nothing to do with your question I was just wondering.

  • You must to post comments
0
0

yop,

for the “tampon” : I’ve just copy my declarative part, and “tampon” is just a temporary name…

And I don’t think it’s realy a problem with Ada, because gcc (the compilator) may compile c and c++ too. But it can be a problem with my bindings, I know. But, if i can use this function without problem with c or c++, i can make that with Ada too. That’s why i want a little (simple) example. If it’s in c or c++ it’s ok, I’ve a big c++ reference ๐Ÿ˜‰

  • You must to post comments
0
0

A little example won’t help you.
If I’d translate your ada code into c++ it would work, because you use fmod the right way in your sources. It has to be a problem with the language or your bindings.

  • You must to post comments
Showing 10 results
Your Answer

Please first to submit.