Giter Site home page Giter Site logo

waveformcontrol's Introduction

WaveformView

Interface for displaying audio data as waveform for Android.

alt tag

The component supports 2 modes:

  • Recording: Suitable for use when recording audio.
  • Playback: Suitable for use when playing audio. Samples are displayed as a classical waveform with optional playback indicator.

##Examples: Recording Example:

activity_main.xml

<com.newventuresoftware.waveform.WaveformView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    app:mode="RECORDING"
    android:background="#000000"
    android:id="@+id/waveformView" />

MainActivity.java

mRealtimeWaveformView = (WaveformView) findViewById(R.id.waveformView);
mRecordingThread = new RecordingThread(new AudioDataReceivedListener() {
    @Override
    public void onAudioDataReceived(short[] data) {
        mRealtimeWaveformView.setSamples(data);
    }
});

Playback Example:

activity_main.xml

<com.newventuresoftware.waveform.WaveformView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    app:mode="PLAYBACK"
    app:waveformStrokeThickness="3"
    app:waveformColor="#e5dc33"
    app:waveformFillColor="#e93519"
    android:background="#000000"
    android:id="@+id/playbackWaveformView" />

MainActivity.java

final WaveformView mPlaybackView = (WaveformView) findViewById(R.id.playbackWaveformView);
mPlaybackThread = new PlaybackThread(samples, new PlaybackListener() {
    @Override
    public void onProgress(int progress) {
        mPlaybackView.setMarkerPosition(progress);
    }
    @Override
    public void onCompletion() {
        mPlaybackView.setMarkerPosition(mPlaybackView.getAudioLength());
    }
});
mPlaybackView.setChannels(1);
mPlaybackView.setSampleRate(44100);
mPlaybackView.setSamples(samples);

For more information on recording and playback of raw audio in Android check out my [blog post] (http://www.newventuresoftware.com/blog/record-play-and-visualize-raw-audio-data-in-android/).

##License MIT

waveformcontrol's People

Contributors

darkmentat avatar liuzhen2008 avatar yavor87 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.