Skip to content
/ WavePlayerView Public template

A Java library for analyzing sound directly by recording sound and plotting waves according to frequencies instantly. Do you think that's the only thing!? No, on the contrary, there is also a drawing of waves according to an audio file from a track or from a file within the application.

License

Notifications You must be signed in to change notification settings

alex11111115/WavePlayerView

StandWithPalestine

ReadMeSupportPalestine

WavePlayerView https://developer.android.com/index.html

WavePlayerView Logo

Analyze real-time audio and display sound waves in an interactive and engaging way 🎡

✨ Features

  • πŸ”Š Real-time audio analysis: View sound waves while recording or playing an audio file.
  • 🎨 Customize Display: Easily adjust wave colors, line widths, and wave speeds.
  • πŸš€ Easy-to-use Programming Interface: Simple and intuitive programming interface for seamless integration.
  • πŸ“± Wide Compatibility: Supports Android API level 21 and above. API
  • πŸŽ›οΈ Advanced Control: Playback speed control, pause/resume functions, and audio progress monitoring.
  • πŸŽ™οΈ Audio Recording: Ability to record audio and display real-time waveforms.
  • πŸ”ˆ Volume Control: Adjust the volume for the left and right channels.
  • πŸ” Repeat Playback: Ability to set repeated playback of the audio file.

πŸ€” Why use WavePlayerView?

  • πŸš€ High Performance: Designed for high efficiency with minimal impact on your app's performance.
  • πŸ”“ Open Source: Full access to the source code for customization and optimization.
  • πŸ‘₯ Community Support: Supported by a dedicated community, with opportunities for contributions and improvements.
  • 🎠 Highly Smooth: Utilizes the latest and most powerful algorithms to deliver an impressive and smooth result

πŸ“Έ Screenshots

Screenshot_Ω’Ω Ω’Ω€Ω Ω¨Ω Ω£-Ω‘Ω€Ω Ω’Ω₯Ω’_WavePlayerView Screenshot_Ω’Ω Ω’Ω€Ω Ω¨Ω Ω£-Ω‘Ω€Ω Ω£Ω Ω₯_WavePlayerView Screenshot_Ω’Ω Ω’Ω€Ω Ω¨Ω Ω£-Ω‘Ω€Ω Ω£Ω‘Ω _WavePlayerView Screenshot_Ω’Ω Ω’Ω€Ω Ω¨Ω Ω£-Ω‘Ω€Ω Ω£Ω‘Ω¨_WavePlayerView Screenshot_Ω’Ω Ω’Ω€Ω Ω¨Ω Ω£-Ω‘Ω€Ω Ω¦Ω€Ω¦_WavePlayerView Screenshot_Ω’Ω Ω’Ω€Ω Ω¨Ω Ω£-Ω‘Ω€Ω Ω¦Ω₯Ω _WavePlayerView Screenshot_Ω’Ω Ω’Ω€Ω Ω¨Ω Ω£-Ω‘Ω€Ω Ω§Ω Ω‘_WavePlayerView Screenshot_Ω’Ω Ω’Ω€Ω Ω¨Ω Ω£-Ω‘Ω€Ω Ω§Ω‘Ω’_WavePlayerView Screenshot_Ω’Ω Ω’Ω€Ω Ω¨Ω Ω£-Ω‘Ω€Ω Ω§Ω‘Ω©_WavePlayerView

How to Use the Library? GitHub top language

1. Add it in your root build.gradle at the end of repositories:

dependencyResolutionManagement {
	repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
	repositories {
		mavenCentral()
        //...
		maven { url 'https://jitpack.io' }
	}
}

2. Add the Library to Your Project

Add the following to your project's build.gradle file:

dependencies {
    implementation 'com.github.alex11111115:WavePlayerView:1.12'
}

3. Use WavePlayerView in Your Layout

Add WavePlayerView to your activity layout file activity_main.xml:

