Skip to content

Commit

Permalink
Merge pull request #16 from umjammer/1.0.17
Browse files Browse the repository at this point in the history
1.0.17
  • Loading branch information
umjammer committed Mar 16, 2024
2 parents 36bb990 + 56cb2f6 commit c484671
Show file tree
Hide file tree
Showing 414 changed files with 2,185 additions and 2,506 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
security-events: write
actions: read
contents: read

strategy:
fail-fast: false
Expand All @@ -30,11 +34,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -45,13 +49,11 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -60,13 +62,11 @@ jobs:
# and modify them (or add more) to build your code if your project
# uses a compiled language
- name: Build with Maven
run: mvn -B package --file pom.xml -s $GITHUB_WORKSPACE/settings.xml -Dmaven.test.skip=true
env:
GITHUB_TOKEN: ${{ github.token }}
run: mvn -B package --file pom.xml -Dmaven.test.skip=true

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check w/o SNAPSHOT when "bump version"
if: ${{ contains(github.event.head_commit.message, 'bump version') }}
run: grep "<version>" pom.xml | head -1 | grep -v SNAPSHOT

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand Down
77 changes: 40 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,57 @@

# vavi-sound

Provides old school Japanese cell phone sounds library as `javax.sound` SPI.
Includes many ADPCM codecs and the [SSRC](https://github.com/shibatch/SSRC) sampling rate converter.

## Status

| **SPI** | **Codec** | **Description** | **IN Status** | **OUT Status** | **SPI Status** | **Comment** |
|:--------|:---------------------------------------------------------|:---------------------------|:--------------|:---------------|:---------------|:----------------------------|
| midi | [MFi](src/main/java/vavi/sound/midi/mfi) | Japanese cell phone format | 🚧 ||| |
| midi | [SMAF](src/main/java/vavi/sound/midi/smaf) | YAMAHA cell phone format | 🚧 ||| |
| sampled | [MFi](src/main/java/vavi/sound/sampled/mfi) | Japanese cell phone format |||| |
| sampled | [SMAF](src/main/java/vavi/sound/sampled/smaf) | YAMAHA cell phone format |||| |
| sampled | [CCITT ADPCM](src/main/java/vavi/sound/adpcm/ccitt) | G711, G721, G723 |||| |
| sampled | [DVI ADPCM](src/main/java/vavi/sound/adpcm/dvi) | DVI ADPCM |||| |
| sampled | [IMA ADPCM](src/main/java/vavi/sound/adpcm/ima) | IMA ADPCM |||| |
| sampled | [MA ADPCM](https://gitlab.com/umjammer/vavi-sound-nda) | YAMAHA ADPCM |||| |
| sampled | [MS ADPCM](src/main/java/vavi/sound/adpcm/ms) | Microsoft ADPCM |||| |
| sampled | [OKI ADPCM](src/main/java/vavi/sound/adpcm/oki) | OKI ADPCM |||| |
| sampled | [ROHM ADPCM](https://gitlab.com/umjammer/vavi-sound-nda) | ROHM ADPCM |||| |
| sampled | [VOX ADPCM](src/main/java/vavi/sound/adpcm/vox) | VOX ADPCM |||| |
| sampled | [YAMAHA ADPCM](src/main/java/vavi/sound/adpcm/yamaha) | YAMAHA ADPCM ||| - | same as ym2068 |
| sampled | [YM2068 ADPCM](src/main/java/vavi/sound/adpcm/ym2608) | YAMAHA ADPCM |||| |
| sampled | [ssrc](src/main/java/vavi/sound/pcm/resampling/ssrc) | resampling || - || need to wait for phase 1 |
Provides old school Japanese cell phone sounds library as `javax.sound` SPI<br/>
includes many ADPCM codecs and the [SSRC](https://github.com/shibatch/SSRC) sampling rate converter.

### Status

| **SPI** | **Codec** | **Description** | **IN Status** | **OUT Status** | **SPI Status** | **Comment** |
|:--------|:---------------------------------------------------------|:-------------------------------------|:-------------:|:--------------:|:---------------:|:-------------------------|
| midi | [MFi](src/main/java/vavi/sound/midi/mfi) | Japanese ring tone format | 🚧 ||| DoCoMo |
| midi | [SMAF](src/main/java/vavi/sound/midi/smaf) | YAMAHA ring tone format | 🚧 ||| au, Softbank |
| sampled | [MFi](src/main/java/vavi/sound/sampled/mfi) | Japanese ring tone format |||| DoCoMo |
| sampled | [SMAF](src/main/java/vavi/sound/sampled/smaf) | YAMAHA ring tone format |||| au, Softbank |
| sampled | [CCITT ADPCM](src/main/java/vavi/sound/adpcm/ccitt) | G711, G721, G723 |||| |
| sampled | [DVI ADPCM](src/main/java/vavi/sound/adpcm/dvi) | DVI ADPCM |||| |
| sampled | [IMA ADPCM](src/main/java/vavi/sound/adpcm/ima) | IMA ADPCM ||| ✅<sup>[1]</sup> | |
| sampled | [MA ADPCM](https://gitlab.com/umjammer/vavi-sound-nda) | YAMAHA ADPCM |||| |
| sampled | [MS ADPCM](src/main/java/vavi/sound/adpcm/ms) | Microsoft ADPCM ||| ✅<sup>[1]</sup> | |
| sampled | [OKI ADPCM](src/main/java/vavi/sound/adpcm/oki) | OKI ADPCM |||| |
| sampled | [ROHM ADPCM](https://gitlab.com/umjammer/vavi-sound-nda) | ROHM ADPCM |||| |
| sampled | [VOX ADPCM](src/main/java/vavi/sound/adpcm/vox) | VOX ADPCM |||| |
| sampled | [YAMAHA ADPCM](src/main/java/vavi/sound/adpcm/yamaha) | YAMAHA ADPCM |||| |
| sampled | [YM2068 ADPCM](src/main/java/vavi/sound/adpcm/ym2608) | YAMAHA ADPCM ||| - | same as yamaha |
| sampled | [ssrc](src/main/java/vavi/sound/pcm/resampling/ssrc) | resampling || - || need to wait for phase 1 |

<sub>[1] wav file readable</sub>

## Install

* https://jitpack.io/#umjammer/vavi-sound
* https://jitpack.io/#umjammer/vavi-sound

## Usage

## FAQ
### FAQ

#### Q. can I use SSRC sampling converter under LGPL license?

A. yes you can, follow those steps

* create a separated jar (ssrc.jar) file including ssrc classes. (**never include those .class files into your application jar file**)
* `vavi/sound/pcm/resampling/ssrc/SSRC.class`
* `vavi/util/SplitRadixFft.class`
* `vavi/util/I0Bessel.class`
***caution**:
* your application complies with the LGPL. customers **have a right to reverse engineering your application**.
* if you include ssrc.jar with a distribution, you **must offer a way to get ssrc source code**.
* see also
* https://opensource.org/licenses/LGPL-2.1
* http://www.gnu.org/licenses/lgpl-java.en.html
* create a separated jar (ssrc.jar) file including ssrc classes. (**never include those .class files into your application jar file**)
* `vavi/sound/pcm/resampling/ssrc/SSRC.class`
* `vavi/util/SplitRadixFft.class`
* `vavi/util/I0Bessel.class`
***caution**:
* your application complies with the LGPL. customers **have a right to reverse engineering your application**.
* if you include ssrc.jar with a distribution, you **must offer a way to get ssrc source code**.
* see also
* https://opensource.org/licenses/LGPL-2.1
* http://www.gnu.org/licenses/lgpl-java.en.html

## Tech Know
### Tech Know

* github actions workflow on ubuntu java8 cannot deal line `PCM_SIGNED 8000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian`
* github actions workflow on ubuntu java8 cannot deal line `PCM_SIGNED 8000.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian`

## TODO

Expand All @@ -60,4 +64,3 @@ A. yes you can, follow those steps
* on macos m2 ultra 1st pass is in a blink of an eye
* ~~`ima`, `ms` adpcm: wav reader~~
* ~~`tritonus:tritonus-remaining:org.tritonus.sampled.file.WaveAudioFileReader`~~
* ~~wip at [vavi-sound-sandbox](https://github.com/umjammer/vavi-sound-sandbox)~~ done in this project
5 changes: 4 additions & 1 deletion local.properties.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ssrc=/foo/bar.wav

#sf2=/Users/nsano/Library/Audio/Sounds/Banks/Orchestra/baz.sf2
#sf2=/Users/foo/Library/Audio/Sounds/Banks/Orchestra/baz.sf2

vavi.test.volume=0.02
vavi.test.volume.midi=0.2
55 changes: 47 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>vavi</groupId>
<artifactId>vavi-sound</artifactId>
<version>1.0.16</version>
<version>1.0.17</version>

<name>Vavi Sound API</name>
<url>https://github.com/umjammer/vavi-sound</url>
Expand All @@ -23,6 +23,11 @@ TODO
<url>https://github.com/umjammer/vavi-sound/issues</url>
</issueManagement>

<properties>
<vavi.test.volume>0.02</vavi.test.volume>
<vavi.test.volume.midi>0.2</vavi.test.volume.midi>
</properties>

<profiles>
<profile>
<id>mac</id>
Expand Down Expand Up @@ -58,6 +63,38 @@ TODO
</properties>
</profile>

<profile>
<id>local</id>
<activation>
<file>
<exists>${basedir}/local.properties</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.1.0</version>
<executions>
<execution>
<id>read-properties</id>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${basedir}/local.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>assembly-with-test</id>
<build>
Expand Down Expand Up @@ -123,12 +160,14 @@ TODO
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<version>3.2.2</version>
<configuration>
<argLine>
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
-Dvavi.test.dev.null=${dev.null}
-Dvavi.test.volume=0.02
-Dvavi.test.volume=${vavi.test.volume}
-Dvavi.test.volume.midi=${vavi.test.volume.midi}
-Dvavi.test.version=${project.version}
</argLine>
<trimStackTrace>false</trimStackTrace>
</configuration>
Expand All @@ -142,7 +181,7 @@ TODO
<url>https://jitpack.io</url>
</repository>
<repository>
<id>gitlab-maven</id>
<id>gitlab-maven-packages</id>
<url>https://gitlab.com/api/v4/projects/30804899/packages/maven</url>
</repository>
</repositories>
Expand All @@ -152,7 +191,7 @@ TODO
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.0</version>
<version>5.10.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -161,9 +200,9 @@ TODO

<dependencies>
<dependency>
<groupId>com.github.umjammer</groupId>
<groupId>com.github.umjammer</groupId> <!-- vavi / com.github.umjammer -->
<artifactId>vavi-commons</artifactId>
<version>1.1.9</version>
<version>1.1.11</version>
</dependency>
<dependency>
<groupId>com.github.umjammer</groupId>
Expand All @@ -177,7 +216,7 @@ TODO
</exclusions>
</dependency>
<dependency>
<groupId>com.github.umjammer</groupId> <!-- com.github.umjammer -->
<groupId>com.github.umjammer</groupId> <!-- vavi / com.github.umjammer -->
<artifactId>vavi-util-codec-sandbox</artifactId>
<version>1.0.2</version>
</dependency>
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/vavi/sound/SoundUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ public static void volume(DataLine line, double gain) {
gainControl.setValue(dB);
}
}

/* */
29 changes: 14 additions & 15 deletions src/main/java/vavi/sound/adpcm/AdpcmInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import vavi.io.BitInputStream;
import vavi.io.BitOutputStream;
import vavi.util.Debug;


/**
Expand All @@ -24,28 +25,28 @@
* @version 0.00 030714 nsano initial version <br>
* 0.01 030714 nsano fine tune <br>
* 0.02 030714 nsano fix available() <br>
* 0.03 030715 nsano read() endian 対応 <br>
* 0.03 030715 nsano support read() endian <br>
* 0.10 060427 nsano refactoring <br>
*/
public abstract class AdpcmInputStream extends FilterInputStream {

/** #read() が返す PCM のフォーマット */
/** PCM format that #read() returns */
protected AudioFormat.Encoding encoding = AudioFormat.Encoding.PCM_SIGNED;

/** #read() が返す PCM のバイトオーダ */
/** PCM byte order that #read() returns */
protected ByteOrder byteOrder;

/** デコーダ */
/** decoder */
protected Codec decoder;

/** */
protected abstract Codec getCodec();

/**
* @param in PCM
* @param byteOrder {@link #read()} 時のバイトオーダ
* @param bits {@link BitOutputStream} のサイズ
* @param bitOrder {@link BitOutputStream} のバイトオーダ
* @param byteOrder byte order for {@link #read()}
* @param bits {@link BitOutputStream} size
* @param bitOrder byte order for {@link BitOutputStream}
*/
public AdpcmInputStream(InputStream in, ByteOrder byteOrder, int bits, ByteOrder bitOrder) {
super(new BitInputStream(in, bits, bitOrder));
Expand All @@ -54,21 +55,21 @@ public AdpcmInputStream(InputStream in, ByteOrder byteOrder, int bits, ByteOrder
//Debug.println(this.in);
}

/** ADPCM (4bit) 換算時の長さ */
/** ADPCM (4bit) length */
@Override
public int available() throws IOException {
//Debug.println("0: " + in.available() + ", " + ((in.available() * 2) + (rest ? 1 : 0)));
// TODO * 2 とか bits で計算すべき?
// TODO "* 2" calc should be in bits?
return (in.available() * 2) + (rest ? 1 : 0);
}

/** 残っているかどうか */
/** remaining or not */
protected boolean rest = false;
/** 現在の値 */
/** current stream value */
protected int current;

/**
* @return PCM H or L (8bit LSB 有効)
* @return PCM H or L (8bit LSB available)
*/
@Override
public int read() throws IOException {
Expand Down Expand Up @@ -129,10 +130,8 @@ public int read(byte[] b, int off, int len) throws IOException {
}
}
} catch (IOException e) {
e.printStackTrace(System.err);
Debug.printStackTrace(e);
}
return i;
}
}

/* */
Loading

0 comments on commit c484671

Please sign in to comment.