Skip to content

add correct audio handling for matrix#195

Merged
poVoq merged 4 commits intomatterbridge-org:masterfrom
SwirlyStone5877:master
Apr 11, 2026
Merged

add correct audio handling for matrix#195
poVoq merged 4 commits intomatterbridge-org:masterfrom
SwirlyStone5877:master

Conversation

@SwirlyStone5877
Copy link
Copy Markdown

@SwirlyStone5877 SwirlyStone5877 commented Mar 24, 2026

This is a community managed project, meaning unless someone agrees with you, proposes an alternative solution and makes a PR for it, this will not be "fixed".

ok


dirty hack for specific inclusion to fix #186 and compromise with #45

this was tested with the following filetypes going from discord to matrix:

  • .aac [sent as m.audio, expected]
  • .flac [sent as m.audio, expected]
  • .wav [sent as m.audio, expected]
  • .mid [sent as m.file, expected]
  • .s3m [sent as m.file, expected]

dirty hack for specific inclusion to solve #186 and compromise with #45
@SwirlyStone5877 SwirlyStone5877 changed the title add audio handling add correct audio handling for matrix Mar 24, 2026
@poVoq
Copy link
Copy Markdown
Collaborator

poVoq commented Mar 24, 2026

@Wohlstand any comments on this since you were the one who originally introduced this?

@SwirlyStone5877
Copy link
Copy Markdown
Author

oddly enough it wont lemme edit the pr comment so ill just drop what i meant to append here

  • .it [sent as m.file, expected]
  • .mod [sent as m.file, expected]
  • .xm [sent as m.file, expected]

@Wohlstand
Copy link
Copy Markdown

Hello! I initially made an initial tweak because de-facto these files never arrived the destination at all, and I forced them to be a regular files as a compromise. It's better that file fails to delivery at all.

@SwirlyStone5877
Copy link
Copy Markdown
Author

Also something to add about #45:

Audio files should be uploaded as files, not as voice messages...

The implementation of m.audio depends on the client. Cinny for example simply will not make audio files playable if they aren't m.audio. I'd like to know what client was being used at the time that interpreted it all as voice messages.

@SwirlyStone5877
Copy link
Copy Markdown
Author

SwirlyStone5877 commented Mar 24, 2026

never arrived the destination at all

The files seem to arrive just fine for me, m.audio or not.
https://fs.swirly.architectenterprises.net/screenshot_kR6IEvIzVRebFBc9.png
https://fs.swirly.architectenterprises.net/screenshot_fmDSZKUml0CiT24a.png

@Wohlstand
Copy link
Copy Markdown

never arrived the destination at all

The files seem to arrive just fine for me, m.audio or not.
https://fs.swirly.architectenterprises.net/screenshot_kR6IEvIzVRebFBc9.png
https://fs.swirly.architectenterprises.net/screenshot_fmDSZKUml0CiT24a.png

Could you resend these files just to here via GitHub? This server seems is dead, it doesn't response from any networks I have including a proxy at Nederland.

@Wohlstand
Copy link
Copy Markdown

Also something to add about #45:

Audio files should be uploaded as files, not as voice messages...

The implementation of m.audio depends on the client. Cinny for example simply will not make audio files playable if they aren't m.audio. I'd like to know what client was being used at the time that interpreted it all as voice messages.

On my end I used Element, Schildichat, Nheko, FluffyChat, and such files so just fail. Also, it was a serious issue when OGF Vorbis files that sent from Matrix to Discord as an audio file, to Discord attempted to send as a voice message and of course it hard fails. And the message comes without an attachment. And the same happens with any files are use non typical formats like tracker music, MIDI, chiptunes, and others.

@SwirlyStone5877
Copy link
Copy Markdown
Author

Could you resend these files just to here via GitHub?

Dangit...
Yeah, sorry. Just took my file server down for maintenance. Here.
2026-03-24_15 22 23
2026-03-24_15 22 39

Also, it was a serious issue when OGF Vorbis files that sent from Matrix to Discord as an audio file, to Discord attempted to send as a voice message and of course it hard fails.

From Matrix to Discord? What? I need to test this, hold please...

@SwirlyStone5877
Copy link
Copy Markdown
Author

SwirlyStone5877 commented Mar 24, 2026

OGG Vorbis files from Matrix to Discord seem to send as regular files...
image
image3

@Wohlstand
Copy link
Copy Markdown

OGG Vorbis files from Matrix to Discord seem to send as regular files...
image
image3

It's because now, before my tweaks it was some glitchy attempt to send a voice message. But it was also other troubles when sending files backwardly from Discord to Matrix. That why I made my initial tweak.

@SwirlyStone5877
Copy link
Copy Markdown
Author

Ah, got it... So it would be fine now, of course?

@Wohlstand
Copy link
Copy Markdown

Actually I should verify how it will behave now de-facto.

@SwirlyStone5877
Copy link
Copy Markdown
Author

After throwing this directly at a musician-focused community and a tracker-focused community (testing in prod my beloved), I can confirm that this PR is highly functional with no errors or mishaps going on.

@poVoq
Copy link
Copy Markdown
Collaborator

poVoq commented Apr 8, 2026

Can you please try to fix those CI errors?

Otherwise if there are no objections left, we can probably merge this.

@SwirlyStone5877
Copy link
Copy Markdown
Author

Ah, I thought those CI errors were normal... Will fix in a bit.

@SwirlyStone5877
Copy link
Copy Markdown
Author

SwirlyStone5877 commented Apr 8, 2026

Oddly enough, running golangci-lint fmt matrix.go for myself yields basically zero change (ran diff with both versions of file).

EDIT: apparently fmt wasn't the command to use... Oops.
EDIT 2: Or... was? This is confusing to me.

@poVoq
Copy link
Copy Markdown
Collaborator

poVoq commented Apr 10, 2026

Thanks, seems to pass now.

I'll try to test it on my server this week.

Maybe you could still squash the commits into a single one? @selfhoster1312 always complains when I merge PRs that haven't been squashed 😅

@SwirlyStone5877
Copy link
Copy Markdown
Author

SwirlyStone5877 commented Apr 10, 2026

I would, but there's other's commits in the middle of my commits, and I'm uncertain as to how I would go about this... I'll just squash the last five for now.

EDIT: figured it out.

@poVoq
Copy link
Copy Markdown
Collaborator

poVoq commented Apr 10, 2026

Looks like something went wrong with you pulling older already merged commits into this PR.

@SwirlyStone5877
Copy link
Copy Markdown
Author

SwirlyStone5877 commented Apr 10, 2026

Fixed it. Will actually squash commits later once I learn how... Clearly random guides around the internet are doing me no good.
EDIT: did a bit of research and it seems like that's a side effect of squashing commits that come before other commits... I can only squash the last five, then.

@SwirlyStone5877
Copy link
Copy Markdown
Author

Why...

 This is a combination of 4 commits.

 This is the 1st commit message:
ah yes, change the changelog

 This is the commit message #2:
this is a good word i think

 This is the commit message #3:
run go fmt because ci error

 This is the commit message #4:
maybe?
@poVoq
Copy link
Copy Markdown
Collaborator

poVoq commented Apr 10, 2026

I tested this with an .opus file and it seems to have worked as expected.

(.mp3 files were working before and thus don't need this workaround?)

@SwirlyStone5877
Copy link
Copy Markdown
Author

(.mp3 files were working before and thus don't need this workaround?)

from experience, didn't. will test again.

@SwirlyStone5877
Copy link
Copy Markdown
Author

@poVoq
Copy link
Copy Markdown
Collaborator

poVoq commented Apr 10, 2026

I first tested with an .mp3 only to realize after that it isn't included in the file type list of this PR.

Edit: ahh, wait. I only tested with Element web, and there the .mp3 file played fine.

Edit2: or is .mp3 somehow recognized as an mpeg file?

@SwirlyStone5877
Copy link
Copy Markdown
Author

SwirlyStone5877 commented Apr 11, 2026

Audio format lesson time!
Technically, the .mp3 format is a container, its real name being MPEG-ES. As such its mimetype is audio/mpeg. However, the MP3 codec (not to be confused with the video format MPEG-3) is meant to be contained inside an .mp3 file, and an .mp3 file can only contain an MP3 audio stream.
In any case, the audio/mpeg mimetype also applies to other formats, the only two of which I know about being .m4a and .3gp files.

@poVoq poVoq merged commit 8441760 into matterbridge-org:master Apr 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audio sends as m.file rather than m.audio on Matrix from Discord (and also .mov with m.video)

3 participants