-Working on recording functionality

This commit is contained in:
Harry van Haaren 2013-08-06 21:55:57 +01:00
parent a4717bd1f0
commit 6d20ae6cb1
6 changed files with 54 additions and 39 deletions

1
FIXME
View file

@ -1,4 +1,5 @@
=TrackOutput, progress should use Logic, not write events to GUI
=TimeManager class, auto register TimeObservers with it.
Segfaulting on register in constructor

2
TODO
View file

@ -1,6 +1,8 @@
=== NEW
- Add AudioBuffer soundfile writer in order to check contents (looper distortion bug)
- Update recording mechanism to request buffers when they're getting full
- Update GUI threading to become controller independant, allowing a

View file

@ -137,6 +137,9 @@ int Jack::process (jack_nframes_t nframes)
// pre-zero output buffers
for(uint i = 0; i < nframes; i++)
{
buffers.audio[Buffers::JACK_MASTER_OUT_L][i] = 0.f;
buffers.audio[Buffers::JACK_MASTER_OUT_R][i] = 0.f;
buffers.audio[Buffers::MASTER_OUT_L] [i] = 0.f;
buffers.audio[Buffers::MASTER_OUT_R] [i] = 0.f;
buffers.audio[Buffers::REVERB] [i] = 0.f;
@ -144,8 +147,8 @@ int Jack::process (jack_nframes_t nframes)
buffers.audio[Buffers::POST_SIDECHAIN] [i] = 0.f;
}
/*
memset( buffers.audio[Buffers::MASTER_OUTPUT] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::MASTER_OUTPUT] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::MASTER_OUT_L] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::MASTER_OUT_R] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::REVERB] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::SIDECHAIN] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::POST_SIDECHAIN] , 0, sizeof(float) * nframes );
@ -196,9 +199,9 @@ int Jack::process (jack_nframes_t nframes)
}
metronome->process( nframes, &buffers );
//metronome->process( nframes, &buffers );
/*
// process fx
float* buf[] = {
buffers.audio[Buffers::REVERB],
@ -212,22 +215,16 @@ int Jack::process (jack_nframes_t nframes)
reverbMeter->process(nframes, buffers.audio[Buffers::REVERB], buffers.audio[Buffers::REVERB] );
//reverb->process( nframes, &buf[0], &buf[2] );
}
*/
// db meter on master output, then memcpy to JACK
masterMeter->process(nframes, buffers.audio[Buffers::MASTER_OUT_L], buffers.audio[Buffers::MASTER_OUT_R] );
//masterMeter->process(nframes, buffers.audio[Buffers::MASTER_OUT_L], buffers.audio[Buffers::MASTER_OUT_R] );
if ( uiUpdateCounter > uiUpdateConstant )
{
EventTrackSignalLevel e(-1, masterMeter->getLeftDB(), masterMeter->getRightDB() );
writeToGuiRingbuffer( &e );
/*
char buf[50];
snprintf( buf, 50, "signal: %f", peak );
EventGuiPrint e2( buf );
writeToGuiRingbuffer(&e2);
*/
uiUpdateCounter = 0;
}
@ -241,6 +238,7 @@ int Jack::process (jack_nframes_t nframes)
memcpy( buffers.audio[Buffers::JACK_MASTER_OUT_R],
buffers.audio[Buffers::MASTER_OUT_R],
//buffers.audio[Buffers::MASTER_OUT_L],
//buffers.audio[Buffers::REVERB], // uncomment to listen to reverb send only
sizeof(float)*nframes);

View file

@ -198,10 +198,6 @@ void Looper::process(int nframes, Buffers* buffers)
{
// copy data from input buffer to recording buffer
if ( clips[clip].nframesAvailable() < LOOPER_SAMPLES_BEFORE_REQUEST )
{
// request bigger buffer for this track/scene
}
}
else if ( clips[clip].playing() )
{

View file

@ -3,6 +3,7 @@
#define LUPPP_LOOPER_CLIP_H
#include <stdio.h>
#include "config.hxx"
#include "audiobuffer.hxx"
/** LooperClip
@ -63,14 +64,19 @@ class LooperClip
void record(int count, float* L, float* R)
{
// write "count" samples into current buffer. If the last
}
int nframesAvailable()
{
// return amount of space left to record
return 0;
// write "count" samples into current buffer.
if ( _buffer )
{
for(int i = 0; i < count; i++)
_buffer->getData().at( _recordhead ) = *L++;
}
if(_buffer->getData().size() - _recordhead < LOOPER_SAMPLES_BEFORE_REQUEST)
{
// request bigger buffer for this LooperClip
}
}
@ -85,8 +91,11 @@ class LooperClip
if ( _playhead >= _buffer->getData().size() || _playhead < 0 )
{
_playhead = 0;
printf("looper resetting playhead\n");
}
float tmp = _buffer->getData().at(_playhead);
std::vector<float>& v = _buffer->getData();
float tmp = v.at(_playhead);
_playhead++;
return tmp;
@ -105,18 +114,16 @@ class LooperClip
}
// Set
void clipLength(int l){_clipLenght = l;}
//void clipLength(int l){_clipLenght = l;}
private:
bool _loaded;
bool _recording;
bool _playing;
long int _playhead;
unsigned int _playhead;
unsigned int _recordhead;
AudioBuffer* _buffer;
// Clip Properties
int _clipLenght;
};
#endif // LUPPP_LOOPER_CLIP_H

View file

@ -4,6 +4,7 @@
#include <stdio.h>
#include "config.hxx"
#include "audioprocessor.hxx"
#include "eventhandler.hxx"
@ -15,11 +16,14 @@ class TrackOutput : public AudioProcessor
TrackOutput(int t, AudioProcessor* ap) :
AudioProcessor(),
track(t),
_trackBuffer( MAX_BUFFER_SIZE, 0.f ),
previousInChain(ap),
dbMeter(44100)
{
printf("trackOutput ID: %i\n", track);
// UI update
uiUpdateConstant = 44100 / 30;
uiUpdateCounter = 44100 / 30;
@ -57,31 +61,37 @@ class TrackOutput : public AudioProcessor
/// copies the track output to master buffer, sidechain & post-side buffer
void process(int nframes, Buffers* buffers)
{
/*
// zero track buffer
float* buf = _trackBuffer;
float* buf = &_trackBuffer[0];
for(int i = 0; i < nframes; i++ )
{
*buf++ = 0.f;
}
*/
memset( &_trackBuffer[0], 0, nframes );
if ( previousInChain )
{
buffers->audio[Buffers::TRACK_0 + track] = _trackBuffer;
//memset( _trackBuffer, 0, nframes );
buffers->audio[Buffers::TRACK_0 + track] = &_trackBuffer[0];
previousInChain->process( nframes, buffers );
}
/*
// run the meter
buf = _trackBuffer;
dbMeter.process( nframes, buf, buf );
if (uiUpdateCounter > uiUpdateConstant )
{
// FIXME: should be using ControllerUpdater
EventTrackSignalLevel e( track, dbMeter.getLeftDB() * _toMaster, dbMeter.getRightDB() * _toMaster );
writeToGuiRingbuffer( &e );
uiUpdateCounter = 0;
}
uiUpdateCounter += nframes;
*/
/// copy audio data into reverb / sidechain / master buffers
float* trackBuf = buffers->audio[Buffers::TRACK_0 + track];
@ -89,15 +99,17 @@ class TrackOutput : public AudioProcessor
float* sidechain = buffers->audio[Buffers::SIDECHAIN];
float* postSidechain = buffers->audio[Buffers::POST_SIDECHAIN];
float* master = buffers->audio[Buffers::MASTER_OUT_L];
float* masterL = buffers->audio[Buffers::MASTER_OUT_L];
float* masterR = buffers->audio[Buffers::MASTER_OUT_R];
for(int i = 0; i < nframes; i++)
{
float tmp = *trackBuf;
float tmp = _trackBuffer[i];
*master++ += tmp * _toMaster;
*masterR++ += tmp; // * _toMaster;
*masterL++ += tmp; // * _toMaster;
*reverb++ += tmp * _toReverb;
//*reverb++ += tmp * _toReverb;
//*sidechain++ += tmp * _toSidechain;
//*postSidechain++ += tmp * _toPostSidechain;
@ -109,13 +121,12 @@ class TrackOutput : public AudioProcessor
~TrackOutput()
{
delete _trackBuffer;
}
private:
int track;
float _trackBuffer[1024];
std::vector<float> _trackBuffer;
float _toMaster;