0
0

Hello,
i want to save the played netstream to disk, so i looked up the examples an implemented this:

The (static) callback for the dspunit:
[code:1785uha0]
void * CFmodNetStream::RawdataProcHandler(void thisBuffer, void *newBuffer, int iLength, void *oParam)
{
return ((CFmodNetStream
)oParam)->OnRawdataEvent(thisBuffer, newBuffer, iLength);
}[/code:1785uha0]
Here i want to write the buffer, m_FileStream is a ios::ofstream.
[code:1785uha0]
void * CFmodNetStream::OnRawdataEvent(void thisBuffer,void *newBuffer, int iLength)
{
try
{
if (m_bDownload == TRUE)
{
if(m_FileStream.is_open())
{
m_FileStream.write((char
)newBuffer, iLength);
}

                    else 
                    { 
                            m_FileStream.open(m_sFilename.c_str(), ios::binary); 
                            m_FileStream.write((char*)newBuffer, iLength); 
                    } 
            }

            return newBuffer; 
    } 
    catch(...) 
    { 
            this->FireErrorEvent(); 
            return newBuffer; 
    } 

}[/code:1785uha0]
So, is the buffer format the same as the streaming format mp3/ogg (i think so), or is it rawdata? And how can i tell m_FileStream.write(signed/unsigned/char*, int ) the size of the buffer? Can i calc the size with the number of samples?
However, my files are always very small and not playable… must i write the headers on my own?

And if new Metadata arrives and i detect its a new song – the last song is still playing. I would like to print the new metadata only if the new song begins to play. So i create a timer with the last time offset of FSOUND_Stream_GetTime(), and fire my metadata event if the timer expires. Take a look at my Metadata function:
[code:1785uha0]
signed char CFmodNetStream::OnMetadataEvent(char* cpName, char* cpValue)
{
try
{
if (!strcmp("ARTIST", cpName))
{
if (m_sArtist.compare(cpValue))
{
m_sArtist = cpValue;
return TRUE;
}

    } 
    else if (!strcmp("TITLE", cpName))
    {
        if (m_sTitel.compare(cpValue))
        { 
            m_sTitel = cpValue;

            /* Get time offset */
            int iOffset = FSOUND_Stream_GetTime(m_fmStream);

                /* Create timer for metadata */
                m_MetaTimer = timeSetEvent(iOffset/100, iOffset/400, 
                    CFmodNetStream::MetaTimerHandler, (DWORD)this, TIME_ONESHOT);

            m_sFilename = m_sArtist + " - " + m_sTitel + "." + m_sType;
            return TRUE;
        }
    }

    return TRUE;
}
catch(...)
{
    this->FireErrorEvent();
    return FALSE;
}

}
[/code:1785uha0]

But this don´t work every time, sometimes the offset value is positive and sometimes negative. So how have i interpret the the returned offset from FSOUND_Stream_GetTime()? Or am i on the wrong lane?

Once again 😉 a question about the metadata callback. Isn´t it possible to get the name of the stream (if its present) and pass the value through the metadata callback?! At time, fmod don´t make this and if there is no other way to get the stream name i want to request that feature!

Greets and thanks in advance.
Spontex

OS: Win
IDE: VC++ 6

  • You must to post comments
0
0

[quote:17yp8ovq]But this don´t work every time, sometimes the offset value is positive and sometimes negative. So how have i interpret the the returned offset from FSOUND_Stream_GetTime()? Or am i on the wrong lane? [/quote:17yp8ovq]

FSOUND_Stream_GetTime returns the total amount of time the stream has been playing in milliseconds. It doesn’t get reset when a new song starts or anything. Metadata is not always sent at exactly the time a new song starts so it can be hard to know exactly when to display it. You’ll probably have to guess a bit by caching the metadata and then waiting for a gap of silence in the stream before displaying it or something.

[quote:17yp8ovq]Once again a question about the metadata callback. Isn´t it possible to get the name of the stream (if its present) and pass the value through the metadata callback?! At time, fmod don´t make this and if there is no other way to get the stream name i want to request that feature! [/quote:17yp8ovq]

