Coder Social home page Coder Social logo

netcoreaudio's People

Contributors

cmjchrisjones avatar empowerfiodar avatar fiodarsazanavets avatar munzili avatar thefner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

netcoreaudio's Issues

Feature request: Volume control

It would be great if the player had a way to set the volume. This would also allow users of the library to build things like fade-in and fade-out or crossfade between different tracks.

I would have made a PR if I could test for linux and mac, but I did throw something together that works on windows:

[DllImport("winmm.dll")]
private static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);
[DllImport("winmm.dll")]
private static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);

public int GetVolume()
{
    var result = waveOutGetVolume(IntPtr.Zero, out var v);
    if (result != 0)
        throw new Exception($"Error executing command 'waveOutGetVolume'. Error code: {result}.");

    var volume = Math.Min(100, v * 100 / ushort.MaxValue);
    return (int)volume;
}

public void SetVolume(int volume)
{
    var v = (uint)(ushort.MaxValue * Math.Max(0, Math.Min(100, volume)) / 100.0);

    var result = waveOutSetVolume(IntPtr.Zero, v);
    if (result != 0)
        throw new Exception($"Error executing command 'waveOutSetVolume'. Error code: {result}.");
}

It always takes the first audio device (IntPtr hwo) - I don't know if this is always correct and it would probably not scale to playing multiple sounds simultaneously but it worked for me. Another thing to note is that if you get the volume without ever having set it, then it will return uint.MaxValue (or something close to it), but my code just converts it to max volume which I think is correct.

[FeatureRequest][BUG] amixer: Unable to find simple control 'Master',0

Hi,

I have try to implement the volume control for linux and I have the error amixer: Unable to find simple control 'Master',0, I know why, I don't have a Master but on your code, for linux var tempProcess = StartBashProcess($"amixer -M set 'Master' {percent}%"); you specify on it the Master

Can you take on argument of Player ctor, in case of linux, the control interface and by default Master ?

Regards

Playing a file just throws an error

Attempting to play a .wav file (or .mp3 file), just throws an error code 266:

image

Windows 10 (latest) with .net core 2.2.
Looks like the error code is this: "Unknown problem while loading the specified device driver." Error 266 is MCIERR_CANNOT_LOAD_DRIVER.

Error when play .wav and .mp3

I get an error whenever trying to run the line
Player.Play(filePath).GetAwaiter().GetResult();

Error
Error executing MCI command 'Status C:\Users\Panda\source\repos\TextToSpeechApi\TextToSpeechApi\bin\Debug\netcoreapp2.1\Voices\testing sound.mp3 Length'. Error code: 310. Message: Specify a device or driver name that is less than 79 characters.

Wasn't sure if this was the same error that has already been posted considering the Error code is different...

Bug: PlaybackFinished event is raise before the audio stops

Platform: Windows

Steps to reproduce:

  1. Instantiate Player
  2. Subscribe to PlaybackFinished event
  3. Play an mp3 file

Expected behaviour:
PlaybackFinished event should be raised when audio stops.

Actual behaviour:
After PlaybackFinished event is raised, audio still plays for 1 or 2 seconds.

Code example:

Player player = new Player();

player.PlaybackFinished += (sender, args) =>
{
   // This event is triggered even if the player still has 1 or 2 seconds to play.
};

player.Play(path);

Resume Freeze MacOS

Whenever I try to use SetVolume before or after calling play or pause, my app freezes. Also, pause makes the sound sort of repeat on a small bit of audio over and over.

Cannot play sounds in quick succession.

I am using the sound component to play a sound in a game when a person makes the wrong selection. The button is attached to an eventhandler that plays the error sound file(about 1 second of audio) with player.play(). If the person presses the wrong button quickly it will crash with a few different errors using the following code:

if (player.Playing || player.Paused)
   {
      await player.Stop();
   }

await player.Play(fileName);

Mainly with Object reference not set to an instance of an object.' on the stop command. or with 'Error executing MCI command 'Close All'. Error code: 288. Message: The specified device is now being closed. Wait a few seconds, and then try again.' on the play command.

Is there a better way to do this? Is there any way to reuse the connection and play different sounds without having to destroy the object and restart it every time which seems to be causing the problem here?

I have only tested this on Windows but the application will run on both windows and Linux(Raspberry Pi).

Feature request: mp4 support

As a .NET Core developer, I've been struggling to read audio from a mp4 file. Why would you ask? Well, I've been trying to basically play mp4 files and, while that's working, I can't seem to be able to get audio to work for some reason.

So now I'm using this library (which works great) to load in a different file (an mp3 extracted from the mp4), but I'd love to have support for mp4 files too!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.