diff --git a/doc/guides/local_ips.md b/doc/guides/local_ips.md index c8adf74ce..affad7355 100644 --- a/doc/guides/local_ips.md +++ b/doc/guides/local_ips.md @@ -2,11 +2,15 @@ module: [kind=guide] local_ips --- -# Allowing access to local IPS +# Allowing access to local IPs By default, ComputerCraft blocks access to local IP addresses for security. This means you can't normally access any HTTP server running on your computer. However, this may be useful for testing programs without having a remote server. You can unblock these IPs in the ComputerCraft config. + - [Minecraft 1.13 and later, CC:T 1.87.0 and later](#cc-1.87.0) + - [Minecraft 1.13 and later, CC:T 1.86.2 and earlier](#cc-1.86.2) + - [Minecraft 1.12.2 and earlier](#mc-1.12) + ## Minecraft 1.13 and later, CC:T 1.87.0 and later {#cc-1.87.0} The configuration file can be located at `serverconfig/computercraft-server.toml` inside the world folder on either single-player or multiplayer. Look for lines that look like this: diff --git a/doc/guides/speaker_audio.md b/doc/guides/speaker_audio.md index 0f9652ae4..4cbe9e437 100644 --- a/doc/guides/speaker_audio.md +++ b/doc/guides/speaker_audio.md @@ -125,7 +125,7 @@ different. First, we require the dfpwm module and call @{cc.audio.dfpwm.make_decoder} to construct a new decoder. This decoder accepts blocks of DFPWM data and converts it to a list of 8-bit amplitudes, which we can then play with our speaker. -As mentioned to above, @{speaker.playAudio} accepts at most 128×1024 samples in one go. DFPMW uses a single bit for each +As mentioned above, @{speaker.playAudio} accepts at most 128×1024 samples in one go. DFPMW uses a single bit for each sample, which means we want to process our audio in chunks of 16×1024 bytes (16KiB). In order to do this, we use @{io.lines}, which provides a nice way to loop over chunks of a file. You can of course just use @{fs.open} and @{fs.BinaryReadHandle.read} if you prefer. @@ -136,22 +136,22 @@ You can mix together samples from different streams by adding their amplitudes, samples, etc... Let's put together a small demonstration here. We're going to add a small delay effect to the song above, so that you -hear a faint echo about a second later. +hear a faint echo a second and a half later. In order to do this, we'll follow a format similar to the previous example, decoding the audio and then playing it. However, we'll also add some new logic between those two steps, which loops over every sample in our chunk of audio, and -adds the sample from one second ago to it. +adds the sample from 1.5 seconds ago to it. -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 +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 [Ring Buffer], which helps makes things a little more efficient. ```lua {data-peripheral=speaker} local dfpwm = require("cc.audio.dfpwm") local speaker = peripheral.find("speaker") --- Speakers play at 48kHz, so one second is 48k samples. We first fill our buffer +-- Speakers play at 48kHz, so 1.5 seconds is 72k samples. We first fill our buffer -- with 0s, as there's nothing to echo at the start of the track! -local samples_i, samples_n = 1, 48000 +local samples_i, samples_n = 1, 48000 * 1.5 local samples = {} for i = 1, samples_n do samples[i] = 0 end @@ -162,7 +162,7 @@ for chunk in io.lines("data/example.dfpwm", 16 * 1024) do for i = 1, #buffer do local original_value = buffer[i] - -- Replace this sample with its current amplitude plus the amplitude from one second ago. + -- Replace this sample with its current amplitude plus the amplitude from 1.5 seconds ago. -- We scale both to ensure the resulting value is still between -128 and 127. buffer[i] = original_value * 0.6 + samples[samples_i] * 0.4 @@ -175,6 +175,11 @@ for chunk in io.lines("data/example.dfpwm", 16 * 1024) do while not speaker.playAudio(buffer) do os.pullEvent("speaker_audio_empty") end + + -- The audio processing above can be quite slow and preparing the first batch of audio + -- may timeout the computer. We sleep to avoid this. + -- There's definitely better ways of handling this - this is just an example! + sleep(0.05) end ``` diff --git a/doc/guides/feature_compat.md b/doc/reference/feature_compat.md similarity index 99% rename from doc/guides/feature_compat.md rename to doc/reference/feature_compat.md index a72f5046f..d0b03cf45 100644 --- a/doc/guides/feature_compat.md +++ b/doc/reference/feature_compat.md @@ -1,5 +1,5 @@ --- -module: [kind=guide] feature_compat +module: [kind=reference] feature_compat --- # Lua 5.2/5.3 features in CC: Tweaked diff --git a/illuaminate.sexp b/illuaminate.sexp index 91d1e99ef..7ddafe9e5 100644 --- a/illuaminate.sexp +++ b/illuaminate.sexp @@ -1,9 +1,7 @@ ; -*- mode: Lisp;-*- (sources - /doc/events/ - /doc/guides/ - /doc/stub/ + /doc/ /build/docs/luaJavadoc/ /src/main/resources/*/computercraft/lua/bios.lua /src/main/resources/*/computercraft/lua/rom/ @@ -29,7 +27,8 @@ (peripheral Peripherals) (generic_peripheral "Generic Peripherals") (event Events) - (guide Guides)) + (guide Guides) + (reference Reference)) (library-path /doc/stub/ diff --git a/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java index 56ff2c96b..65ba23dfc 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java @@ -302,7 +302,7 @@ public abstract class SpeakerPeripheral implements IPeripheral * computer is lagging. * ::: * - * {@literal @}{speaker_audio} provides a more complete guide in to using speakers + * {@literal @}{speaker_audio} provides a more complete guide to using speakers * * @param context The Lua context. * @param audio The audio data to play. diff --git a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/audio/dfpwm.lua b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/audio/dfpwm.lua index 281cde7c6..2b5e2d183 100644 --- a/src/main/resources/data/computercraft/lua/rom/modules/main/cc/audio/dfpwm.lua +++ b/src/main/resources/data/computercraft/lua/rom/modules/main/cc/audio/dfpwm.lua @@ -18,11 +18,12 @@ for each one you write. ## Converting audio to DFPWM DFPWM is not a popular file format and so standard audio processing tools will not have an option to export to it. -Instead, you can convert audio files online using [music.madefor.cc] or with the [LionRay Wav Converter][LionRay] Java -application. +Instead, you can convert audio files online using [music.madefor.cc], the [LionRay Wav Converter][LionRay] Java +application or development builds of [FFmpeg]. [music.madefor.cc]: https://music.madefor.cc/ "DFPWM audio converter for Computronics and CC: Tweaked" [LionRay]: https://github.com/gamax92/LionRay/ "LionRay Wav Converter " +[FFmpeg]: https://ffmpeg.org "FFmpeg command-line audio manipulation library" @see guide!speaker_audio Gives a more general introduction to audio processing and the speaker. @see speaker.playAudio To play the decoded audio data. diff --git a/src/web/index.tsx b/src/web/index.tsx index 12405cff0..a9a4a8ceb 100644 --- a/src/web/index.tsx +++ b/src/web/index.tsx @@ -102,7 +102,7 @@ class Window extends Component {
:
;