Skip to content

Commit

Permalink
Merge pull request #9 from umjammer/1.0.13
Browse files Browse the repository at this point in the history
1.0.13
  • Loading branch information
umjammer authored Oct 22, 2022
2 parents 33c53a6 + 87e337e commit d444d26
Show file tree
Hide file tree
Showing 73 changed files with 1,211 additions and 1,414 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
57 changes: 31 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[![Release](https://jitpack.io/v/umjammer/vavi-sound.svg)](https://jitpack.io/#umjammer/vavi-sound) [![Java CI with Maven](https://github.com/umjammer/vavi-sound/workflows/Java%20CI%20with%20Maven/badge.svg)](https://github.com/umjammer/vavi-sound/actions)
[![Release](https://jitpack.io/v/umjammer/vavi-sound.svg)](https://jitpack.io/#umjammer/vavi-sound)
[![Java CI with Maven](https://github.com/umjammer/vavi-sound/workflows/Java%20CI%20with%20Maven/badge.svg)](https://github.com/umjammer/vavi-sound/actions)
[![CodeQL](https://github.com/umjammer/vavi-sound/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/umjammer/vavi-sound/actions/workflows/codeql-analysis.yml)
![Java](https://img.shields.io/badge/Java-8-b07219)

# vavi-sound

Expand All @@ -7,51 +10,53 @@ Includes many ADPCM codecs and the SSRC sampling rate converter.

## Status

| **SPI** | **Codec** | **Description** | **IN Status** | **OUT Status** | **SPI Status** | **Comment** |
|:--------|:-------------|:---------------------------|:--------------|:---------------|:---------------|:------------|
| midi | MFi | Japanese cell phone format | 🚧 ||| |
| midi | SMAF | YAMAHA cell phone format | 🚧 ||| |
| sampled | MFi | Japanese cell phone format |||| |
| sampled | SMAF | YAMAHA cell phone format |||| |
| sampled | CCITT ADPCM | G711, G721, G723 |||| except `AudioFileReader` |
| sampled | DVI ADPCM | DVI ADPCM |||| except `AudioFileReader` |
| sampled | IMA ADPCM | IMA ADPCM ||| 🚧 | except `AudioFileReader` |
| sampled | MA ADPCM | YAMAHA ADPCM |||| except `AudioFileReader` |
| sampled | MS ADPCM | Microsoft ADPCM ||| 🚧 | except `AudioFileReader` |
| sampled | OKI ADPCM | OKI ADPCM |||| except `AudioFileReader` |
| sampled | ROHM ADPCM | ROHM ADPCM |||| except `AudioFileReader` |
| sampled | VOX ADPCM | VOX ADPCM |||| except `AudioFileReader` |
| sampled | YAMAHA ADPCM | YAMAHA ADPCM ||| - | same as ym2068 |
| sampled | YM2068 ADPCM | YAMAHA ADPCM |||| except `AudioFileReader` |
| sampled | ssrc | resampling || - || waiting for phase 1 |

### Install
| **SPI** | **Codec** | **Description** | **IN Status** | **OUT Status** | **SPI Status** | **Comment** |
|:--------|:-------------|:---------------------------|:--------------|:---------------|:---------------|:----------------------------|
| midi | MFi | Japanese cell phone format | 🚧 ||| |
| midi | SMAF | YAMAHA cell phone format | 🚧 ||| |
| sampled | MFi | Japanese cell phone format |||| |
| sampled | SMAF | YAMAHA cell phone format |||| |
| sampled | CCITT ADPCM | G711, G721, G723 |||| |
| sampled | DVI ADPCM | DVI ADPCM |||| |
| sampled | IMA ADPCM | IMA ADPCM ||| | |
| sampled | MA ADPCM | YAMAHA ADPCM |||| |
| sampled | MS ADPCM | Microsoft ADPCM ||| | |
| sampled | OKI ADPCM | OKI ADPCM |||| |
| sampled | ROHM ADPCM | ROHM ADPCM |||| |
| sampled | VOX ADPCM | VOX ADPCM |||| |
| sampled | YAMAHA ADPCM | YAMAHA ADPCM ||| - | same as ym2068 |
| sampled | YM2068 ADPCM | YAMAHA ADPCM |||| |
| sampled | ssrc | resampling || - || need to wait for phase 1 |

## Install

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

### FAQ
## FAQ

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

A. yes you can, follow those steps

* create a separated jar file including ssrc classes. (**never include those .class files into your application jar file**)
* 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 the way to get ssrc source code**.
* 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

## Teck 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`

## TODO

* use `Receiver` instead of `MetaEventListener`
* ssrc: use nio pipe
* ima,ms adpcm: wav reader
* ssrc: use nio pipe for 1st pass
* ~~`ima`, `ms` adpcm: wav reader~~
* ~~`tritonus:tritonus-remaining:org.tritonus.sampled.file.WaveAudioFileReader`~~
* wip at `vavi-sound-sandbox`
Empty file removed local.properties.sample
Empty file.
12 changes: 7 additions & 5 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.12</version>
<version>1.0.13</version>

<name>Vavi Sound API</name>
<url>https://github.com/umjammer/vavi-sound</url>
Expand Down Expand Up @@ -62,8 +62,9 @@ TODO
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.10.1</version>
<configuration>
<source>8</source>
<target>8</target>
Expand All @@ -88,8 +89,9 @@ TODO
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<version>3.0.0-M7</version>
<configuration>
<argLine>
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
Expand Down Expand Up @@ -117,7 +119,7 @@ TODO
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.8.1</version>
<version>5.9.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -128,7 +130,7 @@ TODO
<dependency>
<groupId>com.github.umjammer</groupId>
<artifactId>vavi-commons</artifactId>
<version>1.1.6</version>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>com.github.umjammer</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/vavi/sound/adpcm/ccitt/G721InputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected Codec getCodec() {
* {@link vavi.io.BitInputStream} は 4bit little endian 固定
* <li>TODO BitInputStream の endian
* <li>TODO PCM encoding
* @param in CCITT ADPCM
* @param in G721 ADPCM
* @param byteOrder #read() 時のバイトオーダ
*/
public G721InputStream(InputStream in, ByteOrder byteOrder) {
Expand Down
17 changes: 7 additions & 10 deletions src/main/java/vavi/sound/mfi/vavi/MetaSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
package vavi.sound.mfi.vavi;

import java.io.Serializable;

import javax.swing.event.EventListenerList;
import java.util.ArrayList;
import java.util.List;

import vavi.sound.mfi.MetaEventListener;
import vavi.sound.mfi.MetaMessage;
Expand All @@ -23,25 +23,22 @@
class MetaSupport implements Serializable {

/** The metaEvent listeners */
private EventListenerList listenerList = new EventListenerList();
private List<MetaEventListener> listeners = new ArrayList<>();

/** {@link MetaEventListener} を追加します. */
public void addMetaEventListener(MetaEventListener l) {
listenerList.add(MetaEventListener.class, l);
listeners.add(l);
}

/** {@link MetaEventListener} を削除します. */
public void removeMetaEventListener(MetaEventListener l) {
listenerList.remove(MetaEventListener.class, l);
listeners.remove(l);
}

/** meta message を発行します. */
public void fireMeta(MetaMessage meta) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == MetaEventListener.class) {
((MetaEventListener) listeners[i + 1]).meta(meta);
}
for (MetaEventListener listener : listeners) {
listener.meta(meta);
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/vavi/sound/midi/MidiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public static String paramString(MidiMessage midiMessage) {
SysexMessage msg = (SysexMessage) midiMessage;
byte[] data = msg.getData();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < data.length; i++) {
sb.append(String.format("%02x", data[i]));
for (byte datum : data) {
sb.append(String.format("%02x", datum));
sb.append(" ");
}
result = "channel=n/a" +
Expand All @@ -80,8 +80,8 @@ public static String paramString(MidiMessage midiMessage) {
int type = msg.getType();
byte[] data = msg.getData();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < data.length; i++) {
sb.append(String.format("%02x", data[i]));
for (byte datum : data) {
sb.append(String.format("%02x", datum));
sb.append(" ");
}
result = "channel=n/a" +
Expand Down Expand Up @@ -254,7 +254,7 @@ public static byte[] getEncodedMessage(String text, String encoding) {
if (value != null) {
String defaultSequencer = value;
Debug.println(Level.FINE, "defaultSequencer: " + defaultSequencer);
if (defaultSequencer.indexOf("#") != -1) {
if (defaultSequencer.contains("#")) {
String[] pair = defaultSequencer.split("#");
sequencerClassName = pair[0];
sequencerDeviceName = pair[1];
Expand All @@ -270,7 +270,7 @@ public static byte[] getEncodedMessage(String text, String encoding) {
if (value != null) {
String defaultSynthesizer = value;
Debug.println("defaultSynthesizer: " + defaultSynthesizer);
if (defaultSynthesizer.indexOf("#") != -1) {
if (defaultSynthesizer.contains("#")) {
String[] pair = defaultSynthesizer.split("#");
synthesizerClassName = pair[0];
synthesizerDeviceName = pair[1];
Expand Down Expand Up @@ -311,7 +311,7 @@ public static Synthesizer getDefaultSynthesizer(Class<? extends MidiDeviceProvid
}
} else {
MidiDevice device = provider.getDevice(info);
if (Synthesizer.class.isInstance(device)) {
if (device instanceof Synthesizer) {
if (device.getClass().getName().equals(synthesizerClassName)) {
Debug.println(Level.FINE, "default synthesizer: " + provider.getClass().getName() + ", " + device.getClass().getName() + ", " + name + ", " + device.hashCode());
return (Synthesizer) device;
Expand Down Expand Up @@ -349,7 +349,7 @@ public static Sequencer getDefaultSequencer(Class<? extends MidiDeviceProvider>
}
} else {
MidiDevice device = provider.getDevice(info);
if (Sequencer.class.isInstance(device)) {
if (device instanceof Sequencer) {
if (device.getClass().getName().equals(sequencerClassName)) {
Debug.println(Level.FINE, "default sequencer: " + provider.getClass().getName() + ", " + device.getClass().getName() + ", " + name + ", " + device.hashCode());
return (Sequencer) device;
Expand All @@ -365,7 +365,7 @@ public static Sequencer getDefaultSequencer(Class<? extends MidiDeviceProvider>
/** */
private static ServiceLoader<MidiDeviceProvider> providers;

/**
/*
* @depends /META-INF/services/javax.sound.midi.spi.MidiDeviceProvider
*/
static {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/vavi/sound/midi/mfi/MfiMidiFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public Sequence getSequence(InputStream is)
}
} catch (IOException e) {
Debug.println(Level.SEVERE, e);
throw e;
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/vavi/sound/midi/mfi/MfiMidiFileWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ public int write(Sequence in, int fileType, OutputStream out)
Debug.println(Level.WARNING, "unknown fileType: " + fileType);
return 0;
}
} catch (InvalidMidiDataException e) {
throw (IOException) new IOException().initCause(e);
} catch (MfiUnavailableException e) {
throw (IOException) new IOException().initCause(e);
} catch (InvalidMidiDataException | MfiUnavailableException e) {
throw new IOException(e);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/vavi/sound/midi/smaf/SmafMidiFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public Sequence getSequence(InputStream is)
}
} catch (IOException e) {
Debug.println(Level.SEVERE, e);
throw e;
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/vavi/sound/midi/smaf/SmafMidiFileWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ public int write(Sequence in, int fileType, OutputStream out)
Debug.println(Level.WARNING, "unknown fileType: " + fileType);
return 0;
}
} catch (InvalidMidiDataException e) {
throw (IOException) new IOException().initCause(e);
} catch (SmafUnavailableException e) {
throw (IOException) new IOException().initCause(e);
} catch (InvalidMidiDataException | SmafUnavailableException e) {
throw new IOException(e);
}
}
}
Expand Down
Loading

0 comments on commit d444d26

Please sign in to comment.