Skip to content

Commit d1c1827

Browse files
committed
ci: 🎨 GitHub actions + improving readme
1 parent 8ded27a commit d1c1827

File tree

7 files changed

+73
-50
lines changed

7 files changed

+73
-50
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
strategy:
10+
fail-fast: false
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Install Crystal
15+
uses: oprypin/install-crystal@v1
16+
with:
17+
crystal: latest
18+
19+
- name: Install linux dependencies
20+
run: |
21+
sudo apt install libopus-dev
22+
23+
- name: Download source
24+
uses: actions/checkout@v2
25+
26+
- name: Install dependencies
27+
run: shards install
28+
29+
# - name: Run specs
30+
# run: |
31+
# crystal spec
32+
# crystal spec --release --no-debug
33+
34+
- name: Check formatting
35+
run: crystal tool format --check
36+
37+
- name: Run ameba linter
38+
run: bin/ameba
39+
40+
- name: Build
41+
run: |
42+
crystal build --progress --time --stats src/opus.cr

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,47 @@
1-
# opus-cr
1+
# Opus
2+
23

3-
TODO: Write a description here
44

55
## Installation
66

77
1. Add the dependency to your `shard.yml`:
88

99
```yaml
1010
dependencies:
11-
opus-cr:
12-
github: your-github-user/opus-cr
11+
opus:
12+
github: krthr/opus
1313
```
1414
1515
2. Run `shards install`
1616

1717
## Usage
1818

1919
```crystal
20-
require "opus-cr"
21-
```
20+
require "opus"
2221
23-
TODO: Write usage instructions here
22+
sample_rate = 48_000
23+
frame_size = 960
24+
channels = 2
2425
25-
## Development
26+
encoder = Opus::Encoder.new(sample_rate, frame_size, channels)
2627
27-
TODO: Write development instructions here
28+
buffer = Bytes.new(encoder.input_length, 0)
29+
30+
while real_length = audio_data.read(buffer)
31+
break if real_length.zero?
32+
opus_encoded_data = encoder.encode(buffer)
33+
# Use the encoded data
34+
end
35+
```
2836

2937
## Contributing
3038

31-
1. Fork it (<https://github.com/your-github-user/opus-cr/fork>)
39+
1. Fork it (<https://github.com/krthr/opus/fork>)
3240
2. Create your feature branch (`git checkout -b my-new-feature`)
3341
3. Commit your changes (`git commit -am 'Add some feature'`)
3442
4. Push to the branch (`git push origin my-new-feature`)
3543
5. Create a new Pull Request
3644

3745
## Contributors
3846

39-
- [Wilson](https://github.com/your-github-user) - creator and maintainer
47+
- [Wilson](https://github.com/krthr) - creator and maintainer

shard.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,13 @@ authors:
66

77
crystal: ">= 1.12.0"
88

9+
documentation: https://crystaldoc.info/github/krthr/opus
10+
11+
libraries:
12+
libopus: "*"
13+
914
license: MIT
15+
16+
development_dependencies:
17+
ameba:
18+
github: crystal-ameba/ameba

spec/opus-cr_spec.cr

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
require "./spec_helper"
22

3-
describe Opus::Cr do
4-
# TODO: Write tests
5-
3+
describe Opus do
64
it "works" do
75
false.should eq(true)
86
end

spec/spec_helper.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
require "spec"
2-
require "../src/opus-cr"
2+
require "../src/opus"

src/opus.cr

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,5 @@
1-
require "log"
21
require "./opus/encoder"
32

43
module Opus
54
VERSION = "0.1.0"
65
end
7-
8-
# sample_rate = 48_000
9-
# channels = 2
10-
11-
# encoder = Opus::Encoder.new(sample_rate, 960, channels)
12-
13-
# input = File.open("/Users/krthr/Projects/discord-music/output.mp3", "r")
14-
# output = File.open("output.opus", "w")
15-
16-
# audio_data = IO::Memory.new
17-
18-
# process = Process.run("ffmpeg", ["-i", "pipe:0",
19-
# "-loglevel", "0",
20-
# "-f", "s16le",
21-
# "-c:a", "pcm_s16le",
22-
# "-ar", sample_rate.to_s,
23-
# "-ac", channels.to_s,
24-
# "pipe:1",
25-
# ], shell: true, input: input, output: audio_data, error: STDOUT)
26-
27-
# audio_data.rewind
28-
29-
# Log.info { "Audio data size in bytes: #{audio_data.size}" }
30-
# Log.info { "Encoder input length: #{encoder.input_length}" }
31-
32-
# buffer = Bytes.new(encoder.input_length, 0)
33-
34-
# while real_length = audio_data.read(buffer)
35-
# break if real_length.zero?
36-
# opus_encoded_data = encoder.encode(buffer)
37-
# output.write_bytes(opus_encoded_data.size.to_i16, IO::ByteFormat::LittleEndian)
38-
# output.write(opus_encoded_data)
39-
# end

src/opus/encoder.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module Opus
1616
LibOpus.opus_encoder_destroy(@encoder)
1717
end
1818

19-
def reset : Nil
19+
def reset : Void
2020
LibOpus.encoder_ctl(@encoder, LibOpus::CTL::RESET_STATE)
2121
end
2222

0 commit comments

Comments
 (0)