wavtool 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/wavtool.rb +73 -0
- metadata +110 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2c895b71f441a9f1d587b5fc845929d6de67e921cba6e6e647c30d1c312e57d7
|
|
4
|
+
data.tar.gz: 54464fb8e2ce5246a9685a8bf29db26e87beb14f682aec60a92709c552fe83c2
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f35d2788c23a68d44e60d84aacde58f392d84768cfde7234e0d9132b39eb7a4431bcf759f4ffd84094957faa9d9e7a6e436708fd4fe67f0c92847106e4d07374
|
|
7
|
+
data.tar.gz: 763b54386619c177ded4ec19396ec1e2e9120e3cd074af91fd470f7479af22ceeb9fd566a83e0f61611407cbcd6b7a1810801d782c585cb286abae9b6c9dc5ac
|
checksums.yaml.gz.sig
ADDED
|
Binary file
|
data.tar.gz.sig
ADDED
|
Binary file
|
data/lib/wavtool.rb
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# file: wavtool.rb
|
|
4
|
+
|
|
5
|
+
# description: Join WAV files together with ease.
|
|
6
|
+
|
|
7
|
+
require 'c32'
|
|
8
|
+
require 'wavefile'
|
|
9
|
+
|
|
10
|
+
class WavTool
|
|
11
|
+
include WaveFile
|
|
12
|
+
using ColouredText
|
|
13
|
+
|
|
14
|
+
def initialize(out: 'out.wav', channels: :mono, format_code: :pcm_16,
|
|
15
|
+
sample_rate: 44100, src_path: '.', verbose: false, debug: false)
|
|
16
|
+
|
|
17
|
+
@format = Format.new(channels, format_code, sample_rate)
|
|
18
|
+
@src_path, @out = src_path, out
|
|
19
|
+
@verbose, @debug = verbose, debug
|
|
20
|
+
|
|
21
|
+
if @verbose then
|
|
22
|
+
puts 'WavTool'.highlight
|
|
23
|
+
puts 'options: generate_silence, concat'.info
|
|
24
|
+
puts
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# creates a WAV file containing only silence for a fixed duration
|
|
29
|
+
#
|
|
30
|
+
def generate_silence(filename=@out, duration: 1)
|
|
31
|
+
|
|
32
|
+
square_cycle = [0] * 100 * duration
|
|
33
|
+
buffer = Buffer.new(square_cycle,
|
|
34
|
+
Format.new(@format.channels, :float, @format.sample_rate))
|
|
35
|
+
|
|
36
|
+
Writer.new(filename, @format) do |writer|
|
|
37
|
+
(@format.sample_rate.to_i / 100).times { writer.write(buffer) }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
alias silence generate_silence
|
|
43
|
+
|
|
44
|
+
# concatenates WAV files into a single WAV file
|
|
45
|
+
#
|
|
46
|
+
def concat(files, save_file=@out)
|
|
47
|
+
|
|
48
|
+
puts ('Running concat ...').info; puts if @verbose
|
|
49
|
+
puts ('files: ' + files.inspect).debug if @debug
|
|
50
|
+
|
|
51
|
+
verbose, debug = @verbose, @debug
|
|
52
|
+
|
|
53
|
+
Writer.new(save_file, @format) do |writer|
|
|
54
|
+
|
|
55
|
+
files.each do |file_name|
|
|
56
|
+
|
|
57
|
+
filepath = File.join(@src_path, file_name)
|
|
58
|
+
puts ('concatenating: ' + filepath.inspect).debug if debug
|
|
59
|
+
Reader.new(filepath).each_buffer(samples_per_buffer=4096) do |buffer|
|
|
60
|
+
writer.write(buffer)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
puts ('WAV file ' + @out + ' created').info if @verbose
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def duration(file_name)
|
|
70
|
+
Reader.new(file_name).total_duration
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: wavtool
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- James Robertson
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain:
|
|
11
|
+
- |
|
|
12
|
+
-----BEGIN CERTIFICATE-----
|
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkxMDI1MTYxNTAzWhcN
|
|
15
|
+
MjAxMDI0MTYxNTAzWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDMEX+U
|
|
17
|
+
F0TObUsAYFI+/CctHvfc2dC4KdM69f67FW/J2rc1dTEE6J0dYXkIhDHCS4Z5CVvK
|
|
18
|
+
AcTdzDKPiauZqKybim5Ij9bVWuVTReiIsKfPl5wvnx5AXd8A2NTYnON/r5eB2xa5
|
|
19
|
+
EXXu8tkQ8ORvl2brpoDull/uazsIguA7z25wmE+OdUYpEKn8dSDF1AtKQHKCvrGG
|
|
20
|
+
8XHozLhNVbTWoW+Y9zjSmp62VB1a47sP4ve3aAuCMYoXHusUPuToKa4k/weeZArj
|
|
21
|
+
SRgDBoWH7j4SVrbHfAuLTmMsbnBHPL1LBuO2B3RYAEPrNFaEfvEg+GJQJWwrZSqK
|
|
22
|
+
ZDI5e/GMhWWsky9kBcVp3bXL0uexH6fbCIHMTV+8ANiwiJEguMWz+3jDTj/jP1D/
|
|
23
|
+
mFJvXVudUaGW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
|
39
|
+
dependencies:
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: c32
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 0.2.0
|
|
47
|
+
- - "~>"
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0.2'
|
|
50
|
+
type: :runtime
|
|
51
|
+
prerelease: false
|
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: 0.2.0
|
|
57
|
+
- - "~>"
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0.2'
|
|
60
|
+
- !ruby/object:Gem::Dependency
|
|
61
|
+
name: wavefile
|
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: 1.1.0
|
|
67
|
+
- - "~>"
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '1.1'
|
|
70
|
+
type: :runtime
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: 1.1.0
|
|
77
|
+
- - "~>"
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: '1.1'
|
|
80
|
+
description:
|
|
81
|
+
email: james@jamesrobertson.eu
|
|
82
|
+
executables: []
|
|
83
|
+
extensions: []
|
|
84
|
+
extra_rdoc_files: []
|
|
85
|
+
files:
|
|
86
|
+
- lib/wavtool.rb
|
|
87
|
+
homepage: https://github.com/jrobertson/wavtool
|
|
88
|
+
licenses:
|
|
89
|
+
- MIT
|
|
90
|
+
metadata: {}
|
|
91
|
+
post_install_message:
|
|
92
|
+
rdoc_options: []
|
|
93
|
+
require_paths:
|
|
94
|
+
- lib
|
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - ">="
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '0'
|
|
105
|
+
requirements: []
|
|
106
|
+
rubygems_version: 3.0.3
|
|
107
|
+
signing_key:
|
|
108
|
+
specification_version: 4
|
|
109
|
+
summary: wavtool
|
|
110
|
+
test_files: []
|
metadata.gz.sig
ADDED
|
Binary file
|