Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kmatheussen/radium
Browse files Browse the repository at this point in the history
Conflicts:
	Changelog
  • Loading branch information
kmatheussen committed Sep 20, 2015
2 parents d7201dc + a86eca2 commit 52667b5
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 30 deletions.
8 changes: 4 additions & 4 deletions Changelog
@@ -1,7 +1,7 @@
Most important changes 3.3.6 -> 3.3.7
* Don"t show assert window if trying to load broken wave file
* Undo/Redo: Move cursor back to where the undo was made again
* Fixed keyboard handling for Mac OS X
Changes 3.3.6 -> 3.3.7:
* Don't show assert window if trying to load broken wave file
* Undo/Redo: Move cursor back to where the undo event was made
* Fixed keyboard handling for OSX


Most important changes 3.3.5 -> 3.3.6
Expand Down
49 changes: 33 additions & 16 deletions api/api_mouse.c
Expand Up @@ -1216,6 +1216,8 @@ int movePianonote(int pianonotenum, float value, float floatplace, int notenum,
return ListPosition3(&track->notes->l, &note->l);
}

static int setPitch2(int num, float value, float floatplace, int tracknum, int blocknum, int windownum, bool replace_note_ends);

int movePianonoteStart(int pianonotenum, float value, float floatplace, int notenum, int tracknum, int blocknum, int windownum){
struct Tracker_Windows *window;
struct WBlocks *wblock;
Expand All @@ -1229,9 +1231,10 @@ int movePianonoteStart(int pianonotenum, float value, float floatplace, int note


if (note->pitches!=NULL) {
setPitch(getPitchNumFromPianonoteNum(pianonotenum, notenum, tracknum, blocknum, windownum),
value, floatplace,
tracknum, blocknum, windownum
setPitch2(getPitchNumFromPianonoteNum(pianonotenum, notenum, tracknum, blocknum, windownum),
value, floatplace,
tracknum, blocknum, windownum,
false
);
return ListPosition3(&track->notes->l, &note->l);
}
Expand Down Expand Up @@ -1271,7 +1274,7 @@ int movePianonoteStart(int pianonotenum, float value, float floatplace, int note
return ListPosition3(&track->notes->l, &note->l);
}

static void MoveEndNote(struct Blocks *block, struct Tracks *track, struct Notes *note, Place *place);
static void MoveEndNote(struct Blocks *block, struct Tracks *track, struct Notes *note, Place *place, bool last_legal_may_be_next_note);

int movePianonoteEnd(int pianonotenum, float value, float floatplace, int notenum, int tracknum, int blocknum, int windownum){
struct Tracker_Windows *window;
Expand All @@ -1286,7 +1289,7 @@ int movePianonoteEnd(int pianonotenum, float value, float floatplace, int notenu

if (note->pitches!=NULL) {
if (floatplace>=0) {
MoveEndNote(block, track, note, PlaceCreate2(floatplace));
MoveEndNote(block, track, note, PlaceCreate2(floatplace), false);
window->must_redraw=true;
}
return notenum;
Expand Down Expand Up @@ -1724,16 +1727,25 @@ static Place *getNextLegalNotePlace(struct Notes *note){
return end;
}

static void MoveEndNote(struct Blocks *block, struct Tracks *track, struct Notes *note, Place *place){
static void MoveEndNote(struct Blocks *block, struct Tracks *track, struct Notes *note, Place *place, bool last_legal_may_be_next_note){
Place firstLegal, lastLegal;

struct Notes *next = FindNextNoteOnSameSubtrack(note);
if (last_legal_may_be_next_note && !ctrlPressed()){

struct Notes *next = FindNextNoteOnSameSubtrack(note);

if (next!=NULL)
PlaceCopy(&lastLegal, &next->l.p);
else
if (next!=NULL)
PlaceCopy(&lastLegal, &next->l.p);
else
PlaceSetLastPos(block, &lastLegal);

}else{

PlaceSetLastPos(block, &lastLegal);

}


Place *last_pitch = ListLastPlace3(&note->pitches->l);
Place *last_velocity = ListLastPlace3(&note->velocities->l);
Place *startPlace = &note->l.p;
Expand All @@ -1754,7 +1766,7 @@ static void MoveEndNote(struct Blocks *block, struct Tracks *track, struct Notes
R_ASSERT(PlaceLessOrEqual(&note->end, &lastLegal));
}

static int MoveNote(struct Blocks *block, struct Tracks *track, struct Notes *note, Place *place){
static int MoveNote(struct Blocks *block, struct Tracks *track, struct Notes *note, Place *place, bool replace_note_ends){
Place old_place = note->l.p;

if (!PlaceEqual(&old_place, place)) {
Expand All @@ -1776,7 +1788,8 @@ static int MoveNote(struct Blocks *block, struct Tracks *track, struct Notes *no
ListRemoveElement3(&track->notes, &note->l);
note->l.p = *place;
ListAddElement3(&track->notes, &note->l);
ReplaceNoteEnds(block, track, &old_place, place);
if (replace_note_ends && !ctrlPressed())
ReplaceNoteEnds(block, track, &old_place, place, note->subtrack);
NOTE_validate(block, track, note);
}PLAYER_unlock();

Expand All @@ -1785,7 +1798,7 @@ static int MoveNote(struct Blocks *block, struct Tracks *track, struct Notes *no
return ListPosition3(&track->notes->l, &note->l);
}

int setPitch(int num, float value, float floatplace, int tracknum, int blocknum, int windownum){
static int setPitch2(int num, float value, float floatplace, int tracknum, int blocknum, int windownum, bool replace_note_ends){
struct Tracker_Windows *window;
struct WBlocks *wblock;
struct WTracks *wtrack = getWTrackFromNumA(windownum, &window, blocknum, &wblock, tracknum);
Expand Down Expand Up @@ -1829,14 +1842,18 @@ int setPitch(int num, float value, float floatplace, int tracknum, int blocknum,
note->note = value;

if (floatplace >= 0) {
MoveNote(block, track, note, PlaceCreate2(floatplace));
MoveNote(block, track, note, PlaceCreate2(floatplace), replace_note_ends);
return getPitchNum(track, note, NULL);
}
}

return num;
}

int setPitch(int num, float value, float floatplace, int tracknum, int blocknum, int windownum){
return setPitch2(num, value, floatplace, tracknum, blocknum, windownum, true);
}

static struct Notes *getNoteAtPlace(struct Tracks *track, Place *place){
struct Notes *note = track->notes;

Expand Down Expand Up @@ -2138,12 +2155,12 @@ int setVelocity(int velocitynum, float value, float floatplace, int notenum, int
if (velocitynum==0) {
note->velocity = R_BOUNDARIES(0,value*MAX_VELOCITY,MAX_VELOCITY);
if (floatplace>=0) {
return MoveNote(block, track, note, PlaceCreate2(floatplace));
return MoveNote(block, track, note, PlaceCreate2(floatplace), true);
}
} else if (velocitynum==nodes->num_elements-1) {
note->velocity_end = R_BOUNDARIES(0,value*MAX_VELOCITY,MAX_VELOCITY);
if (floatplace>=0)
MoveEndNote(block, track, note, PlaceCreate2(floatplace));
MoveEndNote(block, track, note, PlaceCreate2(floatplace), true);

} else {

Expand Down
11 changes: 10 additions & 1 deletion audio/Juce_plugins.cpp
Expand Up @@ -458,7 +458,16 @@ static void send_raw_midi_message(struct SoundPlugin *plugin, int64_t block_delt

static void set_effect_value(struct SoundPlugin *plugin, int64_t time, int effect_num, float value, enum ValueFormat value_format, FX_when when){
Data *data = (Data*)plugin->data;
data->audio_instance->setParameter(effect_num, value);

#if 1
// juce::VSTPluginInstance::setParameter obtains the vst lock. That should not be necessary (Radium ensures that we are alone here), plus that it causes glitches in sound.
// So instead, we call the vst setParameter function directly:
AEffect *aeffect = (AEffect*)data->audio_instance->getPlatformSpecificData();
aeffect->setParameter(aeffect, effect_num, value);
#else
// This causes glitches, especially when doing heavy operations such as opening the gui:
data->audio_instance->setParameter(effect_num, value);
#endif
}

float get_effect_value(struct SoundPlugin *plugin, int effect_num, enum ValueFormat value_format){
Expand Down
2 changes: 1 addition & 1 deletion audio/Sampler_plugin_wav_parse.c
Expand Up @@ -251,7 +251,7 @@ static void set_wav_loop_points(Sample *sample, const wchar_t *filename){
disk_t *file = DISK_open_binary_for_reading(filename);

if(file==NULL){
GFX_Message("Could not open file \"%s\". libsndfile could open the file though. Something might be wrong with your disk.",filename);
GFX_Message(NULL, "Could not open file \"%s\". libsndfile could open the file though. Something might be wrong with your disk.",filename);
return;
}

Expand Down
75 changes: 68 additions & 7 deletions common/notes.c
Expand Up @@ -289,18 +289,76 @@ static void set_legal_start_and_end_pos(const struct Blocks *block, struct Track
if(PlaceGreaterOrEqual(start,&endplace)) {
RError("note is placed after block end. start: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&note->end));
set_new_position(track, note, PlaceCreate(block->num_lines - 2, 0, 1), NULL);
start = &note->l.p;
}

if (start->line < 0) {
RError("note is placed before block start. start: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&note->end));
set_new_position(track, note, PlaceCreate(0,1,1), NULL);
start = &note->l.p;
}

if(PlaceGreaterThan(end,&endplace)) {
RError("note end is placed after block end. start: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&note->end));
set_new_position(track, note, NULL, &endplace);
end = &note->end;
}

if (note->velocities != NULL) {
{
struct Velocities *first_velocity = note->velocities;
if(PlaceGreaterThan(start, &first_velocity->l.p)){
RError("note start is placed after first velocity. start: %f, first: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&first_velocity->l.p), GetfloatFromPlace(&note->end));
float e = p_float(first_velocity->l.p);
e -= 0.01;
e = R_MAX(0.0, e);
Place new_start;
Float2Placement(e, &new_start);
set_new_position(track, note, &new_start, NULL);
start = &note->l.p;
}
}

struct Velocities *last_velocity = (struct Velocities*)ListLast3(&note->velocities->l);
if(PlaceLessThan(end, &last_velocity->l.p)){
RError("note end is placed before last velocity. start: %f, last: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&last_velocity->l.p), GetfloatFromPlace(&note->end));
float e = p_float(last_velocity->l.p);
e += 0.01;
Place new_end;
Float2Placement(e, &new_end);
set_new_position(track, note, NULL, &new_end);
end = &note->end;
}

}

if (note->pitches != NULL) {
{
struct Pitches *first_pitch = note->pitches;
if(PlaceGreaterThan(start, &first_pitch->l.p)){
RError("note start is placed after first pitch. start: %f, first: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&first_pitch->l.p), GetfloatFromPlace(&note->end));
float e = p_float(first_pitch->l.p);
e -= 0.01;
e = R_MAX(0.0, e);
Place new_start;
Float2Placement(e, &new_start);
set_new_position(track, note, &new_start, NULL);
start = &note->l.p;
}
}

struct Pitches *last_pitch = (struct Pitches*)ListLast3(&note->pitches->l);
if(PlaceLessThan(end, &last_pitch->l.p)){
RError("note end is placed before last pitch. start: %f, last: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&last_pitch->l.p), GetfloatFromPlace(&note->end));
float e = p_float(last_pitch->l.p);
e += 0.01;
Place new_end;
Float2Placement(e, &new_end);
set_new_position(track, note, NULL, &new_end);
end = &note->end;
}
}

if(PlaceLessOrEqual(end,start)) {
RError("note end is placed before (or on) note end. start: %f, end: %f", GetfloatFromPlace(&note->l.p), GetfloatFromPlace(&note->end));
float e = p_float(*start);
Expand Down Expand Up @@ -498,16 +556,19 @@ void ReplaceNoteEnds(
struct Blocks *block,
struct Tracks *track,
Place *old_placement,
Place *new_placement
Place *new_placement,
int subtrack
){
struct Notes *note=track->notes;
while(note!=NULL){
if(PlaceGreaterThan(&note->l.p,old_placement)) break;
if(PlaceEqual(&note->end,old_placement)) {
note->end = *new_placement;
NOTE_validate(block, track, note);
}
note=NextNote(note);
if (note->subtrack == subtrack) {
if(PlaceGreaterThan(&note->l.p,old_placement)) break;
if(PlaceEqual(&note->end,old_placement)) {
note->end = *new_placement;
NOTE_validate(block, track, note);
}
}
note=NextNote(note);
}
}

Expand Down
3 changes: 2 additions & 1 deletion common/notes_proc.h
Expand Up @@ -57,7 +57,8 @@ void ReplaceNoteEnds(
struct Blocks *block,
struct Tracks *track,
Place *old_placement,
Place *new_placement
Place *new_placement,
int subtrack
);

void RemoveNote(struct Blocks *block,
Expand Down

0 comments on commit 52667b5

Please sign in to comment.