All pastes #981689 Raw Edit

zonaj

public diff v1 · immutable
·published 2008-04-11 23:39 UTC
rendered paste body
Index: src/libzzub/song.cpp===================================================================--- src/libzzub/song.cpp	(revision 68)+++ src/libzzub/song.cpp	(working copy)@@ -60,6 +60,12 @@ 	} }; +struct find_velocity_column : public std::unary_function<const zzub::parameter*, bool> {+	bool operator()(const zzub::parameter* param) {+		return ( (strstr(param->description, "Velocity")) || (strstr(param->description, "Volume")) );+	}+};+ bool get_note_info(const zzub::info* info, int& note_group, int& note_column) { 	std::vector<const zzub::parameter*>::const_iterator param; @@ -80,6 +86,27 @@ 	return false; } +bool get_velocity_info(const zzub::info* info, int note_group, int& velocity_column) {+	std::vector<const zzub::parameter*>::const_iterator param;++	if(note_group == 1)+	{+		param = find_if(info->global_parameters.begin(), info->global_parameters.end(), find_velocity_column());+		if (param != info->global_parameters.end()) {+			velocity_column = int(param - info->global_parameters.begin());+			return true;+		}+	}++	param = find_if(info->track_parameters.begin(), info->track_parameters.end(), find_velocity_column());+	if (param != info->track_parameters.end()) {+		velocity_column = int(param - info->track_parameters.begin());+		return true;+	}++	return false;+}+ bool is_note_playing(int plugin_id, const std::vector<zzub::keyjazz_note>& keyjazz, int note) { 	for (size_t i = 0; i < keyjazz.size(); i++) 		if (keyjazz[i].plugin_id == plugin_id && keyjazz[i].note == note) return true;@@ -1076,8 +1103,10 @@ 	// ignore note-off when prevNote wasnt already playing, except if prevNote is -1, where we stop all playing notes 	if (note == note_value_off && prevNote != -1 && !is_note_playing(plugin_id, keyjazz, prevNote)) return pattern(); -	int note_group, note_column;+	int note_group, note_column, velocity_column; 	if (!get_note_info(m.info, note_group, note_column)) return pattern();+	if (!get_velocity_info(m.info, note_group, velocity_column))+		velocity_column = -1;  	// create a blank 1-row pattern we're going to play 	zzub::pattern p = create_pattern(plugin_id, 1);// = new zzub::pattern();//plugin->loader->plugin_info, plugin->getConnections(), plugin->getTracks(), 1);@@ -1143,6 +1172,8 @@ 			}  			p.groups[note_group][found_track][note_column][0] = note;+			if(velocity_column != -1 && _velocity)+				p.groups[note_group][found_track][velocity_column][0] = _velocity;  			// find an available track or the one with lowest timestamp 			keyjazz_note ki = { plugin_id, work_position, note_group, found_track, note, false };@@ -1163,6 +1194,8 @@ 					keyjazz.clear();  					p.groups[note_group][0][note_column][0] = note;+					if(velocity_column != -1 && _velocity)+						p.groups[note_group][0][velocity_column][0] = _velocity; 					break; 				} 			}@@ -1172,6 +1205,8 @@ 			keyjazz.push_back(ki);  			p.groups[note_group][0][note_column][0] = note;+			if(velocity_column != -1 && _velocity)+				p.groups[note_group][0][velocity_column][0] = _velocity; 		} 	}