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

Use math.min/max and increase volume limit #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DFPWM and MDFPWM audio player for ComputerCraft.
Quartz can be installed by executing the `download.lua` file or by copy pasting this command:

```
wget run https://raw.github.com/Ale32bit/Quartz/main/download.lua
wget run https://raw.github.com/Ale32Bit/Quartz/main/download.lua
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "bit" is lowercase.

```

## Usage
Expand Down Expand Up @@ -44,4 +44,4 @@ Quartz can be configured with the use of the `set` command.
| `quartz.autoplay` | Automatically plays the disk when the program is started. | boolean | `true` |
| `quartz.distributed` | Play mono audio on all speakers attached to the network. This setting disables `quartz.left` and `quartz.right`. Fine tune `quartz.distance` for best coverage. | boolean | `false` |
| `quartz.raw` | Skip the audio filters when decoding DFPWM. | boolean | `false` |
| `quartz.stream.server` | Server URL of the conversion service. No trailing slash. | string | `https://cc.alexdevs.me` |
| `quartz.stream.server` | Server URL of the conversion service. No trailing slash. | string | `https://cc.alexdevs.me` |
4 changes: 2 additions & 2 deletions download.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local base = "https://raw.github.com/Ale32bit/Quartz/main/"
local base = "https://raw.githubusercontent.com/Bioscreeper/Quartz/main/"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change back to original URL.

local files = {
"player.lua",
"quartz/lib/ui.lua",
Expand Down Expand Up @@ -33,4 +33,4 @@ for i, file in ipairs(files) do
download(base .. file, file)
end

print("Quartz downloaded!")
print("Quartz downloaded!")
14 changes: 2 additions & 12 deletions player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -269,23 +269,13 @@ function quartz.loadTrack(tr, src)
end

function quartz.setVolume(vol)
if vol > 1 then
vol = 1
end
if vol < 0 then
vol = 0
end
vol = math.min(math.max(vol, 0), 5)
speakers.volume = vol
os.queueEvent("quartz_volume", vol)
end

function quartz.setDistance(dist)
if dist > 128 then
dist = 128
end
if dist < 0 then
dist = 0
end
dist = math.min(math.max(dist, 1), 3)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set minimum to 0 instead of 1.
The second argument of speaker.playAudio accepts lower than 1 numbers.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also update the relevant documentation to reflect the range change

speakers.distance = dist
os.queueEvent("quartz_distance", dist)
end
Expand Down