Results 1 to 7 of 7

Thread: Change size of QAudioBuffer - Problems with QAudioProbe

  1. #1
    Join Date
    Nov 2014
    Location
    GRANADA
    Posts
    4
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Exclamation Change size of QAudioBuffer - Problems with QAudioProbe

    I’m doing a project for audio processing in real time. I used the library QAudioRecorder to record and QAudioProbe to process the data. Everything works properly. I plot the result with QWT.

    Captura.jpg


    The problem is that the data buffer stores only 40ms,i change the sampleRate (Fs) and it continue to stores 40ms, 320 samples with 8000Hz or 640 samples with 16000Hz in a mono channel. The problem is that i have to process every 250 ms. I want to change the size of the buffer.. How I can change the buffer size?

    I think I should change this line of code in question, it connect the buffer with the slot Processed.

    Qt Code:
    1. connect (probe, SIGNAL (audioBufferProbed (QAudioBuffer)), this, SLOT (Processed (QAudioBuffer)));
    2. probe-> setSource (Audiorecorder);
    3. audioRecorder.record ();
    To copy to clipboard, switch view to plain text mode 


    I consulted the internet information. I can build a buffer size as desired:
    Qt Code:
    1. QAudioBuffer (int numFrames, QAudioFormat const & format, qint64 startTime = -1)
    To copy to clipboard, switch view to plain text mode 

    I try to do this, define to variables

    Qt Code:
    1. QAudioFormat FORMATO;
    2. const QAudioBuffer Buffer;
    To copy to clipboard, switch view to plain text mode 

    and start it in constructor

    Qt Code:
    1. FORMATO(),
    2. Buffer(400, FORMATO, -1.0) //400 samples for example
    To copy to clipboard, switch view to plain text mode 

    After, i try:

    Qt Code:
    1. connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)),this, SLOT(Procesado( Buffer)));
    To copy to clipboard, switch view to plain text mode 

    I define the slot like:

    Qt Code:
    1. void Processed(const QAudioBuffer Buffer);
    To copy to clipboard, switch view to plain text mode 

    It compile correctly, but when i run the programe:

    Qt Code:
    1. QObject::connect: No such slot MainWindow::Procesado(const Buffer) in ..\ComparadorAlgoritmosEstimadoresPitch\mainwindow .cpp:182
    2. QObject::connect: (receiver name: 'MainWindow')
    To copy to clipboard, switch view to plain text mode 

    How do I set the buffer to the function of QAudioProbe, audioBufferProbed?

    Thank you very much. Sorry but my english is not very good.
    Attached Images Attached Images
    Last edited by mohabb; 14th November 2014 at 13:27.

  2. #2
    Join Date
    Nov 2014
    Location
    GRANADA
    Posts
    4
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Exclamation Change size of QAudioBuffer - Problems with QAudioProbe

    I’m doing a project for audio processing in real time. I used the library QAudioRecorder to record and QAudioProbe to process the data. Everything works properly. I plot the result with QWT.

    Captura.jpg


    The problem is that the data buffer stores only 40ms,i change the sampleRate (Fs) and it continue to stores 40ms, 320 samples with 8000Hz or 640 samples with 16000Hz in a mono channel. The problem is that i have to process every 250 ms. I want to change the size of the buffer.. How I can change the buffer size?

    I think I should change this line of code in question, it connect the buffer with the slot Processed.

    Qt Code:
    1. connect (probe, SIGNAL (audioBufferProbed (QAudioBuffer)), this, SLOT (Processed (QAudioBuffer)));
    2. probe-> setSource (Audiorecorder);
    3. audioRecorder.record ();
    To copy to clipboard, switch view to plain text mode 


    I consulted the internet information. I can build a buffer size as desired:
    Qt Code:
    1. QAudioBuffer (int numFrames, QAudioFormat const & format, qint64 startTime = -1)
    To copy to clipboard, switch view to plain text mode 

    I try to do this, define to variables

    Qt Code:
    1. QAudioFormat FORMATO;
    2. const QAudioBuffer Buffer;
    To copy to clipboard, switch view to plain text mode 

    and start it in constructor

    Qt Code:
    1. FORMATO(),
    2. Buffer(400, FORMATO, -1.0) //400 samples for example
    To copy to clipboard, switch view to plain text mode 

    After, i try:

    Qt Code:
    1. connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)),this, SLOT(Procesado( Buffer)));
    To copy to clipboard, switch view to plain text mode 

    I define the slot like:

    Qt Code:
    1. void Processed(const QAudioBuffer Buffer);
    To copy to clipboard, switch view to plain text mode 

    It compile correctly, but when i run the programe:

    Qt Code:
    1. QObject::connect: No such slot MainWindow::Procesado(const Buffer) in ..\ComparadorAlgoritmosEstimadoresPitch\mainwindow .cpp:182
    2. QObject::connect: (receiver name: 'MainWindow')
    To copy to clipboard, switch view to plain text mode 

    How do I set the buffer to the function of QAudioProbe, audioBufferProbed?

    Thank you very much. Sorry but my english is not very good.
    Last edited by mohabb; 14th November 2014 at 13:26.

  3. #3
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Change size of QAudioBuffer - Problems with QAudioProbe

    I don't know if you translated the slot name but you connect to SLOT(Procesado( Buffer)), but your define is called void Processed(const QAudioBuffer Buffer) and not Procesado

    (Please don't double post)

  4. The following user says thank you to StrikeByte for this useful post:

    mohabb (14th November 2014)

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Change size of QAudioBuffer - Problems with QAudioProbe

    The type of the slot argument is QAudioBuffer. Buffer is the name of an instance of QAudioBuffer.
    The SLOT macro needs the type of the argument, not its name.

    Cheers,
    _

  6. The following user says thank you to anda_skoa for this useful post:

    mohabb (14th November 2014)

  7. #5
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Change size of QAudioBuffer - Problems with QAudioProbe

    the connect should look like this :

    connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)),this, SLOT(Processed(QAudioBuffer)));

    a tip: http://qt-project.org/wiki/Qt_Coding_Style


    anda_skoa: I didn't see that he was using Buffer

  8. The following user says thank you to StrikeByte for this useful post:

    mohabb (14th November 2014)

  9. #6
    Join Date
    Nov 2014
    Location
    GRANADA
    Posts
    4
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Change size of QAudioBuffer - Problems with QAudioProbe

    I will try to explain my problem, when i use the code of the tutorial all work correctly:

    connect (probe, SIGNAL (audioBufferProbed (QAudioBuffer)), this, SLOT (Processed (QAudioBuffer)));
    probe-> setSource (Audiorecorder);
    audioRecorder.record ();

    The problem is that i want to change the size of the buffer, the buffer have only memory for 40ms. Someone could help me?

    Thanks, It's an error, i translated the slot name!

  10. #7
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Change size of QAudioBuffer - Problems with QAudioProbe

    I think the size will depend on the amount of samples you have set.

    do you want to dynamically change the sample size?

Similar Threads

  1. Replies: 3
    Last Post: 21st June 2014, 14:49
  2. Get QAudioBuffer from QMediaPLayer
    By azazaz in forum Qt Programming
    Replies: 2
    Last Post: 18th February 2014, 05:10
  3. change text size and window size - qmessagebox
    By smemamian in forum Newbie
    Replies: 3
    Last Post: 4th July 2013, 07:38
  4. How do you change the size of a QMenubar
    By JonR79 in forum Qt Programming
    Replies: 1
    Last Post: 21st November 2008, 23:15
  5. change font size and button size of QMessageBox
    By nass in forum Qt Programming
    Replies: 6
    Last Post: 13th September 2006, 19:16

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.