Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presets are glitchy in library but sound good in B+B editor #2434

Closed
karmux opened this issue Oct 31, 2015 · 24 comments
Closed

Presets are glitchy in library but sound good in B+B editor #2434

karmux opened this issue Oct 31, 2015 · 24 comments
Milestone

Comments

@karmux
Copy link
Contributor

karmux commented Oct 31, 2015

BitInvader/Bell, LB302/AngryLead, Monstro/Phat - these sound really bad under My Presets. Most of the presets sound glitchy (and with much more volume) under My Presets but sound completely clean in B+B editor or while playing. LMMS master with SDL or Pulseaudio on Kubuntu 15.04.

@tresf
Copy link
Member

tresf commented Nov 2, 2015

@karmux is there a chance this is a duplicate of #1644?

The bug stores an arpeggio in memory and then plays it on top of another preset. This is most obvious when clicking through the file browser and a few arpeggio presets are in the listing.

@karmux
Copy link
Contributor Author

karmux commented Nov 5, 2015

@tresf , no I don't think so. If I open LMMS and play sound that don't have any arpeggio then it already sounds bad.

@musikBear
Copy link

@tresf perhaps a comprehensive post for everything that has to do with preview? imo preview needs a re-thinking /workover.

  • crashing with multi-click
  • vst-orphans
  • artefacts, like the arp issue

are those i remember right now -if uou are short for time, i can find the tickets where preview is mentioned, and give you a list. I have nothing important today :p
Just let me know.

@Umcaruje
Copy link
Member

@karmux please provide exact steps to reproduce, and if possible an audio recording of the glitched presets.

@karmux
Copy link
Contributor Author

karmux commented Jan 25, 2016

@Umcaruje, I recorded BitInvader/Bell and Monstro/Phat from library and then from song editor. Steps to reproduce is just to click on sample.
http://www.upload.ee/files/5511092/glitchy.ogg.html

@Fastigium
Copy link
Contributor

Reproduced and confirmed for BitInvader/bell.xpf and Monstro/Phat.xpf on Ubuntu 14.04.4 x86_64. Switching the audio interface doesn't seem to matter (tried SDL, alsa and pulseaudio).

Steps to reproduce:

  1. Preview the preset by clicking and holding it in My Presets on the left. Note how it sounds.
  2. Drag the preset to the song editor to create a new track.
  3. Open the instrument panel by clicking the track name.
  4. Press and hold the Y key to produce the exact same note as the preview does. Check if it sounds different.

@tresf
Copy link
Member

tresf commented Feb 17, 2016

Can we please get confirmation that this bug is new to the master branch and not also present with stable-1.1 ?

@Fastigium
Copy link
Contributor

New to master; in stable-1.1 the preview and the song editor version sound identical (SDL audio interface).

@zonkmachine
Copy link
Member

I'll try and bisect this.

@zonkmachine
Copy link
Member

LB302/AngryLead

There is a noise hit in the beginning of AngryLead. If you drop it on a track that noise is played isolated without the actual preset... but the noise is about an octave lower.

@zonkmachine
Copy link
Member

There is a noise hit in the beginning of AngryLead.

Because it's got a plate reverb. There's a transient/glitch being fed into the reverb. I interpret this as the noise belonging to the instrument... So the noise is from setting up the sound from the previous preset. This comment from Fastigium is relevant here then.

@zonkmachine
Copy link
Member

New to master; in stable-1.1 the preview and the song editor version sound identical (SDL audio interface).

I saw this in 1.0.3 . I only got deep into lb302 though and it could off course be up to things of it's own.

@Fastigium
Copy link
Contributor

Interesting observation: for TripleOscillator presets, this bug appears to occur whenever stacking is enabled, even if it's on octave with range 1 (i.e. it plays exactly the same note as it would without stacking). I made a very simple preset that only plays a sine on 1 oscillator, then saved it both without and with stacking. The stackless version previewed fine, the stacked version sounded like crap and gave a waveform like this:

crapsine

I've been hunting through the code for possible causes, but haven't found any so far. It's a complicated beast, and the commits that introduced it are so huge that it doesn't help much in pinpointing. I can confirm that the merging of #1088 introduced the issue, but haven't bisected further because this computer compiles so slowly 😴

@tresf
Copy link
Member

tresf commented Feb 18, 2016

I can confirm that the merging of #1088 introduced the issue

AFAIK, MemoryManager went live with 1.1, so this is also present in stable-1.1, no? P.S. Thanks for the investigation into this.

@Fastigium
Copy link
Contributor

@tresf: stable-1.1 does not appear to have include/BufferManager.h, so I guess not.

@tresf
Copy link
Member

tresf commented Feb 18, 2016

@tresf: stable-1.1 does not appear to have include/BufferManager.h, so I guess not.

👍

@Fastigium
Copy link
Contributor

Some progress: if I disable the BufferManager by making BufferManager::acquire() a wrapper around MM_ALLOC and BufferManager::release() a wrapper around MM_FREE, the previews are fine again. This suggests that somehow, a single buffer ends up being used in multiple places. Now to find where that happens!

@Fastigium
Copy link
Contributor

Yaaaaaar! Found it! PresetPreviewPlayHandle keeps a buffer and shares it with the NotePlayHandle it creates. However, when stacking is enabled, that NotePlayHandle releases its buffer and delegates rendering tasks to its subnotes. PresetPreviewPlayHandle still holds a pointer to that released buffer, though, and is attached to an AudioPort, which means that the released buffer is added to the master channel every mixing round. Any PlayHandle or AudioPort may acquire this buffer at any moment and fill it with anything it likes. This causes the crazy distortions as seen on the screenshot above.

I first tried to solve it by checking the usesBuffer() method of the NotePlayHandle in PresetPreviewPlayHandle::play(), but this does not solve another bug: a TripleOscillator preset with a release > 0 in its envelope is cut off hard at mouse button release when no stacking or arpeggio is enabled. In pull request #2586 I fixed both bugs by using a different solution. Testing welcome, I do hope I didn't break anything while fixing this 😅

@karmux
Copy link
Contributor Author

karmux commented Feb 18, 2016

@Fastigium , awesome! 👍 Previews sound so clean now 😃

@Fastigium
Copy link
Contributor

@karmux Cool! Thanks for testing!

@musikBear
Copy link

@Fastigium et al
🎉 🎈 💎

@tresf
Copy link
Member

tresf commented Feb 19, 2016

@Fastigium per the below change, should this method eventually be removed? Shall we mark it as such (e.g. // TODO: Remove)

void PresetPreviewPlayHandle::play( sampleFrame * _working_buffer )
  {
-   m_previewNote->play( _working_buffer );
+   // Do nothing; the preview instrument is played by m_previewNote, which
+   // has been added to the mixer
  }

@Fastigium
Copy link
Contributor

@tresf Unfortunately all PlayHandles are required to implement a play() method per https://github.com/LMMS/lmms/blob/master/include/PlayHandle.h#L99. The problem is at a more conceptual level; PresetPreviewPlayHandle is not used as a PlayHandle anymore in my solution. I don't see a way to keep it in use without coupling it more closely with NotePlayHandle, and that seems Bad Practice. To really fix this conceptually, PresetPreviewPlayHandle's functionality should probably be moved into PreviewTrackContainer somehow. That's not an entirely trivial operation, though.

@tresf
Copy link
Member

tresf commented Feb 19, 2016

@Fastigium 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants