<div dir="ltr"><div dir="ltr">Sorry, here is the link of the code: <a href="https://paste2.org/UpN5xtfO">https://paste2.org/UpN5xtfO</a></div></div><br><div class="gmail_quote"><div dir="ltr">krrr <<a href="mailto:kosareka@gmail.com">kosareka@gmail.com</a>> ezt írta (időpont: 2018. dec. 11., K, 18:57):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I found this answer: <a href="http://gstreamer-devel.966125.n4.nabble.com/Convertion-of-GstBuffer-to-PCM-audio-data-td4676543.html" target="_blank">http://gstreamer-devel.966125.n4.nabble.com/Convertion-of-GstBuffer-to-PCM-audio-data-td4676543.html</a> , and this is very close to my question, however, I'm still wondering if the same applies to mp3 files. I have to calculate the Fourier transform of the songs, that's the reason for the need of getting the songs/samples as an array of numbers. 

I tried the get_buffer() method, mapped it into a MapInfoData object and saved the samples, and this time I got an array with length of 383*4608 for my 10 second mp3 file, where 383 is the number of samples and 4608 is the size of buffer. A saved each element for sample data to an 8-bit unsigned int for the test, but  <a href="https://superuser.com/a/1173507" rel="nofollow" target="_blank">this</a> answer says that bit depth may alter for each sample in the case of mp3. 

Here are the relevant parts from my code:

GstFlowReturn sample_arrived(GstAppSink *appsink, AudioStreamer *audio_streamer)
{
    if (!gst_app_sink_is_eos(appsink))
    {
        GstSample *sample = gst_app_sink_pull_sample(appsink);
        //assert(sample);
        audio_streamer->_samples.push(sample);

        GstBuffer *buffer = gst_sample_get_buffer(sample);
        GstMapInfo info;
        if (gst_buffer_map(buffer, &info, GST_MAP_READ))
        {
           for ( guint i = 0; i < info.size; ++i)
           //g_print("%u\n", info.data[i]);
           audio_streamer->_tmp_samples.push(info.data[i]); //type of _tmp_samples: std::queue<u></u>
        }
        gst_buffer_unmap (buffer, &info);
        gst_sample_unref(sample);
    }
    return GST_FLOW_OK;


Is this the right way for doing this? 

        
        
        
<br><hr align="left" width="300">
Sent from the <a href="http://gstreamer-devel.966125.n4.nabble.com/" target="_blank">GStreamer-devel mailing list archive</a> at Nabble.com.<br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div>