To Record audio and store it in a location and play it again?
-
Hi All,
I am trying to work out a prog with 3 buttons in qml,one for recording an audio,another for stopping and another for playing it. I need to record the audio and store them in a location(path) and retrieve it for playing it again.
I have seen these links but could not find any solution from it.Link 1":http://doc.qt.nokia.com/qtmobility-1.2/multimedia.html "
using this link i am not able to get any idea to proceed..I have seen this similar forum":http://developer.qt.nokia.com/forums/viewthread/14278/ "
But none replied i guess. I am expecting some solutions regarding this !!!
Can anyone help me in sorting out.. -
I have fixed the links in your post. They were borken. Apparently, you have typed/pasted the link and then marked it before pressing the link button. This is meant for explanatory text handling. The link should be introduced in the link message box.
-
check out the qt example "spectrum analyser" what u r asking for is a part of that example
-
Hi, Thanks for your reply..I will check that out and tell you in sometime as i am new to qml,needs some time to go through and tell you...
-
Hi All,
I cannot Understand spectrum properly batosai..so i am trying this I have checked this "link":http://www.qtforum.org/article/35565/audio-recorder.html?s=e744e7b5ed0e159046adc10a548aa194cd2349c6 and tried some functions from those. Now i am able to play the song.. I cannot able to stop and also cannot record the song or voice on my own.Here is my code.
AudioBuffer.cpp
@
#include "AudioBuffer.h"
#include <QAudio>
#include <QMediaPlayer>
#include <QAudioCaptureSource>
#include <QAudioInput>
#include <QAudiooutput>
#include <QAudioCaptureSource>
#include <QMediaRecorder>AudioBuffer::AudioBuffer()
{
audioSource = new QAudioCaptureSource();
capture = new QMediaRecorder(audioSource);QAudioEncoderSettings es; es.setCodec("audio/mp3"); es.setSampleRate(96000); capture->setEncodingSettings(es); capture->setOutputLocation(QUrl("C:/Kalimba.mp3"));
// active = false;
}AudioBuffer::~AudioBuffer()
{
delete audioSource;
delete capture;
}void AudioBuffer::record()
{
???
capture->record();
???
}void AudioBuffer::stop()
{
????
QMediaPlayer *player = new QMediaPlayer;
capture->stop();
qDebug()<<"Player Stopped";
????}
void AudioBuffer::play()
{
QMediaPlayer *player = new QMediaPlayer;
QUrl url = QUrl::fromLocalFile("F:\Vennira Iravugal.mp3");
player->setMedia(url);
qDebug()<< url;
player->setVolume(100);
qDebug()<<"Player: "<< player->errorString();
player->play();
qDebug()<<"Player: "<< player->errorString();
}
@AudioBuffer.h
@
#include <QUrl>
#include <QObject>
#include <QAudioFormat>
#include <QAudioCaptureSource>
#include <QMediaRecorder>class AudioBuffer : public QObject
{
Q_OBJECTpublic:
AudioBuffer();
~AudioBuffer();public slots:
void stop();
void play();
void record();private:
QAudioCaptureSource *audioSource;
QMediaRecorder *capture;
};@MainPage.Qml
@Page {
id: mainPageButton { id: button1 x: 16 y: 324 width: 100 height: 42 text: "Play" onClicked: AudioBuffer.play() } Button { id: button2 x: 126 y: 324 width: 100 height: 42 text: "Stop" onClicked: AudioBuffer.stop() } Button { id: button3 x: 247 y: 324 width: 100 height: 42 text: "Record" onClicked: AudioBuffer.record() }
}@
-
SOLVED:
Hi All,
I finally found the solution on my own.. I would like to share with you all !!!!
@#include "AudioBuffer.h"
#include <QAudio>
#include <QMediaPlayer>
#include <QAudioCaptureSource>
#include <QMediaRecorder>
#include <QFileDialog>
#include <QFile>
#include <QAudioEncoderSettings>AudioBuffer::AudioBuffer()
{
audioSource = new QAudioCaptureSource();
capture = new QMediaRecorder(audioSource);QAudioEncoderSettings audioSettings; audioSettings.setCodec("audio/vorbis"); audioSettings.setQuality(QtMultimediaKit::HighQuality); capture->setEncodingSettings(audioSettings); capture->setOutputLocation(QUrl::fromLocalFile(":\\test.wav"));
}
AudioBuffer::~AudioBuffer()
{
delete audioSource;
delete capture;
}void AudioBuffer::record()
{
capture->record();
}void AudioBuffer::stop()
{
capture->stop();
}
void AudioBuffer::pause()
{
capture->pause();
}void AudioBuffer::play()
{
QMediaPlayer *player = new QMediaPlayer;
QUrl url = QUrl::fromLocalFile(":\test.wav");
player->setMedia(url);
player->setVolume(100);
player->play();
}@Thanks a Lot!!!!
I hope this works well -
Be sure and add [Solved] to the thread title if you have it working. Thanks!