2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* cp_song.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2014-02-10 02:10:30 +01:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#include "cp_song.h"
|
|
|
|
|
|
|
|
void CPSong::set_name(const char *p_name) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (p_name == NULL) {
|
|
|
|
variables.name[0] = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
bool done = false;
|
|
|
|
for (int i = 0; i < MAX_SONG_NAME; i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.name[i] = done ? 0 : p_name[i];
|
|
|
|
if (!done && p_name[i] == 0)
|
|
|
|
done = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.name[MAX_SONG_NAME - 1] = 0; /* just in case */
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
const char *CPSong::get_name() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return variables.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::set_message(const char *p_message) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (p_message == NULL) {
|
|
|
|
variables.message[0] = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
bool done = false;
|
|
|
|
for (int i = 0; i < MAX_MESSAGE_LEN; i++) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.message[i] = done ? 0 : p_message[i];
|
|
|
|
if (!done && p_message[i] == 0)
|
|
|
|
done = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.message[MAX_MESSAGE_LEN - 1] = 0; /* just in case */
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
const char *CPSong::get_message() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return variables.message;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::set_row_highlight_minor(int p_hl_minor) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.row_highlight_minor = p_hl_minor;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
int CPSong::get_row_highlight_minor() {
|
|
|
|
|
|
|
|
return variables.row_highlight_minor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::set_row_highlight_major(int p_hl_major) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.row_highlight_major = p_hl_major;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} /* 0 .. 256 */
|
|
|
|
int CPSong::get_row_highlight_major() {
|
|
|
|
|
|
|
|
return variables.row_highlight_major;
|
|
|
|
|
|
|
|
} /* 0 .. 256 */
|
|
|
|
|
|
|
|
void CPSong::set_mixing_volume(int p_mix_volume) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.mixing_volume = p_mix_volume;
|
2014-02-10 02:10:30 +01:00
|
|
|
} /* 0 .. 128 */
|
|
|
|
int CPSong::get_mixing_volume() {
|
|
|
|
|
|
|
|
return variables.mixing_volume;
|
|
|
|
|
|
|
|
} /* 0 .. 128 */
|
|
|
|
|
|
|
|
void CPSong::set_global_volume(int p_global_volume) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
initial_variables.global_volume = p_global_volume;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} /* 0 .. 128 */
|
|
|
|
int CPSong::get_global_volume() {
|
|
|
|
|
|
|
|
return initial_variables.global_volume;
|
|
|
|
|
|
|
|
} /* 0 .. 128 */
|
|
|
|
|
|
|
|
void CPSong::set_stereo_separation(int p_separation) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.stereo_separation = p_separation;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} /* 0 .. 128 */
|
|
|
|
int CPSong::get_stereo_separation() {
|
|
|
|
|
|
|
|
return variables.stereo_separation;
|
|
|
|
} /* 0 .. 128 */
|
|
|
|
|
|
|
|
void CPSong::set_stereo(bool p_stereo) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.use_stereo = p_stereo;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
bool CPSong::is_stereo() {
|
|
|
|
|
|
|
|
return variables.use_stereo;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::set_instruments(bool p_instruments) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.use_instruments = p_instruments;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
bool CPSong::has_instruments() {
|
|
|
|
|
|
|
|
return variables.use_instruments;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::set_linear_slides(bool p_linear_slides) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.use_linear_slides = p_linear_slides;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
bool CPSong::has_linear_slides() {
|
|
|
|
|
|
|
|
return variables.use_linear_slides;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::set_old_effects(bool p_old_effects) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.old_effects = p_old_effects;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
bool CPSong::has_old_effects() {
|
|
|
|
|
|
|
|
return variables.old_effects;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::set_compatible_gxx(bool p_compatible_gxx) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.compatible_gxx = p_compatible_gxx;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
bool CPSong::has_compatible_gxx() {
|
|
|
|
|
|
|
|
return variables.compatible_gxx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::set_speed(int p_speed) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_ERR_COND(p_speed < MIN_SPEED);
|
|
|
|
CP_ERR_COND(p_speed > MAX_SPEED);
|
|
|
|
|
|
|
|
initial_variables.speed = p_speed;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} /* 1 .. 255 */
|
|
|
|
int CPSong::get_speed() {
|
|
|
|
|
|
|
|
return initial_variables.speed;
|
|
|
|
|
|
|
|
} /* 1 .. 255 */
|
|
|
|
|
|
|
|
void CPSong::set_tempo(int p_tempo) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_ERR_COND(p_tempo < MIN_TEMPO);
|
|
|
|
CP_ERR_COND(p_tempo > MAX_TEMPO);
|
|
|
|
|
|
|
|
initial_variables.tempo = p_tempo;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} /* MIN_TEMPO .. MAX_TEMPO */
|
|
|
|
int CPSong::get_tempo() {
|
|
|
|
|
|
|
|
return initial_variables.tempo;
|
|
|
|
|
|
|
|
} /* MIN_TEMPO .. MAX_TEMPO */
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void CPSong::set_channel_pan(int p_channel, int p_pan) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX(p_channel, CPPattern::WIDTH);
|
|
|
|
CP_FAIL_INDEX(p_pan, CHANNEL_MAX_PAN + 1);
|
|
|
|
|
|
|
|
initial_variables.channel[p_channel].pan = p_pan;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} /* 0 .. CHANNEL_MAX_PAN */
|
|
|
|
int CPSong::get_channel_pan(int p_channel) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX_V(p_channel, CPPattern::WIDTH, -1);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return initial_variables.channel[p_channel].pan;
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void CPSong::set_channel_volume(int p_channel, int p_volume) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX(p_channel, CPPattern::WIDTH);
|
|
|
|
CP_FAIL_INDEX(p_volume, CHANNEL_MAX_VOLUME + 1);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
initial_variables.channel[p_channel].volume = p_volume;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} /* 0 .. CHANNEL_MAX_VOLUME */
|
|
|
|
|
|
|
|
int CPSong::get_channel_volume(int p_channel) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX_V(p_channel, CPPattern::WIDTH, -1);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
return initial_variables.channel[p_channel].volume;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void CPSong::set_channel_chorus(int p_channel, int p_chorus) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX(p_channel, CPPattern::WIDTH);
|
|
|
|
CP_FAIL_INDEX(p_chorus, CHANNEL_MAX_CHORUS + 1);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
initial_variables.channel[p_channel].chorus = p_chorus;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} /* 0 .. CHANNEL_MAX_CHORUS */
|
|
|
|
|
|
|
|
int CPSong::get_channel_chorus(int p_channel) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX_V(p_channel, CPPattern::WIDTH, -1);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
return initial_variables.channel[p_channel].chorus;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void CPSong::set_channel_reverb(int p_channel, int p_reverb) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX(p_channel, CPPattern::WIDTH);
|
|
|
|
CP_FAIL_INDEX(p_reverb, CHANNEL_MAX_REVERB + 1);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
initial_variables.channel[p_channel].reverb = p_reverb;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} /* 0 .. CHANNEL_MAX_CHORUS */
|
|
|
|
|
|
|
|
int CPSong::get_channel_reverb(int p_channel) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX_V(p_channel, CPPattern::WIDTH, -1);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
return initial_variables.channel[p_channel].reverb;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void CPSong::set_channel_surround(int p_channel, bool p_surround) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX(p_channel, CPPattern::WIDTH);
|
|
|
|
initial_variables.channel[p_channel].surround = p_surround;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
bool CPSong::is_channel_surround(int p_channel) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX_V(p_channel, CPPattern::WIDTH, false);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
return initial_variables.channel[p_channel].surround;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void CPSong::set_channel_mute(int p_channel, bool p_mute) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX(p_channel, CPPattern::WIDTH);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
initial_variables.channel[p_channel].mute = p_mute;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
bool CPSong::is_channel_mute(int p_channel) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX_V(p_channel, CPPattern::WIDTH, false);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
return initial_variables.channel[p_channel].mute;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* arrays of stuff */
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CPPattern *CPSong::get_pattern(int p_pattern) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX_V(p_pattern, MAX_PATTERNS, NULL);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
return &pattern[p_pattern];
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
CPSample *CPSong::get_sample(int p_sample) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX_V(p_sample, MAX_SAMPLES, NULL);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return &sample[p_sample];
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
CPInstrument *CPSong::get_instrument(int p_instrument) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX_V(p_instrument, MAX_INSTRUMENTS, NULL);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return &instrument[p_instrument];
|
|
|
|
}
|
|
|
|
|
|
|
|
int CPSong::get_order(int p_order) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX_V(p_order, MAX_ORDERS, CP_ORDER_NONE);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return order[p_order];
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
void CPSong::set_order(int p_order, int p_pattern) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_FAIL_INDEX(p_order, MAX_ORDERS);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
order[p_order] = p_pattern;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::clear_instrument_with_samples(int p_instrument) {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
CPInstrument *ins = get_instrument(p_instrument);
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!ins)
|
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < CPNote::NOTES; i++) {
|
|
|
|
|
|
|
|
CPSample *s = get_sample(ins->get_sample_number(i));
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!s)
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (s->get_sample_data().is_null())
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
s->reset();
|
|
|
|
}
|
|
|
|
ins->reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::make_instrument_from_sample(int p_sample) {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!has_instruments())
|
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_ERR_COND(!get_sample(p_sample));
|
|
|
|
|
|
|
|
for (int i = 0; i < MAX_INSTRUMENTS; i++) {
|
|
|
|
|
|
|
|
CPInstrument *ins = get_instrument(i);
|
|
|
|
|
|
|
|
bool empty_slot = true;
|
|
|
|
for (int n = 0; n < CPNote::NOTES; n++) {
|
|
|
|
|
|
|
|
if (ins->get_sample_number(n) < MAX_SAMPLES) {
|
|
|
|
|
|
|
|
empty_slot = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!empty_slot)
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int n = 0; n < CPNote::NOTES; n++) {
|
|
|
|
|
|
|
|
ins->set_sample_number(n, p_sample);
|
|
|
|
ins->set_note_number(n, n);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
ins->set_name(get_sample(p_sample)->get_name());
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::make_instruments_from_samples() {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < MAX_SAMPLES; i++) {
|
|
|
|
|
|
|
|
CPInstrument *ins = get_instrument(i);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!ins)
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
ins->reset();
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
CPSample *s = get_sample(i);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!s)
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
ins->set_name(s->get_name());
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (s->get_sample_data().is_null())
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int j = 0; j < CPNote::NOTES; j++)
|
|
|
|
ins->set_sample_number(j, i);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void CPSong::reset(bool p_clear_patterns, bool p_clear_samples, bool p_clear_instruments, bool p_clear_variables) {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (p_clear_variables) {
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.name[0] = 0;
|
|
|
|
variables.message[0] = 0;
|
|
|
|
variables.row_highlight_major = 16;
|
|
|
|
variables.row_highlight_minor = 4;
|
|
|
|
variables.mixing_volume = 48;
|
|
|
|
variables.old_effects = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
if (p_clear_instruments) //should not be cleared, if not clearing instruments!!
|
2017-03-19 00:36:26 +01:00
|
|
|
variables.use_instruments = false;
|
|
|
|
variables.stereo_separation = 128;
|
|
|
|
variables.use_linear_slides = true;
|
|
|
|
variables.use_stereo = true;
|
|
|
|
|
|
|
|
initial_variables.global_volume = 128;
|
|
|
|
initial_variables.speed = 6;
|
|
|
|
initial_variables.tempo = 125;
|
|
|
|
|
|
|
|
for (int i = 0; i < CPPattern::WIDTH; i++) {
|
|
|
|
|
|
|
|
initial_variables.channel[i].pan = 32;
|
|
|
|
initial_variables.channel[i].volume = CHANNEL_MAX_VOLUME;
|
|
|
|
initial_variables.channel[i].mute = false;
|
|
|
|
initial_variables.channel[i].surround = false;
|
|
|
|
initial_variables.channel[i].chorus = 0;
|
|
|
|
initial_variables.channel[i].reverb = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
effects.chorus.delay_ms = 6;
|
|
|
|
effects.chorus.separation_ms = 3;
|
|
|
|
effects.chorus.depth_ms10 = 6,
|
|
|
|
effects.chorus.speed_hz10 = 5;
|
|
|
|
effects.reverb_mode = REVERB_MODE_ROOM;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (p_clear_samples) {
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < MAX_SAMPLES; i++)
|
2014-02-10 02:10:30 +01:00
|
|
|
get_sample(i)->reset();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (p_clear_instruments) {
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < MAX_INSTRUMENTS; i++)
|
2014-02-10 02:10:30 +01:00
|
|
|
get_instrument(i)->reset();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (p_clear_patterns) {
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < MAX_PATTERNS; i++)
|
2014-02-10 02:10:30 +01:00
|
|
|
get_pattern(i)->clear();
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < MAX_ORDERS; i++)
|
|
|
|
set_order(i, CP_ORDER_NONE);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CPSong::ReverbMode CPSong::get_reverb_mode() {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return effects.reverb_mode;
|
|
|
|
}
|
|
|
|
void CPSong::set_reverb_mode(ReverbMode p_mode) {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
effects.reverb_mode = p_mode;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::set_chorus_delay_ms(int p_amount) {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
effects.chorus.delay_ms = p_amount;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
void CPSong::set_chorus_separation_ms(int p_amount) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
effects.chorus.separation_ms = p_amount;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
void CPSong::set_chorus_depth_ms10(int p_amount) {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
effects.chorus.depth_ms10 = p_amount;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
void CPSong::set_chorus_speed_hz10(int p_amount) {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
effects.chorus.speed_hz10 = p_amount;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int CPSong::get_chorus_delay_ms() {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return effects.chorus.delay_ms;
|
|
|
|
}
|
|
|
|
int CPSong::get_chorus_separation_ms() {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return effects.chorus.separation_ms;
|
|
|
|
}
|
|
|
|
int CPSong::get_chorus_depth_ms10() {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return effects.chorus.depth_ms10;
|
|
|
|
}
|
|
|
|
int CPSong::get_chorus_speed_hz10() {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return effects.chorus.speed_hz10;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::cleanup_unused_patterns() {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < MAX_PATTERNS; i++) {
|
|
|
|
|
|
|
|
bool used = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
if (get_pattern(i)->is_empty())
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int j = 0; j < MAX_ORDERS; j++) {
|
|
|
|
|
|
|
|
if (get_order(j) == i) {
|
|
|
|
used = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!used)
|
|
|
|
get_pattern(i)->clear();
|
|
|
|
}
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
void CPSong::cleanup_unused_instruments() {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!has_instruments())
|
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
bool instr_found[MAX_INSTRUMENTS];
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < MAX_INSTRUMENTS; i++)
|
|
|
|
instr_found[i] = false;
|
|
|
|
|
|
|
|
for (int i = 0; i < MAX_PATTERNS; i++) {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (get_pattern(i)->is_empty())
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int row = 0; row < get_pattern(i)->get_length(); row++) {
|
|
|
|
|
|
|
|
for (int col = 0; col < CPPattern::WIDTH; col++) {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
CPNote n;
|
2017-03-19 00:36:26 +01:00
|
|
|
n = get_pattern(i)->get_note(col, row);
|
|
|
|
|
|
|
|
if (n.instrument < MAX_INSTRUMENTS)
|
|
|
|
instr_found[n.instrument] = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < MAX_INSTRUMENTS; i++)
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!instr_found[i])
|
|
|
|
get_instrument(i)->reset();
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
void CPSong::cleanup_unused_samples() {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!has_instruments())
|
|
|
|
return;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
bool sample_found[MAX_SAMPLES];
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < MAX_INSTRUMENTS; i++)
|
|
|
|
sample_found[i] = false;
|
|
|
|
|
|
|
|
for (int i = 0; i < MAX_PATTERNS; i++) {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (get_pattern(i)->is_empty())
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int row = 0; row < get_pattern(i)->get_length(); row++) {
|
|
|
|
|
|
|
|
for (int col = 0; col < CPPattern::WIDTH; col++) {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
CPNote n;
|
2017-03-19 00:36:26 +01:00
|
|
|
n = get_pattern(i)->get_note(col, row);
|
|
|
|
|
|
|
|
if (n.instrument >= MAX_SAMPLES)
|
2014-02-10 02:10:30 +01:00
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (has_instruments()) {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int nt = 0; nt < CPNote::NOTES; nt++) {
|
|
|
|
|
|
|
|
int smp = get_instrument(n.instrument)->get_sample_number(nt);
|
|
|
|
if (smp < MAX_SAMPLES)
|
|
|
|
sample_found[smp] = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
} else {
|
2017-03-19 00:36:26 +01:00
|
|
|
if (n.instrument < MAX_SAMPLES)
|
|
|
|
sample_found[n.instrument] = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < MAX_SAMPLES; i++)
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!sample_found[i])
|
|
|
|
get_sample(i)->reset();
|
2017-03-19 00:36:26 +01:00
|
|
|
}
|
|
|
|
void CPSong::cleanup_unused_orders() {
|
|
|
|
|
|
|
|
bool finito = false;
|
|
|
|
for (int j = 0; j < MAX_ORDERS; j++) {
|
|
|
|
|
|
|
|
if (get_order(j) == CP_ORDER_NONE)
|
|
|
|
finito = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
if (finito)
|
2017-03-19 00:36:26 +01:00
|
|
|
set_order(j, CP_ORDER_NONE);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::clear_all_default_pan() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < MAX_INSTRUMENTS; i++)
|
|
|
|
get_instrument(i)->set_pan_default_enabled(false); //die!
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < MAX_SAMPLES; i++)
|
|
|
|
get_sample(i)->set_pan_enabled(false); //die!
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
void CPSong::clear_all_default_vol() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < MAX_SAMPLES; i++)
|
|
|
|
get_sample(i)->set_default_volume(64); //die!
|
|
|
|
for (int i = 0; i < MAX_INSTRUMENTS; i++)
|
|
|
|
get_instrument(i)->set_volume_global_amount(CPInstrument::MAX_VOLUME);
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int CPSong::get_order_in_use_count() {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
int order_count = 0;
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = (MAX_ORDERS - 1); i >= 0; i--) {
|
|
|
|
|
|
|
|
if (get_order(i) != CP_ORDER_NONE) {
|
|
|
|
order_count = i + 1;
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
return order_count;
|
|
|
|
}
|
|
|
|
int CPSong::get_pattern_in_use_count() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int pattern_count = 0;
|
|
|
|
|
|
|
|
for (int i = (CPSong::MAX_PATTERNS - 1); i >= 0; i--) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
if (!get_pattern(i)->is_empty()) {
|
2017-03-19 00:36:26 +01:00
|
|
|
pattern_count = i + 1;
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pattern_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CPSong::get_instrument_in_use_count() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int instrument_count = 0;
|
|
|
|
|
|
|
|
for (int i = (CPSong::MAX_INSTRUMENTS - 1); i >= 0; i--) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
CPInstrument *ins = get_instrument(i);
|
2017-03-19 00:36:26 +01:00
|
|
|
bool in_use = false;
|
|
|
|
|
|
|
|
for (int s = 0; s < CPNote::NOTES; s++) {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
int smp_idx = ins->get_sample_number(s);
|
2017-03-19 00:36:26 +01:00
|
|
|
if (smp_idx < 0 || smp_idx >= CPSong::MAX_SAMPLES)
|
2014-02-10 02:10:30 +01:00
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!get_sample(smp_idx)->get_sample_data().is_null()) {
|
2017-03-19 00:36:26 +01:00
|
|
|
in_use = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (in_use) {
|
2017-03-19 00:36:26 +01:00
|
|
|
instrument_count = i + 1;
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return instrument_count;
|
|
|
|
}
|
|
|
|
#include <stdio.h>
|
|
|
|
int CPSong::get_channels_in_use() {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int max = 0;
|
|
|
|
|
|
|
|
for (int p = 0; p < CPSong::MAX_PATTERNS; p++) {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
CPPattern *pat = get_pattern(p);
|
|
|
|
if (pat->is_empty())
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int c = (CPPattern::WIDTH - 1); c >= 0; c--) {
|
|
|
|
|
|
|
|
if (c < max)
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
bool has_note = false;
|
|
|
|
for (int r = 0; r < pat->get_length(); r++) {
|
|
|
|
|
|
|
|
CPNote n = pat->get_note(c, r);
|
2014-02-10 02:10:30 +01:00
|
|
|
if (!n.is_empty()) {
|
2017-03-19 00:36:26 +01:00
|
|
|
has_note = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
if (has_note) {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
max = c + 1;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPSong::separate_in_one_sample_instruments(int p_instrument) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
CP_ERR_COND(!variables.use_instruments);
|
|
|
|
CP_FAIL_INDEX(p_instrument, MAX_INSTRUMENTS);
|
|
|
|
|
|
|
|
int remapped_count = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
signed char remap[MAX_SAMPLES];
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < MAX_SAMPLES; i++) {
|
|
|
|
|
|
|
|
remap[i] = -1;
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
/* Find remaps */
|
2017-03-19 00:36:26 +01:00
|
|
|
CPInstrument *ins = get_instrument(p_instrument);
|
|
|
|
for (int i = 0; i < CPNote::NOTES; i++) {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
int sn = ins->get_sample_number(i);
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
// check for unusable sample
|
2017-03-19 00:36:26 +01:00
|
|
|
if (sn < 0 || sn >= MAX_SAMPLES || get_sample(sn)->get_sample_data().is_null())
|
2014-02-10 02:10:30 +01:00
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
printf("sample %i\n", sn);
|
|
|
|
if (remap[sn] != -1) {
|
|
|
|
printf("already mapped to %i\n", remap[sn]);
|
2014-02-10 02:10:30 +01:00
|
|
|
continue;
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
printf("isn't remapped\n");
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
// find remap
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int j = 0; j < MAX_INSTRUMENTS; j++) {
|
|
|
|
|
|
|
|
if (!get_instrument(j)->is_empty())
|
2014-02-10 02:10:30 +01:00
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
printf("map to %i\n", j);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
//copy
|
2017-03-19 00:36:26 +01:00
|
|
|
*get_instrument(j) = *ins;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
// assign samples
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int k = 0; k < CPNote::NOTES; k++) {
|
|
|
|
|
|
|
|
get_instrument(j)->set_note_number(k, k);
|
|
|
|
get_instrument(j)->set_sample_number(k, sn);
|
|
|
|
}
|
|
|
|
remap[sn] = j;
|
2014-02-10 02:10:30 +01:00
|
|
|
remapped_count++;
|
|
|
|
break;
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
CP_ERR_COND(remap[sn] == -1); // no more free instruments
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
printf("remapped %i\n", remapped_count);
|
|
|
|
|
|
|
|
if (remapped_count < 2) {
|
2014-02-10 02:10:30 +01:00
|
|
|
//undo if only one is remapped
|
2017-03-19 00:36:26 +01:00
|
|
|
for (int i = 0; i < MAX_SAMPLES; i++) {
|
|
|
|
|
|
|
|
if (remap[i] != -1) {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
get_instrument(remap[i])->reset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
/* remap all song */
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int p = 0; p < CPSong::MAX_PATTERNS; p++) {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
CPPattern *pat = get_pattern(p);
|
|
|
|
if (pat->is_empty())
|
|
|
|
continue;
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
for (int c = 0; c < CPPattern::WIDTH; c++) {
|
|
|
|
|
|
|
|
for (int r = 0; r < pat->get_length(); r++) {
|
|
|
|
|
|
|
|
CPNote n = pat->get_note(c, r);
|
|
|
|
if (n.note < CPNote::NOTES && n.instrument == p_instrument) {
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
int sn = ins->get_sample_number(n.note);
|
2017-03-19 00:36:26 +01:00
|
|
|
if (remap[sn] == -1)
|
|
|
|
pat->set_note(c, r, CPNote());
|
2014-02-10 02:10:30 +01:00
|
|
|
else {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
|
|
|
n.instrument = remap[sn];
|
|
|
|
pat->set_note(c, r, n);
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
ins->reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
CPSong::CPSong() {
|
2017-03-19 00:36:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
reset();
|
|
|
|
}
|
|
|
|
CPSong::~CPSong() {
|
|
|
|
}
|
|
|
|
|
|
|
|
int get_song_next_order_idx(CPSong *p_song, int p_order_idx) {
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
int baseorder, order_counter;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
order_counter = -1;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
baseorder = p_order_idx;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
baseorder++;
|
2017-03-19 00:36:26 +01:00
|
|
|
if (baseorder > (CPSong::MAX_ORDERS - 1)) baseorder = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
order_counter++;
|
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
} while ((p_song->get_order(baseorder) >= (CPSong::MAX_PATTERNS)) && (order_counter < CPSong::MAX_ORDERS));
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-19 00:36:26 +01:00
|
|
|
if (order_counter == CPSong::MAX_ORDERS) {
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return baseorder;
|
|
|
|
}
|
|
|
|
}
|