Fixing whitespace!

This commit is contained in:
Valentin Boettcher 2018-04-01 09:36:21 +02:00
parent 7357ada8b1
commit d6fda7a884
9 changed files with 104 additions and 111 deletions

View file

@ -17,7 +17,6 @@
*/ */
#include "audiobuffer.hxx" #include "audiobuffer.hxx"
#include "eventhandler.hxx"
#include "config.hxx" #include "config.hxx"
#include <stdio.h> #include <stdio.h>

View file

@ -89,12 +89,12 @@ std::string ClipSelector::clipName(int clip)
void ClipSelector::clipName(int clip, std::string name) void ClipSelector::clipName(int clip, std::string name)
{ {
clips[clip].setName( name ); clips[clip].setName( name );
redraw(); redraw();
} }
void ClipSelector::setClipBeats(int scene, int beats, bool isBeatsToRecord) void ClipSelector::setClipBeats(int scene, int beats, bool isBeatsToRecord)
{ {
clips[scene].setBeats(beats, isBeatsToRecord); clips[scene].setBeats(beats, isBeatsToRecord);
} }
void ClipSelector::setSpecial(int scene) void ClipSelector::setSpecial(int scene)
@ -320,22 +320,22 @@ int ClipSelector::handle(int event)
{ "Save" }, { "Save" },
{ "Special"}, { "Special"},
{ "Beats", 0, 0, 0, FL_SUBMENU | FL_MENU_DIVIDER }, { "Beats", 0, 0, 0, FL_SUBMENU | FL_MENU_DIVIDER },
RECORD_LENGTH_MENU_ITEM(1), RECORD_LENGTH_MENU_ITEM(1),
RECORD_LENGTH_MENU_ITEM(2), RECORD_LENGTH_MENU_ITEM(2),
RECORD_LENGTH_MENU_ITEM(4), RECORD_LENGTH_MENU_ITEM(4),
RECORD_LENGTH_MENU_ITEM(8), RECORD_LENGTH_MENU_ITEM(8),
RECORD_LENGTH_MENU_ITEM(16), RECORD_LENGTH_MENU_ITEM(16),
RECORD_LENGTH_MENU_ITEM(32), RECORD_LENGTH_MENU_ITEM(32),
RECORD_LENGTH_MENU_ITEM(64), RECORD_LENGTH_MENU_ITEM(64),
{0}, {0},
{ "Bars to record", 0, 0, 0, FL_SUBMENU | FL_MENU_DIVIDER }, { "Bars to record", 0, 0, 0, FL_SUBMENU | FL_MENU_DIVIDER },
RECORD_BARS_MENU_ITEM(1), RECORD_BARS_MENU_ITEM(1),
RECORD_BARS_MENU_ITEM(2), RECORD_BARS_MENU_ITEM(2),
RECORD_BARS_MENU_ITEM(4), RECORD_BARS_MENU_ITEM(4),
RECORD_BARS_MENU_ITEM(6), RECORD_BARS_MENU_ITEM(6),
RECORD_BARS_MENU_ITEM(8), RECORD_BARS_MENU_ITEM(8),
{"Endless", 0, setRecordBarsCb, (void*)-1, FL_MENU_DIVIDER | (clips[clipNum].getBeatsToRecord() < 0) ? FL_ACTIVATE : 0 }, {"Endless", 0, setRecordBarsCb, (void*)-1, FL_MENU_DIVIDER | (clips[clipNum].getBeatsToRecord() < 0) ? FL_ACTIVATE : 0 },
{"Custom", 0, setRecordBarsCb, (void*)-2}, {"Custom", 0, setRecordBarsCb, (void*)-2},
{0}, {0},
//{ "Record" }, //{ "Record" },
{ "Use as tempo" }, { "Use as tempo" },
@ -423,24 +423,23 @@ int ClipSelector::handle(int event)
return 0; return 0;
default: default:
return Fl_Widget::handle(event); return Fl_Widget::handle(event);
} }
} }
void ClipState::setBeats(int numBeats, bool isBeatsToRecord) void ClipState::setBeats(int numBeats, bool isBeatsToRecord)
{ {
if(numBeats > 0) { if(numBeats > 0) {
barsText = std::to_string(numBeats/4); barsText = std::to_string(numBeats/4);
if(isBeatsToRecord){ if(isBeatsToRecord){
barsText = "(" + barsText + ")"; barsText = "(" + barsText + ")";
beatsToRecord = numBeats; beatsToRecord = numBeats;
} else { } else {
beats = numBeats; beats = numBeats;
beatsToRecord = -1; beatsToRecord = -1;
} }
} }
else else
barsText = std::string(""); barsText = std::string("");
} }
} // Avtk } // Avtk

View file

