/* Copyright (C) 2005 by Olivier Goffart ogoffart@kde.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef HAVE_CONFIG_H #include #endif #ifdef HAVE_ARTS #include "soundrecorder_arts.h" #include #include #include #include #include #include #define FS 11025 #define BITS 16 #define ABS(X) ( ((X)>0) ? (X) : -(X) ) extern "C" KDE_EXPORT KHotKeys::SoundRecorder* khotkeys_soundrecorder_create( TQObject* parent, const char* name ) { return new KHotKeys::SoundRecorderArts( parent, name ); } namespace KHotKeys { SoundRecorderArts::SoundRecorderArts(TQObject *parent, const char *name) : SoundRecorder(parent, name) , m_dis(new KArtsDispatcher( this) ), m_server( new KArtsServer( this ) ) , m_recStream( new KAudioRecordStream( m_server, i18n("khotkeys"), m_server ) ) { create_ptr check = khotkeys_soundrecorder_create; // check the type matches ( void ) check; m_recStream->usePolling( false ); connect( m_recStream, TQT_SIGNAL(data (TQByteArray &)), this, TQT_SLOT(slotDataReceived(TQByteArray& ))); } SoundRecorderArts::~SoundRecorderArts() { delete m_recStream; delete m_server; delete m_dis; } void SoundRecorderArts::start() { m_recStream->start(FS,BITS,2); m_data.resize(0); } void SoundRecorderArts::stop() { m_recStream->stop(); TQTimer::singleShot(400,this,TQT_SLOT(slotEmitSignal())); } void SoundRecorderArts::abort() { m_recStream->stop(); m_data.resize(0); } Sound SoundRecorderArts::sound() { Sound s; uint BytePS=BITS/8; uint length=m_data.size()/BytePS; TQMemArray da(length); s.max=0; s._fs=FS; for(uint f=0;f