+
opusdec - decode audio from Opus format to WAV (or simple audio output) +
opusdec [ -hV ] [ --quiet ] [ --rate Hz ] [ --gain dB ] [ --no-dither ] [ --float ] [ --force-wav ] [ --packet-loss pct ] [ --save-range file ] input.opus [ output.wav ] +
+
opusdec decodes Opus files into PCM Wave (uncompressed) files. +
If the input file is specified as - , then opusdec will read from stdin. Likewise, an output filename of - will cause output to be to stdout. +
If no output is specified opusdec will attempt to play the audio in realtime if it supports audio playback on your system. +
+
Print help message +
Display version information +
Suppresses program output +
+
Force decoding at sampling rate n Hz +
+
Adjust the output volume n dB, negative values make the signal quieter. +
Do not dither 16-bit output +
32-bit floating-point files instead of 16-bit files +
Force including a wav header on output (e.g. for non-wav extensions and stdout) +
Simulate n % random Opus packet loss +
Saves check values for every frame to a file +
Decode a file input.opus to output.wav +
opusdec input.opus output.wav +
+
Play a file input.opus and force output at 48000 regardless of the original sampling rate +
(48kHz output may be faster, due to avoiding resampling and some sound hardware produces higher quality output when run at 48kHz) +
opusdec --rate 48000 input.opus +
+
Re-encode a high bitrate Opus file to a lower rate +
opusdec --force-wav input.opus - | opusenc --bitrate 64 - output.opus +
+
Play an http stream http://icecast.somwhere.org:8000/stream.opus with the help of curl on a system with pulseaudio +
(press ctrl-c to quit) +
curl http://icecast.somwhere.org:8000/stream.opus | padsp opusdec - +
+
+
Jean-Marc Valin <jmvalin@jmvalin.ca> +
Gregory Maxwell <greg@xiph.org> +
+
Opusdec does not currently reject all invalid files which it should reject. It also doesn't provide very helpful output for the corrupted files it does reject. Use opusinfo(1) for somewhat better diagnostics. +
+ This HTML page was made with roffit. + diff --git a/opus/opusenc.exe b/opus/opusenc.exe new file mode 100644 index 0000000..fbccaf0 Binary files /dev/null and b/opus/opusenc.exe differ diff --git a/opus/opusenc.html b/opus/opusenc.html new file mode 100644 index 0000000..8a86d0d --- /dev/null +++ b/opus/opusenc.html @@ -0,0 +1,195 @@ + +
++
opusenc - encode audio into the Opus format +
opusenc [ -h ] [ -V ] [ --help-picture ] [ --quiet ] [ --bitrate kbit/sec ] [ --vbr ] [ --cvbr ] [ --hard-cbr ] [ --comp complexity ] [ --framesize 2.5, 5, 10, 20, 40, 60 ] [ --expect-loss pct ] [ --downmix-mono ] [ --downmix-stereo ] [ --max-delay ms ] [ --title 'track title' ] [ --artist author ] [ --album 'album title' ] [ --genre genre ] [ --date YYYY-MM-DD ] [ --comment tag=value ] [ --picture +
] [ --padding n ] [ --discard-comments ] [ --discard-pictures ] [ --raw ] [ --raw-bits bits/sample ] [ --raw-rate Hz ] [ --raw-chan N ] [ --raw-endianness flag ] [ --ignorelength ] [ --serial serial number ] [ --save-range file ] [ --set-ctl-int ctl=value ] input.wav output.opus +
opusenc reads audio data in Wave, AIFF, FLAC, Ogg/FLAC, or raw PCM format and encodes it into an Ogg Opus stream. If the input file is "-" audio data is read from stdin. Likewise, if the output file is "-" the Ogg Opus stream is written to stdout. +
Unless quieted opusenc displays fancy statistics about the encoding progress. +
+
Show command help +
Show the version number +
Show help on attaching album art +
Enable quiet mode. No messages are displayed. +
+
Set target bitrate in kbit/sec (6-256 per channel) +
In VBR mode this specifies the average rate for a large and diverse collection of audio. In CVBR and Hard-CBR mode it specifies the specific output bitrate. +
Default for >=44.1kHz input is 64kbps per mono stream, 96kbps per coupled pair. +
Use variable bitrate encoding (default) In VBR mode the bitrate may go up and down freely depending on the content to achieve more consistent quality. +
Use constrained variable bitrate encoding. +
Outputs to a specific bitrate. This mode is analogous to CBR in AAC/MP3 encoders and managed mode in Vorbis coders. This delivers less consistent quality than VBR mode but consistent bitrate. +
Use hard constant bitrate encoding. +
With hard-cbr every frame will be exactly the same size, similar to how speech codecs work. This delivers lower overall quality but is useful where bitrate changes might leak data in encrypted channels or on synchronous transports. +
Set encoding computational complexity (0-10, default: 10). Zero gives the fastest encodes but lower quality, while 10 gives the highest quality but slower encoding. +
Set maximum frame size in milliseconds (2.5, 5, 10, 20, 40, 60, default: 20) +
Smaller framesizes achieve lower latency but less quality at a given bitrate. +
Sizes greater than 20ms are only interesting at fairly low bitrates. +
Set expected packet loss in percent (default: 0) +
Downmix to mono +
Downmix to stereo (if >2 channels input) +
Set maximum container delay in milliseconds (0-1000, default: 1000) +
+
Set the track title comment field to title +
Set the artist comment field to artist. This may be used multiple times to list contributing artists individually. Note that some playback software does not display multiple artists gracefully. +
Set the album or collection title field to album +
Set the date comment field to YYYY-MM-DD. This may be shortened to YYYY-MM or YYYY. +
Set the genre comment field to genre. This option may be specified multiple times to tag a track with multiple overlapping genres. +
Add an extra comment. This may be used multiple times. The argument should be in the form "tag=value". See the vorbis-comment specification for well known tag names: http://www.xiph.org/vorbis/doc/v-comment.html +
--picture filename|specification +
Attach album art for the track. +
Either a filename for the artwork or a more complete specification form can be used. The picture is added to a METADATA_BLOCK_PICTURE comment field similar to what is used in +
The specification is a string whose parts are separated by | (pipe) characters. Some parts may be left empty to invoke default values. Passing a plain filename is just shorthand for the "||||filename" specification. +
The format of specification is [type]|[media-type]|[description]|[widthxheightxdepth[/colors]]|filename +
type is an optional number describing the nature of the picture. Defined values are from one of: +
0: Other +
1: 32x32 pixel 'file icon' (PNG only) +
2: Other file icon +
3: Cover (front) +
4: Cover (back) +
5: Leaflet page +
6: Media (e.g., label side of a CD) +
7: Lead artist/lead performer/soloist +
8: Artist/performer +
9: Conductor +
10: Band/Orchestra +
11: Composer +
12: Lyricist/text writer +
13: Recording location +
14: During recording +
15: During performance +
16: Movie/video screen capture +
17: A bright colored fish +
18: Illustration +
19: Band/artist logotype +
20: Publisher/studio logotype +
The default is 3 (front cover). More than one --picture option can be specified to attach multiple pictures. There may only be one picture each of type 1 and 2 in a file. +
media-type is optional. If left blank, it will be detected from the file. For best compatibility with players, use pictures with a media-type of image/jpeg or image/png. The media-type can also be "-->" to mean that filename is actually a URL to an image, though this use is discouraged. The file at the URL will not be fetched. The URL itself is stored in the metadata. +
description is optional. The default is an empty string. +
The next part specifies the resolution and color information. If the media-type is image/jpeg, image/png, or image/gif, this can usually be left empty and the information will be read from the file. Otherwise, you must specify the width in pixels, height in pixels, and color depth in bits-per-pixel. If the image has indexed colors you should also specify the number of colors used. If possible, these are checked against the file for accuracy. +
filename is the path to the picture file to be imported, or the URL if the media-type is "-->". +
Reserve n extra bytes for metadata tags. This can make later tag editing more efficient. Defaults to 512. +
Don't propagate metadata tags from the input file. +
Don't propagate pictures or art from the input file. +
+
Interpret input as raw PCM data without headers +
Set bits/sample for raw input (default: 16) +
Set sampling rate for raw input (default: 48000) +
Set number of channels for raw input (default: 2) +
Set the endianness for raw input: 1 for big endian, 0 for little (default: 0) +
Ignore the data length in Wave headers. Opusenc automatically ignores the length when its implausible (very small or very large) but some STDIN usage may still need this option to avoid truncation. +
+
Force use of a specific stream serial number, rather than one that is randomly generated. This is used to make the encoder deterministic for testing and is not generally recommended. +
Save check values for every frame to a file +
Pass the encoder control x with value y (advanced). Preface with s: to direct the ctl to multistream s +
This may be used multiple times +
+
Simplest usage. Take input as input.wav and produce output as output.opus: +
opusenc input.wav output.opus +
+
+
Produce a very high quality encode with a target rate of 160kbps: +
opusenc --bitrate 160 input.wav output.opus +
+
+
Record and send a live stream to an Icecast HTTP streaming server using oggfwd: +
arecord -c 2 -r 48000 -twav - | opusenc --bitrate 96 - - | oggfwd icecast.somewhere.org 8000 password /stream.opus +
+
+
+
While it is possible to use opusenc for low latency streaming (e.g. with --max-delay set to 0 and netcat instead of Icecast) it's not really designed for this, and the Ogg container and TCP transport aren't the best tools for that application. Shell pipelines themselves will often have high buffering. The ability to set framesizes as low as 2.5 ms in opusenc mostly exists to try out the quality of the format with low latency settings, but not really for actual low latency usage. +
Interactive usage should use UDP/RTP directly. +
+
Gregory Maxwell <greg@xiph.org> +
opusdec (1) opusinfo (1) oggfwd (1)
+ This HTML page was made with roffit. + diff --git a/opus/opusinfo.exe b/opus/opusinfo.exe new file mode 100644 index 0000000..1ac1fc2 Binary files /dev/null and b/opus/opusinfo.exe differ diff --git a/opus/opusinfo.html b/opus/opusinfo.html new file mode 100644 index 0000000..2f276e2 --- /dev/null +++ b/opus/opusinfo.html @@ -0,0 +1,79 @@ + +
++
opusinfo - gives information about Opus files and does extensive validity checking +
opusinfo [ -q | -v ] [ -h ] [ -V ] file1.opus ... fileN.opus +
opusinfo reads one or more Opus files and prints information about stream contents (including chained and/or multiplexed streams) to standard output. It will detect (but not correct) a wide range of common defects, with many additional checks specifically for Opus streams. +
For all stream types opusinfo will print the filename being processed, the stream serial numbers, and various common error conditions. +
For Opus streams, information including the version used for encoding, number of channels and other header information, the bitrate and playback length, the contents of the comment header, and general statistics about the stream are printed. +
Opusinfo is a fork of ogginfo(1) with the non-opus parts largely removed. +
+
Show a help and usage message. +
Quiet mode. This may be specified multiple times. Doing so once will remove the detailed informative messages; twice will remove warnings as well. +
Verbose mode. At the current time, this does not do anything. +
Show program version info and exit. +
+
There are many kinds of errored, invalid, non-normative, or otherwise unwise stream constructions which opusinfo will not produce warnings on. Passing opusinfo with flying colors is not certification of the correctness of a stream. Future versions may detect more error conditions. +
+
Michael Smith <msmith@xiph.org> +
Gregory Maxwell <greg@xiph.org> +
+
+ This HTML page was made with roffit. + diff --git a/sound.py b/sound.py new file mode 100644 index 0000000..ec46691 --- /dev/null +++ b/sound.py @@ -0,0 +1,57 @@ +import sounddevice as sd +from pprint import pformat + +DEFAULT = 0 +sd.default.channels = 2 +sd.default.dtype = "int16" +sd.default.latency = "low" +sd.default.samplerate = 48000 + + +class PCMStream: + def __init__(self): + self.stream = None + + def read(self, num_bytes): + # frame is 4 bytes + frames = int(num_bytes / 4) + data = self.stream.read(frames)[0] + + # convert to pcm format + return bytes(data) + + def change_device(self, num): + if self.stream is not None: + self.stream.stop() + self.stream.close() + + self.stream = sd.RawInputStream(device=num) + self.stream.start() + + +class DeviceNotFoundError(Exception): + def __init__(self): + self.devices = sd.query_devices() + self.host_apis = sd.query_hostapis() + super().__init__("No Devices Found") + + def __str__(self): + return ( + f"Devices \n" + f"{self.devices} \n " + f"Host APIs \n" + f"{pformat(self.host_apis)}" + ) + + +def query_devices(): + options = { + device.get("name"): index + for index, device in enumerate(sd.query_devices()) + if (device.get("max_input_channels") > 0 and device.get("hostapi") == DEFAULT) + } + + if not options: + raise DeviceNotFoundError() + + return options \ No newline at end of file