@ -41,9 +41,9 @@ class ClipState
public: public:
ClipState() : ClipState() :
state(GridLogic::STATE_EMPTY), state(GridLogic::STATE_EMPTY),
name(""), name(""),
barsText("") barsText("")
{} {}
void setName(std::string n) void setName(std::string n)
{ {
@ -65,31 +65,31 @@ public:
return state; return state;
} }
int getBeatsToRecord(){ int getBeatsToRecord(){
return beatsToRecord; return beatsToRecord;
} }
void setBeats(int numBeats, bool isBeatsToRecord); void setBeats(int numBeats, bool isBeatsToRecord);
const char * getBarsString(){ const char * getBarsString(){
return barsText.c_str(); return barsText.c_str();
} }
private: private:
GridLogic::State state; GridLogic::State state;
std::string name; std::string name;
std::string barsText; std::string barsText;
int beatsToRecord; int beatsToRecord;
int beats; int beats;
}; };
class ClipSelector : public Fl_Button class ClipSelector : public Fl_Button
{ {
public: public:
ClipSelector( int _x, int _y, int _w, int _h, ClipSelector( int _x, int _y, int _w, int _h,
const char *_label, bool master = false); const char *_label, bool master = false);
int ID; int ID;
@ -114,7 +114,7 @@ public:
void setState( int clipNum, GridLogic::State s ); void setState( int clipNum, GridLogic::State s );
void clipName(int clip, std::string name); void clipName(int clip, std::string name);
void setClipBeats(int scene, int beats, bool isBeatsToRecord); void setClipBeats(int scene, int beats, bool isBeatsToRecord);
std::string clipName(int clip); std::string clipName(int clip);
@ -132,4 +132,3 @@ private:
} // Avtk } // Avtk
#endif // AVTK_CLIP_SELECTOR_H #endif // AVTK_CLIP_SELECTOR_H

View file

@ -23,7 +23,7 @@
#include <stdint.h> #include <stdint.h>
/* /*
event.hxx event.hxx
This file provides declarations for each type of event that the engine uses. This file provides declarations for each type of event that the engine uses.
*/ */
@ -128,8 +128,8 @@ enum EVENT_TYPE {
// for keeping loop index's inside the enum // for keeping loop index's inside the enum
EVENT_TYPE_FINAL, EVENT_TYPE_FINAL,
// Clip // Clip
CLIP_BEATS_CHANGED, CLIP_BEATS_CHANGED,
}; };
/// returns the pretty name of an event /// returns the pretty name of an event
@ -1177,24 +1177,23 @@ public:
class EventClipBeatsChanged : public EventBase class EventClipBeatsChanged : public EventBase
{ {
public: public:
int type() int type()
{ {
return int(CLIP_BEATS_CHANGED); return int(CLIP_BEATS_CHANGED);
} }
uint32_t size() uint32_t size()
{ {
return sizeof(EventClipBeatsChanged); return sizeof(EventClipBeatsChanged);
} }
int track; int track;
int scene; int scene;
int beats; int beats;
bool isBeatsToRecord; bool isBeatsToRecord;
EventClipBeatsChanged() {} EventClipBeatsChanged() {}
EventClipBeatsChanged(int t, int s, int b, bool i) : track(t), scene(s), beats(b), isBeatsToRecord(i) {} EventClipBeatsChanged(int t, int s, int b, bool i) : track(t), scene(s), beats(b), isBeatsToRecord(i) {}
}; };
#endif // LUPPP_EVENT_H #endif // LUPPP_EVENT_H

View file

@ -307,10 +307,10 @@ void handleDspEvents()
break; break;
/*{ /*{
if ( availableRead >= sizeof(EventFxReverb) ) { if ( availableRead >= sizeof(EventFxReverb) ) {
EventFxReverb ev; EventFxReverb ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventFxReverb) ); jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventFxReverb) );
// TODO implement reverb // TODO implement reverb
break; } break; }
} }
*/ */
case Event::TRACK_VOLUME: { case Event::TRACK_VOLUME: {
@ -476,8 +476,8 @@ void handleDspEvents()
cout << "DSP: Unkown message!! Will clog ringbuffer" << endl; cout << "DSP: Unkown message!! Will clog ringbuffer" << endl;
// just do nothing // just do nothing
break; break;
} }
} }
} else { } else {
// next call will get the half-written event // next call will get the half-written event
return; return;
@ -499,4 +499,3 @@ void writeToDspRingbuffer(EventBase* e)
} }
#endif // LUPPP_EVENT_HANDLER_DSP_H #endif // LUPPP_EVENT_HANDLER_DSP_H

View file

@ -221,7 +221,7 @@ void handleGuiEvents()
delete ev.ab; delete ev.ab;
} else { } else {
gui->getDiskWriter()->writeAudioBuffer(ev.track, ev.scene, ev.ab, gui->getDiskWriter()->writeAudioBuffer(ev.track, ev.scene, ev.ab,
gui->saveBufferPath.c_str()); gui->saveBufferPath.c_str());
gui->saveBufferPath = ""; gui->saveBufferPath = "";
} }
@ -279,14 +279,14 @@ void handleGuiEvents()
break; break;
} }
case Event::CLIP_BEATS_CHANGED: { case Event::CLIP_BEATS_CHANGED: {
if ( availableRead >= sizeof(EventClipBeatsChanged) ) { if ( availableRead >= sizeof(EventClipBeatsChanged) ) {
EventClipBeatsChanged ev; EventClipBeatsChanged ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventClipBeatsChanged) ); jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventClipBeatsChanged) );
gui->getTrack(ev.track)->getClipSelector()->setClipBeats(ev.scene, ev.beats, ev.isBeatsToRecord); gui->getTrack(ev.track)->getClipSelector()->setClipBeats(ev.scene, ev.beats, ev.isBeatsToRecord);
} }
break; break;
} }
case Event::TRACK_SEND: { case Event::TRACK_SEND: {
if ( availableRead >= sizeof(EventTrackSend) ) { if ( availableRead >= sizeof(EventTrackSend) ) {
@ -298,7 +298,7 @@ void handleGuiEvents()
} }
if ( ev.send == SEND_XSIDE ) if ( ev.send == SEND_XSIDE )
if ( ev.track < NTRACKS ) { if ( ev.track < NTRACKS ) {
gui->getTrack(ev.track)->setXSide( ev.value ); gui->getTrack(ev.track)->setXSide( ev.value );
} }
} }
break; break;
@ -499,4 +499,3 @@ void writeToGuiRingbuffer(EventBase* e)
} }
#endif // LUPPP_EVENT_HANDLER_DSP_H #endif // LUPPP_EVENT_HANDLER_DSP_H

View file

@ -115,7 +115,7 @@ void Looper::process(unsigned int nframes, Buffers* buffers)
if ( clips[clip]->recordSpaceAvailable() < LOOPER_SAMPLES_BEFORE_REQUEST && if ( clips[clip]->recordSpaceAvailable() < LOOPER_SAMPLES_BEFORE_REQUEST &&
!clips[clip]->newBufferInTransit() ) { !clips[clip]->newBufferInTransit() ) {
EventLooperClipRequestBuffer e( track, clip, clips[clip]->audioBufferSize() + LOOPER_SAMPLES_UPDATE_SIZE); EventLooperClipRequestBuffer e( track, clip, clips[clip]->audioBufferSize() + LOOPER_SAMPLES_UPDATE_SIZE);
writeToGuiRingbuffer( &e ); writeToGuiRingbuffer( &e );
clips[clip]->newBufferInTransit(true); clips[clip]->newBufferInTransit(true);
@ -199,11 +199,11 @@ void Looper::pitchShift(int count, float* input, float* output)
int iTemp5 = int(fTemp4); int iTemp5 = int(fTemp4);
float out=output[0]; float out=output[0];
out += (float)(((1 - fTemp3) * (((fTemp4 - iTemp5) * out += (float)(((1 - fTemp3) * (((fTemp4 - iTemp5) *
fVec0[(IOTA-int((int((1 + iTemp5)) & 65535)))&65535]) + ((0 - (( fVec0[(IOTA-int((int((1 + iTemp5)) & 65535)))&65535]) + ((0 - ((
fRec0[0] + fSlow3) - iTemp5)) * fVec0[(IOTA-int((iTemp5 & 65535))) fRec0[0] + fSlow3) - iTemp5)) * fVec0[(IOTA-int((iTemp5 & 65535)))
&65535]))) + (fTemp3 * (((fRec0[0] - iTemp1) * fVec0[(IOTA-int((int( &65535]))) + (fTemp3 * (((fRec0[0] - iTemp1) * fVec0[(IOTA-int((int(
iTemp2) & 65535)))&65535]) + ((iTemp2 - fRec0[0]) * fVec0[(IOTA-int(( iTemp2) & 65535)))&65535]) + ((iTemp2 - fRec0[0]) * fVec0[(IOTA-int((
iTemp1 & 65535)))&65535])))); iTemp1 & 65535)))&65535]))));
output[0]=out; output[0]=out;
fRec0[1] = fRec0[0]; fRec0[1] = fRec0[0];

View file

@ -48,9 +48,9 @@ void LooperClip::init()
_queuePlay = false; _queuePlay = false;
_queueStop = false; _queueStop = false;
_queueRecord= false; _queueRecord= false;
_wantedBeats= -1; _wantedBeats= -1;
setBeats(0); setBeats(0);
if ( _buffer ) { if ( _buffer ) {
_buffer->init(); _buffer->init();
@ -114,8 +114,8 @@ void LooperClip::load( AudioBuffer* ab )
} }
_buffer = ab; _buffer = ab;
EventClipBeatsChanged e( track, scene, _wantedBeats, true ); EventClipBeatsChanged e( track, scene, _wantedBeats, true );
writeToGuiRingbuffer( &e ); writeToGuiRingbuffer( &e );
_playhead = 0; _playhead = 0;
jack->getControllerUpdater()->setTrackSceneProgress(track, scene, 0 ); jack->getControllerUpdater()->setTrackSceneProgress(track, scene, 0 );
@ -155,7 +155,7 @@ void LooperClip::setRequestedBuffer( AudioBuffer* ab )
void LooperClip::recieveSaveBuffer( AudioBuffer* saveBuffer ) void LooperClip::recieveSaveBuffer( AudioBuffer* saveBuffer )
{ {
if ( saveBuffer->getSize() >= _buffer->getDataL().at(0) || if ( saveBuffer->getSize() >= _buffer->getDataL().at(0) ||
saveBuffer->getSize() >= _buffer->getDataR().at(0) ) { saveBuffer->getSize() >= _buffer->getDataR().at(0) ) {
// copy current contents into save buffer, // copy current contents into save buffer,
// getData() contains L and R buffer, so twice the size is needed // getData() contains L and R buffer, so twice the size is needed
size_t framesBySize = _buffer->getAudioFrames(); size_t framesBySize = _buffer->getAudioFrames();
@ -183,15 +183,15 @@ void LooperClip::setPlayHead(float ph)
{ {
if(!_recording&&_playing) { if(!_recording&&_playing) {
_playhead = ph; _playhead = ph;
jack->getControllerUpdater()->setTrackSceneProgress( track, scene, getProgress() ); jack->getControllerUpdater()->setTrackSceneProgress( track, scene, getProgress() );
} }
} }
void LooperClip::setBarsToRecord(int bars) void LooperClip::setBarsToRecord(int bars)
{ {
_wantedBeats = bars * 4; // we set beats _wantedBeats = bars * 4; // we set beats
EventClipBeatsChanged e( track, scene, _wantedBeats, true); EventClipBeatsChanged e( track, scene, _wantedBeats, true);
writeToGuiRingbuffer(&e); writeToGuiRingbuffer(&e);
} }
int LooperClip::getBeatsToRecord() int LooperClip::getBeatsToRecord()
@ -205,7 +205,7 @@ int LooperClip::getBarsToRecord(){
void LooperClip::record(int count, float* L, float* R) void LooperClip::record(int count, float* L, float* R)
{ {
// write "count" samples into current buffer. // write "count" samples into current buffer.
if ( _buffer ) { if ( _buffer ) {
size_t size = _buffer->getSize(); size_t size = _buffer->getSize();
@ -255,11 +255,11 @@ void LooperClip::setBeats(int beats)
{ {
if ( _buffer ) { if ( _buffer ) {
_buffer->setBeats( beats ); _buffer->setBeats( beats );
} }
// Even on Reset! // Even on Reset!
EventClipBeatsChanged e(track, scene, beats, false); EventClipBeatsChanged e(track, scene, beats, false);
writeToGuiRingbuffer(&e); writeToGuiRingbuffer(&e);
} }
int LooperClip::getBeats() int LooperClip::getBeats()
@ -291,10 +291,10 @@ void LooperClip::bar()
GridLogic::State s = GridLogic::STATE_EMPTY; GridLogic::State s = GridLogic::STATE_EMPTY;
// first update the buffer, as time has passed // first update the buffer, as time has passed
if ( _recording ) { if ( _recording ) {
// FIXME: assumes 4 beats in a bar // FIXME: assumes 4 beats in a bar
setBeats( _buffer->getBeats() + 4 ); setBeats( _buffer->getBeats() + 4 );
_buffer->setAudioFrames( jack->getTimeManager()->getFpb() * _buffer->getBeats() ); _buffer->setAudioFrames( jack->getTimeManager()->getFpb() * _buffer->getBeats() );
} }
if ( _playhead >= _recordhead ) { if ( _playhead >= _recordhead ) {
@ -438,8 +438,8 @@ void LooperClip::getSample(float playSpeed, float* L, float* R)
{ {
if ( _buffer && (_buffer->getSize() > 0)) { if ( _buffer && (_buffer->getSize() > 0)) {
if ( _playhead >= _recordhead || if ( _playhead >= _recordhead ||
_playhead >= _buffer->getSize() || _playhead >= _buffer->getSize() ||
_playhead < 0 ) { _playhead < 0 ) {
_playhead = 0; _playhead = 0;
EventGuiPrint e( "LooperClip resetting _playhead" ); EventGuiPrint e( "LooperClip resetting _playhead" );

View file

@ -151,4 +151,3 @@ private:
}; };
#endif // LUPPP_LOOPER_CLIP_H #endif // LUPPP_LOOPER_CLIP_H