-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: 🎨 GitHub actions + improving readme
- Loading branch information
Showing
7 changed files
with
73 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
fail-fast: false | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Install Crystal | ||
uses: oprypin/install-crystal@v1 | ||
with: | ||
crystal: latest | ||
|
||
- name: Install linux dependencies | ||
run: | | ||
sudo apt install libopus-dev | ||
- name: Download source | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies | ||
run: shards install | ||
|
||
# - name: Run specs | ||
# run: | | ||
# crystal spec | ||
# crystal spec --release --no-debug | ||
|
||
- name: Check formatting | ||
run: crystal tool format --check | ||
|
||
- name: Run ameba linter | ||
run: bin/ameba | ||
|
||
- name: Build | ||
run: | | ||
crystal build --progress --time --stats src/opus.cr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,47 @@ | ||
# opus-cr | ||
# Opus | ||
|
||
|
||
TODO: Write a description here | ||
|
||
## Installation | ||
|
||
1. Add the dependency to your `shard.yml`: | ||
|
||
```yaml | ||
dependencies: | ||
opus-cr: | ||
github: your-github-user/opus-cr | ||
opus: | ||
github: krthr/opus | ||
``` | ||
2. Run `shards install` | ||
|
||
## Usage | ||
|
||
```crystal | ||
require "opus-cr" | ||
``` | ||
require "opus" | ||
TODO: Write usage instructions here | ||
sample_rate = 48_000 | ||
frame_size = 960 | ||
channels = 2 | ||
## Development | ||
encoder = Opus::Encoder.new(sample_rate, frame_size, channels) | ||
TODO: Write development instructions here | ||
buffer = Bytes.new(encoder.input_length, 0) | ||
while real_length = audio_data.read(buffer) | ||
break if real_length.zero? | ||
opus_encoded_data = encoder.encode(buffer) | ||
# Use the encoded data | ||
end | ||
``` | ||
|
||
## Contributing | ||
|
||
1. Fork it (<https://github.com/your-github-user/opus-cr/fork>) | ||
1. Fork it (<https://github.com/krthr/opus/fork>) | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create a new Pull Request | ||
|
||
## Contributors | ||
|
||
- [Wilson](https://github.com/your-github-user) - creator and maintainer | ||
- [Wilson](https://github.com/krthr) - creator and maintainer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
require "spec" | ||
require "../src/opus-cr" | ||
require "../src/opus" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,5 @@ | ||
require "log" | ||
require "./opus/encoder" | ||
|
||
module Opus | ||
VERSION = "0.1.0" | ||
end | ||
|
||
# sample_rate = 48_000 | ||
# channels = 2 | ||
|
||
# encoder = Opus::Encoder.new(sample_rate, 960, channels) | ||
|
||
# input = File.open("/Users/krthr/Projects/discord-music/output.mp3", "r") | ||
# output = File.open("output.opus", "w") | ||
|
||
# audio_data = IO::Memory.new | ||
|
||
# process = Process.run("ffmpeg", ["-i", "pipe:0", | ||
# "-loglevel", "0", | ||
# "-f", "s16le", | ||
# "-c:a", "pcm_s16le", | ||
# "-ar", sample_rate.to_s, | ||
# "-ac", channels.to_s, | ||
# "pipe:1", | ||
# ], shell: true, input: input, output: audio_data, error: STDOUT) | ||
|
||
# audio_data.rewind | ||
|
||
# Log.info { "Audio data size in bytes: #{audio_data.size}" } | ||
# Log.info { "Encoder input length: #{encoder.input_length}" } | ||
|
||
# buffer = Bytes.new(encoder.input_length, 0) | ||
|
||
# while real_length = audio_data.read(buffer) | ||
# break if real_length.zero? | ||
# opus_encoded_data = encoder.encode(buffer) | ||
# output.write_bytes(opus_encoded_data.size.to_i16, IO::ByteFormat::LittleEndian) | ||
# output.write(opus_encoded_data) | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters