Skip to content

Changing to Pyglet from Soloud for Sound #746

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

Merged
merged 65 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
74a33f1
feat(sound): Initial Pyglet sound implementation
Cleptomania Sep 3, 2020
692a051
Update to automatically load ffmpeg
Cleptomania Sep 3, 2020
5d5c6d2
feat(sound): Final auto-loading of ffmpeg. Also added Windows ffmpeg …
Cleptomania Sep 3, 2020
6854123
Moved "libs" into arcade module
Cleptomania Sep 3, 2020
d7a590c
moved ffmpeg library loading to main __init__ so that it happens befo…
Cleptomania Sep 3, 2020
bdf249a
tests(sound): Increased test coverage for sound module
Cleptomania Sep 4, 2020
e754451
tests(sound): Improvements to duration checking tests
Cleptomania Sep 4, 2020
8abf1e2
tests(sound): Improvements for cross-platform checking of sound durat…
Cleptomania Sep 4, 2020
aec1f47
tests(sound): more duration checking fixes
Cleptomania Sep 4, 2020
c9c864d
tests(sound): removed duration checking tests
Cleptomania Sep 4, 2020
de41451
build: Pinned minimum Pyglet version of 1.5.2 to ensure full support …
Cleptomania Sep 4, 2020
2f1e1e7
build: Removed ffmpeg binaries for Windows
Cleptomania Sep 4, 2020
75a3a39
build: Added maximum Pyglet version to avoid updating to Pyglet 2
Cleptomania Sep 4, 2020
354856f
docs(sound): Improved comments for the Sound module
Cleptomania Sep 4, 2020
87a5bdb
Highlight imporant lines in move-by-keyboard example.
pvcraven Oct 9, 2020
fe14de8
Update sprite movement by keyboard example code.
pvcraven Oct 9, 2020
5af11c4
Update examples around moving animations, and facing left/right.
pvcraven Oct 12, 2020
5287261
Index buffer example: template with shader
einarf Oct 17, 2020
0fb2af3
Bug: num_vertices incorrect when index buffer is used
einarf Oct 17, 2020
c61dea9
Geometry: Remove old error check
einarf Oct 17, 2020
8c42f30
Example: Working index buffer example
einarf Oct 17, 2020
c310f5b
Geometry: Support 8, 16 and 32 bit index buffers
einarf Oct 17, 2020
8b9fa92
Index buffer example
einarf Oct 17, 2020
3bc3e4c
Tests: Missing BufferDescription checks
einarf Oct 18, 2020
a684af5
Tests: 8, 16 and 32 bit index buffers
einarf Oct 18, 2020
9fdf3aa
Fix gui tests (missing 'on_resize' and 'on_update' event type on Mock…
eruvanos Oct 18, 2020
1ab5209
gl: Missing type Context type hints
einarf Oct 24, 2020
de81dcf
arcade.gl: Improve module description
einarf Oct 26, 2020
3ccb80f
Spelling errors
einarf Oct 27, 2020
7d68288
Remove redundant tobytes() calls
einarf Oct 27, 2020
6aa6465
docs: gl module warning should be more visible
einarf Oct 29, 2020
2582e81
docs: customize arcade.gl index
einarf Oct 29, 2020
3c98901
gl: Instancing example
einarf Nov 3, 2020
e256e4d
Update instancing.py
einarf Nov 4, 2020
fdcafd4
Tessellation shader support
einarf Nov 4, 2020
570d80c
Tessellation example: Bezier curve
einarf Nov 4, 2020
093886b
draw_commands: Specify return types in docs
einarf Nov 5, 2020
c53c7e4
ArcadeContext: Allow loading tessellation shaders from file
einarf Nov 6, 2020
dbb724e
Window: Allow specifying opengl version
einarf Nov 6, 2020
83c6316
Tessellation example should request OpenGL 4.1
einarf Nov 6, 2020
64bb3f3
release notes spelling error
einarf Nov 6, 2020
12c6707
Release notes mockup (unreleased)
einarf Nov 6, 2020
c238dcc
Structural changes to better support rapidly playing sounds
Cleptomania Nov 7, 2020
c953495
BufferDescription: Sanity check buffer parameter
einarf Nov 7, 2020
070c7e8
Fix incorrect PyInstaller data file path handling docs #773 (#774)
SirGnip Nov 7, 2020
e45a756
Added Texture.byte_size + tests
einarf Nov 7, 2020
094e28d
Merge branch 'development' of https://github.com/pythonarcade/arcade …
einarf Nov 7, 2020
9844fba
Issue #782 Using shapely to find line of sight (#783)
akapkotel Nov 7, 2020
3051413
Merge remote-tracking branch 'upstream/development' into using_shapel…
akapkotel Nov 16, 2020
91dd7f1
Update setuptools configuration to align with PEP 517/518 (#780)
Cleptomania Nov 16, 2020
604ca70
feat(sound): Initial Pyglet sound implementation
Cleptomania Sep 3, 2020
559d4a4
Update to automatically load ffmpeg
Cleptomania Sep 3, 2020
d8c40f3
feat(sound): Final auto-loading of ffmpeg. Also added Windows ffmpeg …
Cleptomania Sep 3, 2020
dc1e9c6
Moved "libs" into arcade module
Cleptomania Sep 3, 2020
db88442
moved ffmpeg library loading to main __init__ so that it happens befo…
Cleptomania Sep 3, 2020
945e04c
tests(sound): Increased test coverage for sound module
Cleptomania Sep 4, 2020
c7b7231
tests(sound): Improvements to duration checking tests
Cleptomania Sep 4, 2020
f5e393c
tests(sound): Improvements for cross-platform checking of sound durat…
Cleptomania Sep 4, 2020
c8688e2
tests(sound): more duration checking fixes
Cleptomania Sep 4, 2020
b1518c6
tests(sound): removed duration checking tests
Cleptomania Sep 4, 2020
1b13888
build: Removed ffmpeg binaries for Windows
Cleptomania Sep 4, 2020
69ce65d
docs(sound): Improved comments for the Sound module
Cleptomania Sep 4, 2020
1b7ac89
Structural changes to better support rapidly playing sounds
Cleptomania Nov 7, 2020
2a1dc95
Merge branch 'sound-pyglet' of github.com:pythonarcade/arcade into so…
Cleptomania Nov 19, 2020
4a5c61b
Update build MANIFSET to remove SoLoud and add ffmpeg binaries
Cleptomania Nov 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
# one-liner to get extensions in package: set([l.split(",")[0].split('.')[-1] for l in open('files.txt').readlines()])

recursive-exclude arcade *.pyc
recursive-include arcade *.typed
recursive-include arcade/resources *.txt *.md *.url
recursive-include arcade/resources *.mp3 *.wav *.ogg
recursive-include arcade/resources *.png *.jpg *.gif
recursive-include arcade/resources *.tmx *.tsx
recursive-include arcade/resources *.glsl
recursive-include arcade/resources *.yml
recursive-include arcade/soloud *.dll *.dylib *.so
recursive-include arcade/lib *.dylib
20 changes: 19 additions & 1 deletion arcade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# Error out if we import Arcade with an incompatible version of Python.
import platform
import sys
import os

from pathlib import Path

if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 6):
sys.exit("The Arcade Library requires Python 3.6 or higher.")
Expand All @@ -31,6 +34,22 @@ def configure_logging(level: int = None):
ch.setFormatter(logging.Formatter('%(relativeCreated)s %(name)s %(levelname)s - %(message)s'))
LOG.addHandler(ch)

# The following is used to load ffmpeg libraries.
# Currently Arcade is only shipping binaries for Mac OS
# as ffmpeg is not needed for support on Windows and Linux.
# However it is setup to load ffmpeg if the binaries are present
# on Windows and Linux. So if you need ffmpeg you can simply
# drop the binaries in the "lib" folder of Arcade
lib_location = Path(__file__).parent.absolute()
lib_location = lib_location / "lib"

if sys.platform == "darwin" or sys.platform.startswith("linux"):
if "LD_LIBRARY_PATH" in os.environ:
os.environ["LD_LIBRARY_PATH"] += ":" + str(lib_location)
else:
os.environ["LD_LIBRARY_PATH"] = str(lib_location)
else:
os.environ["PATH"] += str(lib_location)

# noinspection PyPep8
import pyglet
Expand Down Expand Up @@ -443,4 +462,3 @@ def configure_logging(level: int = None):
]

