jameskmurphy / nes

A Nintendo Entertainment System (NES) emulator in Python and Cython.
MIT License
121 stars 10 forks source link

ImportError: cannot import name 'SYNC_AUDIO' from 'nes' #4

Open ManPython opened 7 months ago

ManPython commented 7 months ago

Error:

pygame 2.4.0 (SDL 2.26.4, Python 3.11.3)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "E:\Pyntendo\main.pyw", line 1, in <module>
    from nes import NES, SYNC_AUDIO, SYNC_NONE, SYNC_PYGAME, SYNC_VSYNC
ImportError: cannot import name 'SYNC_AUDIO' from 'nes' (E:\Python311-venv\Lib\site-packages\nes\__init__.py)

Code:

from nes import NES, SYNC_AUDIO, SYNC_NONE, SYNC_PYGAME, SYNC_VSYNC

SYNC_NONE = 0  # no sync: runs very fast, unplayable, music is choppy
SYNC_AUDIO = 1  # sync to audio: rate is perfect, can glitch sometimes, screen tearing can be bad
SYNC_PYGAME = 2  # sync to pygame's clock, adaptive audio: generally reliable, some screen tearing
SYNC_VSYNC = 3  # sync to external vsync, adaptive audio: requires ~60Hz vsync, no tearing

nes = NES(rom_file,                  # the rom file to load
          screen_scale=3,            # factor by which to scale the screen (NES screen is 256x240 pixels with overscan)
          log_file=None,             # file to log to (logging is largely turned off by default and is exceptionally slow for high-volume parts of the system)
          log_level=None,            # level of logging (logging is largely turned off by default)
          opengl=False,              # use opengl for screen rendering
          sync_mode=SYNC_AUDIO,      # audio / video sync mode  (one of SYNC_AUDIO, SYNC_NONE, SYNC_PYGAME, SYNC_VSYNC; see below)
          verbose=True,              # whether to print out cartridge info at startup
          show_nametables=False,     # shows the nametables alongside the main screen (for debug, not compatible with opengl=True)
          vertical_overscan=False,   # show the top and bottom 8 pixels (not usually visible on CRT TVs)
          horizontal_overscan=False, # show the left and right 8 pixels (often not visible on CRT TVs)
          palette_file=None,         # supply a palette file to use; None gives default
          headless=False,            # runs the nes in headless mode without the pygame screen being started
          )

nes = NES("2.nes")
nes.run()
ManPython commented 7 months ago

@jameskmurphy is this support a sound? In whole internet version can't find anything what working with sound.

ManPython commented 7 months ago

Sound working but imports are wrong in relation to docs.

Nsansoterra commented 5 months ago

How did you get audio working? I am struggling to figure it out

Nsansoterra commented 5 months ago

Nevermind, I got it

ManPython commented 5 months ago

; ) You overused params and imports probably as in docs.