Audio API #5389

Closed
benno1237 wants to merge 45 commits from benno1237/audio_api into V3/develop
benno1237 commented 2021-10-13 19:42:35 +02:00 (Migrated from github.com)

(Semi) Functional API for Red's audio cog

this is proof of concept PR and is far from being ready to review yet. I am however more than happy about any comments/suggestions/contributions. It's quite a lot of code so expect some things to break please. I will thoroughly test this in the near future and hopefully eliminate each and every issue.
Since it is just a draft PR for now, I also didn't really care about code style tools like isort and black.

Yes, it adds 10k+ lines. Atm, there is heaps of duplicated code in the API and core audio. My idea was however to keep the initial PR as "small" as somehow possible. Thus core audio only has the changes which are needed in order for it to work (hopefully?). IF an interest exists however, I will go ahead and rewrite the majority of core audio to use the functionality provided by this API.

Semi good docs of what it includes can be seen here: https://red-discordbot-audio.readthedocs.io/en/latest/framework_audio.html

Please, ignore the messy commit history.

### (Semi) Functional API for Red's audio cog this is proof of concept PR and is far from being ready to review yet. I am however more than happy about any comments/suggestions/contributions. It's quite a lot of code so expect some things to break please. I will thoroughly test this in the near future and hopefully eliminate each and every issue. Since it is just a draft PR for now, I also didn't really care about code style tools like isort and black. Yes, it adds 10k+ lines. Atm, there is heaps of duplicated code in the API and core audio. My idea was however to keep the initial PR as "small" as somehow possible. Thus core audio only has the changes which are needed in order for it to work (hopefully?). IF an interest exists however, I will go ahead and rewrite the majority of core audio to use the functionality provided by this API. Semi good docs of what it includes can be seen here: https://red-discordbot-audio.readthedocs.io/en/latest/framework_audio.html Please, ignore the messy commit history.
aikaterna (Migrated from github.com) reviewed 2021-10-13 19:42:35 +02:00
PredaaA (Migrated from github.com) reviewed 2021-10-13 19:42:35 +02:00
Vexed01 (Migrated from github.com) reviewed 2022-01-04 22:08:38 +01:00
Vexed01 (Migrated from github.com) left a comment

Hey Benno,

First off I just want to say thank you for doing this. It's great to be able to hook into audio and I'll be honest, I was surprised when my simple piece of code worked first time!

I've just got a few things as review comments for the example.

The API itself is working great, so far I have a podcasts cog over at Vexed01/vex-unsupported-cogs which functions.

However, I've noticed some of the core audio commands don't appear to work. llset java and llset external don't respond and neither does play or sing. now skip stop disconnect do work for me. I'm running the latest version (as of midday 4th Jan) with external lavalink on 1275.

I also sometimes get this whenever I start my bot:

[16:25:27] INFO     [red] Loading packages...
           ERROR    [red.core.audio.lavalink] Unhandled exception whilst connecting to Lavalink, aborting...
╭─────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────╮
│ c:\data\git\vexed-unsupported-cogs\.venv\lib\site-packages\redbot\core\audio_utils\lavalink.py:105 in start                                      │
│ ❱ 105                     resume_key=f"Red-Core-Audio-{self._bot.user.id}-{data_manager.instan                                                   │
│       ce_name}"                                                                                                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'NoneType' object has no attribute 'id'

I also got this on my cog; the fix was await bot.wait_until_red_ready() in a task before initializing the connection. You might want to add this to the example as well as Red.

Hey Benno, First off I just want to say thank you for doing this. It's great to be able to hook into audio and I'll be honest, I was surprised when my simple piece of code worked first time! I've just got a few things as review comments for the example. The API itself is working great, so far I have a podcasts cog over at [Vexed01/vex-unsupported-cogs](https://github.com/Vexed01/vex-unsupported-cogs) which functions. However, I've noticed some of the core audio commands don't appear to work. `llset java` and `llset external` don't respond and neither does `play` or `sing`. `now` `skip` `stop` `disconnect` do work for me. I'm running the latest version (as of midday 4th Jan) with external lavalink on 1275. I also *sometimes* get this whenever I start my bot: ``` [16:25:27] INFO [red] Loading packages... ERROR [red.core.audio.lavalink] Unhandled exception whilst connecting to Lavalink, aborting... ╭─────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────╮ │ c:\data\git\vexed-unsupported-cogs\.venv\lib\site-packages\redbot\core\audio_utils\lavalink.py:105 in start │ │ ❱ 105 resume_key=f"Red-Core-Audio-{self._bot.user.id}-{data_manager.instan │ │ ce_name}" │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ AttributeError: 'NoneType' object has no attribute 'id' ``` I also got this on my cog; the fix was `await bot.wait_until_red_ready()` in a task before initializing the connection. You might want to add this to the example as well as Red.
@ -0,0 +1,186 @@
.. config shite
Vexed01 (Migrated from github.com) commented 2022-01-04 11:41:51 +01:00
            self.bot.loop.create_task(self.shutdown())
```suggestion self.bot.loop.create_task(self.shutdown()) ```
Vexed01 (Migrated from github.com) commented 2022-01-04 11:48:33 +01:00
                player = await audio.connect(self.bot, ctx.author.voice.channel)
```suggestion player = await audio.connect(self.bot, ctx.author.voice.channel) ```
Vexed01 (Migrated from github.com) commented 2022-01-04 11:49:00 +01:00
            self.bot.loop.create_task(self.initialize())
```suggestion self.bot.loop.create_task(self.initialize()) ```
Vexed01 (Migrated from github.com) commented 2022-01-04 21:48:23 +01:00
            await ctx.send(f"Successfully connected to {channel.mention}")
```suggestion await ctx.send(f"Successfully connected to {channel.mention}") ```
benno1237 commented 2022-01-05 19:02:01 +01:00 (Migrated from github.com)

Again, thanks for your effort Vexed. You were right, the sing command wasn't working. Latest commit has a few changes which did fix it for me tho. The play command however was working for me beforehand too. Would be nice to further elaborate on that (or did the last commit fix that for you?).
Thanks for your docs changes too. Did them manually in my IDE so... should be all present in the latest commit

Again, thanks for your effort Vexed. You were right, the sing command wasn't working. Latest commit has a few changes which did fix it for me tho. The play command however was working for me beforehand too. Would be nice to further elaborate on that (or did the last commit fix that for you?). Thanks for your docs changes too. Did them manually in my IDE so... should be all present in the latest commit
Vexed01 commented 2022-01-06 16:35:45 +01:00 (Migrated from github.com)

Talked about this in Discord. Everything I've tried now works for me, this gets a big 👍 for functionality.

Talked about this in Discord. Everything I've tried now works for me, this gets a big 👍 for functionality.
laggron42 (Migrated from github.com) reviewed 2022-01-19 12:18:54 +01:00
laggron42 (Migrated from github.com) left a comment

Hey, first of all thanks a lot for this PR, it's great to be able to extend Audio's features while staying compatible with the cog, and I have been waiting for this, so I was excited to try it out!

This PR is big, and I want to test it properly on my bot. I will explain what I'm gonna do in the following days/months:

Our blind test events

I wanted to try the API by writing a blind test cog. If you don't know, a blind test is basically throwing some songs with the bot, and people have to try to guess the music first.

We use the Audio cog for these events a lot and it's working well. However, it's a horrible mess to manage, we usually need one animator who does the talk, and someone else for managing the bot. Imagine the following situation :

  • You have between 10 and 40 people listening in a voice channel and talking in a text channel, members that you have to moderate, and watch their answers (it's really spammy)
  • While watching that channel, you have to manage the bot. The playlist feature is not adapted to this event (we don't want the bot to skip over to the next song automatically, and skipping starts the song automatically)
  • So we're queuing the songs one by one. !play, !stop, !play, !stop, but that's not all!
  • When the animator is talking, you have to lower the bot's volume so he can be heard. !volume 20, !volume 70, !volume 20, !volume 70, ...

Mix the command mess, the moderation in that active channel, the talking, watching for answers, writing the scores in a separate doc, also finding the next song link... And that's how we currently manage blind tests, a lot of work that could be simplified.

The blind test cog

So I had the idea of making things easier with the bot for long, but the components and audio API are what motivated me to finally do it!

It's a player. With buttons. You load a playlist, then you shall only have to use buttons, and no one talks/enter commands.

Here's a demo video. I know, it's french, but you should mostly understand it. (Buttons when clicking on the menu mean: bumpskip, bump, remove, insert song after x).

https://user-images.githubusercontent.com/23153234/150119026-9c8e269e-a68b-4273-b360-ffa738879446.mp4

The issues I had so far

Lot of them. Then none. If you saw my conversation on Discord, you saw that I had some issues, well I couldn't reproduce any of them :P

I will report what I have in the future, but for now it's pretty stable, and I can fall back to the Audio cog's commands easily. I guess the issues caused in the beginning were due to my intense testing and let lavalink in a weird state.

How things will go

I'm gonna move Botnol (99 servers, handles a 27k members server alone) to dpy2 and audio API from now on for Audio features, and will report issues, both from the API and the Audio cog.

This is just a comment review, but things started well! If it's still stable after some time, I will approve the PR and comment the experience I had. Thanks a lot for your hard work, I hope this will be merged soon!


Oh btw, I published my blind test cog, you can see it here : https://github.com/laggron42/Laggrons-Dumb-Cogs/tree/blind_test/alpha/blindtest

Hey, first of all thanks a lot for this PR, it's great to be able to extend Audio's features while staying compatible with the cog, and I have been waiting for this, so I was excited to try it out! This PR is **big**, and I want to test it properly on my bot. I will explain what I'm gonna do in the following days/months: ## Our blind test events I wanted to try the API by writing a blind test cog. If you don't know, a blind test is basically throwing some songs with the bot, and people have to try to guess the music first. We use the Audio cog for these events a lot and it's working well. However, it's a horrible mess to manage, we usually need one animator who does the talk, and someone else for managing the bot. Imagine the following situation : - You have between 10 and 40 people listening in a voice channel and talking in a text channel, members that you have to moderate, and watch their answers (it's really spammy) - While watching that channel, you have to manage the bot. The playlist feature is not adapted to this event (we don't want the bot to skip over to the next song automatically, and skipping starts the song automatically) - So we're queuing the songs one by one. !play, !stop, !play, !stop, but that's not all! - When the animator is talking, you have to lower the bot's volume so he can be heard. !volume 20, !volume 70, !volume 20, !volume 70, ... Mix the command mess, the moderation in that active channel, the talking, watching for answers, writing the scores in a separate doc, also finding the next song link... And that's how we currently manage blind tests, a lot of work that could be simplified. ## The blind test cog So I had the idea of making things easier with the bot for long, but the components and audio API are what motivated me to finally do it! It's a player. With buttons. You load a playlist, then you shall only have to use buttons, and no one talks/enter commands. Here's a demo video. I know, it's french, but you should mostly understand it. (Buttons when clicking on the menu mean: bumpskip, bump, remove, insert song after x). https://user-images.githubusercontent.com/23153234/150119026-9c8e269e-a68b-4273-b360-ffa738879446.mp4 ## The issues I had so far Lot of them. Then none. If you saw my conversation on Discord, you saw that I had some issues, well I couldn't reproduce any of them :P I will report what I have in the future, but for now it's pretty stable, and I can fall back to the Audio cog's commands easily. I guess the issues caused in the beginning were due to my intense testing and let lavalink in a weird state. ## How things will go I'm gonna move Botnol (99 servers, handles a 27k members server alone) to dpy2 and audio API from now on for Audio features, and will report issues, both from the API and the Audio cog. This is just a comment review, but things started well! If it's still stable after some time, I will approve the PR and comment the experience I had. Thanks a lot for your hard work, I hope this will be merged soon! ---- Oh btw, I published my blind test cog, you can see it here : https://github.com/laggron42/Laggrons-Dumb-Cogs/tree/blind_test/alpha/blindtest
Vexed01 (Migrated from github.com) reviewed 2022-01-19 22:35:09 +01:00
@ -0,0 +1,231 @@
import asyncio
Vexed01 (Migrated from github.com) commented 2022-01-19 22:35:09 +01:00

Hey Benno, just noticed this when external Lavalink is configured but unavailable:
traceback

Hey Benno, just noticed this when external Lavalink is configured but unavailable: ![traceback](https://img.vexcodes.com/IYV8xE)
Owner

Ich schließe den PR: Er umfasst über 10.000 geänderte Zeilen in 84 Dateien, stammt von 2021 und hat massive Konflikte mit dem heutigen Audio-Cog (Lavalink-v4-Umbau, Java-Versionen, neue Managed-Node-Logik). So ist er weder reviewbar noch portierbar. Eine Audio-API müsste neu und in kleinen Schritten gegen den aktuellen Code entstehen.


Generated by Claude Code

Ich schließe den PR: Er umfasst über 10.000 geänderte Zeilen in 84 Dateien, stammt von 2021 und hat massive Konflikte mit dem heutigen Audio-Cog (Lavalink-v4-Umbau, Java-Versionen, neue Managed-Node-Logik). So ist er weder reviewbar noch portierbar. Eine Audio-API müsste neu und in kleinen Schritten gegen den aktuellen Code entstehen. --- _Generated by [Claude Code](https://claude.ai/code)_
Mrcoolgamer11 closed this pull request 2026-11-21 22:32:03 +01:00

Pull request closed

Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!5389
No description provided.