Music file rhythm and intensity detection on Xamarin.Forms - c#

Our product is a dimmable light bulb, connected via Bluetooth and App, App can adjust the brightness (color) of the bulb, the brightness value is 1-100.
Now the App wants to add a function that automatically dims according to music (Mp3). While playing music, it automatically adjusts the brightness of the light according to the rhythm and sound size of the music.
The music has been played using https://github.com/adrianstevens/Xamarin-Plugins/tree/master/SimpleAudioPlayer
My question is, when playing music (Mp3), how do I convert the rhythm and intensity of the music to a 1-100 number and send it as a brightness value to the light bulb?
A lot of C# (Windows-based) music analysis examples were found online, but Xamarin was not found.
Thank you for your help!

Sounds cool! There are two parts to your problem,
Enhancing the audio player - Since you have implemented the Audio Player already, all you need to do is add a Value changed event to the slider, as shown in this official Microsoft Example, so that changing the value of the slider will now also communicate with your device/bulb
Communicating with your device - This will depend on how your device accepts values over bluetooth. We wouldn't be able to know for sure what serial values your bulb is accepting, but you have to send serial data values through bluetooth. You can use this to help simplify with this part.

Related

Joining a channel on Agora (Unity/iOS) makes in-game music almost inaudible

I'm trying to integrate Agora voice SDK in a multiplayer project (built using Photon). The level has loads of 3D spacial audio setup and a background music that is properly audible. The moment I join a voice channel, all the in-game audio levels drop drastically. The voice chat volume itself sounds fine however. And this happens only on actual device(iOS), not on Unity editor.
I tried reproducing this issue in the HelloUnity3D sample scene that comes with the SDK. No code change. Simply added an audio source in the scene with a music clip. Seems to be happening there as well.
Is this expected? How do I keep Agora from modifying other audio sources?
Unity version:2020.3.28f1. Agora SDK version: 3.5.0.70
For anyone running into this issue, I was able to fix it by setting the audio profile to AUDIO_SCENARIO_GAME_STREAMING.
mRtcEngine.SetAudioProfile(AUDIO_PROFILE_TYPE.AUDIO_PROFILE_SPEECH_STANDARD, AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_GAME_STREAMING);
The idea is to simply treat the voice chat audio as media volume instead of 'call' volume.
This answer about audio ducking with the Agora SDK is likely what you're after. You might have to add some iOS specific code to your project to achieve it:
https://stackoverflow.com/a/62840934/2156765

C# bass detection from windows audio output

I want to create somewhat of a simple visualizer for my PC audio output channel (same as speakers/headphones) that will send signals to my arduino board when there is bass or treble being played. I already have LEDs wired up and my own program with animations and colors running, I also developed a game modification that lets me control the lights using game events. All I need now is to read my PC audio output channel, find there a specific sound (probably bass, right?) and send byte on serial port just as I did previously.
I can't find any simple tutorials how to read windows audio so I decided to ask here. Where should I start? BASS.NET looks very complicated for that "simple" task. Is there something built-in in standard .NET libraries? I am by no means audio mastermind, I am not even sure if I am using correct terms. In simple words I just want to make lights light up to the rhythm when there is real-time music playing.

How to change from rear to front audio input?

Is there a way in c# to change rear and front audio input volume or default device?
I've tried looking for existing answers, but I can't find any information for this.

set a video as background on mobile app unity

I am making a login screen for a mobile app in unity3d, that has a video keep on playing in the background and can work on iOS and Android. I have searched online and found out movie texture doesn't work on mobile.
Currently I only can play a video using Handheld.PlayFullScreenMovie, but it is not what I want. I want the video playing and still see the text and have button to click.
I see similar post Set a video as background. But I am using C#. Does anyone know how to do this in unity? Many Thanks!

I want help and idea about how to draw The path of GPS in C#

as you can see i want to do senior project about soccer player tracking with gps to show the path that player was using or tracking in real time
i already study about basic gps function in c# but I Really Have problems on how to draw paths on the map or picture that i want to use after we got the data from gps.
the hardware part are already finish but i get stuck in and idea for how to get the data from gps to draw path of player
I appreciate with any help on me ( sorry for bad english) Thank you very much
Link of my designed project picture :
http://image.ohozaa.com/view2/weK9gVKBzGZqRxKC
Just think about what you're doing.
GPS data (from each player) is received as a sequence of points (Latitude/Longitude?).
Convert those points to X/Y coordinates for your football field image
Use a graphics API (such as GDI / System.Drawing ) to draw lines between subsequent points
If you're using C# you might save time and trouble by using WinForms and subclassing Control and painting directly to the control's surface. You'll need to store a list of all the recent points for each player (because you'll need to constantly repaint the control).
Note that the geolocation features in .NET won't help you here unless all of your football players are going to be carrying laptops strapped to their backs. You'd want small GPS trackers attached to each player along with a small radiotransmitter that sends the data. An easy way to do this is with a commodity Bluetooth GPS unit, but I don't know if Bluetooth can support that many transceivers in such a small space, or even if the signal will reach from one end of the field to another. The most expensive way is to write a phone app and have each player carry a smartphone that sends geolocation data via a 3G or Wifi connection.
Note that GPS units tend to have a usable accuracy of about 5m (maybe 2.5m on a good day), and are useless indoors. Then consider the 5 minutes it takes for them to secure a good lock in the first place (mobile phones have quick geolocation because they use assistance from mobile phone masts). Football fields aren't very big, and even with 2.5m accuracy the data isn't going to be very useful.
In real sports they don't use GPS for this reason. Instead they use higher-precision radio units and specialist transmitter/receiver units placed around the pitch. An alternative is visual tracking, but that's an immature science (Turing help you if two players or more wearing the same team colour collapse into each other).
Looking at the picture you provided I'd say something like this is feasible with a WPF application using the Canvas control and the Line class. You'd have to convert your GPS data to (x,y)-coordinates where the origin is located at the upper left corner of the soccer field. Then you could connect subsequent points using line segments.

Categories