Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with linux mint 19 snap package #19

Open
thehans opened this issue Mar 19, 2020 · 11 comments
Open

Problems with linux mint 19 snap package #19

thehans opened this issue Mar 19, 2020 · 11 comments

Comments

@thehans
Copy link

thehans commented Mar 19, 2020

I just installed the snap package and the music sounds very distorted, warbling compared to the html5 version which worked fine for me.

Also attempting to playback recorded files just starts the game normally and doesn't show me the recording: .\ascii-patrol 2 filename.rec

@msokalski
Copy link
Owner

Audio problem, can be related to pulse pulseaudio configuration or snapcraft library packager. I think best we can try is to build game from sources on your system. Let me know if it makes any difference or if you need help with it.

Regarding rec file replaying, I have no clue, just looked into temp.cpp, beginning of main() function, I cannot see how it could run game instead of replay.

@thehans
Copy link
Author

thehans commented Mar 20, 2020

OK, i built from source and the recording playback works now, but I still have the sound issues.

I don't understand much about linux sound but I ran pactl list and saw some differences between running in browser vs terminal, which maybe help explain whats going on?

Here is a diff of the relevant sections from each:
https://gist.github.com/thehans/b64c309063b320697237e20647b0583e/revisions

This difference seemed noteworthy: (terminal)
Sample Specification: s16le 2ch 44100Hz
vs browser
Sample Specification: float32le 2ch 44100Hz
Does this mean maybe its mis-interpreting float sample data as signed 16 bit?

Also not sure if this is relevant but the terminal run seems to have 1/5th the buffer latency, and no "Resample method", whatever that means:

	Buffer Latency: 19705 usec
	Sink Latency: 100866 usec
	Resample method: n/a

Compared to browser:

	Buffer Latency: 97006 usec
	Sink Latency: 100934 usec
	Resample method: copy

@thehans
Copy link
Author

thehans commented Mar 20, 2020

I figured I'd also upload a sample so you can hear what I hear:
asciipat.wav.zip
I recorded with audacity on its default settings.

Strangely I think I notice slightly more stuttering/crackling when playing back the wav compared to what I hear when recording it, but the "warbling" is mostly the same.

edit: Also, while it could just be something wonky about my pulse config, this is the first application I've experienced any audio issues with on this system.

@msokalski
Copy link
Owner

msokalski commented Mar 21, 2020

Thanks for update on the issue!
Your wav recording sounds like buffer latency is too short. I didn't have problems with 20ms before but it may be worth to try increasing it to 50ms.
Could you try to replace it in spec_nix.cpp (line: 1658)?

attr.tlength = 44100*2*sizeof(short) * 20/1000

Just change 20/1000 to 50/1000 and recompile.

If it solves the problem I'll add env var for tweaking it without need to rebuild :)

@thehans
Copy link
Author

thehans commented Mar 21, 2020

It didn't help. I tried 50ms, then 200, then even removing the divisor entirely for a full 1s buffer, and it sounds clean for the first second, then just goes back to warbling.

@thehans
Copy link
Author

thehans commented Mar 21, 2020

I created another gist, this time comparing audio going through my NVIDA card HDMI cable, instead of onboard sound line-out that I normally use.
It actually sounds fine when I use NVIDIA's audio, but I don't use this because I can only hear through tiny anemic speakers builtin to my cheap monitor.

This time I included the full output of pactl list, for the onboard HD Audio analog line-out, and the HDMI output:
https://gist.github.com/thehans/a35510e1ea68f87695270146df3fc0b2/revisions
The main thing I see here is that NVIDIA card is set to 48K Hz instead of 44.1
edit: looks like the unused device just defaults to 48KHz, but both are 44.1 during use.

Here are the two devices snipped from sudo lspci -vvv:

...
08:00.1 Audio device: NVIDIA Corporation TU116 High Definition Audio Controller (rev a1)                             
        Subsystem: eVga.com. Corp. Device 1161
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 0, Cache Line Size: 64 bytes                                                                
        Interrupt: pin B routed to IRQ 103                                                                  
        Region 0: Memory at f7080000 (32-bit, non-prefetchable) [size=16K]
        Capabilities: [60] Power Management version 3                  
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+                              
                Address: 0000000000000000  Data: 0000                                                                     
        Capabilities: [78] Express (v2) Endpoint, MSI 00                                                     
                DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s unlimited, L1 <64us                   
                        ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset- SlotPowerLimit 0.000W
                DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-
                        RlxdOrd+ ExtTag+ PhantFunc- AuxPwr- NoSnoop+
                        MaxPayload 128 bytes, MaxReadReq 512 bytes
                DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend+
                LnkCap: Port #0, Speed 8GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <1us, L1 <4us
                        ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp+
                LnkCtl: ASPM L0s L1 Enabled; RCB 64 bytes Disabled- CommClk+
                        ExtSynch- ClockPM+ AutWidDis- BWInt- AutBWInt-
                LnkSta: Speed 8GT/s, Width x16, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
                DevCap2: Completion Timeout: Range AB, TimeoutDis+, LTR+, OBFF Via message
                DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
                LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
                         EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
        Capabilities: [100 v2] Advanced Error Reporting
                UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UEMsk:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
                CESta:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr-
                CEMsk:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
                AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel
...
0a:00.3 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) HD Audio Controller
        Subsystem: ASUSTeK Computer Inc. Family 17h (Models 00h-0fh) HD Audio Controller                
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx- 
        Latency: 0, Cache Line Size: 64 bytes                                                               
        Interrupt: pin C routed to IRQ 105                         
        Region 0: Memory at f7a00000 (32-bit, non-prefetchable) [size=32K]
        Capabilities: [48] Vendor Specific Information: Len=08 <?>        
        Capabilities: [50] Power Management version 3             
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0+,D1-,D2-,D3hot+,D3cold+)                
                Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-                                       
        Capabilities: [64] Express (v2) Endpoint, MSI 00                                                    
                DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <4us, L1 unlimited
                        ExtTag+ AttnBtn- AttnInd- PwrInd- RBE+ FLReset- SlotPowerLimit 0.000W             
                DevCtl: Report errors: Correctable- Non-Fatal- Fatal- Unsupported-                           
                        RlxdOrd+ ExtTag+ PhantFunc- AuxPwr- NoSnoop+
                        MaxPayload 256 bytes, MaxReadReq 512 bytes
                DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend-
                LnkCap: Port #0, Speed 8GT/s, Width x16, ASPM L0s L1, Exit Latency L0s <64ns, L1 <1us
                        ClockPM- Surprise- LLActRep- BwNot- ASPMOptComp+
                LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- CommClk+
                        ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
                LnkSta: Speed 8GT/s, Width x16, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
                DevCap2: Completion Timeout: Range ABCD, TimeoutDis+, LTR-, OBFF Not Supported
                DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-, LTR-, OBFF Disabled
                LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
                         EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
        Capabilities: [a0] MSI: Enable+ Count=1/1 Maskable- 64bit+
                Address: 00000000fee00000  Data: 0000
        Capabilities: [100 v1] Vendor Specific Information: ID=0001 Rev=1 Len=010 <?>
        Capabilities: [150 v2] Advanced Error Reporting
                UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UEMsk:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt- UnxCmplt- RxOF- MalfTLP- ECRC- UnsupReq- ACSViol-
                UESvrt: DLP+ SDES+ TLP- FCP+ CmpltTO- CmpltAbrt- UnxCmplt- RxOF+ MalfTLP+ ECRC- UnsupReq- ACSViol-
                CESta:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
                CEMsk:  RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+
                AERCap: First Error Pointer: 00, GenCap- CGenEn- ChkCap- ChkEn-
        Capabilities: [2a0 v1] Access Control Services
                ACSCap: SrcValid- TransBlk- ReqRedir- CmpltRedir- UpstreamFwd- EgressCtrl- DirectTrans-
                ACSCtl: SrcValid- TransBlk- ReqRedir- CmpltRedir- UpstreamFwd- EgressCtrl- DirectTrans-
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel
...

Thanks for any help you can provide. Just wanted to say that despite my audio troubles, I'm truly blown away by the quality of "graphics" you've accomplished with this game!

@msokalski
Copy link
Owner

msokalski commented Mar 22, 2020

No! What's wrong with onboard chip?
Could you please try this beep program, it makes almost the same setup as ascii-patrol and is written by pulseaudio developer. Only difference I can see is that beep uses 1 channel (mono) and calls pa_usec_to_bytes() to calculate buffer sizes while ascii-patrol calculates it on its own, so there's a hope that using this function may do some magic but necessary rounding / alignments.

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/Samples/AsyncPlayback/

EDIT: function has extra rounding on single sample size (num of channels * sizeof(amplitude_value)) but for 20ms this rounding would do nothing, so that is not our case unfortunately.

@thehans
Copy link
Author

thehans commented Mar 22, 2020

I built the sample pa-beep. I had to add #include <math.h> for cos function
And for some reason gcc wouldn't link pulse libs with the build command given on that page, but clang worked for me, after adding -lm for math lib.

Here's some of my observations:

  • The first line just outputs random (uninitialized?) latency for me
  • Latency is ramped up quickly after the first few output lines to 100-200ms, and tends to mostly hover somewhere around 200ms
  • Sometimes latency randomly goes down much lower around 40ms, sometimes single digit ms, and even occasionally shows 0us for a consecutive second or two.
  • I get a small pop every 6-7seconds, but I think that's just the sampledata buffer not being an exact multiple length of the waveform.
  • If I change the volume via my system tray (it plays its own little system sound effect when I do this), this seems to mess with the pulse latency and causes even more pops/stuttering. (only observed with asciipat and pa-beep so far)
  • Since all other apps I use for audio are GUI based and work ok, I thought maybe something about GNOME Terminal was to blame, I tried in virtual console (Ctrl-Alt-F1) and got the same audio problems. I also use byobu (frontend for GNU screen), so I tested outside of that, in a bare bash shell, and again same audio problems in asciipat.

Here's the output from running pa-beep for a few seconds, and scrolling the volume up and down a bit at the same time.
log.txt.zip

@msokalski
Copy link
Owner

Not good. I wish we could find some minimal pulseaudio example that plays well on your system. So last blind shot is pacat it simply copies some raw audio data to device. Could you try it?
Thank you for your patience :)

@thehans
Copy link
Author

thehans commented Mar 22, 2020

pacat works fine. I recorded audio from asciipatrol in browser with audacity, 44100Hz, 16-bit PCM, then exported as RAW uncompressed 16-bit signed PCM, and played the file from terminal pacat without any distortion.

I also tested the volume changing trick, which did not add any errors during pacat playback.

But for some reason, if I changed the volume during recording in Audacity, afterwards, the playback has huge stutters(totally different from warbling before) during every little blip from the system volume change sound.
During the recording it actually sounds fine, its just what audacity records that is wrong, like it can't mix two sources properly... no idea if that helps understand what's wrong, but I attached the raw file where I change volume 4 ticks over ~10s.
stutter.raw.zip

@msokalski
Copy link
Owner

Ok, I'll try to find the difference, at least it should play fine whitout sliding the volume at the same time. Thanks!
Once I've something to test I'll let you know right here.

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

No branches or pull requests

2 participants