The name of the stream (and some other useful info) is put into a tag when you first connect to the stream. Use the FSOUND_Tag_xxx functions to access it i.e. FSOUND_Stream_GetNumTagFields, FSOUND_Stream_GetTagField.

Cheers,

  • You must to post comments
0
0

[quote="brett":zbbh8583]
DSP callback is the format of the mixing engine, not the format of the sound. (it continues constantly even if sounds arent playing, and what happens if multiple sounds are playing at once?)
[/quote:zbbh8583]

Oh, this explains my problem… later i have tested my dspcallback with a very simple funktion like this:
[code:zbbh8583]
void * CFmodNetStream::OnRawdataEvent(void *thisBuffer,void *newBuffer, int iLength)
{

if (m_bDownload == TRUE)
{
    fwrite(newBuffer, iLength * m_iMixfactor, 1, m_FileStream);
}
return newBuffer;

}
[/code:zbbh8583]

It works, but my files were very huge an still not playable. Then i looked how much callbacks are coming in… and wondering how much that was. So every callback i get 1024 samples, that are 4096 bytes of data. And after a few seconds my file size was 2-3 MB. But after i read your post, i understand why.

So i want to get the sound data, because there are no needs to re-encode it and this will waste perfomance – the net streamed data is present in sound format. Is there any way to get the sound data from the net stream? I hope so!

[quote="andrew":zbbh8583]
FSOUND_Stream_GetTime returns the total amount of time the stream has been playing in milliseconds. It doesn’t get reset when a new song starts or anything. Metadata is not always sent at exactly the time a new song starts so it can be hard to know exactly when to display it. You’ll probably have to guess a bit by caching the metadata and then waiting for a gap of silence in the stream before displaying it or something.
[/quote:zbbh8583]

I will poke around a bit – to see if i find a good solution, or leave it 😉

[quote="andrew":zbbh8583]The name of the stream (and some other useful info) is put into a tag when you first connect to the stream. Use the FSOUND_Tag_xxx functions to access it i.e. FSOUND_Stream_GetNumTagFields, FSOUND_Stream_GetTagField.
[/quote:zbbh8583]

Thanks, i looked up the functions in the manual and it seems to be easy.

Greets
Spontex

  • You must to post comments
0
0

[quote:1yol13w2] So i want to get the sound data, because there are no needs to re-encode it and this will waste perfomance – the net streamed data is present in sound format. Is there any way to get the sound data from the net stream? I hope so!
[/quote:1yol13w2]

This feature won’t be added to FMOD3 but will be in FMOD4.

Cheers,

  • You must to post comments
0
0

[quote="andrew":2sqylxpi][quote:2sqylxpi] So i want to get the sound data, because there are no needs to re-encode it and this will waste perfomance – the net streamed data is present in sound format. Is there any way to get the sound data from the net stream? I hope so!
[/quote:2sqylxpi]

This feature won’t be added to FMOD3 but will be in FMOD4.

Cheers,[/quote:2sqylxpi]

How long must i wait for FMOD 4? Because i don´t want to re-change to the engine i used befor, i just like fmod!

  • You must to post comments
0
0

You can still use FMOD3 you’ll just have to encode the streams before writing them, which isn’t hard. It’s also good in a way because you can give the user the option of what encoding they’d like and also add info/tags that would be lost if you saved the raw stream directly.

FMOD4 will be ready when it’s done. It’s currently nearing Alpha right now.

  • You must to post comments
0
0

[quote="andrew":2k3n57ol]You can still use FMOD3 you’ll just have to encode the streams before writing them, which isn’t hard. It’s also good in a way because you can give the user the option of what encoding they’d like and also add info/tags that would be lost if you saved the raw stream directly.
[/quote:2k3n57ol]

Yes thats right, but in my case i don´t think its a good idea. Because the prototyp i have written with another engine runs with 100 Streams and more at the same time. And then the encoding of over 100 Streams will need a littel bit performance… 😉 I´ll see what i do.

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.