├── .circleci
└── config.yml
├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── LICENSE
├── README.md
├── audiovisualizer
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── chibde
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── chibde
│ │ │ ├── BaseVisualizer.java
│ │ │ └── visualizer
│ │ │ ├── BarVisualizer.java
│ │ │ ├── BlazingColorVisualizer.java
│ │ │ ├── CircleBarVisualizer.java
│ │ │ ├── CircleBarVisualizerSmooth.java
│ │ │ ├── CircleVisualizer.java
│ │ │ ├── LineBarVisualizer.java
│ │ │ ├── LineVisualizer.java
│ │ │ └── SquareBarVisualizer.java
│ └── res
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── chibde
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── sample
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── chibde
│ │ └── audiovisualizer
│ │ └── sample
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── chibde
│ │ │ └── audiovisualizer
│ │ │ └── sample
│ │ │ ├── BaseActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── MediaPlayerService.java
│ │ │ ├── ServiceExampleActivity.java
│ │ │ └── visualizer
│ │ │ ├── BarVisualizerActivity.java
│ │ │ ├── CircleBarVisualizerActivity.java
│ │ │ ├── CircleVisualizerActivity.java
│ │ │ ├── LineBarVisualizerActivity.java
│ │ │ ├── LineVisualizerActivity.java
│ │ │ └── SquareBarVisualizerActivity.java
│ └── res
│ │ ├── drawable
│ │ ├── ic_pause_red_48dp.xml
│ │ ├── ic_play_red_48dp.xml
│ │ └── ic_replay_red_48dp.xml
│ │ ├── layout
│ │ ├── activity_bar_visualizer.xml
│ │ ├── activity_circle_bar_visualizer.xml
│ │ ├── activity_circle_visualizer.xml
│ │ ├── activity_line_bar_visualizer.xml
│ │ ├── activity_line_visualizer.xml
│ │ ├── activity_main.xml
│ │ ├── activity_service_example.xml
│ │ ├── activity_square_bar_visualizer.xml
│ │ └── layout_audio_buttons.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── raw
│ │ └── red_e.mp3
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── chibde
│ └── audiovisualizer
│ └── sample
│ └── ExampleUnitTest.java
└── settings.gradle
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2.1
2 |
3 | orbs:
4 | android: circleci/android@1.0.3
5 |
6 | jobs:
7 | build-and-test:
8 | executor:
9 | name: android/android-machine
10 |
11 | steps:
12 | - checkout
13 |
14 | - android/run-tests:
15 | test-command: ./gradlew lint testDebug --continue
16 |
17 | - run:
18 | name: Assemble release build
19 | command: |
20 | ./gradlew assembleRelease
21 |
22 | build-verify:
23 | executor:
24 | name: android/android-machine
25 | steps:
26 | - checkout
27 | - run:
28 | name: Assemble release build
29 | command: |
30 | ./gradlew clean assemble
31 |
32 | deploy-to-sonatype:
33 | executor:
34 | name: android/android-machine
35 | resource-class: large
36 | steps:
37 | - checkout
38 | - run:
39 | name: Define ORG_GRADLE_PROJECT_LIBRARY_VERSION Environment Variable at Runtime
40 | command: |
41 | if [ $CIRCLE_TAG ]
42 | then
43 | echo 'export ORG_GRADLE_PROJECT_LIBRARY_VERSION=$CIRCLE_TAG' >> $BASH_ENV
44 | else
45 | echo "export ORG_GRADLE_PROJECT_LIBRARY_VERSION=`git tag | tail -1`-SNAPSHOT" >> $BASH_ENV
46 | fi
47 | source $BASH_ENV
48 | - run:
49 | name: Inject Maven signing key
50 | command: |
51 | echo $GPG_SIGNING_KEY \
52 | | awk 'NR == 1 { print "SIGNING_KEY=" } 1' ORS='\\n' \
53 | >> gradle.properties
54 | - run:
55 | name: Publish to Maven
56 | command: ./gradlew assemble publishToSonatype closeAndReleaseSonatypeStagingRepository
57 |
58 | workflows:
59 | build-test-deploy:
60 | jobs:
61 | - build-and-test
62 | - build-verify:
63 | name: build-test
64 | filters:
65 | tags:
66 | only: /^[0-9]+.*/
67 | - hold-for-approval:
68 | type: approval
69 | requires:
70 | - build-test
71 | filters:
72 | tags:
73 | only: /^[0-9]+.*/
74 | branches:
75 | ignore: /.*/
76 | - deploy-to-sonatype:
77 | name: Deploy to Maven Central
78 | requires:
79 | - hold-for-approval
80 | filters:
81 | tags:
82 | only: /^[0-9]+.*/
83 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | ## Summary
11 |
12 |
13 | ## Code to reproduce
14 |
15 |
16 | ## Android version
17 |
18 |
19 |
20 | ## Impacted devices
21 |
22 |
23 | ## Installation method
24 |
25 |
26 | ## SDK classes
27 |
28 |
29 | ## Video
30 |
34 |
35 | ## Other information
36 |
37 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.*~
2 | local/
3 | .idea/
4 | *.log
5 | *.orig
6 | /build
7 | com_crashlytics_export_strings.xml
8 | local.properties
9 | gradle/
10 | .gradle/
11 | .signing/
12 | .idea/libraries/
13 | .idea/workspace.xml
14 | .idea/tasks.xml
15 | .idea/.name
16 | .idea/compiler.xml
17 | .idea/copyright/profiles_settings.xml
18 | .idea/encodings.xml
19 | .idea/misc.xml
20 | .idea/modules.xml
21 | .idea/scopes/scope_settings.xml
22 | .idea/vcs.xml
23 | *.iml
24 | .DS_Store
25 | .DS_Store?
26 | ._*
27 | .Spotlight-V100
28 | .Trashes
29 | ehthumbs.db
30 | Thumbs.db
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | [](https://circleci.com/gh/GautamChibde/android-audio-visualizer/tree/master) [](https://codebeat.co/projects/github-com-gautamchibde-android-audio-visualizer-master) [](https://central.sonatype.com/artifact/io.github.gautamchibde/audiovisualizer) [](https://android-arsenal.com/api?level=19)
4 |
5 | # Demo
6 |
7 |      
8 |
9 | # Importing the Library
10 |
11 | Apache Maven
12 |
13 | ```xml
14 |
15 | io.github.gautamchibde
16 | audiovisualizer
17 | 2.2.5
18 |
19 | ```
20 |
21 | Gradle Groovy DSL
22 |
23 | ```groovy
24 | implementation 'io.github.gautamchibde:audiovisualizer:2.2.5'
25 | ```
26 |
27 | Gradle Kotlin DSL
28 |
29 | ```kotlin
30 | implementation("io.github.gautamchibde:audiovisualizer:2.2.5")
31 | ```
32 |
33 | Library is available in maven repository [here](https://search.maven.org/artifact/io.github.gautamchibde/audiovisualizer)
34 |
35 | # How to use
36 |
37 | Refer to the [sample](https://github.com/GautamChibde/android-audio-visualizer/tree/master/sample) project on how to use visualizer or refer to [WIKI](https://github.com/GautamChibde/android-audio-visualizer/wiki) docs.
38 |
39 | ## Visualizers
40 | * [LineVisualizer](https://github.com/GautamChibde/android-audio-visualizer/wiki/Line-Visualizer)
41 | * [BarVisualizer](https://github.com/GautamChibde/android-audio-visualizer/wiki/Bar-Visualizer)
42 | * [CircleVisualizer](https://github.com/GautamChibde/android-audio-visualizer/wiki/Circle-Visualizer)
43 | * [Circle Bar Visualizer](https://github.com/GautamChibde/android-audio-visualizer/wiki/Circle-Bar-Visualizer)
44 | * [Line Bar Visualizer](https://github.com/GautamChibde/android-audio-visualizer/wiki/Line-Bar-Visualizer)
45 | * [Square Bar Visualizer](https://github.com/GautamChibde/android-audio-visualizer/wiki/SquareBar-Visualizer)
46 |
47 | License
48 | =======
49 | Copyright 2017 Gautam Chibde
50 |
51 | Licensed under the Apache License, Version 2.0 (the "License");
52 | you may not use this file except in compliance with the License.
53 | You may obtain a copy of the License at
54 |
55 | http://www.apache.org/licenses/LICENSE-2.0
56 |
57 | Unless required by applicable law or agreed to in writing, software
58 | distributed under the License is distributed on an "AS IS" BASIS,
59 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
60 | See the License for the specific language governing permissions and
61 | limitations under the License.
62 |
--------------------------------------------------------------------------------
/audiovisualizer/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/audiovisualizer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'maven-publish'
3 | apply plugin: 'signing'
4 |
5 | def artifactId = 'audiovisualizer'
6 | def ossrhUsername = findProperty('OSSRH_USERNAME')
7 | def ossrhPassword = findProperty('OSSRH_PASSWORD')
8 | def signingKey = findProperty('SIGNING_KEY')
9 | def signingKeyPwd = findProperty('SIGNING_KEY_PWD')
10 |
11 | group = "io.github.gautamchibde"
12 | version = findProperty('LIBRARY_VERSION') ? findProperty('LIBRARY_VERSION') : "1.0.13-snapshot" //Hardcoding snapshot version if none exist in environment variable
13 |
14 | android {
15 | compileSdkVersion 33
16 |
17 | defaultConfig {
18 | minSdkVersion 19
19 | targetSdkVersion 33
20 |
21 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
22 |
23 | }
24 | buildTypes {
25 | release {
26 | minifyEnabled false
27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
28 | }
29 | }
30 | }
31 |
32 | dependencies {
33 | implementation fileTree(dir: 'libs', include: ['*.jar'])
34 | androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1', {
35 | exclude group: 'com.android.support', module: 'support-annotations'
36 | })
37 | implementation 'androidx.appcompat:appcompat:1.6.1'
38 | testImplementation 'junit:junit:4.13.2'
39 | }
40 |
41 | println("Version to use")
42 | println(version)
43 |
44 | task javadoc(type: Javadoc) {
45 |
46 | doFirst {
47 | configurations.implementation
48 | .filter { it.name.endsWith('.aar') }
49 | .each { aar ->
50 | copy {
51 | from zipTree(aar)
52 | include "**/classes.jar"
53 | into "$buildDir/tmp/aarsToJars/${aar.name.replace('.aar', '')}/"
54 | }
55 | }
56 | }
57 |
58 | configurations.implementation.setCanBeResolved(true)
59 | source = android.sourceSets.main.java.srcDirs
60 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
61 | classpath += configurations.implementation
62 | classpath += fileTree(dir: "$buildDir/tmp/aarsToJars/")
63 | destinationDir = file("${project.buildDir}/outputs/javadoc/")
64 | failOnError false
65 | exclude '**/BuildConfig.java'
66 | exclude '**/R.java'
67 | }
68 |
69 | task javadocJar(type: Jar, dependsOn: javadoc) {
70 | archiveClassifier.set('javadoc')
71 | from javadoc
72 | }
73 |
74 | task androidSourcesJar(type: Jar) {
75 | archiveClassifier.set('sources')
76 | from android.sourceSets.main.java.srcDirs
77 | }
78 |
79 | afterEvaluate {
80 | publishing {
81 | publications {
82 | release(MavenPublication) {
83 | from components.release
84 | // You can then customize attributes of the publication as shown below.
85 | groupId = group
86 | artifactId = artifactId
87 | version = version
88 |
89 | artifact androidSourcesJar
90 | artifact javadocJar
91 |
92 | pom {
93 | name = artifactId
94 | description = ' Audio visualisation for android MediaPlayer'
95 | url = 'https://github.com/GautamChibde/android-audio-visualizer'
96 | licenses {
97 | license {
98 | name = 'Apache License 2.0'
99 | url = 'https://github.com/GautamChibde/android-audio-visualizer/blob/master/LICENSE'
100 | }
101 | }
102 | developers {
103 | developer {
104 | id = 'gautamchibde'
105 | name = 'Gautam Chibde'
106 | email = 'gautamchibde@gmail.com'
107 | }
108 | }
109 | scm {
110 | connection = 'scm:git@github.com:GautamChibde/android-audio-visualizer.git'
111 | developerConnection = 'scm:git:ssh://github.com:GautamChibde/android-audio-visualizer.git'
112 | url = 'https://github.com/GautamChibde/android-audio-visualizer/tree/master'
113 | }
114 | }
115 | }
116 | }
117 | repositories {
118 | maven {
119 | name = "sonatype"
120 |
121 | def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
122 | def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
123 | url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
124 |
125 | credentials {
126 | username ossrhUsername
127 | password ossrhPassword
128 | }
129 | }
130 | }
131 | }
132 | }
133 |
134 | signing {
135 | useInMemoryPgpKeys(signingKey, signingKeyPwd)
136 | sign publishing.publications
137 | }
138 |
139 |
--------------------------------------------------------------------------------
/audiovisualizer/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/gautam/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/audiovisualizer/src/androidTest/java/com/chibde/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.chibde;
2 |
3 | import android.content.Context;
4 | import androidx.test.InstrumentationRegistry;
5 | import androidx.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static junit.framework.Assert.assertEquals;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.chibde.audiovisulaizer.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/audiovisualizer/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/audiovisualizer/src/main/java/com/chibde/BaseVisualizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde;
17 |
18 | import android.content.Context;
19 | import android.graphics.Color;
20 | import android.graphics.Paint;
21 | import android.media.MediaPlayer;
22 | import android.media.audiofx.Visualizer;
23 | import android.util.AttributeSet;
24 | import android.view.View;
25 |
26 | import androidx.annotation.Nullable;
27 |
28 | /**
29 | * Base class that contains common implementation for all
30 | * visualizers.
31 | * Created by gautam chibde on 28/10/17.
32 | */
33 |
34 | abstract public class BaseVisualizer extends View {
35 | protected byte[] bytes;
36 | protected Paint paint;
37 | protected Visualizer visualizer;
38 | protected int color = Color.BLUE;
39 |
40 | public BaseVisualizer(Context context) {
41 | super(context);
42 | init(null);
43 | init();
44 | }
45 |
46 | public BaseVisualizer(Context context, @Nullable AttributeSet attrs) {
47 | super(context, attrs);
48 | init(attrs);
49 | init();
50 | }
51 |
52 | public BaseVisualizer(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
53 | super(context, attrs, defStyleAttr);
54 | init(attrs);
55 | init();
56 | }
57 |
58 | private void init(AttributeSet attributeSet) {
59 | paint = new Paint();
60 | }
61 |
62 | /**
63 | * Set color to visualizer with color resource id.
64 | *
65 | * @param color color resource id.
66 | */
67 | public void setColor(int color) {
68 | this.color = color;
69 | this.paint.setColor(this.color);
70 | }
71 |
72 | /**
73 | * @deprecated will be removed in next version use {@link BaseVisualizer#setPlayer(int)} instead
74 | * @param mediaPlayer MediaPlayer
75 | */
76 | @Deprecated
77 | public void setPlayer(MediaPlayer mediaPlayer) {
78 | setPlayer(mediaPlayer.getAudioSessionId());
79 | }
80 |
81 | public void setPlayer(int audioSessionId) {
82 | visualizer = new Visualizer(audioSessionId);
83 | visualizer.setEnabled(false);
84 | visualizer.setCaptureSize(Visualizer.getCaptureSizeRange()[1]);
85 |
86 | visualizer.setDataCaptureListener(new Visualizer.OnDataCaptureListener() {
87 | @Override
88 | public void onWaveFormDataCapture(Visualizer visualizer, byte[] bytes,
89 | int samplingRate) {
90 | BaseVisualizer.this.bytes = bytes;
91 | invalidate();
92 | }
93 |
94 | @Override
95 | public void onFftDataCapture(Visualizer visualizer, byte[] bytes,
96 | int samplingRate) {
97 | }
98 | }, Visualizer.getMaxCaptureRate() / 2, true, false);
99 |
100 | visualizer.setEnabled(true);
101 | }
102 |
103 | public void release() {
104 | //will be null if setPlayer hasn't yet been called
105 | if (visualizer == null)
106 | return;
107 |
108 | visualizer.release();
109 | bytes = null;
110 | invalidate();
111 | }
112 |
113 | public Visualizer getVisualizer() {
114 | return visualizer;
115 | }
116 |
117 | protected abstract void init();
118 | }
119 |
--------------------------------------------------------------------------------
/audiovisualizer/src/main/java/com/chibde/visualizer/BarVisualizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.visualizer;
17 |
18 | import android.content.Context;
19 | import android.graphics.Canvas;
20 | import android.graphics.Paint;
21 | import androidx.annotation.Nullable;
22 | import android.util.AttributeSet;
23 |
24 | import com.chibde.BaseVisualizer;
25 |
26 | /**
27 | * Custom view that creates a Bar visualizer effect for
28 | * the android {@link android.media.MediaPlayer}
29 | *
30 | * Created by gautam chibde on 28/10/17.
31 | */
32 |
33 | public class BarVisualizer extends BaseVisualizer {
34 |
35 | private float density = 50;
36 | private int gap;
37 |
38 | public BarVisualizer(Context context) {
39 | super(context);
40 | }
41 |
42 | public BarVisualizer(Context context,
43 | @Nullable AttributeSet attrs) {
44 | super(context, attrs);
45 | }
46 |
47 | public BarVisualizer(Context context,
48 | @Nullable AttributeSet attrs,
49 | int defStyleAttr) {
50 | super(context, attrs, defStyleAttr);
51 | }
52 |
53 | @Override
54 | protected void init() {
55 | this.density = 50;
56 | this.gap = 4;
57 | paint.setStyle(Paint.Style.FILL);
58 | }
59 |
60 | /**
61 | * Sets the density to the Bar visualizer i.e the number of bars
62 | * to be displayed. Density can vary from 10 to 256.
63 | * by default the value is set to 50.
64 | *
65 | * @param density density of the bar visualizer
66 | */
67 | public void setDensity(float density) {
68 | this.density = density;
69 | if (density > 256) {
70 | this.density = 256;
71 | } else if (density < 10) {
72 | this.density = 10;
73 | }
74 | }
75 |
76 | @Override
77 | protected void onDraw(Canvas canvas) {
78 | if (bytes != null) {
79 | float barWidth = getWidth() / density;
80 | float div = bytes.length / density;
81 | paint.setStrokeWidth(barWidth - gap);
82 |
83 | for (int i = 0; i < density; i++) {
84 | int bytePosition = (int) Math.ceil(i * div);
85 | int top = getHeight() +
86 | ((byte) (Math.abs(bytes[bytePosition]) + 128)) * getHeight() / 128;
87 | float barX = (i * barWidth) + (barWidth / 2);
88 | canvas.drawLine(barX, getHeight(), barX, top, paint);
89 | }
90 | super.onDraw(canvas);
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/audiovisualizer/src/main/java/com/chibde/visualizer/BlazingColorVisualizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.visualizer;
17 |
18 | import android.content.Context;
19 | import android.graphics.Canvas;
20 | import android.graphics.Color;
21 | import android.graphics.LinearGradient;
22 | import android.graphics.Shader;
23 | import androidx.annotation.Nullable;
24 | import android.util.AttributeSet;
25 |
26 | import com.chibde.BaseVisualizer;
27 |
28 | /**
29 | * TODO
30 | *
31 | * Created by gautam chibde on 29/10/17.
32 | */
33 |
34 | class BlazingColorVisualizer extends BaseVisualizer {
35 | private Shader shader;
36 |
37 | public BlazingColorVisualizer(Context context) {
38 | super(context);
39 | }
40 |
41 | public BlazingColorVisualizer(Context context,
42 | @Nullable AttributeSet attrs) {
43 | super(context, attrs);
44 | }
45 |
46 | public BlazingColorVisualizer(Context context,
47 | @Nullable AttributeSet attrs,
48 | int defStyleAttr) {
49 | super(context, attrs, defStyleAttr);
50 | }
51 |
52 | @Override
53 | protected void init() {
54 | shader = new LinearGradient(0,
55 | 0,
56 | 0,
57 | getHeight(),
58 | Color.BLUE,
59 | Color.GREEN,
60 | Shader.TileMode.MIRROR /*or REPEAT*/);
61 | }
62 |
63 | @Override
64 | protected void onDraw(Canvas canvas) {
65 | if (bytes != null) {
66 | paint.setShader(shader);
67 | for (int i = 0, k = 0; i < (bytes.length - 1) && k < bytes.length; i++, k++) {
68 | int top = getHeight() +
69 | ((byte) (Math.abs(bytes[k]) + 128)) * getHeight() / 128;
70 | canvas.drawLine(i, getHeight(), i, top, paint);
71 | }
72 | super.onDraw(canvas);
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/audiovisualizer/src/main/java/com/chibde/visualizer/CircleBarVisualizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.chibde.visualizer;
18 |
19 | import android.content.Context;
20 | import android.graphics.Canvas;
21 | import android.graphics.Paint;
22 | import androidx.annotation.Nullable;
23 | import android.util.AttributeSet;
24 |
25 | import com.chibde.BaseVisualizer;
26 |
27 | /**
28 | * Custom view that creates a Circle and Bar visualizer effect for
29 | * the android {@link android.media.MediaPlayer}
30 | *
31 | * Created by gautam chibde on 20/11/17.
32 | */
33 |
34 | public class CircleBarVisualizer extends BaseVisualizer {
35 | private float[] points;
36 | private Paint circlePaint;
37 | private int radius;
38 |
39 | public CircleBarVisualizer(Context context) {
40 | super(context);
41 | }
42 |
43 | public CircleBarVisualizer(Context context,
44 | @Nullable AttributeSet attrs) {
45 | super(context, attrs);
46 | }
47 |
48 | public CircleBarVisualizer(Context context,
49 | @Nullable AttributeSet attrs,
50 | int defStyleAttr) {
51 | super(context, attrs, defStyleAttr);
52 | }
53 |
54 | @Override
55 | protected void init() {
56 | paint.setStyle(Paint.Style.STROKE);
57 | circlePaint = new Paint();
58 | radius = -1;
59 | }
60 |
61 | @Override
62 | protected void onDraw(Canvas canvas) {
63 | if (radius == -1) {
64 | radius = getHeight() < getWidth() ? getHeight() : getWidth();
65 | radius = (int) (radius * 0.65 / 2);
66 | double circumference = 2 * Math.PI * radius;
67 | paint.setStrokeWidth((float) (circumference / 120));
68 | circlePaint.setStyle(Paint.Style.STROKE);
69 | circlePaint.setStrokeWidth(4);
70 | }
71 | circlePaint.setColor(color);
72 | canvas.drawCircle(getWidth() / 2f, getHeight() / 2f, radius, circlePaint);
73 | if (bytes != null) {
74 | if (points == null || points.length < bytes.length * 4) {
75 | points = new float[bytes.length * 4];
76 | }
77 | double angle = 0;
78 |
79 | for (int i = 0; i < 120; i++, angle += 3) {
80 | int x = (int) Math.ceil(i * 8.5);
81 | int t = ((byte) (-Math.abs(bytes[x]) + 128)) * (getHeight() / 4) / 128;
82 |
83 | points[i * 4] = (float) (getWidth() / 2
84 | + radius
85 | * Math.cos(Math.toRadians(angle)));
86 |
87 | points[i * 4 + 1] = (float) (getHeight() / 2
88 | + radius
89 | * Math.sin(Math.toRadians(angle)));
90 |
91 | points[i * 4 + 2] = (float) (getWidth() / 2
92 | + (radius + t)
93 | * Math.cos(Math.toRadians(angle)));
94 |
95 | points[i * 4 + 3] = (float) (getHeight() / 2
96 | + (radius + t)
97 | * Math.sin(Math.toRadians(angle)));
98 | }
99 |
100 | canvas.drawLines(points, paint);
101 | }
102 | super.onDraw(canvas);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/audiovisualizer/src/main/java/com/chibde/visualizer/CircleBarVisualizerSmooth.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.chibde.visualizer;
18 |
19 |
20 | import android.content.Context;
21 | import android.graphics.Canvas;
22 | import android.graphics.Paint;
23 |
24 |
25 | import android.util.AttributeSet;
26 |
27 | import androidx.annotation.Nullable;
28 |
29 | import com.chibde.BaseVisualizer;
30 |
31 | import java.util.HashMap;
32 | import java.util.Map;
33 |
34 | /**
35 | * Custom view that creates a Circle and Bar visualizer effect for the android
36 | * {@link android.media.MediaPlayer}
37 | *
38 | * Created by gautam chibde on 20/11/17. Smooth effect added by Ali heidari
39 | */
40 |
41 | public class CircleBarVisualizerSmooth extends BaseVisualizer {
42 | private final static float _StepsCount = 2;
43 | private final static int _BarCount = 120;
44 | private final static float _AngleStep = 360f / _BarCount;
45 | private float[] points;
46 | private float[] endPoints;
47 | private float[] diffs;
48 | // Stores radius and step-counter which every invoking of "onDraw" requires them
49 | private Map configs = null;
50 |
51 |
52 | public CircleBarVisualizerSmooth(Context context,
53 | @Nullable AttributeSet attrs) {
54 | super(context, attrs);
55 | }
56 |
57 | @Override
58 | protected void init() {
59 | paint.setStyle(Paint.Style.STROKE);
60 | }
61 |
62 | /*
63 | * Returns the value of given configuration-key with handling
64 | * @see java.lang#NullPointerException
65 | */
66 | private int getConfig(String key) {
67 | Object obj = configs.get(key);
68 | if (obj != null)
69 | return (int) obj;
70 | else
71 | return 0;
72 | }
73 |
74 | /*
75 | *set new value of given configuration-key
76 | */
77 | private void setConfig(String key, int value) {
78 | configs.put(key, value);
79 | }
80 |
81 | /*
82 | *Get smaller dimension of visualizer
83 | */
84 | private int getSmallerDimen() {
85 | if (getHeight() < getWidth()) return getHeight();
86 | else return getWidth();
87 | }
88 |
89 | /*
90 | * Fill the initial configurations
91 | */
92 | private void fillConfigs() {
93 | if (configs != null)
94 | return;
95 | configs = new HashMap<>();
96 | // Calculates the radius of center circle.
97 | // Formula disclaimer : 0.65 = 3.14 * 0.02
98 | int radius = (int) (getSmallerDimen() * 0.65 / 2) * 6 / 10;
99 | // Width of each bar
100 | double circumference = 1.5 * Math.PI * radius;
101 | paint.setStrokeWidth((float) (circumference / _BarCount));
102 | // Store initial configs
103 | configs.put("needsInit", 1);//0 = false, 1 = true
104 | configs.put("radius", radius);
105 | configs.put("stepCounter", 0);
106 | }
107 |
108 | /*
109 | * Initializes the points
110 | */
111 | private void initPoints() {
112 | // Set points sizes if it is first time we got here or for any reasons arrays
113 | // are broken.
114 | if (getConfig("needsInit") == 1 || points == null || points.length < bytes.length * 2) {
115 | // It needs to multiply by 4 because for every byte should be
116 | // StartX,StartY,EndX,EndY
117 | points = new float[bytes.length * 4];
118 | // It needs to multiply by 4 because for every byte should be EndX,EndY,OldEndX,OldEndY
119 | endPoints = new float[bytes.length * 4];
120 | // It needs to multiply by 2 because there are X and Y differences
121 | diffs = new float[bytes.length * 2];
122 | }
123 | }
124 |
125 |
126 | /*
127 | * Fill the points for end of each bar.
128 | * Only needs to calculate the end of bar-line, because starting is not changing
129 | */
130 | private void fillPoints(int round, int i) {
131 | int indexM2 = i * 2;
132 | int indexM4 = i * 4;
133 | // Increase/Decrease the length of bar so oldEnd can match with ends
134 | if (round <= _StepsCount) {
135 | // Find endX to be drawn
136 | points[indexM4 + 2] = endPoints[indexM4 + 2] + diffs[indexM2] * round;
137 | // Find endX to be drawn
138 | points[indexM4 + 3] = endPoints[indexM4 + 3] + diffs[indexM2 + 1] * round;
139 | }
140 | }
141 |
142 | /*
143 | * Fills the end points and differences
144 | */
145 | private void fillEndPointsAndDiffs(int i, float newX, float newY) {
146 | // Set the old ends before assign new value the ends
147 | endPoints[i * 4 + 2] = endPoints[i * 4];
148 | endPoints[i * 4 + 3] = endPoints[i * 4 + 1];
149 | // Find endX
150 | endPoints[i * 4] = newX;
151 | // Find endY
152 | endPoints[i * 4 + 1] = newY;
153 |
154 | // If it is not first time, so we have oldEnds for calculation of differences
155 | if (getConfig("needsInit") == 0) {
156 | // Find differences of Xs
157 | diffs[i * 2] = (endPoints[i * 4] - endPoints[i * 4 + 2]) / _StepsCount;
158 | // Find differences of Ys
159 | diffs[i * 2 + 1] = (endPoints[i * 4 + 1] - endPoints[i * 4 + 3]) / _StepsCount;
160 | } else {
161 | // Set the old ends
162 | endPoints[i * 4 + 2] = endPoints[i * 4];
163 | endPoints[i * 4 + 3] = endPoints[i * 4 + 1];
164 | }
165 | }
166 |
167 | /*
168 | * Calculates the points of each round. Round represents amount of decrease/increase the length of bar
169 | */
170 | private void calcRound(int i, double angle) {
171 | // Calculates ceiling regarded to bytes length. The ceiling is a coefficient for
172 | // byte indexer.
173 | // Because we have 120 bars, so the buffer should be filtered and only 120 bytes
174 | // from the buffer will have chosen to be shown.
175 | // Get length of bar
176 | int t = getBarLength(i, (bytes.length - bytes.length % 4f) / _BarCount);
177 | // Find the round by
178 | int round = (int) (getConfig("stepCounter") % _StepsCount);
179 | if (round == 0) {
180 | float radius_p_t = getConfig("radius") + t;
181 | //Fill the endPoints and differences
182 | this.fillEndPointsAndDiffs(i, (float) (getWidth() / 2 + radius_p_t * Math.cos(angle)), (float) (getHeight() / 2 + radius_p_t * Math.sin(angle)));
183 | }
184 | // Fill points
185 | this.fillPoints(round, i);
186 | }
187 |
188 | /*
189 | * Calculates the legth of bar
190 | */
191 | private int getBarLength(int i, float ceiling) {
192 | // Find the index of byte inside buffer
193 | int x = (int) Math.ceil(i * ceiling);
194 | // Change the sign of byte
195 | byte a = (byte) (-Math.abs(bytes[x]) + 128);
196 | // Gets the length of the line
197 | return a * (getHeight() / 4) / 128;
198 | }
199 |
200 | /*
201 | * Calculate first points
202 | */
203 | private void fillStartingPoints(int i, double angle) {
204 | int indexM4 = i * 4;
205 | // First time calculates the startX and startY for every byte
206 | if (getConfig("needsInit") == 1) {
207 | // Find startX
208 | points[indexM4] = (float) (this.getWidth() / 2 + getConfig("radius") * Math.cos(angle));
209 | // Find startY
210 | points[indexM4 + 1] = (float) (this.getHeight() / 2 + getConfig("radius") * Math.sin(angle));
211 | }
212 | // Calculates points for current round
213 | calcRound(i, angle);
214 | }
215 |
216 | /*
217 | * Draw waveform It calculates the StartX,StartY just once because it never
218 | * changes. Then calculates EndX, EndY, OldEndX and OldEndY every 3 frames. So
219 | * OldEndX and OldEndY can increase/decrease toward EndX and EndY respectively.
220 | * To perform such an action(Animation) you need differences of X and Y. It
221 | * achieves using EndX - OldEndX and EndY - OldEndY Then find the steps using
222 | * Differences / 3 Finally when OldEnd(s) matched to End(s) Need to set End with
223 | * OldEnd value And the action will be repeated until visualizer is running.
224 | */
225 | @Override
226 | protected void onDraw(Canvas canvas) {
227 | // Check if bytes initiated before
228 | if (bytes == null)
229 | return;
230 |
231 | // Init configs
232 | fillConfigs();
233 |
234 | // Fill the points
235 | initPoints();
236 |
237 | // We start with angle 0 and go against clock's direction
238 | double angle = 0;
239 | // Calculates every points and iterate along increasing angle
240 | for (int i = 0; i < _BarCount; i++, angle += _AngleStep) {
241 |
242 | // Convert to radians
243 | double radianAngle = Math.toRadians(angle);
244 |
245 | this.fillStartingPoints(i, radianAngle);
246 |
247 |
248 | }
249 | if (getConfig("needsInit") == 0)
250 | canvas.drawLines(points, paint);
251 |
252 | super.onDraw(canvas);
253 |
254 | // Resets configurations variable for next calling of onDraw
255 | this.resetConfigs();
256 | }
257 |
258 | /*
259 | * Reset configs
260 | */
261 | private void resetConfigs() {
262 | // The stepCounter increases
263 | setConfig("stepCounter", getConfig("stepCounter") + 1);
264 | // Initialized, no longer need initializing
265 | if (getConfig("needsInit") == 1)
266 | setConfig("needsInit", 0);
267 | }
268 | }
--------------------------------------------------------------------------------
/audiovisualizer/src/main/java/com/chibde/visualizer/CircleVisualizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.visualizer;
17 |
18 | import android.content.Context;
19 | import android.graphics.Canvas;
20 | import androidx.annotation.Nullable;
21 | import android.util.AttributeSet;
22 |
23 | import com.chibde.BaseVisualizer;
24 |
25 | /**
26 | * Custom view that creates a circle visualizer effect for
27 | * the android {@link android.media.MediaPlayer}
28 | *
29 | * Created by gautam on 13/11/17.
30 | */
31 | public class CircleVisualizer extends BaseVisualizer {
32 | private float[] points;
33 | private float radiusMultiplier = 1;
34 | private float strokeWidth = 0.005f;
35 |
36 | public CircleVisualizer(Context context) {
37 | super(context);
38 | }
39 |
40 | public CircleVisualizer(Context context, @Nullable AttributeSet attrs) {
41 | super(context, attrs);
42 | }
43 |
44 | public CircleVisualizer(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
45 | super(context, attrs, defStyleAttr);
46 | }
47 |
48 | @Override
49 | protected void init() {
50 | }
51 |
52 | /**
53 | * set Stroke width for your visualizer takes input between 1-10
54 | *
55 | * @param strokeWidth stroke width between 1-10
56 | */
57 | public void setStrokeWidth(int strokeWidth) {
58 | if (strokeWidth > 10) {
59 | this.strokeWidth = 10 * 0.005f;
60 | } else if (strokeWidth < 1) {
61 | this.strokeWidth = 0.005f;
62 | }
63 | this.strokeWidth = strokeWidth * 0.005f;
64 | }
65 |
66 | /**
67 | * This method sets the multiplier to the circle, by default the
68 | * multiplier is set to 1. you can provide value more than 1 to
69 | * increase size of the circle visualizer.
70 | *
71 | * @param radiusMultiplier multiplies to the radius of the circle.
72 | */
73 | public void setRadiusMultiplier(float radiusMultiplier) {
74 | this.radiusMultiplier = radiusMultiplier;
75 | }
76 |
77 | @Override
78 | protected void onDraw(Canvas canvas) {
79 | if (bytes != null) {
80 | paint.setStrokeWidth(getHeight() * strokeWidth);
81 | if (points == null || points.length < bytes.length * 4) {
82 | points = new float[bytes.length * 4];
83 | }
84 | double angle = 0;
85 |
86 | for (int i = 0; i < 360; i++, angle++) {
87 | points[i * 4] = (float) (getWidth() / 2
88 | + Math.abs(bytes[i * 2])
89 | * radiusMultiplier
90 | * Math.cos(Math.toRadians(angle)));
91 | points[i * 4 + 1] = (float) (getHeight() / 2
92 | + Math.abs(bytes[i * 2])
93 | * radiusMultiplier
94 | * Math.sin(Math.toRadians(angle)));
95 |
96 | points[i * 4 + 2] = (float) (getWidth() / 2
97 | + Math.abs(bytes[i * 2 + 1])
98 | * radiusMultiplier
99 | * Math.cos(Math.toRadians(angle + 1)));
100 |
101 | points[i * 4 + 3] = (float) (getHeight() / 2
102 | + Math.abs(bytes[i * 2 + 1])
103 | * radiusMultiplier
104 | * Math.sin(Math.toRadians(angle + 1)));
105 | }
106 | canvas.drawLines(points, paint);
107 | }
108 | super.onDraw(canvas);
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/audiovisualizer/src/main/java/com/chibde/visualizer/LineBarVisualizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.visualizer;
17 |
18 | import android.content.Context;
19 | import android.graphics.Canvas;
20 | import android.graphics.Color;
21 | import android.graphics.Paint;
22 | import androidx.annotation.Nullable;
23 | import android.util.AttributeSet;
24 |
25 | import com.chibde.BaseVisualizer;
26 |
27 | /**
28 | * Custom view that creates a Line and Bar visualizer effect for
29 | * the android {@link android.media.MediaPlayer}
30 | *
31 | * Created by gautam chibde on 22/11/17.
32 | */
33 |
34 | public class LineBarVisualizer extends BaseVisualizer {
35 | private Paint middleLine;
36 | private float density;
37 | private int gap;
38 |
39 | public LineBarVisualizer(Context context) {
40 | super(context);
41 | }
42 |
43 | public LineBarVisualizer(Context context, @Nullable AttributeSet attrs) {
44 | super(context, attrs);
45 | }
46 |
47 | public LineBarVisualizer(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
48 | super(context, attrs, defStyleAttr);
49 | }
50 |
51 | @Override
52 | protected void init() {
53 | density = 50;
54 | gap = 4;
55 | middleLine = new Paint();
56 | middleLine.setColor(Color.BLUE);
57 | }
58 |
59 | /**
60 | * Sets the density to the Bar visualizer i.e the number of bars
61 | * to be displayed. Density can vary from 10 to 256.
62 | * by default the value is set to 50.
63 | *
64 | * @param density density of the bar visualizer
65 | */
66 | public void setDensity(float density) {
67 | if (this.density > 180) {
68 | this.middleLine.setStrokeWidth(1);
69 | this.gap = 1;
70 | } else {
71 | this.gap = 4;
72 | }
73 | this.density = density;
74 | if (density > 256) {
75 | this.density = 256;
76 | this.gap = 0;
77 | } else if (density <= 10) {
78 | this.density = 10;
79 | }
80 | }
81 |
82 | @Override
83 | protected void onDraw(Canvas canvas) {
84 | if (middleLine.getColor() != Color.BLUE) {
85 | middleLine.setColor(color);
86 | }
87 | if (bytes != null) {
88 | float barWidth = getWidth() / density;
89 | float div = bytes.length / density;
90 | canvas.drawLine(0, getHeight() / 2, getWidth(), getHeight() / 2, middleLine);
91 | paint.setStrokeWidth(barWidth - gap);
92 |
93 | for (int i = 0; i < density; i++) {
94 | int bytePosition = (int) Math.ceil(i * div);
95 | int top = getHeight() / 2
96 | + (128 - Math.abs(bytes[bytePosition]))
97 | * (getHeight() / 2) / 128;
98 |
99 | int bottom = getHeight() / 2
100 | - (128 - Math.abs(bytes[bytePosition]))
101 | * (getHeight() / 2) / 128;
102 |
103 | float barX = (i * barWidth) + (barWidth / 2);
104 | canvas.drawLine(barX, bottom, barX, getHeight() / 2, paint);
105 | canvas.drawLine(barX, top, barX, getHeight() / 2, paint);
106 | }
107 | super.onDraw(canvas);
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/audiovisualizer/src/main/java/com/chibde/visualizer/LineVisualizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.visualizer;
17 |
18 | import android.content.Context;
19 | import android.graphics.Canvas;
20 | import android.graphics.Rect;
21 | import androidx.annotation.Nullable;
22 | import android.util.AttributeSet;
23 |
24 | import com.chibde.BaseVisualizer;
25 |
26 | /**
27 | * Custom view that creates a Bar visualizer effect for
28 | * the android {@link android.media.MediaPlayer}
29 | *
30 | * Created by gautam chibde on 28/10/17.
31 | */
32 |
33 | public class LineVisualizer extends BaseVisualizer {
34 | private float[] points;
35 | private Rect rect = new Rect();
36 | private float strokeWidth = 0.005f;
37 |
38 | public LineVisualizer(Context context) {
39 | super(context);
40 | }
41 |
42 | public LineVisualizer(Context context,
43 | @Nullable AttributeSet attrs) {
44 | super(context, attrs);
45 | }
46 |
47 | public LineVisualizer(Context context,
48 | @Nullable AttributeSet attrs,
49 | int defStyleAttr) {
50 | super(context, attrs, defStyleAttr);
51 | }
52 |
53 | @Override
54 | protected void init() {
55 | }
56 |
57 | /**
58 | * set Stroke width for your visualizer takes input between 1-10
59 | *
60 | * @param strokeWidth stroke width between 1-10
61 | */
62 | public void setStrokeWidth(int strokeWidth) {
63 | if (strokeWidth > 10) {
64 | this.strokeWidth = 10 * 0.005f;
65 | } else if (strokeWidth < 1) {
66 | this.strokeWidth = 0.005f;
67 | }
68 | this.strokeWidth = strokeWidth * 0.005f;
69 | }
70 |
71 | @Override
72 | protected void onDraw(Canvas canvas) {
73 | if (bytes != null) {
74 | if (points == null || points.length < bytes.length * 4) {
75 | points = new float[bytes.length * 4];
76 | }
77 | paint.setStrokeWidth(getHeight() * strokeWidth);
78 | rect.set(0, 0, getWidth(), getHeight());
79 |
80 | for (int i = 0; i < bytes.length - 1; i++) {
81 | points[i * 4] = rect.width() * i / (bytes.length - 1);
82 | points[i * 4 + 1] = rect.height() / 2
83 | + ((byte) (bytes[i] + 128)) * (rect.height() / 3) / 128;
84 | points[i * 4 + 2] = rect.width() * (i + 1) / (bytes.length - 1);
85 | points[i * 4 + 3] = rect.height() / 2
86 | + ((byte) (bytes[i + 1] + 128)) * (rect.height() / 3) / 128;
87 | }
88 | canvas.drawLines(points, paint);
89 | }
90 | super.onDraw(canvas);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/audiovisualizer/src/main/java/com/chibde/visualizer/SquareBarVisualizer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.visualizer;
17 |
18 | import android.content.Context;
19 | import android.graphics.Canvas;
20 | import android.graphics.Paint;
21 | import android.util.AttributeSet;
22 |
23 | import androidx.annotation.Nullable;
24 |
25 | import com.chibde.BaseVisualizer;
26 |
27 | /**
28 | * Custom view that creates a Bar visualizer effect for
29 | * the android {@link android.media.MediaPlayer}
30 | *
31 | * Created by gautam chibde on 28/10/17.
32 | */
33 |
34 | public class SquareBarVisualizer extends BaseVisualizer {
35 |
36 | private float density = 16;
37 | private int gap;
38 |
39 | public SquareBarVisualizer(Context context) {
40 | super(context);
41 | }
42 |
43 | public SquareBarVisualizer(Context context,
44 | @Nullable AttributeSet attrs) {
45 | super(context, attrs);
46 | }
47 |
48 | public SquareBarVisualizer(Context context,
49 | @Nullable AttributeSet attrs,
50 | int defStyleAttr) {
51 | super(context, attrs, defStyleAttr);
52 | }
53 |
54 | @Override
55 | protected void init() {
56 | this.density = 16;
57 | this.gap = 2;
58 | paint.setStyle(Paint.Style.FILL);
59 | }
60 |
61 | /**
62 | * Sets the density to the Bar visualizer i.e the number of bars
63 | * to be displayed. Density can vary from 10 to 256.
64 | * by default the value is set to 50.
65 | *
66 | * @param density density of the bar visualizer
67 | */
68 | public void setDensity(float density) {
69 | this.density = density;
70 | if (density > 256) {
71 | this.density = 256;
72 | } else if (density < 16) {
73 | this.density = 16;
74 | }
75 | }
76 |
77 | /**
78 | * Set Spacing between the Square in visualizer in pixel.
79 | *
80 | * @param gap Spacing between the square
81 | */
82 | public void setGap(int gap) {
83 | this.gap = gap;
84 | }
85 |
86 | @Override
87 | protected void onDraw(Canvas canvas) {
88 | if (bytes != null) {
89 | float barWidth = getWidth() / density;
90 | float div = bytes.length / density;
91 | paint.setStrokeWidth(barWidth - gap);
92 | for (int i = 0; i < density; i++) {
93 | int count = 0;
94 | int bytePosition = (int) Math.ceil(i * div);
95 | int top = getHeight() + ((byte) (Math.abs(bytes[bytePosition]) + 128)) * getHeight() / 128;
96 | int col = Math.abs((getHeight() - top));
97 | for (int j = 0; j < col + 1; j += barWidth) {
98 | float barX = (i * barWidth) + (barWidth / 2);
99 | float y1 = getHeight() - ((barWidth + (gap / 2f)) * count);
100 | float y2 = getHeight() - ((barWidth - gap / 2f) + ((barWidth + gap / 2f) * count));
101 | canvas.drawLine(barX, y1, barX, y2, paint);
102 | count++;
103 | }
104 | }
105 | super.onDraw(canvas);
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/audiovisualizer/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AudioVisulaizer
3 |
4 |
--------------------------------------------------------------------------------
/audiovisualizer/src/test/java/com/chibde/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.chibde;
2 |
3 | import org.junit.Test;
4 |
5 | import static junit.framework.Assert.assertEquals;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void additionIsCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | mavenCentral()
4 | google()
5 | }
6 | dependencies {
7 | classpath 'com.android.tools.build:gradle:7.0.4'
8 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
9 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
10 | }
11 | }
12 |
13 | plugins {
14 | id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
15 | }
16 |
17 | allprojects {
18 | tasks.withType(Test).configureEach {
19 | forkEvery = 100
20 | }
21 |
22 | repositories {
23 | mavenCentral()
24 | google()
25 | }
26 | }
27 |
28 | task clean(type: Delete) {
29 | delete rootProject.buildDir
30 | }
31 |
32 | group = "io.github.gautamchibde"
33 | version = findProperty('LIBRARY_VERSION') ? findProperty('LIBRARY_VERSION') : "2.2.1-snapshot" //Hardcoding snapshot version if none exist in environment variable
34 |
35 |
36 | nexusPublishing {
37 | repositories {
38 | sonatype { //only for users registered in Sonatype after 24 Feb 2021
39 | nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
40 | snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
41 | username = findProperty('OSSRH_USERNAME')
42 | password = findProperty('OSSRH_PASSWORD')
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue May 25 12:18:18 IST 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 33
5 | defaultConfig {
6 | applicationId "com.chibde.audiovisualizer.sample"
7 | minSdkVersion 19
8 | targetSdkVersion 33
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation project(':audiovisualizer')
24 | androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | implementation 'androidx.appcompat:appcompat:1.6.1'
28 | implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
29 | testImplementation 'junit:junit:4.13.2'
30 | }
31 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/gautam/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/sample/src/androidTest/java/com/chibde/audiovisualizer/sample/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.audiovisualizer.sample;
17 |
18 | import android.content.Context;
19 | import androidx.test.InstrumentationRegistry;
20 | import androidx.test.runner.AndroidJUnit4;
21 |
22 | import org.junit.Test;
23 | import org.junit.runner.RunWith;
24 |
25 | import static org.junit.Assert.*;
26 |
27 | /**
28 | * Instrumentation test, which will execute on an Android device.
29 | *
30 | * @see Testing documentation
31 | */
32 | @RunWith(AndroidJUnit4.class)
33 | public class ExampleInstrumentedTest {
34 | @Test
35 | public void useAppContext() throws Exception {
36 | // Context of the app under test.
37 | Context appContext = InstrumentationRegistry.getTargetContext();
38 |
39 | assertEquals("com.chibde.audiovisualizer.sample", appContext.getPackageName());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
29 |
32 |
33 |
37 |
40 |
41 |
45 |
49 |
52 |
53 |
57 |
60 |
61 |
62 |
66 |
67 |
70 |
71 |
72 |
75 |
76 |
77 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/chibde/audiovisualizer/sample/BaseActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.audiovisualizer.sample;
17 |
18 | import android.Manifest;
19 | import android.content.pm.PackageManager;
20 | import android.media.MediaPlayer;
21 | import android.os.Bundle;
22 | import androidx.annotation.NonNull;
23 | import androidx.annotation.Nullable;
24 | import androidx.core.content.ContextCompat;
25 | import androidx.appcompat.app.AppCompatActivity;
26 | import android.widget.ImageButton;
27 |
28 | /**
29 | * BaseActivity that contains common code for all visualizers
30 | *
31 | * Created by gautam chibde on 18/11/17.
32 | */
33 | abstract public class BaseActivity extends AppCompatActivity {
34 | public static final int AUDIO_PERMISSION_REQUEST_CODE = 102;
35 |
36 | public static final String[] WRITE_EXTERNAL_STORAGE_PERMS = {
37 | Manifest.permission.RECORD_AUDIO
38 | };
39 |
40 | protected MediaPlayer mediaPlayer;
41 |
42 | @Override
43 | protected void onCreate(@Nullable Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | if (getLayout() != 0) {
46 | setContentView(getLayout());
47 | } else {
48 | throw new NullPointerException("Provide layout file for the activity");
49 | }
50 | setActionBar();
51 | initialize();
52 | }
53 |
54 | private void initialize() {
55 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M
56 | && checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
57 | requestPermissions(WRITE_EXTERNAL_STORAGE_PERMS, AUDIO_PERMISSION_REQUEST_CODE);
58 | } else {
59 | setPlayer();
60 | }
61 | }
62 |
63 | private void setActionBar() {
64 | if (getActionBar() != null) {
65 | getActionBar().setDisplayHomeAsUpEnabled(true);
66 | }
67 | }
68 |
69 | private void setPlayer() {
70 | mediaPlayer = MediaPlayer.create(this, R.raw.red_e);
71 | mediaPlayer.setLooping(false);
72 | init();
73 | }
74 |
75 | @Override
76 | protected void onStop() {
77 | super.onStop();
78 | if (mediaPlayer != null && mediaPlayer.isPlaying()) {
79 | mediaPlayer.stop();
80 | mediaPlayer.release();
81 | }
82 | }
83 |
84 | @Override
85 | public void onRequestPermissionsResult(
86 | int requestCode,
87 | @NonNull String[] permissions,
88 | @NonNull int[] grantResults) {
89 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
90 | if (requestCode == AUDIO_PERMISSION_REQUEST_CODE) {
91 | if (grantResults.length > 0
92 | && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
93 | setPlayer();
94 | } else {
95 | this.finish();
96 | }
97 | }
98 | }
99 |
100 | public void playPauseBtnClicked(ImageButton btnPlayPause) {
101 | if (mediaPlayer != null) {
102 | if (mediaPlayer.isPlaying()) {
103 | mediaPlayer.pause();
104 | btnPlayPause.setImageDrawable(ContextCompat.getDrawable(
105 | this,
106 | R.drawable.ic_play_red_48dp));
107 | } else {
108 | mediaPlayer.start();
109 | btnPlayPause.setImageDrawable(ContextCompat.getDrawable(
110 | this,
111 | R.drawable.ic_pause_red_48dp));
112 | }
113 | }
114 | }
115 |
116 | protected int getLayout() {
117 | return 0;
118 | }
119 |
120 | protected abstract void init();
121 | }
122 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/chibde/audiovisualizer/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.audiovisualizer.sample;
17 |
18 | import android.content.Intent;
19 | import android.os.Bundle;
20 | import androidx.appcompat.app.AppCompatActivity;
21 | import android.view.View;
22 |
23 | import com.chibde.audiovisualizer.sample.visualizer.BarVisualizerActivity;
24 | import com.chibde.audiovisualizer.sample.visualizer.CircleBarVisualizerActivity;
25 | import com.chibde.audiovisualizer.sample.visualizer.CircleVisualizerActivity;
26 | import com.chibde.audiovisualizer.sample.visualizer.LineBarVisualizerActivity;
27 | import com.chibde.audiovisualizer.sample.visualizer.LineVisualizerActivity;
28 | import com.chibde.audiovisualizer.sample.visualizer.SquareBarVisualizerActivity;
29 | import com.chibde.visualizer.SquareBarVisualizer;
30 |
31 | public class MainActivity extends AppCompatActivity {
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | setContentView(R.layout.activity_main);
36 | }
37 |
38 | public void line(View view) {
39 | startActivity(LineVisualizerActivity.class);
40 | }
41 |
42 | public void bar(View view) {
43 | startActivity(BarVisualizerActivity.class);
44 | }
45 |
46 | public void circle(View view) {
47 | startActivity(CircleVisualizerActivity.class);
48 | }
49 |
50 | public void circleBar(View view) {
51 | startActivity(CircleBarVisualizerActivity.class);
52 | }
53 |
54 | public void lineBar(View view) {
55 | startActivity(LineBarVisualizerActivity.class);
56 | }
57 |
58 | public void service(View view) {
59 | startActivity(ServiceExampleActivity.class);
60 | }
61 |
62 | public void square(View view) {
63 | startActivity(SquareBarVisualizerActivity.class);
64 | }
65 |
66 | public void startActivity(Class clazz) {
67 | startActivity(new Intent(this, clazz));
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/chibde/audiovisualizer/sample/MediaPlayerService.java:
--------------------------------------------------------------------------------
1 | package com.chibde.audiovisualizer.sample;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.media.MediaPlayer;
6 | import android.os.Binder;
7 | import android.os.IBinder;
8 | import androidx.annotation.Nullable;
9 | import androidx.localbroadcastmanager.content.LocalBroadcastManager;
10 |
11 | public class MediaPlayerService extends Service {
12 |
13 | public static final String INTENT_FILTER = "MediaPlayerServiceIntentFilter";
14 | public static final String INTENT_AUDIO_SESSION_ID = "intent_audio_session_id";
15 |
16 | private IBinder mediaPlayerServiceBinder = new MediaPlayerServiceBinder();
17 | private MediaPlayer mediaPlayer;
18 |
19 | @Override
20 | public void onCreate() {
21 | super.onCreate();
22 | mediaPlayer = MediaPlayer.create(this, R.raw.red_e);
23 | mediaPlayer.setLooping(false);
24 |
25 | Intent intent = new Intent(INTENT_FILTER); //put the same message as in the filter you used in the activity when registering the receiver
26 | intent.putExtra(INTENT_AUDIO_SESSION_ID, mediaPlayer.getAudioSessionId());
27 | // Send audio session id through
28 | LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
29 | }
30 |
31 | @Nullable
32 | @Override
33 | public IBinder onBind(Intent intent) {
34 | return mediaPlayerServiceBinder;
35 | }
36 |
37 | public void replay() {
38 | if (mediaPlayer != null) {
39 | mediaPlayer.seekTo(0);
40 | }
41 | }
42 |
43 | @Override
44 | public void onRebind(Intent intent) {
45 | super.onRebind(intent);
46 | }
47 |
48 | @Override
49 | public boolean onUnbind(Intent intent) {
50 | return true;
51 | }
52 |
53 | @Override
54 | public void onDestroy() {
55 | super.onDestroy();
56 | if (mediaPlayer != null) {
57 | mediaPlayer.release();
58 | }
59 | }
60 |
61 | public boolean isPlaying() {
62 | return mediaPlayer != null && mediaPlayer.isPlaying();
63 | }
64 |
65 | public void pause() {
66 | if (mediaPlayer != null) {
67 | mediaPlayer.pause();
68 | }
69 | }
70 |
71 | public void start() {
72 | if (mediaPlayer != null) {
73 | mediaPlayer.start();
74 | }
75 | }
76 |
77 | public class MediaPlayerServiceBinder extends Binder {
78 | MediaPlayerService getService() {
79 | return MediaPlayerService.this;
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/chibde/audiovisualizer/sample/ServiceExampleActivity.java:
--------------------------------------------------------------------------------
1 | package com.chibde.audiovisualizer.sample;
2 |
3 | import android.Manifest;
4 | import android.content.BroadcastReceiver;
5 | import android.content.ComponentName;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.content.IntentFilter;
9 | import android.content.ServiceConnection;
10 | import android.content.pm.PackageManager;
11 | import android.os.IBinder;
12 | import androidx.annotation.NonNull;
13 | import androidx.core.content.ContextCompat;
14 | import androidx.localbroadcastmanager.content.LocalBroadcastManager;
15 | import androidx.appcompat.app.AppCompatActivity;
16 | import android.os.Bundle;
17 | import android.view.View;
18 | import android.widget.ImageButton;
19 |
20 | import com.chibde.visualizer.BarVisualizer;
21 |
22 | public class ServiceExampleActivity extends AppCompatActivity {
23 | private MediaPlayerService mBoundService;
24 | private BarVisualizer barVisualizer;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | if (getActionBar() != null) {
30 | getActionBar().setDisplayHomeAsUpEnabled(true);
31 | }
32 | setContentView(R.layout.activity_service_example);
33 | barVisualizer = findViewById(R.id.visualizer);
34 |
35 | // set custom color to the line.
36 | barVisualizer.setColor(ContextCompat.getColor(this, R.color.custom));
37 |
38 | // define custom number of bars you want in the visualizer between (10 - 256).
39 | barVisualizer.setDensity(70);
40 | initialize();
41 | }
42 |
43 | @Override
44 | protected void onStart() {
45 | super.onStart();
46 | // register LocalBroadcastManager
47 | LocalBroadcastManager.getInstance(this).registerReceiver(bReceiver, new IntentFilter(MediaPlayerService.INTENT_FILTER));
48 | Intent intent = new Intent(this, MediaPlayerService.class);
49 | startService(intent);
50 | bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
51 | }
52 |
53 | private void initialize() {
54 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M
55 | && checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
56 | requestPermissions(BaseActivity.WRITE_EXTERNAL_STORAGE_PERMS, BaseActivity.AUDIO_PERMISSION_REQUEST_CODE);
57 | }
58 | }
59 |
60 | @Override
61 | public void onRequestPermissionsResult(
62 | int requestCode,
63 | @NonNull String[] permissions,
64 | @NonNull int[] grantResults) {
65 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
66 | switch (requestCode) {
67 | case BaseActivity.AUDIO_PERMISSION_REQUEST_CODE:
68 | if (grantResults.length > 0
69 | && grantResults[0] != PackageManager.PERMISSION_GRANTED) {
70 | finish();
71 | }
72 | }
73 | }
74 |
75 |
76 | public void replay(View view) {
77 | mBoundService.replay();
78 | }
79 |
80 | public void playPause(View view) {
81 | playPauseBtnClicked((ImageButton) view);
82 | }
83 |
84 | /**
85 | * receive audio session id required for visualizer through
86 | * broadcast receiver from service
87 | * ref https://stackoverflow.com/a/27652660/5164673
88 | */
89 | private BroadcastReceiver bReceiver = new BroadcastReceiver() {
90 |
91 | @Override
92 | public void onReceive(Context context, Intent intent) {
93 | int audioSessionId = intent.getIntExtra(MediaPlayerService.INTENT_AUDIO_SESSION_ID, -1);
94 | if (audioSessionId != -1) {
95 | barVisualizer.setPlayer(audioSessionId);
96 | }
97 | }
98 | };
99 |
100 | @Override
101 | protected void onDestroy() {
102 | super.onDestroy();
103 | stopService(new Intent(this, MediaPlayerService.class));
104 | unbindService(serviceConnection);
105 | }
106 |
107 | protected void onPause() {
108 | super.onPause();
109 | // unregister LocalBroadcastManager
110 | LocalBroadcastManager.getInstance(this).unregisterReceiver(bReceiver);
111 | }
112 |
113 | public void playPauseBtnClicked(ImageButton btnPlayPause) {
114 | if (mBoundService.isPlaying()) {
115 | mBoundService.pause();
116 | btnPlayPause.setImageDrawable(ContextCompat.getDrawable(
117 | this,
118 | R.drawable.ic_play_red_48dp));
119 | } else {
120 | mBoundService.start();
121 | btnPlayPause.setImageDrawable(ContextCompat.getDrawable(
122 | this,
123 | R.drawable.ic_pause_red_48dp));
124 | }
125 | }
126 |
127 | private ServiceConnection serviceConnection = new ServiceConnection() {
128 |
129 | @Override
130 | public void onServiceDisconnected(ComponentName name) {
131 | }
132 |
133 | @Override
134 | public void onServiceConnected(ComponentName name, IBinder service) {
135 | MediaPlayerService.MediaPlayerServiceBinder myBinder = (MediaPlayerService.MediaPlayerServiceBinder) service;
136 | mBoundService = myBinder.getService();
137 | }
138 | };
139 | }
140 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/chibde/audiovisualizer/sample/visualizer/BarVisualizerActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.audiovisualizer.sample.visualizer;
17 |
18 | import androidx.core.content.ContextCompat;
19 | import android.view.View;
20 | import android.widget.ImageButton;
21 |
22 | import com.chibde.audiovisualizer.sample.BaseActivity;
23 | import com.chibde.audiovisualizer.sample.R;
24 | import com.chibde.visualizer.BarVisualizer;
25 |
26 | public class BarVisualizerActivity extends BaseActivity {
27 |
28 | @Override
29 | protected void init() {
30 | BarVisualizer barVisualizer = findViewById(R.id.visualizer);
31 |
32 | // set custom color to the line.
33 | barVisualizer.setColor(ContextCompat.getColor(this, R.color.custom));
34 |
35 | // define custom number of bars you want in the visualizer between (10 - 256).
36 | barVisualizer.setDensity(70);
37 |
38 | // Set your media player to the visualizer.
39 | barVisualizer.setPlayer(mediaPlayer.getAudioSessionId());
40 | }
41 |
42 | public void replay(View view) {
43 | if (mediaPlayer != null) {
44 | mediaPlayer.seekTo(0);
45 | }
46 | }
47 |
48 | public void playPause(View view) {
49 | playPauseBtnClicked((ImageButton) view);
50 | }
51 |
52 | @Override
53 | protected int getLayout() {
54 | return R.layout.activity_bar_visualizer;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/chibde/audiovisualizer/sample/visualizer/CircleBarVisualizerActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.audiovisualizer.sample.visualizer;
17 |
18 | import androidx.core.content.ContextCompat;
19 | import android.view.View;
20 | import android.widget.ImageButton;
21 |
22 | import com.chibde.audiovisualizer.sample.BaseActivity;
23 | import com.chibde.audiovisualizer.sample.R;
24 | import com.chibde.visualizer.CircleBarVisualizer;
25 |
26 | public class CircleBarVisualizerActivity extends BaseActivity {
27 |
28 | @Override
29 | protected void init() {
30 | CircleBarVisualizer circleBarVisualizer = findViewById(R.id.visualizer);
31 | circleBarVisualizer.setColor(ContextCompat.getColor(this, R.color.custom));
32 | circleBarVisualizer.setPlayer(mediaPlayer.getAudioSessionId());
33 | }
34 |
35 | public void replay(View view) {
36 | if (mediaPlayer != null) {
37 | mediaPlayer.seekTo(0);
38 | }
39 | }
40 |
41 | public void playPause(View view) {
42 | playPauseBtnClicked((ImageButton) view);
43 | }
44 |
45 | @Override
46 | protected int getLayout() {
47 | return R.layout.activity_circle_bar_visualizer;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/chibde/audiovisualizer/sample/visualizer/CircleVisualizerActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.audiovisualizer.sample.visualizer;
17 |
18 | import androidx.core.content.ContextCompat;
19 | import android.view.View;
20 | import android.widget.ImageButton;
21 |
22 | import com.chibde.audiovisualizer.sample.BaseActivity;
23 | import com.chibde.audiovisualizer.sample.R;
24 | import com.chibde.visualizer.CircleVisualizer;
25 |
26 | public class CircleVisualizerActivity extends BaseActivity {
27 |
28 | @Override
29 | protected void init() {
30 | CircleVisualizer circleVisualizer = findViewById(R.id.visualizer);
31 | // set custom color to the line.
32 | circleVisualizer.setColor(ContextCompat.getColor(this, R.color.custom));
33 |
34 | // Customize the size of the circle. by defalut multipliers is 1.
35 | circleVisualizer.setRadiusMultiplier(2f);
36 |
37 | // set the line with for the visualizer between 1-10 default 1.
38 | circleVisualizer.setStrokeWidth(1);
39 |
40 | // Set your media player to the visualizer.
41 | circleVisualizer.setPlayer(mediaPlayer.getAudioSessionId());
42 | }
43 |
44 | public void replay(View view) {
45 | if (mediaPlayer != null) {
46 | mediaPlayer.seekTo(0);
47 | }
48 | }
49 |
50 | public void playPause(View view) {
51 | playPauseBtnClicked((ImageButton) view);
52 | }
53 |
54 | @Override
55 | protected int getLayout() {
56 | return R.layout.activity_circle_visualizer;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/chibde/audiovisualizer/sample/visualizer/LineBarVisualizerActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.audiovisualizer.sample.visualizer;
17 |
18 | import androidx.core.content.ContextCompat;
19 | import android.view.View;
20 | import android.widget.ImageButton;
21 |
22 | import com.chibde.audiovisualizer.sample.BaseActivity;
23 | import com.chibde.audiovisualizer.sample.R;
24 | import com.chibde.visualizer.LineBarVisualizer;
25 |
26 | public class LineBarVisualizerActivity extends BaseActivity {
27 |
28 | @Override
29 | protected void init() {
30 | LineBarVisualizer lineBarVisualizer = findViewById(R.id.visualizer);
31 |
32 | // set custom color to the line.
33 | lineBarVisualizer.setColor(ContextCompat.getColor(this, R.color.custom));
34 |
35 | // define custom number of bars you want in the visualizer between (10 - 256).
36 | lineBarVisualizer.setDensity(90f);
37 |
38 | // Set your media player to the visualizer.
39 | lineBarVisualizer.setPlayer(mediaPlayer.getAudioSessionId());
40 | }
41 |
42 | public void replay(View view) {
43 | if (mediaPlayer != null) {
44 | mediaPlayer.seekTo(0);
45 | }
46 | }
47 |
48 | public void playPause(View view) {
49 | playPauseBtnClicked((ImageButton) view);
50 | }
51 |
52 | @Override
53 | protected int getLayout() {
54 | return R.layout.activity_line_bar_visualizer;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/chibde/audiovisualizer/sample/visualizer/LineVisualizerActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.audiovisualizer.sample.visualizer;
17 |
18 | import androidx.core.content.ContextCompat;
19 | import android.view.View;
20 | import android.widget.ImageButton;
21 |
22 | import com.chibde.audiovisualizer.sample.BaseActivity;
23 | import com.chibde.audiovisualizer.sample.R;
24 | import com.chibde.visualizer.LineVisualizer;
25 |
26 | public class LineVisualizerActivity extends BaseActivity {
27 |
28 | @Override
29 | protected void init() {
30 | LineVisualizer lineVisualizer = findViewById(R.id.visualizer);
31 | // set custom color to the line.
32 | lineVisualizer.setColor(ContextCompat.getColor(this, R.color.custom));
33 |
34 | // set the line with for the visualizer between 1-10 default 1.
35 | lineVisualizer.setStrokeWidth(1);
36 |
37 | // Set you media player to the visualizer.
38 | lineVisualizer.setPlayer(mediaPlayer.getAudioSessionId());
39 | }
40 |
41 | public void replay(View view) {
42 | if (mediaPlayer != null) {
43 | mediaPlayer.seekTo(0);
44 | }
45 | }
46 |
47 | public void playPause(View view) {
48 | playPauseBtnClicked((ImageButton) view);
49 | }
50 |
51 | @Override
52 | protected int getLayout() {
53 | return R.layout.activity_line_visualizer;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/chibde/audiovisualizer/sample/visualizer/SquareBarVisualizerActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 Gautam Chibde
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.chibde.audiovisualizer.sample.visualizer;
17 |
18 | import android.view.View;
19 | import android.widget.ImageButton;
20 |
21 | import androidx.core.content.ContextCompat;
22 |
23 | import com.chibde.audiovisualizer.sample.BaseActivity;
24 | import com.chibde.audiovisualizer.sample.R;
25 | import com.chibde.visualizer.SquareBarVisualizer;
26 |
27 | public class SquareBarVisualizerActivity extends BaseActivity {
28 |
29 | @Override
30 | protected void init() {
31 | SquareBarVisualizer squareBarVisualizer = findViewById(R.id.visualizer);
32 |
33 | // set custom color to the line.
34 | squareBarVisualizer.setColor(ContextCompat.getColor(this, R.color.custom));
35 |
36 | // define custom number of bars you want in the visualizer between (10 - 256).
37 | squareBarVisualizer.setDensity(65);
38 |
39 | // set Gap
40 | squareBarVisualizer.setGap(2);
41 |
42 | // Set your media player to the visualizer.
43 | squareBarVisualizer.setPlayer(mediaPlayer.getAudioSessionId());
44 | }
45 |
46 | public void replay(View view) {
47 | if (mediaPlayer != null) {
48 | mediaPlayer.seekTo(0);
49 | }
50 | }
51 |
52 | public void playPause(View view) {
53 | playPauseBtnClicked((ImageButton) view);
54 | }
55 |
56 | @Override
57 | protected int getLayout() {
58 | return R.layout.activity_square_bar_visualizer;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_pause_red_48dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_play_red_48dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_replay_red_48dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_bar_visualizer.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_circle_bar_visualizer.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_circle_visualizer.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_line_bar_visualizer.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_line_visualizer.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
27 |
28 |
40 |
41 |
53 |
54 |
66 |
67 |
79 |
80 |
88 |
89 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_service_example.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_square_bar_visualizer.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/layout_audio_buttons.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
18 |
19 |
27 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sample/src/main/res/raw/red_e.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GautamChibde/android-audio-visualizer/24942123cd6dc57e657b46c600e3cb22d177d1c1/sample/src/main/res/raw/red_e.mp3
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #3F51B5
7 | #FFFFFF
8 |
9 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AudioVisualizer
3 | Play Pause Button
4 | Replay Button
5 | Line Visualizer
6 | Bar Visualizer
7 | Circle Visualizer
8 | Circle Bar Visualizer
9 | Line Bar Visualizer
10 | Activity With Service
11 | Square Bar Visualizer
12 |
13 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/test/java/com/chibde/audiovisualizer/sample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.chibde.audiovisualizer.sample;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':sample', ':audiovisualizer'
2 |
--------------------------------------------------------------------------------