From aae832386fdafe251dc1836b16c20756b22984d3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 23 Feb 2018 09:07:42 +0100 Subject: [PATCH] Fixed warnings in Timidity++ code emitted by XCode, except one which cannot be eliminatet without compromising the code. --- src/sound/i_soundfont.h | 3 +-- src/sound/timiditypp/playmidi.cpp | 11 ++++------- src/sound/timiditypp/recache.h | 11 ++++++----- src/sound/timiditypp/reverb.cpp | 18 ++++++------------ src/sound/timiditypp/sffile.cpp | 6 ++---- src/sound/timiditypp/smplfile.cpp | 7 ++++--- 6 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/sound/i_soundfont.h b/src/sound/i_soundfont.h index 2b470c282d..9208351e48 100644 --- a/src/sound/i_soundfont.h +++ b/src/sound/i_soundfont.h @@ -40,6 +40,7 @@ protected: public: + virtual ~FSoundFontReader() {} virtual FileReader *OpenMainConfigFile() = 0; // this is special because it needs to be synthesized for .sf files and set some restrictions for patch sets virtual FileReader *OpenFile(const char *name) = 0; std::pair LookupFile(const char *name); @@ -96,7 +97,6 @@ class FLumpPatchSetReader : public FSoundFontReader public: FLumpPatchSetReader(const char *filename); - ~FLumpPatchSetReader(); virtual FileReader *OpenMainConfigFile() override; virtual FileReader *OpenFile(const char *name) override; virtual FString basePath() const override @@ -120,7 +120,6 @@ class FPatchSetReader : public FSoundFontReader public: FPatchSetReader(); FPatchSetReader(const char *filename); - ~FPatchSetReader(); virtual FileReader *OpenMainConfigFile() override; virtual FileReader *OpenFile(const char *name) override; virtual FString basePath() const override diff --git a/src/sound/timiditypp/playmidi.cpp b/src/sound/timiditypp/playmidi.cpp index 5f49fdc93c..b8ff70566f 100644 --- a/src/sound/timiditypp/playmidi.cpp +++ b/src/sound/timiditypp/playmidi.cpp @@ -2467,8 +2467,6 @@ void Player::make_drum_effect(int ch) struct DrumParts *drum; struct DrumPartEffect *de; - if (channel[ch].drums == NULL) {return;} - if (channel[ch].drum_effect_flag == 0) { free_drum_effect(ch); memset(note_table, 0, sizeof(int8_t) * 128); @@ -4489,8 +4487,7 @@ void Player::update_rpn_map(int ch, int addr, int update_now) } else channel[ch].drums[note]->pan_random = 0; channel[ch].drums[note]->drum_panning = val; - if (update_now && adjust_panning_immediately - && ! channel[ch].pan_random) + if (update_now && adjust_panning_immediately && ! channel[ch].pan_random) adjust_drum_panning(ch, note); break; case NRPN_ADDR_1D00: /* Reverb Send Level of Drum */ @@ -6123,7 +6120,7 @@ void Player::send_long_event(const uint8_t *sysexbuffer, int exlen) MidiEvent evm[260]; SysexConvert sc; - if ((sysexbuffer[0] != '\xf0') && (sysexbuffer[0] != '\xf7')) return; + if ((sysexbuffer[0] != 0xf0) && (sysexbuffer[0] != 0xf7)) return; if (sc.parse_sysex_event(sysexbuffer + 1, exlen - 1, &ev, instruments)) { @@ -6141,7 +6138,7 @@ void Player::send_long_event(const uint8_t *sysexbuffer, int exlen) } play_event(&ev); } - if (ne = sc.parse_sysex_event_multi(sysexbuffer + 1, exlen - 1, evm, instruments)) + if ((ne = sc.parse_sysex_event_multi(sysexbuffer + 1, exlen - 1, evm, instruments))) { for (i = 0; i < ne; i++) { @@ -6152,4 +6149,4 @@ void Player::send_long_event(const uint8_t *sysexbuffer, int exlen) -} \ No newline at end of file +} diff --git a/src/sound/timiditypp/recache.h b/src/sound/timiditypp/recache.h index 4e9d58e4c8..79f01d611a 100644 --- a/src/sound/timiditypp/recache.h +++ b/src/sound/timiditypp/recache.h @@ -64,11 +64,11 @@ class Recache struct cache_hash *cache[128]; }; - CNote channel_note_table[MAX_CHANNELS] = { 0 }; - sample_t *cache_data = NULL; - splen_t cache_data_len = 0; - struct cache_hash *cache_hash_table[HASH_TABLE_SIZE] = { 0 }; - MBlockList hash_entry_pool = { nullptr, 0 }; + CNote channel_note_table[MAX_CHANNELS]; + sample_t *cache_data; + splen_t cache_data_len; + struct cache_hash *cache_hash_table[HASH_TABLE_SIZE]; + MBlockList hash_entry_pool; void free_cache_data(void); @@ -82,6 +82,7 @@ public: Recache(Player *p) { + memset(this, 0, sizeof(*this)); player = p; resamp_cache_reset(); } diff --git a/src/sound/timiditypp/reverb.cpp b/src/sound/timiditypp/reverb.cpp index 0e69f16828..eaf3396b84 100644 --- a/src/sound/timiditypp/reverb.cpp +++ b/src/sound/timiditypp/reverb.cpp @@ -1284,7 +1284,7 @@ void Reverb::do_ch_freeverb(int32_t *buf, int32_t count, InfoFreeverb *rev) return; } - for (k = 0; k < count; k++) + for (k = 0; k < count; k+=2) { input = reverb_effect_buffer[k] + reverb_effect_buffer[k + 1]; outl = outr = reverb_effect_buffer[k] = reverb_effect_buffer[k + 1] = 0; @@ -1303,7 +1303,6 @@ void Reverb::do_ch_freeverb(int32_t *buf, int32_t count, InfoFreeverb *rev) } buf[k] += imuldiv24(outl, rev->wet1i) + imuldiv24(outr, rev->wet2i); buf[k + 1] += imuldiv24(outr, rev->wet1i) + imuldiv24(outl, rev->wet2i); - ++k; } } @@ -1500,7 +1499,7 @@ void Reverb::do_ch_plate_reverb(int32_t *buf, int32_t count, InfoPlateReverb *in return; } - for (i = 0; i < count; i++) + for (i = 0; i < count; i+=2) { outr = outl = 0; x = (reverb_effect_buffer[i] + reverb_effect_buffer[i + 1]) >> 1; @@ -1573,8 +1572,6 @@ void Reverb::do_ch_plate_reverb(int32_t *buf, int32_t count, InfoPlateReverb *in buf[i] += outl; buf[i + 1] += outr; - - ++i; } info->t1 = t1, info->t1d = t1d; } @@ -2266,7 +2263,7 @@ void Reverb::do_overdrive1(int32_t *buf, int32_t count, EffectList *ef) } else if(count == MAGIC_FREE_EFFECT_INFO) { return; } - for(i = 0; i < count; i++) { + for(i = 0; i < count; i+=2) { input = (buf[i] + buf[i + 1]) >> 1; /* amp simulation */ (this->*do_amp_sim)(&input, asdi); @@ -2281,7 +2278,6 @@ void Reverb::do_overdrive1(int32_t *buf, int32_t count, EffectList *ef) input = imuldiv24(high + input, leveli); buf[i] = do_left_panning(input, pan); buf[i + 1] = do_right_panning(input, pan); - ++i; } } @@ -2317,7 +2313,7 @@ void Reverb::do_distortion1(int32_t *buf, int32_t count, EffectList *ef) } else if(count == MAGIC_FREE_EFFECT_INFO) { return; } - for(i = 0; i < count; i++) { + for(i = 0; i < count; i+=2) { input = (buf[i] + buf[i + 1]) >> 1; /* amp simulation */ (this->*do_amp_sim)(&input, asdi); @@ -2332,7 +2328,6 @@ void Reverb::do_distortion1(int32_t *buf, int32_t count, EffectList *ef) input = imuldiv24(high + input, leveli); buf[i] = do_left_panning(input, pan); buf[i + 1] = do_right_panning(input, pan); - ++i; } } @@ -2504,7 +2499,7 @@ void Reverb::do_hexa_chorus(int32_t *buf, int32_t count, EffectList *ef) spt5 = index - pdelay5 - (f5 >> 8); /* integral part of delay */ if(spt5 < 0) {spt5 += size;} - for(i = 0; i < count; i++) { + for(i = 0; i < count; i+=2) { v0 = ebuf[spt0], v1 = ebuf[spt1], v2 = ebuf[spt2], v3 = ebuf[spt3], v4 = ebuf[spt4], v5 = ebuf[spt5]; @@ -2556,7 +2551,6 @@ void Reverb::do_hexa_chorus(int32_t *buf, int32_t count, EffectList *ef) + do_right_panning(hist4, pan4) + do_right_panning(hist5, pan5) + imuldiv24(buf[i + 1], dryi); - ++i; } buf0->size = size, buf0->index = index; info->spt0 = spt0, info->spt1 = spt1, info->spt2 = spt2, @@ -4434,4 +4428,4 @@ void Reverb::init_effect_status(int play_system_mode) } ///////////////////////////////////////////////////////////////////// -} \ No newline at end of file +} diff --git a/src/sound/timiditypp/sffile.cpp b/src/sound/timiditypp/sffile.cpp index da02477e75..26df7abca0 100644 --- a/src/sound/timiditypp/sffile.cpp +++ b/src/sound/timiditypp/sffile.cpp @@ -257,9 +257,7 @@ int Instruments::chunkid(char *id) {"ICMT", ICMT_ID}, }; - int i; - - for (i = 0; i < sizeof(idlist) / sizeof(idlist[0]); i++) { + for (unsigned i = 0; i < sizeof(idlist) / sizeof(idlist[0]); i++) { if (strncmp(id, idlist[i].str, 4) == 0) return idlist[i].id; } @@ -720,4 +718,4 @@ void Instruments::correct_samples(SFInfo *sf) } } } -} \ No newline at end of file +} diff --git a/src/sound/timiditypp/smplfile.cpp b/src/sound/timiditypp/smplfile.cpp index 80c5862e42..e34703004d 100644 --- a/src/sound/timiditypp/smplfile.cpp +++ b/src/sound/timiditypp/smplfile.cpp @@ -752,7 +752,7 @@ int Instruments::import_aiff_load(char *sample_file, Instrument *inst) if (compressed) { READ_LONG_BE(compressionType); - if (compressionType != BE_LONG(0x4E4F4E45) /* NONE */) + if (compressionType != (uint32_t)BE_LONG(0x4E4F4E45) /* NONE */) { char compressionName[256]; uint8_t compressionNameLength; @@ -789,9 +789,10 @@ int Instruments::read_AIFFSoundDataChunk(struct timidity_file *tf, AIFFSoundData if (mode == 0) /* read both information and data */ return read_AIFFSoundData(tf, sound->inst, sound->common); /* read information only */ - if ((sound->position = tf_tell(tf)) == -1) + auto pos = tf_tell(tf); + if (pos == -1) goto fail; - sound->position += offset; + sound->position = pos + offset; csize -= 8; if (tf_seek(tf, csize, SEEK_CUR) == -1) goto fail;