0
0

Hi! can someone help me why i getting unsupported file or audio format error?

[code:2mg4e5sv]
QString file = QFileDialog::getOpenFileName(this, tr("Open file"));
qDebug() << "loading file: " << file;
result = system->createSound(file.toStdString().c_str(),FMOD_LOOP_NORMAL,NULL,&sound1);
errorcheck(result);
qDebug() << "loading complete";
system->update();

float freq;
FMOD_SOUND_FORMAT format;
int channels,bits;
unsigned int lenMs, lenPcm, lenPcmBytes;
sound1-&gt;getDefaults(&amp;freq, 0, 0, 0);
sound1-&gt;getFormat(0, &amp;format, &amp;channels, &amp;bits);
sound1-&gt;getLength(&amp;lenMs,       FMOD_TIMEUNIT_MS);
sound1-&gt;getLength(&amp;lenPcm,      FMOD_TIMEUNIT_PCM);
sound1-&gt;getLength(&amp;lenPcmBytes, FMOD_TIMEUNIT_PCMBYTES);

qDebug() &lt;&lt; &quot;freq: &quot; &lt;&lt; freq;
qDebug() &lt;&lt; &quot;format: &quot; &lt;&lt; format;
qDebug() &lt;&lt; &quot;channels: &quot; &lt;&lt; channels;
qDebug() &lt;&lt; &quot;bits: &quot; &lt;&lt; bits;
qDebug() &lt;&lt; &quot;lenMs: &quot; &lt;&lt; lenMs;
qDebug() &lt;&lt; &quot;lenPcm: &quot; &lt;&lt; lenPcm;
qDebug() &lt;&lt; &quot;lenPcmBytes: &quot; &lt;&lt; lenPcmBytes;

FMOD_CREATESOUNDEXINFO exinfo2;

