Wohlstand / libADLMIDI

A Software MIDI Synthesizer library with OPL3 (YMF262) emulator
GNU Lesser General Public License v3.0
176 stars 17 forks source link

Add Highpass Filter @ 5Hz #21

Open sneakernets opened 7 years ago

sneakernets commented 7 years ago

Without a highpass filter: image This is also splattering like mad. It's basically brickwalled.

With a highpass filter: image

That's much better.

Seems like it needs to be done on each chip's output, if that's even possible.

Wohlstand commented 7 years ago

Try to capture real chip's output and tell me does it produces same/similar?

Seems like it needs to be done on each chip's output, if that's even possible.

That possible, but, still a question how result will be heard... I think I can add it as togglable option since it will eat extra CPU while work

sneakernets commented 7 years ago

Unfortunately, I do see this on the real chip, but it was never an issue until multiple cards came into question. I managed to "fix" it by reducing the volume of the offending instruments. Heretic uses a lot of percussion that caused the splattering.

jpcima commented 6 years ago

I've also had some issues of dc offset occasionally with nuked OPL, and I would be happy if these problems go away. You can have a dc filter from a low order IIR, which is only a small computation.

I have this bit of code which may be useful for the purpose.

struct DcFilter {
    double b0_ = 0;
    double p_ = 0;
    double last_in_ = 0;
    double last_out_ = 0;

    // f = normalized cutoff (fc/fs) for -3dB
    void cutoff(double f) {
        double wn = M_PI * f;
        double b0 = b0_ = 1.0 / (1.0 + wn);
        p_ = (1.0 - wn) * b0;
    }

    double process(double in) {
        in *= b0_;
        double out = (in - last_in_) + p_ * last_out_;
        last_in_ = in;
        last_out_ = out;
        return out;
    }
};
jpcima commented 6 years ago

This is easily implemented externally on software using the libADLMIDI, like I do in all of them. If not implemented in libADLMIDI, at least maybe midiplay can have it?

Wohlstand commented 6 years ago

Yeah, let's try to make this on MIDIPlay side and let it be toggle-able to be able compare results :fox_face: :+1:

jpcima commented 6 years ago

Oh yeah.. but I forgot about how audio is not so easily manipulated in this, because of having all of the possible format choices. Do you want that I edit adljack to have the hpf switchable?