GithubHelp home page GithubHelp logo

epnw / opus_dart Goto Github PK

View Code? Open in Web Editor NEW
12.0 12.0 6.0 908 KB

Wraps libopus in dart, and additionally provides a dart friendly API for encoding and decoding

Home Page: https://pub.dev/packages/opus_dart

License: BSD 2-Clause "Simplified" License

Dockerfile 0.03% Dart 99.94% Batchfile 0.01% JavaScript 0.01% HTML 0.01%

opus_dart's People

Contributors

epnw-eric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

opus_dart's Issues

Does no longer work for new dart versions

Since some methods in the ffi package (not the dart:ffi namespace) are not longer supported with newer dart versions, opus dart does no longer work. I'm currently working on a fix.

Clarify endianess

The opus encoders an decoders take lists of ints or floats in / put lists of ints or floats out. The Int16List and Float32List dart classes are used therefor. Datatypes with a byte size greater than one are subject to an endianess. Dart doesn't let uns inflence what the endianess in such a list is, and just assumes big endian when e.g. calling ByteBuffer.asFloat32List. But most pcm data are recorded and played with little endian, and especially opus only works with little endian data (as far as I know).

All this means that:

  • if you where about to actually access an value in an Int16List put out by an opus decoder in dart and want to actually work with it (like filtering, ...), it is most likely in the wrong byte order, and thus you work with an int that "has the wrong value"
  • if you construct an Int16List on your own in dart using actuall numerical values for its entries and pass it to an encoder, you would not get any meaningfull output from that encoder, since opus needs the byte order to be little endian

If you just use the data from the decoder to play audio there should be no problem, since the thing playing the data most likely assumes little endian anyway, and if you just use the encoder to encode recorded data, there also should be no problem, since these data are moste likely recorded using little endian.

In the next update of opus_dart we should document the endian behaviour in more detail.

OpusException -1: invalid argument

Hi,

I'm trying to encode audio data using the SimpleOpusEncoder.
But I get the error:

Future<void> main() async {
  initOpus(await opus_flutter.load());
  runApp(const MyApp());
}

 SimpleOpusEncoder encoder = SimpleOpusEncoder(sampleRate: 44100, channels: 1, application: Application.voip);


The following OpusException was thrown building Builder:
OpusException -1: invalid argument

libopus 1.3.1

Any ideas why this happens?

Thanks

Use AllocatorAlloc extension instead of custom size calculation

In the next release, instead of doing

final Map<Type, int> _sizes = {
Double: sizeOf<Double>(),
Float: sizeOf<Float>(),
Int8: sizeOf<Int8>(),
Int16: sizeOf<Int16>(),
Int32: sizeOf<Int32>(),
Int64: sizeOf<Int64>(),
IntPtr: sizeOf<IntPtr>(),
Pointer: sizeOf<Pointer>(),
Uint8: sizeOf<Uint8>(),
Uint16: sizeOf<Uint16>(),
Uint32: sizeOf<Uint32>(),
Uint64: sizeOf<Uint64>()
};
Pointer<T> allocate<T extends NativeType>({required int count}) {
int? elementSize = _sizes[T];
if (elementSize == null) {
throw new UnsupportedError(
'The size of type $T could not be calculated! Alloacting this type is not allowed!');
}
int byteCount = count * elementSize;
return ffipackage.malloc.allocate<T>(byteCount);
}

we should use the AllocatorAlloc extension to allocate space. Then we can omit the custom size calculation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.