Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Code refactoring #82

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 5 additions & 2 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### Linux

Most distributions do not package all of Saucedacity's dependencies (yet).
wxWidgets 3.1 is required for building Saucedacity but many distributions only
wxWidgets 3.1 or later is required for building Saucedacity but many distributions only
package wxWidgets 3.0. [PortMidi](https://github.com/mixxxdj/portmidi) and
[PortSMF](https://github.com/tenacityteam/portsmf) are required for MIDI support
but some distributions do not package PortSMF (Saucedacity can still build without
Expand All @@ -15,6 +15,9 @@ distribution package managers either. Optionally,
[vcpkg can be used](#vcpkg-on-Linux) to build dependencies from source which
may be helpful if your distribution is missing some packages.

**Note**: Building wxWidgets as a static library does **NOT** work! You will need to build
it as a shared library.

Installing ccache and ninja-build is highly recommended for faster builds but
not required. CMake will automatically use ccache if it is installed.

Expand All @@ -26,7 +29,7 @@ To install Saucedacity's dependencies, run:
sudo apt-get install build-essential libavcodec-dev libavformat-dev libavutil-dev libflac++-dev libglib2.0-dev libgtk-3-dev libid3tag0-dev libjack-dev liblilv-dev libmad0-dev libmp3lame-dev libogg-dev libpng-dev portaudio19-dev libportmidi-dev libportsmf-dev libserd-dev libsndfile1-dev libsord-dev libsoundtouch-dev libsoxr-dev libsuil-dev libtwolame-dev vamp-plugin-sdk libvorbis-dev lv2-dev zlib1g-dev cmake ninja-build libjpeg-dev libtiff-dev liblzma-dev libsqlite3-dev
```

wxWidgets 3.1 is required but not packaged in Debian or Ubuntu. Refer
wxWidgets 3.1 or later is required but not packaged in Debian or Ubuntu. Refer
to the
[wxWidgets documentation](https://docs.wxwidgets.org/3.1/overview_cmake.html)
for how to install it from source code. The above package list
Expand Down
6 changes: 3 additions & 3 deletions lib-src/libnyquist/nyquist/cmt/cext.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
#include "cext.h"
#include "userio.h"

#define calc_middle(top, bot) (((top - bot) / 2 ) + bottom )
#define calc_middle(top, bot) ((((top) - (bot)) / 2 ) + bottom )

#define kbyte 1000
#define outof_mem(blocksize) (blocksize == 0 )
#define done_search(top, bot, middle) ( (( (top - bot) < kbyte ) && \
#define outof_mem(blocksize) ((blocksize) == 0 )
#define done_search(top, bot, middle) ( (( ((top) - (bot)) < kbyte ) && \
( !toomuch_mem(middle)) ) || \
( outof_mem( middle )) )

Expand Down
2 changes: 1 addition & 1 deletion lib-src/libnyquist/nyquist/cmt/cmtio.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define NOCHAR -2
#define NOCHAR (-2)

extern int IOinputfd;
extern int IOnochar;
Expand Down
3 changes: 1 addition & 2 deletions lib-src/libnyquist/nyquist/cmt/midifile.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "userio.h"
#include "string.h"

#define MIDIFILE_ERROR -1
#define MIDIFILE_ERROR (-1)

#ifdef PROTOTYPES
#define NOARGS void
Expand Down Expand Up @@ -365,7 +365,6 @@ readtrack() /* read a track chunk */
}
if ( Mf_endtrack )
(*Mf_endtrack)();
return;
}

static void
Expand Down
5 changes: 2 additions & 3 deletions lib-src/libnyquist/nyquist/cmt/midifns.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,7 @@ void eventwait(long timeout)
int c = getc(stdin);
ungetc(c, stdin);
}
return;
}
}
#else
void eventwait(long timeout)
{
Expand Down Expand Up @@ -955,7 +954,7 @@ void midi_bend(int channel, int value)
*
****************************************************************************/

boolean midi_buffer(byte huge *buffer, ulong size)
boolean midi_buffer(const byte huge *buffer, ulong size)
{
if (!buffer) return FALSE;
#ifdef AMIGA
Expand Down
2 changes: 1 addition & 1 deletion lib-src/libnyquist/nyquist/cmt/midifns.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void l_rest(long time);
void l_restuntil(long time);
void metronome(boolean onflag);
void midi_bend(int channel, int value);
boolean midi_buffer(byte *buffer, ulong size);
boolean midi_buffer(const byte *buffer, ulong size);
void midi_clock(void);
void midi_cont(boolean onflag);
void midi_ctrl(int channel, int control, int value);
Expand Down
6 changes: 3 additions & 3 deletions lib-src/libnyquist/nyquist/cmt/musiprog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
* make a nested call to rest(), the original rest will be locked out
* until the nested one returns. It's better to use cause().
*/
#define rest(x) l_rest( (long) x )
#define restuntil(x) l_restuntil( (long) x)
#define rest(x) l_rest( (long) (x) )
#define restuntil(x) l_restuntil( (long) (x))

#define repeat(var, count) {int var; for (var=1; var <= count; var++) {
#define repeat(var, count) {int (var); for ((var)=1; (var) <= (count); (var)++) {
#define endrep ;}}

4 changes: 2 additions & 2 deletions lib-src/libnyquist/nyquist/cmt/seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private char *chunk_alloc(seq_type seq, int size);
private void clock_tick(call_args_type args);
private void ramp_event(call_args_type args);
/*private*/ void send_macro(register unsigned char *ptr, int voice,
short parameter[], int parm_num, int value, int nline);
const short parameter[], int parm_num, int value, int nline);

/* chunk_alloc -- allocate data for a sequence */
/*
Expand Down Expand Up @@ -776,7 +776,7 @@ void report_enabled_channels(seq)
void send_macro(ptr, voice, parameter, parm_num, value, nline)
register unsigned char *ptr;
int voice;
short parameter[];
const short parameter[];
int parm_num;
int value;
int nline;
Expand Down
38 changes: 19 additions & 19 deletions lib-src/libnyquist/nyquist/cmt/seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,23 +211,23 @@ extern seq_type sequence;
chunk_type chunk_create(boolean first_flag);

#define seq_cause_noteoff(seq, delay, voice, pitch) \
(*(((seq_type) seq)->cause_noteoff_fn))(seq, delay, voice, pitch)
(*(((seq_type) (seq))->cause_noteoff_fn))(seq, delay, voice, pitch)
#define seq_midi_bend(seq, voice, value) \
(*(((seq_type) seq)->midi_bend_fn))(seq, voice, value)
(*(((seq_type) (seq))->midi_bend_fn))(seq, voice, value)
#define seq_midi_ctrl(seq, voice, ctrl, value) \
(*(((seq_type) seq)->midi_ctrl_fn))(seq, voice, ctrl, value)
(*(((seq_type) (seq))->midi_ctrl_fn))(seq, voice, ctrl, value)
#define seq_midi_program(seq, voice, prog) \
(*(((seq_type) seq)->midi_program_fn))(seq, voice, prog)
(*(((seq_type) (seq))->midi_program_fn))(seq, voice, prog)
#define seq_midi_touch(seq, voice, value) \
(*(((seq_type) seq)->midi_touch_fn))(seq, voice, value)
(*(((seq_type) (seq))->midi_touch_fn))(seq, voice, value)
#define seq_noteoff(seq, args) \
(*(((seq_type) seq)->noteoff_fn))(args)
(*(((seq_type) (seq))->noteoff_fn))(args)
#define seq_noteon(seq, voice, pitch, vel) \
(*(((seq_type) seq)->noteon_fn))(seq, voice, pitch, vel)
#define seq_free(seq) (*(((seq_type) seq)->free_fn))(seq)
(*(((seq_type) (seq))->noteon_fn))(seq, voice, pitch, vel)
#define seq_free(seq) (*(((seq_type) (seq))->free_fn))(seq)
#define seq_register(seq) \
cu_register((cu_fn_type) (((seq_type) seq)->free_fn), seq)
#define seq_reset(seq) (*(((seq_type) seq)->reset_fn))(seq)
cu_register((cu_fn_type) (((seq_type) (seq))->free_fn), seq)
#define seq_reset(seq) (*(((seq_type) (seq))->reset_fn))(seq)
/* LISP: void (SEQ-RESET SEQ) */

extern boolean seq_print; /* debugging switch */
Expand Down Expand Up @@ -266,18 +266,18 @@ void seq_cause_noteoff_meth(seq_type seq, time_type delay, int voice, int pitch)
seq_type seq_copy(seq_type from_seq); /* LISP: (SEQ-COPY SEQ) */
seq_type seq_create(void); /* LISP: (SEQ-CREATE) */
void seq_cycle(seq_type seq, boolean flag, time_type dur);
#define seq_duration(seq) (((seq_type) seq)->chunklist->u.info.duration)
#define seq_duration(seq) (((seq_type) (seq))->chunklist->u.info.duration)
void seq_end_event(call_args_type args);
#define seq_events(seq) (((seq_type) seq)->chunklist ? \
(((seq_type) seq)->chunklist->u.info.eventlist) : NULL)
#define seq_events(seq) (((seq_type) (seq))->chunklist ? \
(((seq_type) (seq))->chunklist->u.info.eventlist) : NULL)
#define seq_dictionary(seq) (seq)->chunklist->u.info.dictionary
#define seq_eventlist(seq) (seq)->chunklist->u.info.eventlist
#define seq_ctrlcount(seq) (seq)->chunklist->u.info.ctrlcount
#define seq_notecount(seq) (seq)->chunklist->u.info.notecount
#define seq_used_mask(seq) (seq)->chunklist->u.info.used_mask
void seq_free_chunks(seq_type seq);
seq_type seq_init(seq_type seq, int create_chunk);
#define seq_loudness(seq) (((seq_type) seq)->loudness)
#define seq_loudness(seq) (((seq_type) (seq))->loudness)
void seq_midi_bend_meth(seq_type seq, int voice, int value);
void seq_midi_ctrl_meth(seq_type seq, int voice, int ctrl, int value);
void seq_midi_program_meth(seq_type seq, int voice, int prog);
Expand All @@ -286,15 +286,15 @@ void seq_noteon_meth(seq_type seq, int voice, int pitch, int vel);
void seq_noteoff_meth(call_args_type args);
time_type seq_pause(seq_type seq, boolean flag);
void seq_play(seq_type seq);
#define seq_rate(seq) ((seq_type) seq)->rate
#define seq_rate(seq) ((seq_type) (seq))->rate
void seq_reset_meth(seq_type seq);
#define seq_runflag(seq) ((seq_type) seq)->runflag
#define seq_runflag(seq) ((seq_type) (seq))->runflag
#define seq_set_channel_mask(seq, cm) ((seq)->channel_mask) = (cm)
void seq_set_loudness(seq_type seq, int offset);
void seq_set_rate(seq_type seq, time_type rate);
#define seq_set_timebase(seq, tb) ((seq_type) seq)->timebase = (tb)
#define seq_set_timebase(seq, tb) ((seq_type) (seq))->timebase = (tb)
void seq_set_transpose(seq_type seq, int trans);
void seq_start_time(seq_type seq, time_type start_time);
void seq_stop(seq_type seq);
#define seq_timebase(seq) ((seq_type) seq)->timebase
#define seq_transpose(seq) ((seq_type) seq)->transpose
#define seq_timebase(seq) ((seq_type) (seq))->timebase
#define seq_transpose(seq) ((seq_type) (seq))->transpose
4 changes: 2 additions & 2 deletions lib-src/libnyquist/nyquist/cmt/seqmwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void smfw_noteoff(call_args_type args);
private void smfw_noteon(seq_type seq, int voice, int pitch, int vel);
private void smfw_process_event(call_args_type args);
private void smfw_ramp_event(call_args_type args);
private void smfw_send_macro(unsigned char *ptr, int voice, short parameter[],
private void smfw_send_macro(unsigned char *ptr, int voice, const short parameter[],
int parm_num, int value);
private void smfw_touch(seq_type seq, int voice, int value);
private void writevarlen(long value);
Expand Down Expand Up @@ -520,7 +520,7 @@ private void smfw_ramp_event(call_args_type args)

/* smfw_send_macro -- write msg to midi file from a seq "macro" event */
/**/
private void smfw_send_macro(unsigned char *ptr, int voice, short parameter[],
private void smfw_send_macro(unsigned char *ptr, int voice, const short parameter[],
int parm_num, int value)
{
unsigned char code, *loc;
Expand Down
12 changes: 6 additions & 6 deletions lib-src/libnyquist/nyquist/cmt/seqread.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ extern int abort_flag;
8 bits from the right:
****************************************************************************/

#define precise(x) (((time_type) x) << 8)
#define seqround(x) ((((time_type) x) + 128) >> 8)
#define trunc(x) (((time_type) x) >> 8)
#define precise(x) (((time_type) (x)) << 8)
#define seqround(x) ((((time_type) (x)) + 128) >> 8)
#define trunc(x) (((time_type) (x)) >> 8)

#define nullstring(s) (s[0] == EOS)
#define nullstring(s) ((s)[0] == EOS)


/****************************************************************************
Expand Down Expand Up @@ -146,7 +146,7 @@ private void parsefield(void);
private boolean parsenote(void);
private boolean parseparm(long *valptr);
private int scan(void);
private int scan1(char *start);
private int scan1(const char *start);
private long scanint(void);
private void scansymb(char *);
private long scansgnint(void);
Expand Down Expand Up @@ -1744,7 +1744,7 @@ private int scan(void)
* copies one char from start into token, converting to upper case
****************************************************************************/

private int scan1(char *start)
private int scan1(const char *start)
{
int i = 0;

Expand Down
4 changes: 2 additions & 2 deletions lib-src/libnyquist/nyquist/cmt/timebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ void timebase_use(timebase_type base);
((base)->virt_base + (((rtime) - (base)->real_base) << 8) / (base)->rate))

#define virt_to_real(base, vtime) ((base)->rate >= STOPRATE ? \
((base)->virt_base > vtime ? (base)->real_base : MAXTIME) : \
((base)->virt_base > (vtime) ? (base)->real_base : MAXTIME) : \
(base)->real_base + ((((vtime) - (base)->virt_base) * (base)->rate) >> 8))

#define virt_to_real_256(base, vtime) ((base)->rate >= STOPRATE ? \
((base)->virt_base > vtime ? (base)->real_base << 8 : MAXTIME) : \
((base)->virt_base > (vtime) ? (base)->real_base << 8 : MAXTIME) : \
((base)->real_base << 8) + ((((vtime) - (base)->virt_base) * (base)->rate)))
2 changes: 1 addition & 1 deletion lib-src/libnyquist/nyquist/cmt/userio.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ int askbool(prompt, deflt)
char *prompt;
int deflt;
{
#define undefined -1
#define undefined (-1)
char defchar; /* the default answer */
char c; /* user input */
char in_string[100];
Expand Down
2 changes: 1 addition & 1 deletion lib-src/libnyquist/nyquist/cmt/userio.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define BREAK_LEVEL 1
#define ABORT_LEVEL 2

#define read_to_eol(ch) if (ch != CR) { char temp[100]; ggets(temp); }
#define read_to_eol(ch) if ((ch) != CR) { char temp[100]; ggets(temp); }

extern char fileopen_name[];
extern int abort_flag;
Expand Down
2 changes: 1 addition & 1 deletion lib-src/libnyquist/nyquist/cmupv/src/cmupv.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ void compute_one_frame(PV *pv, int ana_hopsize)
}


void update_position_queue(PV *pv, float *ana_center)
void update_position_queue(PV *pv, const float *ana_center)
{
int fftsize = pv->fftsize;
float *frame_next = pv->frame_next;
Expand Down
4 changes: 2 additions & 2 deletions lib-src/libnyquist/nyquist/ffts/src/fftlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ parts of ffts1
*************************************************/

//inline void bitrevR2(float *ioptr, long M, short *BRLow);
static inline void bitrevR2(float *ioptr, long M, short *BRLow){
static inline void bitrevR2(float *ioptr, long M, const short *BRLow){
/*** bit reverse and first radix 2 stage of forward or inverse fft ***/
float f0r;
float f0i;
Expand Down Expand Up @@ -1130,7 +1130,7 @@ parts of iffts1
*************************************************/

// inline void scbitrevR2(float *ioptr, long M, short *BRLow, float scale);
static inline void scbitrevR2(float *ioptr, long M, short *BRLow, float scale){
static inline void scbitrevR2(float *ioptr, long M, const short *BRLow, float scale){
/*** scaled bit reverse and first radix 2 stage forward or inverse fft ***/
float f0r;
float f0i;
Expand Down
6 changes: 3 additions & 3 deletions lib-src/libnyquist/nyquist/nyqsrc/f0.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// f0 -- frequency estimation

#include <stdio.h>
#include <cstdio>



Expand Down Expand Up @@ -38,7 +38,7 @@ float parabolic_interp(float x1, float x2, float x3, float y1, float y2, float y



float f0_estimate(float *samples, int n, int m, float threshold, float *results, float *min)
float f0_estimate(const float *samples, int n, int m, float threshold, float *results, float *min)
// samples is a buffer of samples
// n is the number of samples, equals twice longest period, must be even
// m is the shortest period in samples
Expand Down Expand Up @@ -121,7 +121,7 @@ float best_f0(float *samples, int n, int m, float threshold, int Tmax)
// results is an array of size n/2 - m + 1, the number of different lags
// Tmax is the length of the search
{
float* results=new float[n/2-m+1];
auto* results=new float[n/2-m+1];
float min=10000000.0;
float temp;
float best_f0;
Expand Down
4 changes: 2 additions & 2 deletions lib-src/libnyquist/nyquist/nyqsrc/ffilterkit.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

fast_float FilterUp(float Imp[], float ImpD[],
int Nwing, boolean Interp,
float *Xp, double Ph, int Inc)
const float *Xp, double Ph, int Inc)
{
float *Hp, *Hdp = NULL, *End;
fast_float a = 0;
Expand Down Expand Up @@ -77,7 +77,7 @@ fast_float FilterUp(float Imp[], float ImpD[],

fast_float FilterUD( float Imp[], float ImpD[],
int Nwing, boolean Interp,
float *Xp, double Ph, int Inc, double dhb)
const float *Xp, double Ph, int Inc, double dhb)
{
double a;
float *Hp, *Hdp, *End;
Expand Down
4 changes: 2 additions & 2 deletions lib-src/libnyquist/nyquist/nyqsrc/ffilterkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/

fast_float FilterUp(mem_float Imp[], mem_float ImpD[], int Nwing,
boolean Interp, mem_float *Xp, double Ph, int Inc);
boolean Interp, const mem_float *Xp, double Ph, int Inc);

fast_float FilterUD(mem_float Imp[], mem_float ImpD[], int Nwing,
boolean Interp, mem_float *Xp, double Ph, int Inc,
boolean Interp, const mem_float *Xp, double Ph, int Inc,
double dhb);

2 changes: 1 addition & 1 deletion lib-src/libnyquist/nyquist/nyqsrc/lpanal.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void abs_max(double *x, long desde, long hasta, double *x_maxptr, long *indptr)

}

void xcorr(double *s, double *rxx, long N)
void xcorr(const double *s, double *rxx, long N)
{
/* use:
xcorr(s,rxx,N);
Expand Down
8 changes: 4 additions & 4 deletions lib-src/libnyquist/nyquist/nyqsrc/multiseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ sample_block_type multiseq_get_next(sound_type snd, long * cnt);
void multiseq_print_tree(snd_susp_type a_susp, int n);


#define susp_cnt_time(ssp, ms, cnt) (ssp->susp.t0 - ms->t0 + (cnt)/ssp->s1->sr)
#define susp_cnt_time(ssp, ms, cnt) ((ssp)->susp.t0 - (ms)->t0 + (cnt)/(ssp)->s1->sr)
#define susp_time(ssp, ms) susp_cnt_time(ssp, ms, \
(ssp->susp.current + ssp->s1_cnt))
#define susp_low_water(ssp, ms) susp_cnt_time(ssp, ms, ssp->susp.current)
#define susp_log_stop_time(ssp, ms) susp_cnt_time(ssp, ms, ssp->susp.log_stop_cnt)
((ssp)->susp.current + (ssp)->s1_cnt))
#define susp_low_water(ssp, ms) susp_cnt_time(ssp, ms, (ssp)->susp.current)
#define susp_log_stop_time(ssp, ms) susp_cnt_time(ssp, ms, (ssp)->susp.log_stop_cnt)


/* multiseq_advance fetches from each channel to advance to target time */
Expand Down
Loading