__version__ = VERSION

7 changes: 5 additions & 2 deletions arcade/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self,
resizable: bool = False,
update_rate: Optional[float] = 1 / 60,
antialiasing: bool = True,
gl_version: Tuple[int, int] = (3, 3),
screen: pyglet.canvas.Screen = None):
"""
Construct a new window
Expand All @@ -69,10 +70,12 @@ def __init__(self,
:param bool resizable: Can the user resize the window?
:param float update_rate: How frequently to update the window.
:param bool antialiasing: Should OpenGL's anti-aliasing be enabled?
:param Tuple[int,int] gl_version: What OpenGL version to request. This is ``(3, 3)`` by default
and can be overridden when using more advanced OpenGL features.
"""
if antialiasing:
config = pyglet.gl.Config(major_version=3,
minor_version=3,
config = pyglet.gl.Config(major_version=gl_version[0],
minor_version=gl_version[1],
double_buffer=True,
sample_buffers=1,
samples=4)
Expand Down
10 changes: 10 additions & 0 deletions arcade/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def load_program(
vertex_shader: Union[str, Path],
fragment_shader: Union[str, Path] = None,
geometry_shader: Union[str, Path] = None,
tess_control_shader: Union[str, Path] = None,
tess_evaluation_shader: Union[str, Path] = None,
defines: dict = None,
) -> Program:
"""Create a new program given a file names that contain the vertex shader and
Expand Down Expand Up @@ -211,17 +213,25 @@ def load_program(
vertex_shader_src = resolve_resource_path(vertex_shader).read_text()
fragment_shader_src = None
geometry_shader_src = None
tess_control_src = None
tess_evaluation_src = None

if fragment_shader:
fragment_shader_src = resolve_resource_path(fragment_shader).read_text()

if geometry_shader:
geometry_shader_src = resolve_resource_path(geometry_shader).read_text()

if tess_control_shader and tess_evaluation_shader:
tess_control_src = resolve_resource_path(tess_control_shader)
tess_evaluation_src = resolve_resource_path(tess_evaluation_shader)

return self.program(
vertex_shader=vertex_shader_src,
fragment_shader=fragment_shader_src,
geometry_shader=geometry_shader_src,
tess_control_shader=tess_control_src,
tess_evaluation_shader=tess_evaluation_src,
defines=defines,
)

Expand Down
22 changes: 12 additions & 10 deletions arcade/draw_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def draw_ellipse_filled(center_x: float, center_y: float,
program['color'] = color_normalized
program['shape'] = width / 2, height / 2, tilt_angle
program['segments'] = num_segments
buffer.write(data=array.array('f', (center_x, center_y)).tobytes())
buffer.write(data=array.array('f', (center_x, center_y)))

geometry.render(program, mode=gl.GL_POINTS, vertices=1)

Expand Down Expand Up @@ -328,7 +328,7 @@ def draw_ellipse_outline(center_x: float, center_y: float, width: float,
:param float tilt_angle: Angle in degrees to tilt the ellipse.
:param int num_segments: Number of triangle segments that make up this
circle. Higher is better quality, but slower render time.
The default value of -1 means arcade will try to calulate a reasonable
The default value of -1 means arcade will try to calculate a reasonable
amount of segments based on the size of the circle.
"""
window = get_window()
Expand All @@ -348,7 +348,7 @@ def draw_ellipse_outline(center_x: float, center_y: float, width: float,
program['color'] = color_normalized
program['shape'] = width / 2, height / 2, tilt_angle, border_width
program['segments'] = num_segments
buffer.write(data=array.array('f', (center_x, center_y)).tobytes())
buffer.write(data=array.array('f', (center_x, center_y)))

geometry.render(program, mode=gl.GL_POINTS, vertices=1)

Expand Down Expand Up @@ -454,8 +454,8 @@ def gen_flatten(my_list):
ctx.generic_draw_line_strip_vbo.orphan(ctx.generic_draw_line_strip_vbo.size * 2)
ctx.generic_draw_line_strip_color.orphan(ctx.generic_draw_line_strip_color.size * 2)

ctx.generic_draw_line_strip_vbo.write(vertices.tobytes())
ctx.generic_draw_line_strip_color.write(a.tobytes())
ctx.generic_draw_line_strip_vbo.write(vertices)
ctx.generic_draw_line_strip_color.write(a)

geometry.render(program, mode=mode)

Expand Down Expand Up @@ -514,7 +514,7 @@ def draw_line(start_x: float, start_y: float, end_x: float, end_y: float,
program['line_width'] = line_width
program['color'] = color_normalized
ctx.shape_line_buffer_pos.write(
data=array.array('f', [start_x, start_y, end_x, end_y]).tobytes())
data=array.array('f', [start_x, start_y, end_x, end_y]))
geometry.render(program, mode=gl.GL_LINES, vertices=2)

# NOTE: Keep old code just in case
Expand Down Expand Up @@ -558,7 +558,7 @@ def draw_lines(point_list: PointList,
program['line_width'] = line_width
program['color'] = color_normalized
ctx.shape_line_buffer_pos.write(
data=array.array('f', [v for point in point_list for v in point]).tobytes())
data=array.array('f', [v for point in point_list for v in point]))
geometry.render(program, mode=gl.GL_LINES, vertices=len(point_list))

# Keep old code just in case
Expand Down Expand Up @@ -911,7 +911,7 @@ def draw_rectangle_filled(center_x: float, center_y: float, width: float,

program['color'] = color_normalized
program['shape'] = width, height, tilt_angle
buffer.write(data=array.array('f', (center_x, center_y)).tobytes())
buffer.write(data=array.array('f', (center_x, center_y)))
geometry.render(program, mode=ctx.POINTS, vertices=1)

# p1 = [-width // 2 + center_x, -height // 2 + center_y]
Expand Down Expand Up @@ -996,7 +996,7 @@ def get_pixel(x: int, y: int) -> Tuple[int, int, int]:

:param int x: x location
:param int y: y location
:returns: Color
:rtype: Color
"""
# noinspection PyCallingNonCallable,PyTypeChecker

Expand All @@ -1016,14 +1016,16 @@ def get_pixel(x: int, y: int) -> Tuple[int, int, int]:
return red, green, blue


def get_image(x: int = 0, y: int = 0, width: int = None, height: int = None):
def get_image(x: int = 0, y: int = 0, width: int = None, height: int = None) -> PIL.Image.Image:
"""
Get an image from the screen.

:param int x: Start (left) x location
:param int y: Start (top) y location
:param int width: Width of image. Leave blank for grabbing the 'rest' of the image
:param int height: Height of image. Leave blank for grabbing the 'rest' of the image
:returns: A Pillow Image
:rtype: PIL.Image.Image

You can save the image like:

Expand Down
38 changes: 11 additions & 27 deletions arcade/examples/sprite_face_left_or_right.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"""

import arcade
import os

SPRITE_SCALING = 0.5

Expand All @@ -21,6 +20,7 @@

MOVEMENT_SPEED = 5

# Index of textures, first element faces left, second faces right
TEXTURE_LEFT = 0
TEXTURE_RIGHT = 1

Expand All @@ -30,18 +30,19 @@ class Player(arcade.Sprite):
def __init__(self):
super().__init__()

self.scale = SPRITE_SCALING
self.textures = []

# Load a left facing texture and a right facing texture.
# flipped_horizontally=True will mirror the image we load.
texture = arcade.load_texture(":resources:images/enemies/bee.png")
self.textures.append(texture)
texture = arcade.load_texture(":resources:images/enemies/bee.png", flipped_horizontally=True)
texture = arcade.load_texture(":resources:images/enemies/bee.png",
flipped_horizontally=True)
self.textures.append(texture)

self.scale = SPRITE_SCALING

# By default, face right.
self.set_texture(TEXTURE_RIGHT)
self.texture = texture

def update(self):
self.center_x += self.change_x
Expand All @@ -53,16 +54,6 @@ def update(self):
elif self.change_x > 0:
self.texture = self.textures[TEXTURE_RIGHT]

if self.left < 0:
self.left = 0
elif self.right > SCREEN_WIDTH - 1:
self.right = SCREEN_WIDTH - 1

if self.bottom < 0:
self.bottom = 0
elif self.top > SCREEN_HEIGHT - 1:
self.top = SCREEN_HEIGHT - 1


class MyGame(arcade.Window):
"""
Expand All @@ -77,15 +68,8 @@ def __init__(self, width, height, title):
# Call the parent class initializer
super().__init__(width, height, title)

# Set the working directory (where we expect to find files) to the same
# directory this .py file is in. You can leave this out of your own
# code, but it is needed to easily run the examples using "python -m"
# as mentioned at the top of this program.
file_path = os.path.dirname(os.path.abspath(__file__))
os.chdir(file_path)

# Variables that will hold sprite lists
self.all_sprites_list = None
self.player_sprite_list = None

# Set up the player info
self.player_sprite = None
Expand All @@ -97,13 +81,13 @@ def setup(self):
""" Set up the game and initialize the variables. """

# Sprite lists
self.all_sprites_list = arcade.SpriteList()
self.player_sprite_list = arcade.SpriteList()

# Set up the player
self.player_sprite = Player()
self.player_sprite.center_x = SCREEN_WIDTH / 2
self.player_sprite.center_y = SCREEN_HEIGHT / 2
self.all_sprites_list.append(self.player_sprite)
self.player_sprite_list.append(self.player_sprite)

def on_draw(self):
"""
Expand All @@ -114,14 +98,14 @@ def on_draw(self):
arcade.start_render()

# Draw all the sprites.
self.all_sprites_list.draw()
self.player_sprite_list.draw()

def on_update(self, delta_time):
""" Movement and game logic """

# Call update on all sprites (The sprites don't do much in this
# example though.)
self.all_sprites_list.update()
self.player_sprite_list.update()

def on_key_press(self, key, modifiers):
"""Called whenever a key is pressed. """
Expand Down
Loading