Skip to content

Commit b1367ec

Browse files
committed
softer detune, new commands for wave offset, harder modulation level, triangle LFO shape, 128 channels
1 parent 4c70b31 commit b1367ec

15 files changed

+120
-44
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
/objs.*
33
/bin.*
44
/res
5-
/src/version_number.h
6-
/src/version.h
75
*.dll
86
*.exe
97
zip/data/Default.kt
108
zip
119
.vscode/ipch/*
1210
themetemp
11+
/src/version_number.h
12+
/src/version.h

src/action.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ void new_song_action(void *unused1, void *unused2, void *unused3)
270270
{
271271
if (confirm(domain, mused.slider_bevel, &mused.largefont, "Clear song and data?"))
272272
{
273-
stop(0,0,0);
273+
stop(0, 0, 0);
274274
new_song();
275275
}
276276
}
@@ -558,7 +558,7 @@ void change_channels(void *delta, void *unused1, void *unused2)
558558
mused.cyd.n_channels = mused.song.num_channels;
559559
}
560560

561-
else if (CASTPTR(int,delta) > 0 && mused.song.num_channels < MUS_MAX_CHANNELS)
561+
else if (CASTPTR(int, delta) > 0 && mused.song.num_channels < MUS_MAX_CHANNELS)
562562
{
563563
set_channels(mused.song.num_channels + 1);
564564
mused.cyd.n_channels = mused.song.num_channels;

src/command.c

+23-2
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,30 @@ static const InstructionDesc instruction_desc[] =
102102
{MUS_FX_EXT_PORTA_DN, 0xfff0, "Fine portamento down", "PortDnFine", 0, 0xf},
103103
{MUS_FX_EXT_NOTE_CUT, 0xfff0, "Note cut", "NoteCut", 0, 0xf},
104104
{MUS_FX_EXT_RETRIGGER, 0xfff0, "Retrigger", "Retrig", 0, 0xf},
105+
105106
{MUS_FX_WAVETABLE_OFFSET, 0xf000, "Wavetable offset", "WaveOffs", 0, 0xfff},
106107
{MUS_FX_WAVETABLE_OFFSET_UP, 0xff00, "Wavetable offset up", "WaveOffsUp", 0, 0xff}, //wasn't there
107108
{MUS_FX_WAVETABLE_OFFSET_DOWN, 0xff00, "Wavetable offset down", "WaveOffsDn", 0, 0xff}, //wasn't there
109+
{MUS_FX_WAVETABLE_OFFSET_UP_FINE, 0xfff0, "Wavetable offset up (fine)", "WaveOffsUpFine", 0, 0xf}, //wasn't there
110+
{MUS_FX_WAVETABLE_OFFSET_DOWN_FINE, 0xfff0, "Wavetable offset down (fine)", "WaveOffsDnFine", 0, 0xf}, //wasn't there
108111

109112
{MUS_FX_WAVETABLE_END_POINT, 0xf000, "Wavetable end offset", "WaveEndOffs", 0, 0xfff}, //wasn't there
110113
{MUS_FX_WAVETABLE_END_POINT_UP, 0xff00, "Wavetable end offset up", "WaveEndOffsUp", 0, 0xff}, //wasn't there
111114
{MUS_FX_WAVETABLE_END_POINT_DOWN, 0xff00, "Wavetable end offset down", "WaveEndOffsDn", 0, 0xff}, //wasn't there
115+
{MUS_FX_WAVETABLE_END_POINT_UP_FINE, 0xfff0, "Wavetable end offset up (fine)", "WaveEndOffsUpFine", 0, 0xf}, //wasn't there
116+
{MUS_FX_WAVETABLE_END_POINT_DOWN_FINE, 0xfff0, "Wavetable end offset down (fine)", "WaveEndOffsDnFine", 0, 0xf}, //wasn't there
112117

113118
{MUS_FX_FM_WAVETABLE_OFFSET, 0xff00, "FM wavetable offset", "FMWaveOffs", 0, 0xff}, //wasn't there
114119
{MUS_FX_FM_WAVETABLE_OFFSET_UP, 0xff00, "FM wavetable offset up", "FMWaveOffsUp", 0, 0xff}, //wasn't there
115120
{MUS_FX_FM_WAVETABLE_OFFSET_DOWN, 0xff00, "FM wavetable offset down", "FMWaveOffsDn", 0, 0xff}, //wasn't there
121+
{MUS_FX_FM_WAVETABLE_OFFSET_UP_FINE, 0xfff0, "FM wavetable offset up (fine)", "FMWaveOffsUpFine", 0, 0xf}, //wasn't there
122+
{MUS_FX_FM_WAVETABLE_OFFSET_DOWN_FINE, 0xfff0, "FM wavetable offset down (fine)", "FMWaveOffsDnFine", 0, 0xf}, //wasn't there
116123

117124
{MUS_FX_FM_WAVETABLE_END_POINT, 0xff00, "FM wavetable end offset", "FMWaveEndOffs", 0, 0xff}, //wasn't there
118125
{MUS_FX_FM_WAVETABLE_END_POINT_UP, 0xff00, "FM wavetable end offset up", "FMWaveEndOffsUp", 0, 0xff}, //wasn't there
119126
{MUS_FX_FM_WAVETABLE_END_POINT_DOWN, 0xff00, "FM wavetable end offset down", "FMWaveEndOffsDn", 0, 0xff}, //wasn't there
127+
{MUS_FX_FM_WAVETABLE_END_POINT_UP_FINE, 0xfff0, "FM wavetable end offset up (fine)", "FMWaveEndOffsUpFine", 0, 0xf}, //wasn't there
128+
{MUS_FX_FM_WAVETABLE_END_POINT_DOWN_FINE, 0xfff0, "FM wavetable end offset down (fine)", "FMWaveEndOffsDnFine", 0, 0xf}, //wasn't there
120129

121130
{MUS_FX_SET_PANNING, 0xff00, "Set panning", "SetPan", -1, -1},
122131
{MUS_FX_PAN_LEFT, 0xff00, "Pan left", "PanLeft", -1, -1},
@@ -273,7 +282,20 @@ void get_command_desc(char *text, size_t buffer_size, Uint16 inst)
273282
{
274283
if (inst & 0xf)
275284
{
276-
snprintf(text, buffer_size, "%s (%s%s%s)\n", name, (inst & 0b1) ? "1-bit" : "", (inst & 0b10) ? " Metal" : "", (inst & 0b100) ? " Fixed pitch" : "");
285+
snprintf(text, buffer_size, "%s (%s%s%s)\n", name, (inst & 0b1) ? "1-bit" : "", (inst & 0b10) ? ((inst & 0b1) ? " Metal" : "Metal") : "", (inst & 0b100) ? ((inst & 0b10) || (inst & 0b1) ? " Fixed pitch" : "Fixed pitch") : "");
286+
}
287+
288+
else
289+
{
290+
snprintf(text, buffer_size, "%s (Default)\n", name);
291+
}
292+
}
293+
294+
else if ((fi & 0xfff0) == MUS_FX_SET_EXPONENTIALS || (fi & 0xfff0) == MUS_FX_FM_SET_EXPONENTIALS)
295+
{
296+
if (inst & 0xf)
297+
{
298+
snprintf(text, buffer_size, "%s (%s%s%s%s)\n", name, (inst & 0b1) ? "V" : "", (inst & 0b10) ? "A" : "", (inst & 0b100) ? "D" : "", (inst & 0b1000) ? "R" : "");
277299
}
278300

279301
else
@@ -318,7 +340,6 @@ Uint16 validate_command(Uint16 command)
318340
}
319341

320342
return command;
321-
322343
}
323344

324345

src/diskop.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -864,17 +864,17 @@ int open_song(FILE *f)
864864

865865
for (int c = 0; c < MUS_MAX_CHANNELS; ++c)
866866
for (int s = 1; s < mused.song.num_sequences[c] && mused.song.sequence[c][s-1].position < mused.song.song_length; ++s)
867-
if (mused.sequenceview_steps > mused.song.sequence[c][s].position - mused.song.sequence[c][s-1].position)
867+
if (mused.sequenceview_steps > mused.song.sequence[c][s].position - mused.song.sequence[c][s - 1].position)
868868
{
869-
mused.sequenceview_steps = mused.song.sequence[c][s].position - mused.song.sequence[c][s-1].position;
869+
mused.sequenceview_steps = mused.song.sequence[c][s].position - mused.song.sequence[c][s - 1].position;
870870
}
871871

872872
for (int c = 0; c < MUS_MAX_CHANNELS; ++c)
873-
if (mused.song.num_sequences[c] > 0 && mused.song.sequence[c][mused.song.num_sequences[c]-1].position < mused.song.song_length)
873+
if (mused.song.num_sequences[c] > 0 && mused.song.sequence[c][mused.song.num_sequences[c] - 1].position < mused.song.song_length)
874874
{
875-
if (mused.sequenceview_steps > mused.song.song_length - mused.song.sequence[c][mused.song.num_sequences[c]-1].position)
875+
if (mused.sequenceview_steps > mused.song.song_length - mused.song.sequence[c][mused.song.num_sequences[c] - 1].position)
876876
{
877-
mused.sequenceview_steps = mused.song.song_length - mused.song.sequence[c][mused.song.num_sequences[c]-1].position;
877+
mused.sequenceview_steps = mused.song.song_length - mused.song.sequence[c][mused.song.num_sequences[c] - 1].position;
878878
}
879879
}
880880

src/event.c

+35-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ OTHER DEALINGS IN THE SOFTWARE.
3535
#include "mymsg.h"
3636
#include "command.h"
3737

38+
#include "theme.h"
39+
3840
extern Mused mused;
3941

4042
#define flipbit(val, bit) { val ^= bit; };
@@ -1337,7 +1339,6 @@ void four_op_add_param(int a)
13371339

13381340
static int note_playing[MUS_MAX_CHANNELS] = {-1};
13391341

1340-
13411342
static int find_playing_note(int n)
13421343
{
13431344
cyd_lock(&mused.cyd, 1);
@@ -3597,7 +3598,6 @@ void wave_add_param(int d)
35973598

35983599
}
35993600

3600-
36013601
void wave_event(SDL_Event *e)
36023602
{
36033603
switch (e->type)
@@ -3618,6 +3618,39 @@ void wave_event(SDL_Event *e)
36183618
if (mused.wavetable_param >= W_N_PARAMS) mused.wavetable_param = W_N_PARAMS - 1;
36193619
}
36203620
break;
3621+
3622+
case SDLK_DELETE:
3623+
{
3624+
char buffer[500];
3625+
3626+
snprintf(buffer, 499, "Delete selected wavetable (%s)?", mused.song.wavetable_names[mused.selected_wavetable]);
3627+
3628+
if (confirm(domain, mused.slider_bevel, &mused.largefont, buffer))
3629+
{
3630+
CydWavetableEntry *wave = &mused.mus.cyd->wavetable_entries[mused.selected_wavetable];
3631+
3632+
wave->flags = 0;
3633+
wave->sample_rate = 0;
3634+
wave->samples = 0;
3635+
wave->loop_begin = 0;
3636+
wave->loop_end = 0;
3637+
wave->loop_point = 0;
3638+
wave->base_note = 0;
3639+
3640+
free(wave->data);
3641+
wave->data = NULL;
3642+
3643+
memset(mused.song.wavetable_names[mused.selected_wavetable], 0, MUS_WAVETABLE_NAME_LEN + 1);
3644+
3645+
if (!(mused.flags & SHOW_WAVEGEN))
3646+
{
3647+
SDL_FillRect(mused.wavetable_preview->surface, NULL, SDL_MapRGB(mused.wavetable_preview->surface->format, (colors[COLOR_WAVETABLE_BACKGROUND] >> 16) & 255, (colors[COLOR_WAVETABLE_BACKGROUND] >> 8) & 255, colors[COLOR_WAVETABLE_BACKGROUND] & 255));
3648+
3649+
gfx_update_texture(domain, mused.wavetable_preview);
3650+
}
3651+
}
3652+
}
3653+
break;
36213654

36223655
case SDLK_UP:
36233656
{

src/event.h

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ OTHER DEALINGS IN THE SOFTWARE.
2929
#include "SDL.h"
3030
#include "gui/slider.h"
3131

32+
#include "../klystron/src/gui/toolutil.h"
33+
3234
void edit_instrument_event(SDL_Event *e);
3335
void sequence_event(SDL_Event *e);
3436
void pattern_event(SDL_Event *e);

src/export.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool export_wav(MusSong *song, CydWavetableEntry * entry, FILE *f, int channel)
4242
MusEngine mus;
4343
CydEngine cyd;
4444

45-
cyd_init(&cyd, 44100, song->num_channels); //cyd_init(&cyd, 100000, MUS_MAX_CHANNELS);
45+
cyd_init(&cyd, 44100, song->num_channels); //cyd_init(&cyd, 100000, 64);
4646
cyd.flags |= CYD_SINGLE_THREAD;
4747
mus_init_engine(&mus, &cyd);
4848
mus.volume = song->master_volume;
@@ -168,7 +168,7 @@ bool export_wav_hires(MusSong *song, CydWavetableEntry * entry, FILE *f, int cha
168168
MusEngine mus;
169169
CydEngine cyd;
170170

171-
cyd_init(&cyd, 384000, song->num_channels); //cyd_init(&cyd, 100000, MUS_MAX_CHANNELS);
171+
cyd_init(&cyd, 384000, song->num_channels); //cyd_init(&cyd, 100000, 64);
172172
cyd.flags |= CYD_SINGLE_THREAD;
173173
mus_init_engine(&mus, &cyd);
174174
mus.volume = song->master_volume;

src/main.c

+33-15
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,10 @@ int main(int argc, char **argv)
225225
// Set directsound as the audio driver because SDL>=2.0.6 sets wasapi as the default
226226
// which means no audio on some systems (needs format conversion and that doesn't
227227
// exist yet in klystron). Can still be overridden with the environment variable.
228-
228+
229229
SDL_setenv("SDL_AUDIODRIVER", "directsound", 0);
230230
#endif
231+
231232
init_genrand(time(NULL));
232233
init_resources_dir();
233234

@@ -239,19 +240,29 @@ int main(int argc, char **argv)
239240
atexit(SDL_Quit);
240241

241242
default_settings();
243+
242244
load_config(".klystrack", false); //was `load_config(TOSTRING(CONFIG_PATH), false);`
243245

244246
domain = gfx_create_domain(VERSION_STRING, SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | ((mused.flags & WINDOW_MAXIMIZED) ? SDL_WINDOW_MAXIMIZED : 0), mused.window_w, mused.window_h, mused.pixel_scale);
247+
245248
domain->fps = 30;
246249
domain->scale = mused.pixel_scale;
247250
domain->window_min_w = 320;
248251
domain->window_min_h = 240;
252+
249253
gfx_domain_update(domain, false);
250254

251255
MusInstrument instrument[NUM_INSTRUMENTS];
252256
MusPattern pattern[NUM_PATTERNS];
253-
MusSeqPattern sequence[MUS_MAX_CHANNELS][NUM_SEQUENCES];
257+
//MusSeqPattern sequence[MUS_MAX_CHANNELS][NUM_SEQUENCES];
254258
MusChannel channel[CYD_MAX_CHANNELS];
259+
260+
MusSeqPattern** sequence = (MusSeqPattern**)malloc(MUS_MAX_CHANNELS * sizeof(MusSeqPattern*));
261+
262+
for(int i = 0; i < MUS_MAX_CHANNELS; ++i)
263+
{
264+
sequence[i] = (MusSeqPattern*)malloc(NUM_SEQUENCES * sizeof(MusSeqPattern));
265+
}
255266

256267
init(instrument, pattern, sequence, channel);
257268

@@ -339,7 +350,7 @@ int main(int argc, char **argv)
339350
switch (e.type)
340351
{
341352
case SDL_QUIT:
342-
quit_action(0,0,0);
353+
quit_action(0, 0, 0);
343354
break;
344355

345356
case SDL_WINDOWEVENT:
@@ -364,21 +375,21 @@ int main(int argc, char **argv)
364375
break;
365376

366377
case SDL_WINDOWEVENT_RESIZED:
367-
{
368-
debug("SDL_WINDOWEVENT_RESIZED %dx%d", e.window.data1, e.window.data2);
369-
370-
domain->screen_w = my_max(320, e.window.data1 / domain->scale);
371-
domain->screen_h = my_max(240, e.window.data2 / domain->scale);
378+
{
379+
debug("SDL_WINDOWEVENT_RESIZED %dx%d", e.window.data1, e.window.data2);
372380

373-
if (!(mused.flags & FULLSCREEN))
374-
{
375-
mused.window_w = domain->screen_w * domain->scale;
376-
mused.window_h = domain->screen_h * domain->scale;
377-
}
381+
domain->screen_w = my_max(320, e.window.data1 / domain->scale);
382+
domain->screen_h = my_max(240, e.window.data2 / domain->scale);
378383

379-
gfx_domain_update(domain, false);
384+
if (!(mused.flags & FULLSCREEN))
385+
{
386+
mused.window_w = domain->screen_w * domain->scale;
387+
mused.window_h = domain->screen_h * domain->scale;
380388
}
381-
break;
389+
390+
gfx_domain_update(domain, false);
391+
}
392+
break;
382393
}
383394
break;
384395

@@ -635,6 +646,13 @@ int main(int argc, char **argv)
635646
cyd_unregister(&mused.cyd);
636647
debug("cyd_deinit");
637648
cyd_deinit(&mused.cyd);
649+
650+
for(int i = 0; i < MUS_MAX_CHANNELS; ++i)
651+
{
652+
free(sequence[i]);
653+
}
654+
655+
free(sequence);
638656

639657
save_config(".klystrack"); //was `save_config(TOSTRING(CONFIG_PATH));`
640658

src/mused.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void default_settings()
244244
}
245245

246246

247-
void init(MusInstrument *instrument, MusPattern *pattern, MusSeqPattern sequence[MUS_MAX_CHANNELS][NUM_SEQUENCES], MusChannel *channel)
247+
void init(MusInstrument *instrument, MusPattern *pattern, MusSeqPattern **sequence, MusChannel *channel)//void init(MusInstrument *instrument, MusPattern *pattern, MusSeqPattern sequence[MUS_MAX_CHANNELS][NUM_SEQUENCES], MusChannel *channel)
248248
{
249249
memset(&mused, 0, sizeof(mused));
250250

src/mused.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ void default_settings();
270270
void change_mode(int newmode);
271271
void clear_pattern(MusPattern *pat);
272272
void clear_pattern_range(MusPattern *pat, int first, int last);
273-
void init(MusInstrument *instrument, MusPattern *pattern, MusSeqPattern sequence[MUS_MAX_CHANNELS][NUM_SEQUENCES], MusChannel *channel);
273+
void init(MusInstrument *instrument, MusPattern *pattern, MusSeqPattern** sequence, MusChannel *channel);//void init(MusInstrument *instrument, MusPattern *pattern, MusSeqPattern sequence[MUS_MAX_CHANNELS][NUM_SEQUENCES], MusChannel *channel);
274274
void deinit();
275275
void new_song();
276276
void kt_default_instrument(MusInstrument *instrument);

0 commit comments

Comments
 (0)