Coder Social home page Coder Social logo

Volume control does not seem to work. about nico HOT 11 CLOSED

ftsf avatar ftsf commented on September 27, 2024
Volume control does not seem to work.

from nico.

Comments (11)

ftsf avatar ftsf commented on September 27, 2024

Thanks, I'll look into it!

from nico.

ftsf avatar ftsf commented on September 27, 2024

Hi, looks like it works, however volume is between 0 and 255.
Here's your example code updated to allow you to adjust the volume with left and right buttons, you should be able to hear the volume change as you adjust the volume.

import nico

proc init() =
    music(0,2,0)
    musicVol(255)
    masterVol(255)

proc update(dt : Pfloat) =
  if btnpr(pcLeft):
    # adjust volume down
    var vol = musicVol()
    vol -= 10
    musicVol(vol)
  if btnpr(pcRight):
    # adjust volume up
    var vol = musicVol()
    vol += 10
    musicVol(vol)

proc draw() =
  cls()
  setColor(7)
  # draw music volume
  rectfill(1,1,(screenWidth-1).float32 * musicVol().float32 / 255.0f,4)

nico.init("BeefGame","Random Game")

nico.createWindow("nico",128,128,4,false)
loadMusic(0,"music.ogg")

nico.run(init,update,draw)

from nico.

beef331 avatar beef331 commented on September 27, 2024

That example doesnt run properly either. Volume is at a constant 100%. I tried both system libraries, building sdl2 from source, and also using the Steam Runtime libraries. All have the same volume at 100% unless musicVol is 0, which then it mutes. Video of what happens(Very loud so rip ears)

from nico.

ftsf avatar ftsf commented on September 27, 2024

@beef331 can you confirm which version of nim and nico you're using when this doesn't work?
the above example is working correctly for me with nim 1.2.0 and nico 0.2.1.

from nico.

beef331 avatar beef331 commented on September 27, 2024

Those versions match the ones I'm running. Worth noting my entire system audio gets distorted when launching nico. The issue is not present with your game Moving In.

from nico.

ftsf avatar ftsf commented on September 27, 2024

@beef331 Very strange, which platform are you running this on? I've been testing on Windows 10.
Moving In is made with a very old version of Nico, so it's not directly comparable.

from nico.

beef331 avatar beef331 commented on September 27, 2024

I've had this issue on Ubuntu and Regolith Linux 64bit.

from nico.

ftsf avatar ftsf commented on September 27, 2024

@beef331 ok, i'll do some testing on linux soon, thanks.

from nico.

geotre avatar geotre commented on September 27, 2024

I'm also having audio issues, audio is completely distorted and very loud on the platformer and paint examples.

Ubuntu 18.04
Using sdl2 from the apt repos and sdl2 built from scratch
using libsndfile from apt repos and libsndfile built from scratch

Compiling and running a demo program included with the libsndfile source code does not have the same issue

from nico.

ftsf avatar ftsf commented on September 27, 2024

this should be fixed now! I was using the wrong sample format when opening the audio device. I dont know why it worked on windows.

from nico.

geotre avatar geotre commented on September 27, 2024

Latest update fixed the audio for me πŸ‘

from nico.

Related Issues (20)

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.