ryanheise / just_waveform

A Flutter plugin to extract waveform data from an audio file suitable for visual rendering.
MIT License
81 stars 16 forks source link

add support window #19

Open yelkamel opened 2 years ago

yelkamel commented 2 years ago

Hello,

Thank you for this plugin.

We create an app of meditation and sound relaxing named Evolum (4.9 stars in stores). We wanted to add audio wave in our app. As you know we can't get the audiowave file on the file directly in the app when an user want to relax.

We have a dashboard where internal user can upload audio to be available in the app.

This dashboard is web so we can't generate the audiowave file so we wanted to do by deploying our dashboard in macOS but some of our internal user have only window...

We try to doc something with Google Cloud function when a file is uploaded in our storage with that

https://github.com/bbc/audiowaveform

but we didn't successed...

So if adding window support is not a big challenge maybe that can be usefull for us.

Thanks,

ryanheise commented 2 years ago

As I don't personally have Windows, that would have to be a contribution if anyone is willing (although first I'd have to move to the federated plugin model).

But for your use case, I'd still recommend running audiowaveform server-side. It's simple enough to do (or you could just outsource the work.)

yelkamel commented 2 years ago

Okay thank you

if anyone is interessed to do that, contact me.

zjjt commented 1 year ago

@yelkamel , Salut , i have a need to run this plugin on windows , have you found a way? @ryanheise Hello, and thanks for the plugin it works wonderfully well on ios macos and android, could you please point to the alternative way as to have the progress stream server side and reuse your package's code as wrapper ? I use it to detect silences and make my avatar speak... unfortunately for me my target device for production is Windows


final progressStream = JustWaveform.extract(
        audioInFile: audioFile,
        waveOutFile: waveFile,
      );
      progressStream.listen((waveformProgress) {
        if (waveformProgress.waveform != null) {
          final waveform = waveformProgress.waveform;
          leoCurrentState = LeoState.talk;
          var player = soundPlayer.play(assetFilePath: soundPath);
          oldPlayer = player;
          // if (loop) {
          //   player.setReleaseMode(ReleaseMode.loop);
          // }
          player.onPlayerComplete.listen((event) async {
            leoCurrentState = LeoState.stopTalking;
            if (loop) {
              await Future.delayed(const Duration(milliseconds: 2000));
              _soundRepeat(soundPlayer, soundPath, loop, waveform);
            }
          });
          player.onPositionChanged.listen((Duration p) {
            final currentMaxPixelAtPosition =
                waveform?.getPixelMax(waveform.positionToPixel(p).toInt());
            leoCurrentState = _isSilence(currentMaxPixelAtPosition!, -100)
                ? LeoState.stopTalking
                : LeoState.talk;
          });
        }
      });
ryanheise commented 1 year ago

Unfortunately I don't have any sample code, and everybody will likely be using a different language in the server side, not necessarily Dart. But it should be simple for anyone who knows how to build a restful service, so if you don't know how to do that, you should first learn how to do that in whatever language you're using on the server side.

zjjt commented 1 year ago

@ryanheise I know how to build one in fact my app has its backend written in rust and I thought about creating an endpoint to get the waveform data of an audio that I send to it ...what I am lacking is how to call the program audiowaveform ...I also thought of using the java code you made for the plug in on android to implement the c++ code for Windows using chatGPT since its been so long and my due date is next week and I have no time left to learn c++ ...I am that desperate

ryanheise commented 1 year ago

what I am lacking is how to call the program audiowaveform

Do you mean how to call exec to execute a program on the OS? I would expect that to be simple also, so I'm not sure whether that's what you mean is your obstacle. If you mean which command line options to pass to the program, the README of that program describes the options and this library is closely modelled on that.

If you are interested in porting to Windows, you might also want to look at the iOS implementation which is written in C (well, Objective C, but it's still mostly C).

zjjt commented 1 year ago

@ryanheise yeah indeed it was exec on the Os ill create that endpoint today. I'll use it as last resort and I'll also try porting It to windows directly thanks for the time I'll look into the ios c code .in the 1st case the waveform class can be used to parse the output of the program ?

ryanheise commented 1 year ago

Yes, I have intentionally used that format in order to make it compatible with audiowaveform. Note that audiowaveform has an option to output in JSON as well which just_waveform doesn't support, so just make sure you get it to output in the binary format.

zjjt commented 1 year ago

@ryanheise All right understood. I am almost done writing the endpoint. thanks a lot for your time and inputs