<sound.wave.kilobyte.WavePlayerView
    android:id="@+id/waveView"
    android:layout_width="250dp"
    android:layout_height="75dp"
    android:padding="2dp"
    android:gravity="center"
    android:orientation="horizontal"
    android:layout_gravity="center"
    app:waveColor1="#FF8E8DE5"
    app:waveStrokeWidth1="5dp"
    app:waveColor2="#FFE8D8FB"
    app:waveStrokeWidth2="5dp"
    app:waveSpeed="0.5"
    app:wave2Visible="true" />

4. Control the Waves from Your Code

In your MainActivity.java file, you can control the WavePlayerView as follows:

To start using it, you need to initialize it first

public class MainActivity extends AppCompatActivity {

    private WavePlayerView waveView;
    
    //....

    @Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
        
        waveView = findViewById(R.id.waveView);
        
        //.....
        
    }
}

To play from file path:

// Play audio from a file path
waveView.playAudioWithWaveFromPath(filePath);

To play from your app resources:

// Play audio from app resources
waveView.playAudioWithWave(R.raw.mus); //Replace 'mus' with your audio

To pause media and waves:

// Pause media and waves
waveView.pauseAudioWithWave();

To resume media and waves:

// Resume media and waves
waveView.resumeAudioWithWave();

To stop media and waves:

// Stop media and waves
waveView.stopAudioWithWave();

To start listening and show waves live:

// Start listening and show live waves
waveView.startListening();

To stop listening:

// Stop listening
waveView.stopListening();

To set playback speed:

// Set playback speed (default is "1.0")
waveView.setPlaybackSpeed("1.5");

To set wave properties:

// Set wave properties
waveView.setWaveProperties(color1, wave1Width, color2, wave2Width, waveSpeed);

To set wave1 alpha

waveView.setWave1Alpha(alpha1);

To set wave2 alpha

waveView.setWave2Alpha(alpha2);

To control the visibility of the second wave:

// Hide the second wave
waveView.setWave2Visible(false);

// Show the second wave
waveView.setWave2Visible(true);

To handle audio completion events:

// Handle audio completion events
waveView.setOnAudioCompleteListener(() -> {
//your code here
});

To track audio progress:

// Track audio progress
waveView.setOnAudioProgressListener(currentMilliSec -> {
    //your codes here
});

To seek to a position in the media:

// Seek to a position in the media
progressbar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
    @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
        value = progress; // Store value
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
        waveView.pauseAudioWithWave(); // Pause media
    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
        waveView.seekToPosition((int) value); // Seek to new position
        waveView.setPlaybackSpeed(s);
    }
});

Getting the duration of the audio

// Getting the duration of the audio
int duration = waveView.getAudioDuration();

Get the current position of the audio

// Get the current position of the audio
int currentPosition = waveView.getCurrentAudioPosition();

Adjusting the volume

// Adjusting the volume
waveView.setVolume(leftVolume, rightVolume);

setLooping

// setLooping
waveView.setLooping(true);

Put this in "onDestroy" as follows

if (waveView != null) {
  waveView.release();
}

Permissions

Add the following permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO" />

πŸ“ Important Notes

  • Be sure to ask for audio recording permissions at runtime for devices running Android 6.0 and above.
  • The appearance of the waves can be customized through various properties available in XML or programmatically.
  • Use setPlaybackSpeed() to change the playback speed. Allowable values range from 0.2 to 6.0.
  • You can control the volume with setVolume() where the values range from 0.0 (mute) to 1.0 (loudest).
  • Use setLooping() to set whether the sound will automatically repeat after it ends.

Credits

WavePlayerView is developed and maintained by alex11111115.

Contribution

We welcome contributions from the community! If you have ideas or improvements, feel free to submit pull requests or open issues on the GitHub repository.

License

WavePlayerView is licensed under the Apache License 2.0. GitHub license

StandWithPalestine StandWithPalestineBadgeBordered

More Info

Total Downloads

Total Downloads

Repo Size

Repo Size

Code Size

Code Size

Last Commit

Last Commit

Latest Release

Latest Release

Project Status

Project Status

Build Status

Build Status

About

A Java library for analyzing sound directly by recording sound and plotting waves according to frequencies instantly. Do you think that's the only thing!? No, on the contrary, there is also a drawing of waves according to an audio file from a track or from a file within the application.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages