Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sources/Application/Audio/DummyAudioOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ void DummyAudioOut::Stop() {
SAFE_DELETE(thread_) ;
} ;

void DummyAudioOut::SetSoftclip(int clip, int attn) {}
void DummyAudioOut::SetSoftclip(int clip, int gain) {}
void DummyAudioOut::SetMasterVolume(int volume) {}

void DummyAudioOut::SendPulse()
{
Expand Down
1 change: 1 addition & 0 deletions sources/Application/Audio/DummyAudioOut.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DummyAudioOut: public AudioOut {
virtual int GetAudioPreBufferCount() ;
virtual double GetStreamTime() ;
virtual void SetSoftclip(int, int);
virtual void SetMasterVolume(int);

private:
DummyOutThread *thread_ ;
Expand Down
10 changes: 6 additions & 4 deletions sources/Application/Mixer/MixerService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,22 @@ bool MixerService::Clipped() {
return out_->Clipped() ;
} ;

void MixerService::SetMasterVolume(int vol) {
void MixerService::SetPregain(int vol) {
Mixer *mixer = Mixer::GetInstance();

fixed masterVolume = fp_mul(i2fp(vol), fl2fp(0.01f));

for (int i = 0; i < SONG_CHANNEL_COUNT; i++) {
bus_[i].SetVolume(masterVolume);
}
} ;
};

void MixerService::SetSoftclip(int clip, int attn) {
out_->SetSoftclip(clip, attn);
void MixerService::SetSoftclip(int clip, int gain) {
out_->SetSoftclip(clip, gain);
}

void MixerService::SetMasterVolume(int attn) { out_->SetMasterVolume(attn); }

int MixerService::GetPlayedBufferPercentage() {
return out_->GetPlayedBufferPercentage() ;
}
Expand Down
3 changes: 2 additions & 1 deletion sources/Application/Mixer/MixerService.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class MixerService:
void OnPlayerStop() ;

bool Clipped() ;
void SetMasterVolume(int) ;
void SetPregain(int);
void SetSoftclip(int, int);
void SetMasterVolume(int);
int GetPlayedBufferPercentage() ;

virtual void Execute(FourCC id,float value) ;
Expand Down
36 changes: 22 additions & 14 deletions sources/Application/Model/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,23 @@ Project::Project()
,midiDeviceList_(0),
tempoNudge_(0)
{

WatchedVariable *tempo=new WatchedVariable("tempo",VAR_TEMPO,138) ;
this->Insert(tempo) ;
Variable *masterVolume=new Variable("master",VAR_MASTERVOL,100) ;
this->Insert(masterVolume) ;
Variable *wrap=new Variable("wrap",VAR_WRAP,false) ;
this->Insert(wrap) ;
Variable *transpose=new Variable("transpose",VAR_TRANSPOSE,0) ;
this->Insert(transpose) ;
WatchedVariable *tempo = new WatchedVariable("tempo", VAR_TEMPO, 138);
this->Insert(tempo);
Variable *pregain =
new Variable("pregain", VAR_PREGAIN, 100, 200);
this->Insert(pregain);
Variable *softclip =
new Variable("softclip", VAR_SOFTCLIP, softclipStates, 5, 0);
this->Insert(softclip);
Variable *clipAttenuation =
new Variable("clipAttenuation", VAR_CLIP_ATTENUATION, 100);
this->Insert(clipAttenuation);
Variable *softclipGain = new Variable("softclipGain", VAR_SOFTCLIP_GAIN,
softclipGainStates, 2, 0);
this->Insert(softclipGain);
Variable *masterVolume=new Variable("master", VAR_MASTERVOL, 100, 100);
this->Insert(masterVolume) ;
Variable *wrap=new Variable("wrap", VAR_WRAP, false);
this->Insert(wrap);
Variable *transpose=new Variable("transpose", VAR_TRANSPOSE, 0);
this->Insert(transpose);
Variable *scale =
new Variable("scale", VAR_SCALE, scaleNames, scaleCount, 0);
this->Insert(scale);
Expand Down Expand Up @@ -96,8 +98,14 @@ int Project::GetSoftclip() {
return v->GetInt();
}

int Project::GetAttenuation() {
Variable *v = FindVariable(VAR_CLIP_ATTENUATION);
int Project::GetSoftclipGain() {
Variable *v = FindVariable(VAR_SOFTCLIP_GAIN);
NAssert(v);
return v->GetBool();
}

int Project::GetPregain() {
Variable *v = FindVariable(VAR_PREGAIN);
NAssert(v);
return v->GetInt();
}
Expand Down
21 changes: 11 additions & 10 deletions sources/Application/Model/Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
#include "Foundation/Types/Types.h"
#include "Foundation/Observable.h"


#define VAR_TEMPO MAKE_FOURCC('T','M','P','O')
#define VAR_MASTERVOL MAKE_FOURCC('M','S','T','R')
#define VAR_WRAP MAKE_FOURCC('W','R','A','P')
#define VAR_MIDIDEVICE MAKE_FOURCC('M','I','D','I')
#define VAR_TRANSPOSE MAKE_FOURCC('T','R','S','P')
#define VAR_SOFTCLIP MAKE_FOURCC('S', 'F', 'T', 'C')
#define VAR_CLIP_ATTENUATION MAKE_FOURCC('C', 'A', 'T', 'N')
#define VAR_SCALE MAKE_FOURCC('S', 'C', 'A', 'L')
#define VAR_TEMPO MAKE_FOURCC('T', 'M', 'P', 'O')
#define VAR_MASTERVOL MAKE_FOURCC('M', 'S', 'T', 'R')
#define VAR_WRAP MAKE_FOURCC('W', 'R', 'A', 'P')
#define VAR_MIDIDEVICE MAKE_FOURCC('M', 'I', 'D', 'I')
#define VAR_TRANSPOSE MAKE_FOURCC('T', 'R', 'S', 'P')
#define VAR_SOFTCLIP MAKE_FOURCC('S', 'F', 'T', 'C')
#define VAR_SOFTCLIP_GAIN MAKE_FOURCC('S', 'F', 'G', 'N')
#define VAR_PREGAIN MAKE_FOURCC('P', 'R', 'G', 'N')
#define VAR_SCALE MAKE_FOURCC('S', 'C', 'A', 'L')

#define PROJECT_NUMBER "1"
#define PROJECT_RELEASE "4"
Expand All @@ -41,7 +41,8 @@ class Project: public Persistent,public VariableContainer,I_Observer {
int GetTempo() ; // Takes nudging into account
int GetTranspose() ;
int GetSoftclip();
int GetAttenuation();
int GetSoftclipGain();
int GetPregain();

void Trigger();

Expand Down
3 changes: 2 additions & 1 deletion sources/Application/Model/ProjectDatas.h
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
char *softclipStates[] = {"off", "subtle", "medium", "heavy", "insane"};
char *softclipStates[] = {"Bypass", "Subtle", "Medium", "Heavy", "Insane"};
char *softclipGainStates[] = {"(normal)", "(boosted)"};
3 changes: 2 additions & 1 deletion sources/Application/Player/PlayerMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ void PlayerMixer::Update(Observable &o,I_ObservableData *d) {
channel_[i]->SetMixBus(mixer->GetBus(i));
}
MixerService *ms=MixerService::GetInstance();
ms->SetPregain(project_->GetPregain());
ms->SetSoftclip(project_->GetSoftclip(), project_->GetSoftclipGain());
ms->SetMasterVolume(project_->GetMasterVolume());
ms->SetSoftclip(project_->GetSoftclip(), project_->GetAttenuation());
clipped_=ms->Clipped();
} ;

Expand Down
3 changes: 3 additions & 0 deletions sources/Application/Utils/minmax.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// min/max macro

#include "minmax.h"
2 changes: 2 additions & 0 deletions sources/Application/Utils/minmax.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
42 changes: 27 additions & 15 deletions sources/Application/Views/ProjectView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "BaseClasses/UIActionField.h"
#include "BaseClasses/UIField.h"
#include "BaseClasses/UIIntVarField.h"
#include "BaseClasses/UIStaticField.h"
#include "BaseClasses/UITempoField.h"
#include "Services/Midi/MidiService.h"
#include "System/System/System.h"
Expand Down Expand Up @@ -102,31 +103,42 @@ ProjectView::ProjectView(GUIWindow &w,ViewData *data):FieldView(w,data) {
GUIPoint position=GetAnchor() ;

Variable *v=project_->FindVariable(VAR_TEMPO) ;
UITempoField *f=new UITempoField(ACTION_TEMPO_CHANGED,position,*v,"tempo: %d [%2.2x] ",60,400,1,10) ;
T_SimpleList<UIField>::Insert(f) ;
UITempoField *f = new UITempoField(ACTION_TEMPO_CHANGED, position, *v,
"Tempo: %d [%2.2x] ", 60, 400, 1, 10);
T_SimpleList<UIField>::Insert(f) ;
f->AddObserver(*this) ;
tempoField_=f ;

v=project_->FindVariable(VAR_MASTERVOL) ;
position._y+=1 ;
v = project_->FindVariable(VAR_PREGAIN);
position._y+=2 ;
UIIntVarField *field =
new UIIntVarField(position, *v, "master: %d", 10, 200, 1, 10);
T_SimpleList<UIField>::Insert(field) ;
new UIIntVarField(position, *v, "Pre-gain: %d", 10, 200, 1, 10);
T_SimpleList<UIField>::Insert(field);

v = project_->FindVariable(VAR_SOFTCLIP);
position._y += 1;
field = new UIIntVarField(position, *v, "soft clip: %s", 0, 4, 1, 3);
UIStaticField *staticField = new UIStaticField(position, "Saturation:");
T_SimpleList<UIField>::Insert(staticField) ;

v = project_->FindVariable(VAR_SOFTCLIP);
position._x += 12;
field = new UIIntVarField(position, *v, "%s", 0, 4, 1, 4);
T_SimpleList<UIField>::Insert(field);
position._x -= 12;

v = project_->FindVariable(VAR_CLIP_ATTENUATION);
position._x += 18;
field = new UIIntVarField(position, *v, "post: %d", 1, 100, 1, 10);
v = project_->FindVariable(VAR_SOFTCLIP_GAIN);
position._x += 19;
field = new UIIntVarField(position, *v, "%s", 0, 1, 1, 1);
T_SimpleList<UIField>::Insert(field);
position._x -= 19;

v = project_->FindVariable(VAR_MASTERVOL);
position._y += 1;
field = new UIIntVarField(position, *v, "Master: %d", 0, 100, 1, 10);
T_SimpleList<UIField>::Insert(field);
position._x -= 18;

v = project_->FindVariable(VAR_TRANSPOSE);
position._y+=2 ;
UIIntVarField *f2=new UIIntVarField(position,*v,"transpose: %3.2d",-48,48,0x1,0xC) ;
position._y += 2;
UIIntVarField *f2=new UIIntVarField(position,*v,"Transpose: %3.2d",-48,48,0x1,0xC) ;
T_SimpleList<UIField>::Insert(f2) ;

v = project_->FindVariable(VAR_SCALE);
Expand All @@ -136,7 +148,7 @@ ProjectView::ProjectView(GUIWindow &w,ViewData *data):FieldView(w,data) {
}
position._y += 1;
field =
new UIIntVarField(position, *v, "scale: %s", 0, scaleCount - 1, 1, 10);
new UIIntVarField(position, *v, "Scale: %s", 0, scaleCount - 1, 1, 10);
T_SimpleList<UIField>::Insert(field);

position._y += 2;
Expand Down
23 changes: 13 additions & 10 deletions sources/Foundation/Variables/Variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ Variable::Variable(const char *name,FourCC id,float value) {
type_=FLOAT ;
} ;

Variable::Variable(const char *name,FourCC id,int value) {
name_=name ;
id_=id ;
value_.int_=value ;
defaultValue_.int_ = value;
Variable::Variable(const char *name, FourCC id, int value, int max) {
int result = max ? MIN(value, max) : value;
name_=name;
id_=id;
value_.int_= result;
defaultValue_.int_ = result;
maxValue_.int_ = max;
type_=INT ;
} ;
};

Variable::Variable(const char *name,FourCC id,bool value) {
name_=name ;
Expand Down Expand Up @@ -201,16 +203,17 @@ void Variable::SetString(const char *string,bool notify) {
value_.float_=float(atof(string));
break ;
case INT:
value_.int_=atoi(string);
break ;
value_.int_ = maxValue_.int_ ? MIN(atoi(string), maxValue_.int_)
: atoi(string);
break ;
case BOOL:
value_.bool_=(!strcmp("false",string)?false:true) ;
break ;
case STRING:
stringValue_=string ;
break ;
case CHAR_LIST:
value_.index_=-1 ;
case CHAR_LIST:
value_.index_=0 ;
for (int i=0;i<listSize_;i++) {
if (list_.char_[i]) {
const char *d=list_.char_[i] ;
Expand Down
74 changes: 39 additions & 35 deletions sources/Foundation/Variables/Variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,33 @@ class Variable {
} ;

public:
Variable(const char *name, FourCC id, int value = 0, int max = 0);
Variable(const char *name, FourCC id, float value = 0.0f);
Variable(const char *name, FourCC id, bool value = false);
Variable(const char *name, FourCC id, const char *value = 0);
Variable(const char *name, FourCC id, char **list, int size, int index = -1);
Variable(const char *name, FourCC id, const char *const *list, int size,
int index = -1);

Variable(const char *name,FourCC id,int value=0) ;
Variable(const char *name,FourCC id,float value=0.0f) ;
Variable(const char *name, FourCC id, bool value = false);
Variable(const char *name,FourCC id,const char *value=0) ;
Variable(const char *name,FourCC id,char **list,int size,int index=-1) ;
Variable(const char *name, FourCC id, const char *const *list, int size,
int index = -1);
virtual ~Variable();

virtual ~Variable();
FourCC GetID();
const char *GetName();

FourCC GetID();
const char *GetName();

Type GetType() ;
void SetInt(int value,bool notify=true) ;
int GetInt() ;
void SetFloat(float value,bool notify=true) ;
float GetFloat() ;
void SetString(const char *string,bool notify=true) ;
const char *GetString() ;
void SetBool(bool value,bool notify=true) ;
bool GetBool() ;
void CopyFrom(Variable &other) ;
// Not very clean !
int GetListSize() ;
char **GetListPointer() ;
void Reset() ;
Type GetType();
void SetInt(int value, bool notify = true);
int GetInt();
void SetFloat(float value, bool notify = true);
float GetFloat();
void SetString(const char *string, bool notify = true);
const char *GetString();
void SetBool(bool value, bool notify = true);
bool GetBool();
void CopyFrom(Variable &other);
// Not very clean !
int GetListSize();
char **GetListPointer();
void Reset();

protected:
virtual void onChange() {} ;
Expand All @@ -60,22 +59,27 @@ class Variable {
bool bool_ ;
int index_ ;
} value_ ;
union {
int int_ ;

union {
int int_ ;
float float_ ;
bool bool_ ;
int index_ ;
} defaultValue_ ;

} maxValue_;

union {
int int_ ;
float float_ ;
bool bool_ ;
int index_ ;
} defaultValue_;

union {
char **char_ ;
} list_ ;
union {
char **char_ ;
} list_;

std::string stringValue_ ;
std::string stringDefaultValue_ ;
std::string stringValue_;
std::string stringDefaultValue_ ;

int listSize_ ;

Expand Down
Loading