added basic support for recording sound into sample tracks

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1508 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-08-27 13:52:21 +00:00
parent d1283bc54e
commit 1410f2bc92
12 changed files with 509 additions and 12 deletions

View File

@@ -64,6 +64,11 @@ public:
virtual void renamePort( audioPort * _port );
inline bool supportsCapture( void ) const
{
return( m_supportsCapture );
}
inline sample_rate_t sampleRate( void ) const
{
return( m_sampleRate );
@@ -156,6 +161,8 @@ protected:
bool hqAudio( void ) const;
protected:
bool m_supportsCapture;
private:
sample_rate_t m_sampleRate;

View File

@@ -288,6 +288,7 @@ public:
sample_rate_t baseSampleRate( void ) const;
sample_rate_t outputSampleRate( void ) const;
sample_rate_t inputSampleRate( void ) const;
sample_rate_t processingSampleRate( void ) const;
@@ -347,6 +348,16 @@ public:
m_playHandlesToRemoveMutex.unlock();
}
void lockInputFrames( void )
{
m_inputFramesMutex.lock();
}
void unlockInputFrames( void )
{
m_inputFramesMutex.unlock();
}
// audio-buffer-mgm
void bufferToPort( const sampleFrame * _buf,
const fpp_t _frames,
@@ -374,6 +385,18 @@ public:
return( m_fifoWriter != NULL );
}
void pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames );
inline const sampleFrame * inputBuffer( void )
{
return m_inputBuffer[ m_inputBufferRead ];
}
inline const f_cnt_t inputBufferFrames( void )
{
return m_inputBufferFrames[ m_inputBufferRead ];
}
inline const surroundSampleFrame * nextBuffer( void )
{
return( hasFifoWriter() ? m_fifo->read() : renderNextBuffer() );
@@ -430,6 +453,12 @@ private:
sampleFrame * m_workingBuf;
sampleFrame * m_inputBuffer[2];
f_cnt_t m_inputBufferFrames[2];
f_cnt_t m_inputBufferSize[2];
int m_inputBufferRead;
int m_inputBufferWrite;
surroundSampleFrame * m_readBuf;
surroundSampleFrame * m_writeBuf;
@@ -472,6 +501,7 @@ private:
QMutex m_globalMutex;
QMutex m_playHandlesMutex;
QMutex m_playHandlesToRemoveMutex;
QMutex m_inputFramesMutex;
fifo * m_fifo;

View File

@@ -0,0 +1,74 @@
/*
* sample_record_handle.h - play-handle for recording a sample
*
* Copyright (c) 2008 Csaba Hruska <csaba.hruska/at/gmail.com>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* 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 General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef _SAMPLE_RECORD_HANDLE_H
#define _SAMPLE_RECORD_HANDLE_H
#include <QtCore/QList>
#include <QtCore/QPair>
#include <qobject.h>
#include "mixer.h"
#include "sample_buffer.h"
class bbTrack;
class pattern;
class sampleTCO;
class track;
class sampleRecordHandle : public playHandle
{
public:
sampleRecordHandle( sampleTCO * _tco );
virtual ~sampleRecordHandle();
virtual void play( bool _try_parallelizing,
sampleFrame * _working_buffer );
virtual bool done( void ) const;
virtual bool isFromTrack( const track * _track ) const;
f_cnt_t framesRecorded( void ) const;
void createSampleBuffer( sampleBuffer * * _sample_buf );
private:
virtual void writeBuffer( const sampleFrame * _ab,
const fpp_t _frames );
typedef QList<QPair<sampleFrame *, fpp_t> > bufferList;
bufferList m_buffers;
f_cnt_t m_framesRecorded;
midiTime m_minLength;
track * m_track;
bbTrack * m_bbTrack;
sampleTCO * m_tco;
} ;
#endif

View File

@@ -40,6 +40,7 @@ class sampleBuffer;
class sampleTCO : public trackContentObject
{
Q_OBJECT
mapPropertyFromModel(bool,isRecord,setRecord,m_recordModel);
public:
sampleTCO( track * _track );
virtual ~sampleTCO();
@@ -65,12 +66,15 @@ public:
public slots:
void setSampleBuffer( sampleBuffer * _sb );
void setSampleFile( const QString & _sf );
void updateLength( bpm_t = 0 );
void toggleRecord( void );
private:
sampleBuffer * m_sampleBuffer;
boolModel m_recordModel;
friend class sampleTCOView;
@@ -96,6 +100,8 @@ public slots:
protected:
virtual void contextMenuEvent( QContextMenuEvent * _cme );
virtual void mousePressEvent( QMouseEvent * _me );
virtual void dragEnterEvent( QDragEnterEvent * _dee );
virtual void dropEvent( QDropEvent * _de );
virtual void mouseDoubleClickEvent( QMouseEvent * );

View File

@@ -65,6 +65,8 @@ private slots:
void setHighQuality( bool );
void play( void );
void record( void );
void recordAccompany( void );
void stop( void );
void masterVolumeChanged( int _new_val );
@@ -101,6 +103,8 @@ private:
QWidget * m_toolBar;
toolButton * m_playButton;
toolButton * m_recordButton;
toolButton * m_recordAccompanyButton;
toolButton * m_stopButton;
lcdSpinBox * m_tempoSpinBox;