memset(&amp;exinfo2, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo2.cbsize            = sizeof(FMOD_CREATESOUNDEXINFO);              /* required. */
//exinfo2.decodebuffersize  = freq;                                       /* Chunk size of stream update in samples.  This will be the amount of data passed to the user callback. */
exinfo2.length            = lenPcmBytes; /* Length of PCM data in bytes of whole song (for Sound::getLength) */
//exinfo2.numchannels       = channels;                                    /* Number of channels in the sound. */
//exinfo2.defaultfrequency  = freq;                                       /* Default playback rate of sound. */
//exinfo2.format            = FMOD_SOUND_FORMAT_PCM16;                     /* Data format of sound. */
//exinfo2.pcmreadcallback   = pcmreadcallback;                             /* User callback for reading. */
//exinfo2.pcmsetposcallback = pcmsetposcallback;                           /* User callback for seeking. */

void  *pointer1;
void  *pointer2;
unsigned int length;
unsigned int length1;
unsigned int length2;

result = sound1-&gt;getLength(&amp;length, FMOD_TIMEUNIT_PCM);
errorcheck(result);
qDebug() &lt;&lt; &quot;length&quot; &lt;&lt; length;

// lock the buffer
result = soundPlay-&gt;lock(0, length, &amp;pointer1, &amp;pointer2, &amp;length1, &amp;length2);
errorcheck(result);
qDebug() &lt;&lt; &quot;lock&quot;;
//std::string temp = &quot;&quot;;
QString temp = &quot;&quot;;
qint16* dataPtr = (qint16*)pointer1;
for (int j = 0; j &lt; (int)length; j++)
{
    temp.append(QString(&quot;%1&quot;).arg(dataPtr[j]));
}
result = sound1-&gt;unlock(pointer1, pointer2, length1, length2);
errorcheck(result);
qDebug() &lt;&lt; &quot;unlock&quot;;

qDebug() &lt;&lt; &quot;loading file from temp&quot;;
//qDebug() &lt;&lt; temp.toStdString().c_str();
result = system-&gt;createSound(temp.toStdString().c_str(), FMOD_OPENMEMORY ,&amp;exinfo2,&amp;sound2); //THE ERROR IS HERE
errorcheck(result);
qDebug() &lt;&lt; &quot;loading complete&quot;;
qDebug() &lt;&lt; &quot;try to play&quot;;
result = system-&gt;playSound(FMOD_CHANNEL_FREE,sound2,false,&amp;channel2);
errorcheck(result);
qDebug() &lt;&lt; &quot;playing&quot;;

[/code:2mg4e5sv]

THX

  • You must to post comments
0
0

Can you link with the logging version of FMOD and provide the fmod.log output.

  • You must to post comments
0
0

i solve the problem but now the new problem is some files played normali and some play only a few sec
i think i need a read callback and a seek callback but i have no idea how they work :S time for rtfm ๐Ÿ˜€

and the current code:
[code:1o2sq7wh]
result = FMOD::System_Create(&system);
errorcheck(result);

unsigned int version;
result = system-&gt;getVersion(&amp;version);
errorcheck(result);

if (version &lt; FMOD_VERSION)
{
    printf(&quot;Error!  You are using an old version of FMOD %08x.  This program requires %08x\n&quot;, version, FMOD_VERSION);
    exit(-2);
}

result = system-&gt;init(32, FMOD_INIT_NORMAL, 0);
errorcheck(result);

soundLoad = 0;
soundPlay = 0;
soundTest = 0;

QString file = QFileDialog::getOpenFileName(this, tr(&quot;Open file&quot;));
qDebug() &lt;&lt; &quot;loading file: &quot; &lt;&lt; file;
result = system-&gt;createSound(file.toStdString().c_str(),FMOD_SOFTWARE,NULL,&amp;soundLoad);
errorcheck(result);
qDebug() &lt;&lt; &quot;loading complete&quot;;
system-&gt;update();

float freq;
FMOD_SOUND_FORMAT format;
int channels,bits;
unsigned int lenMs, lenPcm, lenPcmBytes;
soundLoad-&gt;getDefaults(&amp;freq, 0, 0, 0);
soundLoad-&gt;getFormat(0, &amp;format, &amp;channels, &amp;bits);
soundLoad-&gt;getLength(&amp;lenMs,       FMOD_TIMEUNIT_MS);
soundLoad-&gt;getLength(&amp;lenPcm,      FMOD_TIMEUNIT_PCM);
soundLoad-&gt;getLength(&amp;lenPcmBytes, FMOD_TIMEUNIT_PCMBYTES);

qDebug() &lt;&lt; &quot;freq: &quot; &lt;&lt; freq;
qDebug() &lt;&lt; &quot;format: &quot; &lt;&lt; format;
qDebug() &lt;&lt; &quot;pcm16: &quot; &lt;&lt; FMOD_SOUND_FORMAT_PCM16;
qDebug() &lt;&lt; &quot;channels: &quot; &lt;&lt; channels;
qDebug() &lt;&lt; &quot;bits: &quot; &lt;&lt; bits;
qDebug() &lt;&lt; &quot;lenMs: &quot; &lt;&lt; lenMs;
qDebug() &lt;&lt; &quot;lenPcm: &quot; &lt;&lt; lenPcm;
qDebug() &lt;&lt; &quot;lenPcmBytes: &quot; &lt;&lt; lenPcmBytes;

FMOD_CREATESOUNDEXINFO exinfo;

memset(&amp;exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize            = sizeof(FMOD_CREATESOUNDEXINFO);/* required. */
exinfo.decodebuffersize  = freq;/* Chunk size of stream update in samples.  This will be the amount of data passed to the user callback. */
exinfo.length            = lenPcmBytes; /* Length of PCM data in bytes of whole song (for Sound::getLength) */
exinfo.numchannels       = channels;/* Number of channels in the sound. */
exinfo.defaultfrequency  = freq;/* Default playback rate of sound. */
exinfo.format            = format; /* Data format of sound. */
//exinfo.pcmreadcallback   = pcmreadcallback;/* User callback for reading. */
//exinfo.pcmsetposcallback = pcmsetposcallback; /* User callback for seeking. */

void  *pointer1;
void  *pointer2;
unsigned int length1;
unsigned int length2;

wavData_i8.clear();
wavData_i16.clear();
wavData_i32.clear();
wavData_f.clear();
// lock the buffer
result = soundLoad-&gt;lock(0, lenPcmBytes, &amp;pointer1, &amp;pointer2, &amp;length1,&amp;length2);
errorcheck(result);
qDebug() &lt;&lt; &quot;lock&quot;;
qint8* dataPtr_i8 = (qint8*)pointer1;
qint16* dataPtr_i16 = (qint16*)pointer1;
qint32* dataPtr_i32 = (qint32*)pointer1;
float* dataPtr_f = (float*)pointer1;
for (int j = 0; j &lt; (int)lenPcm; j++)
{
    switch(format){
    case 1 : wavData_i8.append(dataPtr_i8[j]);
             break;
    case 2 : wavData_i16.append(dataPtr_i16[j]);
             break;
    case 3 : wavData_i32.append(dataPtr_i32[j]);
        break;
    case 4 : wavData_f.append(dataPtr_f[j]);
             break;
    default : exit(-4);
    }
}
result = soundLoad-&gt;unlock(pointer1, pointer2, length1, length2);
errorcheck(result);
qDebug() &lt;&lt; &quot;unlock&quot;;

qDebug() &lt;&lt; &quot;loading file from temp&quot;;
result = system-&gt;createSound(0,FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_HARDWARE,&amp;exinfo,&amp;soundPlay);
errorcheck(result);
qDebug() &lt;&lt; &quot;loading complete&quot;;
//--------------
soundPlay-&gt;getLength(&amp;lenPcm,      FMOD_TIMEUNIT_PCM);
soundPlay-&gt;getLength(&amp;lenPcmBytes, FMOD_TIMEUNIT_PCMBYTES);
result = soundPlay-&gt;lock(0, lenPcmBytes, &amp;pointer1, &amp;pointer2, &amp;length1,&amp;length2);
errorcheck(result);
qDebug() &lt;&lt; &quot;lock&quot;;
qint8* dataPtr2_i8 = (qint8*)pointer1;
qint16* dataPtr2_i16 = (qint16*)pointer1;
qint32* dataPtr2_i32 = (qint32*)pointer1;
float* dataPtr2_f = (float*)pointer1;
for (int j = 0; j &lt; (int)lenPcm; j++)
{
    switch(format){
    case 1 : dataPtr2_i8[j] = wavData_i8.at(j);
             break;
    case 2 : dataPtr2_i16[j] = wavData_i16.at(j);
             break;
    case 3 : dataPtr2_i32[j] = wavData_i32.at(j);
        break;
    case 4 : dataPtr2_f[j] = wavData_f.at(j);
             break;
    default : exit(-4);
    }
}
result = soundPlay-&gt;unlock(pointer1, pointer2, length1, length2);
errorcheck(result);
qDebug() &lt;&lt; &quot;unlock&quot;;
qDebug() &lt;&lt; &quot;try to play&quot;;
result = system-&gt;playSound(FMOD_CHANNEL_FREE,soundPlay,false,&amp;channelPlay);
errorcheck(result);
qDebug() &lt;&lt; &quot;playing&quot;;
system-&gt;update();

[/code:1o2sq7wh]

  • You must to post comments
0
0

and its working without callback perfectly ๐Ÿ˜€
huhh ๐Ÿ˜›
the new problem is when i loading in the the int size and the pcmformat not enough, some multiplication needed, i think in the for cycle at the lock unlock code, the lenPcm not the correct value :S but im working on it ๐Ÿ˜€

  • You must to post comments
0
0

i figured out the format problem and there is no and there is no 24bit in default :S
FMOD can "resample" (i dont now but found some resample thing but dont know how to use that)

current code:
[code:2xleiatu]
/switch(format){
case 1 : wavData_i8.append(dataPtr_i8[j]);
break;
case 2 : wavData_i16.append(dataPtr_i16[j]);
break;
case 3 : ?????? 24bit stuff
break;
case 4 : wavData_i32.append(dataPtr_i32[j]);
break;
case 5 : wavData_f.append(dataPtr_f[j]);
break;
default : exit(-4);
}
/
[/code:2xleiatu]

i dont want to implement a new int24 class beacuse i want to use the array in other things like ffwt3 and i dont know it will be good…

the question is how can convert into e.g. 32bit int?
(at the moment i save in 8bit int but i dont know that it will be good at the end :S and it slow :D)

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.