Skip to content

Commit 87a1c1a

Browse files
committed
Some minor documentation fixes
- Add a TOC to the Local IPs page. - Increase the echo delay in our speaker audio page to 1.5s. This sounds much better and is less clashy than 1s. Also add a sleep(0) (eww, I know) to fix timeouts on some browsers/computers. - Move Lua feature compat to a new "reference" section. Still haven't figured out how to structure these docs - open to any ideas really. - Mention FFmpeg as an option for converting to DFPWM (closes #1075). - Allow data-mount to override built-in files. See my comment in #1069.
1 parent be45b71 commit 87a1c1a

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

doc/guides/local_ips.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
module: [kind=guide] local_ips
33
---
44

5-
# Allowing access to local IPS
5+
# Allowing access to local IPs
66
By default, ComputerCraft blocks access to local IP addresses for security. This means you can't normally access any
77
HTTP server running on your computer. However, this may be useful for testing programs without having a remote
88
server. You can unblock these IPs in the ComputerCraft config.
99

10+
- [Minecraft 1.13 and later, CC:T 1.87.0 and later](#cc-1.87.0)
11+
- [Minecraft 1.13 and later, CC:T 1.86.2 and earlier](#cc-1.86.2)
12+
- [Minecraft 1.12.2 and earlier](#mc-1.12)
13+
1014
## Minecraft 1.13 and later, CC:T 1.87.0 and later {#cc-1.87.0}
1115
The configuration file can be located at `serverconfig/computercraft-server.toml` inside the world folder on either
1216
single-player or multiplayer. Look for lines that look like this:

doc/guides/speaker_audio.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ different.
125125
First, we require the dfpwm module and call @{cc.audio.dfpwm.make_decoder} to construct a new decoder. This decoder
126126
accepts blocks of DFPWM data and converts it to a list of 8-bit amplitudes, which we can then play with our speaker.
127127

128-
As mentioned to above, @{speaker.playAudio} accepts at most 128×1024 samples in one go. DFPMW uses a single bit for each
128+
As mentioned above, @{speaker.playAudio} accepts at most 128×1024 samples in one go. DFPMW uses a single bit for each
129129
sample, which means we want to process our audio in chunks of 16×1024 bytes (16KiB). In order to do this, we use
130130
@{io.lines}, which provides a nice way to loop over chunks of a file. You can of course just use @{fs.open} and
131131
@{fs.BinaryReadHandle.read} if you prefer.
@@ -136,22 +136,22 @@ You can mix together samples from different streams by adding their amplitudes,
136136
samples, etc...
137137

138138
Let's put together a small demonstration here. We're going to add a small delay effect to the song above, so that you
139-
hear a faint echo about a second later.
139+
hear a faint echo a second and a half later.
140140

141141
In order to do this, we'll follow a format similar to the previous example, decoding the audio and then playing it.
142142
However, we'll also add some new logic between those two steps, which loops over every sample in our chunk of audio, and
143-
adds the sample from one second ago to it.
143+
adds the sample from 1.5 seconds ago to it.
144144

145-
For this, we'll need to keep track of the last 48k samples - exactly one seconds worth of audio. We can do this using a
145+
For this, we'll need to keep track of the last 72k samples - exactly 1.5 seconds worth of audio. We can do this using a
146146
[Ring Buffer], which helps makes things a little more efficient.
147147

148148
```lua {data-peripheral=speaker}
149149
local dfpwm = require("cc.audio.dfpwm")
150150
local speaker = peripheral.find("speaker")
151151

152-
-- Speakers play at 48kHz, so one second is 48k samples. We first fill our buffer
152+
-- Speakers play at 48kHz, so 1.5 seconds is 72k samples. We first fill our buffer
153153
-- with 0s, as there's nothing to echo at the start of the track!
154-
local samples_i, samples_n = 1, 48000
154+
local samples_i, samples_n = 1, 48000 * 1.5
155155
local samples = {}
156156
for i = 1, samples_n do samples[i] = 0 end
157157

@@ -162,7 +162,7 @@ for chunk in io.lines("data/example.dfpwm", 16 * 1024) do
162162
for i = 1, #buffer do
163163
local original_value = buffer[i]
164164

165-
-- Replace this sample with its current amplitude plus the amplitude from one second ago.
165+
-- Replace this sample with its current amplitude plus the amplitude from 1.5 seconds ago.
166166
-- We scale both to ensure the resulting value is still between -128 and 127.
167167
buffer[i] = original_value * 0.6 + samples[samples_i] * 0.4
168168

@@ -175,6 +175,11 @@ for chunk in io.lines("data/example.dfpwm", 16 * 1024) do
175175
while not speaker.playAudio(buffer) do
176176
os.pullEvent("speaker_audio_empty")
177177
end
178+
179+
-- The audio processing above can be quite slow and preparing the first batch of audio
180+
-- may timeout the computer. We sleep to avoid this.
181+
-- There's definitely better ways of handling this - this is just an example!
182+
sleep(0.05)
178183
end
179184
```
180185

doc/guides/feature_compat.md renamed to doc/reference/feature_compat.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
module: [kind=guide] feature_compat
2+
module: [kind=reference] feature_compat
33
---
44

55
# Lua 5.2/5.3 features in CC: Tweaked

illuaminate.sexp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
; -*- mode: Lisp;-*-
22

33
(sources
4-
/doc/events/
5-
/doc/guides/
6-
/doc/stub/
4+
/doc/
75
/build/docs/luaJavadoc/
86
/src/main/resources/*/computercraft/lua/bios.lua
97
/src/main/resources/*/computercraft/lua/rom/
@@ -29,7 +27,8 @@
2927
(peripheral Peripherals)
3028
(generic_peripheral "Generic Peripherals")
3129
(event Events)
32-
(guide Guides))
30+
(guide Guides)
31+
(reference Reference))
3332

3433
(library-path
3534
/doc/stub/

src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public final boolean playSound( ILuaContext context, String name, Optional<Doubl
302302
* computer is lagging.
303303
* :::
304304
*
305-
* {@literal @}{speaker_audio} provides a more complete guide in to using speakers
305+
* {@literal @}{speaker_audio} provides a more complete guide to using speakers
306306
*
307307
* @param context The Lua context.
308308
* @param audio The audio data to play.

src/main/resources/data/computercraft/lua/rom/modules/main/cc/audio/dfpwm.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ for each one you write.
1818
1919
## Converting audio to DFPWM
2020
DFPWM is not a popular file format and so standard audio processing tools will not have an option to export to it.
21-
Instead, you can convert audio files online using [music.madefor.cc] or with the [LionRay Wav Converter][LionRay] Java
22-
application.
21+
Instead, you can convert audio files online using [music.madefor.cc], the [LionRay Wav Converter][LionRay] Java
22+
application or development builds of [FFmpeg].
2323
2424
[music.madefor.cc]: https://music.madefor.cc/ "DFPWM audio converter for Computronics and CC: Tweaked"
2525
[LionRay]: https://github.com/gamax92/LionRay/ "LionRay Wav Converter "
26+
[FFmpeg]: https://ffmpeg.org "FFmpeg command-line audio manipulation library"
2627
2728
@see guide!speaker_audio Gives a more general introduction to audio processing and the speaker.
2829
@see speaker.playAudio To play the decoded audio data.

src/web/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Window extends Component<WindowProps, WindowState> {
102102
</div>
103103
<div class="computer-container">
104104
<Computer key={exampleIdx} files={{
105-
...example!.files, ...defaultFiles
105+
...defaultFiles, ...example!.files,
106106
}} peripherals={{ back: example!.peripheral }} />
107107
</div>
108108
</div> : <div class="example-window example-window-hidden" />;

0 commit comments

Comments
 (0)