orhun / linuxwave

Generate music from the entropy of Linux 🐧🎵
http://orhun.dev/linuxwave/
MIT License
532 stars 15 forks source link

Audible "tick" is produced at the beginning (or end maybe?) of each note #37

Open kevenwyld opened 6 days ago

kevenwyld commented 6 days ago

Describe the bug

Definitely not a big deal, but figured I'd report it since I noticed it. There is an audible "tick" is produced at the beginning (or end maybe?) of each note. You can see it on a spectrogram but also hear it depending on the pitch, distortion, etc.

To reproduce

  1. Run linuxwave -n 27 -o bass.wav
  2. Run ffmpeg -i bass.wav -lavfi showspectrumpic=s=1920x1080:mode=separate spectrogram.png
  3. View spectrogram.png

Expected behavior

A smooth transition between tones or notes

Screenshots / Logs

spectrogram

Software information

Additional context

This is a totally awesome project! Thank you for making it!

It's possible this is unique to my machine. I have only tested on one device.

kevenwyld commented 5 days ago

As far as I can tell this seems to be caused by harsh transitions between each note because the waveforms intersect abruptly rather than decaying and overlapping with the next note.

Screenshot_2024-10-21_09-15-44

orhun commented 5 days ago

Hello, thanks for the report and kind words!

ffmpeg -i bass.wav -lavfi showspectrumpic=s=1920x1080:mode=separate spectrogram.png

This is quite cool, I didn't know ffmpeg could do that!

It's possible this is unique to my machine. I have only tested on one device.

Would love to hear it and compare it with my results if you can share it :)

As far as I can tell this seems to be caused by harsh transitions between each note because the waveforms intersect abruptly rather than decaying and overlapping with the next note.

Yup, that sounds correct. Something is going on in the wav.zig module...

kevenwyld commented 5 days ago

Would love to hear it and compare it with my results if you can share it :)

Here's a file I generated. There was some post processing on this one to resample, and get rid of the DC offset. The original is included in the zip too:

bass_44100.wav.zip

post processing steps:

ffmpeg -i bass.wav -ac 1 -ar 44100 bass_44100.wav
wavegain -y bass_44100.wav

The tick is in the original too but none of my equipment plays nice with the DC offset so I have to post process to play them.

My friend sent me an interesting video about this issue and creating a window function to deal with it. I was messing around with it but I don't quite have the understanding to implement anything yet. https://youtu.be/PjKlMXhxtTM?si=JQPNJWQybmlZVTY5&t=742

orhun commented 3 days ago

bass_44100.wav.zip

Yeah I see. That's an issue that I was aware of but not able to fix so far :/ It's probably related to the encoding of the samples...

My friend sent me an interesting video about this issue and creating a window function to deal with it. I was messing around with it but I don't quite have the understanding to implement anything yet.

That's a good reference - your friend has a big brain!

I tried implementing the Hann window function in #38 - it makes things a bit better. But I think it can be improved. Can you take a look? 🙂