Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
Error GetPlayPosition

sascha
Registered User
Quote
2011-12-09 00:54:43

Hi All

I have found two bugs or I do something wrong.

First if I use ESOD_DIRECT_SOUND_8 and call getPlayPosition() in a thread after each 25000 it is starting from 0, why?


if I use ESOD_WIN_MM on windows to use ISoundMixedOutputReceiver as callback the pointer on addSoundSourceFromFile(...) return a valid pointer, but if I call getAudioFormat() on the ISoundSource* it is crasing, why?

I hope somebody can help or support me!

Many thanks


niko
Moderator
Quote
2011-12-09 07:44:29

About the 25000 play position wrap: Is your sound longer than 25 seconds? If it's not, it should be the correct value then.

About the crash: are you grab()ing the ISoundSource* pointer to be sure it stays valid? Maybe your sound source has already been deleted in the meantime?


sascha
Guest
Quote
2011-12-09 20:03:36

Hi

Yes, the sound is longer than 6min...

About the pointer I will try again this weekend, to find out some errors in the code.

For me it is more the problem about the trust of the getPlayPosition() function. If i use the ESOD_WIN_MM than the function return always the right value.


niko
Moderator
Quote
2011-12-10 07:43:11

Not sure either, seems to be a bug with the DirectSound driver. I think it works internally with microseconds, and maybe for long sounds, it gets overflown or similar. I'll have a look at that, but don't expect a fix for this soon, better use WinMM then instead.


sascha
Guest
Quote
2011-12-11 18:39:55

HI thanks

I have also a little problem to understand the type of getSampleData().

Is it a ik_u8 or ik_s16?

The problem is getSampleDataSize() return the number of bytes independend of type, for this reaon it should be always a ik_u8.
But if it is right why return the function a void*.

I try the following to get the left channel, but it is crashing:

ik_u8 * data = ik_u8*)m_soundSource->getSampleData();
if ( data == NULL ) return 0;
int fs = m_streamFormat.getFrameSize();
int nn = n*fs;
int cc = 0;
for ( int i = 0 ; i < nn; i+=fs ) {
if ( ESF_U8 == m_streamFormat.SampleFormat ) // one unsigned byte (0;255)
{
ik_u8 d = data[i];
x[cc] = (double) d;
y[cc] = 0.0;
}
else // 16 bit, signed (-32k;32k) little endian
{
short res = (data[i+1]);
res = (data[i] << 8);
x[cc] = (double) res;
y[cc] = 0.0;
}
cc++;
}
return cc;


Can you please make a short example to support me.

Many hanks
Sascha


niko
Moderator
Quote
2011-12-11 21:44:02

Hm, difficult to say. You are sure that x and y are at least of size nn?
And n is set to FrameCount, I guess?


Andreas
Guest
Quote
2011-12-25 12:49:42

To get the data use something like this:

void* data = (void*)m_soundSource->getSampleData();
int cc = GetChannelCount();
int tt = GetSampleDataSize()/cc;
int k = 0;
for ( int i = start ; i <tt; i+=cc )
{
if ( ESF_U8 == m_streamFormat.SampleFormat )
{
val = (double)((ik_u8*)data)[i];
val /= 256.0;
}
else
{
val = (double)((ik_s16*)data)[i];
val /= 32768.0;
}
x[k] = val;
k++;
}


niko
Moderator
Quote
2011-12-26 14:16:01

By just looking at that, seems to be correct. But maybe I don't see the error. Stepping through it using a debugger should easily reveal the error, I guess.


rojart
Registered User
Quote
2014-07-04 22:27:43

sascha wrote:
...
First if I use ESOD_DIRECT_SOUND_8 and call getPlayPosition() in a thread after each 25000 it is starting from 0, why?
...

It's possible to get it working (by me each ~24343 ms)?

I know with ESOD_WIN_MM works well, but i need ISoundEffectControl, too.


rojart
Registered User
Quote
2014-07-06 15:00:19

Ok, it works now, was my fault, sorry!

E_STREAM_MODE was wrong initialized.


gjaegy
Registered User
Quote
2023-07-07 11:31:50

Hi,

I'm facing the exact same issue.

I've observed a noticeable difference in the way the volume of 3D sounds are being handled when using the WinMM backend (basically, the volume increase significantly when crossing the "minDistance" boundary, volume being surprisingly lower in the [0..minDistance] range).

So ideally I would keep using the DirectSound8 backend.

I'm still using 1.5, has this issue been fixed in the latest 1.6 release ?

Thanks for any input !


niko
Moderator
Quote
2023-07-07 13:55:26

No, that's the same in 1.6, sorry.


gjaegy
Registered User
Quote
2023-07-10 12:39:31

OK understood, thanks for the reply.

Any chance you'll be able to fix that issue at some point (I'm afraid we'll have to find a fix for that problem in our software and I would really like to avoid having to integrate another sound library to be honest :/) ?


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internati?nal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact