arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Flutter Sound Helpers API

The τ utilities API.

hashtag
Module instanciation

Dart definition (prototype) :

You do not need to instanciate the Flutter Sound Helper module. To use this module, you can just use the singleton offers by the module : flutterSoundHelper.

Example:

hashtag
convertFile()

Dart definition (prototype) :

This verb is useful to convert a sound file to a new format.

  • infile is the file path of the file you want to convert

  • codecin is the actual file format

  • outfile

Be careful : outfile and codecout must be compatible. The output file extension must be a correct file extension for the new format.

Note : this verb uses FFmpeg and is not available int the LITE flavor of Flutter Sound.

Example:

hashtag
pcmToWave()

Dart definition (prototype) :

This verb is usefull to convert a Raw PCM file to a Wave file.

It adds a Wave envelop to the PCM file, so that the file can be played back with startPlayer().

Note: the parameters numChannels and sampleRate are mandatory, and must match the actual PCM data. a discussion about Raw PCM and WAVE file format.

Example:

hashtag
pcmToWaveBuffer()

Dart definition (prototype) :

This verb is usefull to convert a Raw PCM buffer to a Wave buffer.

It adds a Wave envelop in front of the PCM buffer, so that the file can be played back with startPlayerFromBuffer().

Note: the parameters numChannels and sampleRate are mandatory, and must match the actual PCM data. a discussion about Raw PCM and WAVE file format.

Example:

hashtag
waveToPCM()

Dart definition (prototype) :

This verb is usefull to convert a Wave file to a Raw PCM file.

It removes the Wave envelop from the PCM file.

Example:

hashtag
waveToPCMBuffer()

Dart definition (prototype) :

This verb is usefull to convert a Wave buffer to a Raw PCM buffer. Note that this verb is not asynchronous and does not return a Future.

It removes the Wave envelop from the PCM buffer.

Example:

hashtag
duration()

Dart definition (prototype) :

This verb is used to get an estimation of the duration of a sound file. Be aware that it is just an estimation, based on the Codec used and the sample rate.

Note : this verb uses FFmpeg and is not available int the LITE flavor of Flutter Sound.

Example:

hashtag
isFFmpegAvailable()

Dart definition (prototype) :

This verb is used to know during runtime if FFmpeg is linked with the App.

Example:

hashtag
executeFFmpegWithArguments()

Dart definition (prototype) :

This verb is a wrapper for the great FFmpeg application. The command "man ffmpeg" (if you have installed ffmpeg on your computer) will give you many informations. If you do not have ffmpeg on your computer you will find easyly on internet many documentation on this great program.

Example:

hashtag
getLastFFmpegReturnCode()

Dart definition (prototype) :

This simple verb is used to get the result of the last FFmpeg command

Example:

hashtag
getLastFFmpegCommandOutput()

Dart definition (prototype) :

This simple verb is used to get the output of the last FFmpeg command

Example:

hashtag
FFmpegGetMediaInformation

Dart definition (prototype) :

This verb is used to get various informations on a file.

The informations got with FFmpegGetMediaInformation() are .

Example:

FlutterSoundHelper flutterSoundHelper = FlutterSoundHelper(); // Singleton
is the path of the file you want to create
  • codecout is the new file format

  • See herearrow-up-right
    See herearrow-up-right
    documented herearrow-up-right
    Duration t = await flutterSoundHelper.duration(aPathFile);
    Future<bool> convertFile
    (
            String infile,
            Codec codecin,
            String outfile,
            Codec codecout
    ) async
            String inputFile = '$myInputPath/bar.wav';
            var tempDir = await getTemporaryDirectory();
            String outpufFile = '${tempDir.path}/$foo.mp3';
            await flutterSoundHelper.convertFile(inputFile, codec.pcm16WAV, outputFile, Codec.mp3)
    Future<void> pcmToWave
    (
          {
              String inputFile,
              String outputFile,
              int numChannels,
              int sampleRate,
          }
    ) async
            String inputFile = '$myInputPath/bar.pcm';
            var tempDir = await getTemporaryDirectory();
            String outpufFile = '${tempDir.path}/$foo.wav';
            await flutterSoundHelper.pcmToWave(inputFile: inputFile, outpoutFile: outputFile, numChannels: 1, sampleRate: 8000);
    Future<Uint8List> pcmToWaveBuffer
    (
          {
            Uint8List inputBuffer,
            int numChannels,
            int sampleRate,
          }
    ) async
            Uint8List myWavBuffer = await flutterSoundHelper.pcmToWaveBuffer(inputBuffer: myPCMBuffer, numChannels: 1, sampleRate: 8000);
    Future<void> waveToPCM
    (
          {
              String inputFile,
              String outputFile,
           }
    ) async
            String inputFile = '$myInputPath/bar.pcm';
            var tempDir = await getTemporaryDirectory();
            String outpufFile = '${tempDir.path}/$foo.wav';
            await flutterSoundHelper.waveToPCM(inputFile: inputFile, outpoutFile: outputFile);
    Uint8List waveToPCMBuffer (Uint8List inputBuffer)
            Uint8List pcmBuffer flutterSoundHelper.waveToPCMBuffer(inputBuffer: aWaveBuffer);
     Future<Duration> duration(String uri) async
            Duration d = flutterSoundHelper.duration("$myFilePath/bar.wav");
    Future<bool> isFFmpegAvailable() async
            if ( await flutterSoundHelper.isFFmpegAvailable() )
            {
                    Duration d = flutterSoundHelper.duration("$myFilePath/bar.wav");
            }
    Future<int> executeFFmpegWithArguments(List<String> arguments)
     int rc = await flutterSoundHelper.executeFFmpegWithArguments
     ([
            '-loglevel',
            'error',
            '-y',
            '-i',
            infile,
            '-c:a',
            'copy',
            outfile,
    ]); // remux OGG to CAF
    Future<int> getLastFFmpegReturnCode() async
            int result = await getLastFFmpegReturnCode();
    Future<String> getLastFFmpegCommandOutput() async
            print( await getLastFFmpegCommandOutput() );
    Future<Map<dynamic, dynamic>> FFmpegGetMediaInformation(String uri) async
    Map<dynamic, dynamic> info = await flutterSoundHelper.FFmpegGetMediaInformation( uri );