0
0

Hello,

I try use fmod (linux) and I’ve problem with volume – it’s too too loud, very bad!

I think problem there is at my way to read data from buf. I do this that:

short int play_data [buffer_size *2];

sound1->readData(play_data, nframes*4, &read);

for (i = 0 ; i < read ; i++)
{
out [0] [i] = play_data [i]; // left channel of server JACK
out [1] [i] = play_data [2*i]; // right channel of server JACK
}

I try some at buff (signed char l, r), etc., but it’s not help. When I send to JACK out [0] and [1] data (PCM) from another audio lib (libsndfile) it’s works OK.

Where is the problem? Tempo is OK, I tryied some diffrent stereo mp3 and wavs, but each time the sound is very loud, very bad, can’t listen that!

Peter

  • You must to post comments
0
0

Hi! Thank you for answer, but still I’m not sure some things. Today I find way to get normal, clear sound (not too loud like yesterday): I move bits, write about this under.
You are right, of course yesterday I maked mistake at my count of bytes, but that wasn’t “a head” of my problem.

So of course when I started work with fmod first I read the documentation (with introduction), but still I don’t understand:

1) if buffer (from readData) looks like:

0 1 2 3 4 5 6 … [samples (frames)]
L R L R L R L R L R L R L R … [channels]
0 1 2 3 4 5 6 7 8 9 0 1 2 3 … [position at buffer from readData = short int = 2 * bytes = 2 * 8?! bits]

and when I read to my buffer (short int buff [buffer_size] – short int has 16 bits = 2 bytes * 8 bits) I must read data this way:

 sound1-&gt;readData(play_data_short, nframes*4, &amp;read);

 for (i = 0 ; i &lt; nframes ; i++) // nframes - frames from JACK, at 44100 there are 2048 per one cycle
      {
      out [0] [i] = (play_data_short [2*i] / 65536.0); // JACK pcm buff L
      out [1] [i] = (play_data_short [2*i+1] / 65536.0); // JACK pcm buff R
      }

so I get:
JACK 0 frame, L = sample 0, L (position 0 at buffer from readData)
JACK 0 frame, R = sample 0, R (pos. 1)
JACK 1 frame, L = sample 1, L (pos. 2)
JACK 1 frame, R = sample 1, R (pos. 3)
JACK 2 frame, L = sample 2, L (pos. 4)
JACK 3 frame, R = sample 2, R (pos. 5)

and this looks clear, but:
a) why I must divide by 65536 (2^16 – move 16 bits?) at each data?
b) each channel has 2 bytes, so:
– I read only one bytes to my short int (2 bytes) at buffer
– or two at one time (0bytes + 256*1bytes)?

2) If sets at:

 fmod_system-&gt;setStreamBufferSize(BUFFER_SIZE, FMOD_TIMEUNIT_PCMBYTES);

make anything at structure of buffer at readData (FMOD_TIMEUNIT_PCMBYTES?) ? If yes how looks that structure?

And this all for this time :-) Thanks again.

Peter

PS.
Thanks for your job and idea to lets used your libs for non-commercial soft. The fmod libs are very friendly: I think it’s very important for programmers, specially for young people who try to start to programmers world. At young people are future! :-)

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.