Android Open Source - BLE-MIDI-for-Android Tone






From Project

Back to project page BLE-MIDI-for-Android.

License

The source code is released under:

Apache License

If you think the Android project BLE-MIDI-for-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package jp.kshoji.blemidi.sample.util;
/* w w w.  j  a  v  a2s  . com*/
/**
 * Holder for tone information
 * 
 * @author K.Shoji
 */
public class Tone {
  public static final int FORM_SIN = 0;
  public static final int FORM_SAW = 1;
  public static final int FORM_SQUARE = 2;
  public static final int FORM_TRIANGLE = 3;
  public static final int FORM_MAX = 4;

  private double frequency;
  private double volume;
  private int form;
  private int note;
  
  private double generateTone(int src) {
    return 440.0 * Math.pow(2.0, (src - 69) / 12.0);
  }
  
  public Tone(int note, double volume, int form) {
    this.frequency = generateTone(note);
    this.volume = volume;
    this.form = form;
    this.note = note;
  }
  
  /**
   * @param frequency the frequency to set
   */
  public void setFrequency(double frequency) {
    this.frequency = frequency;
  }
  
  /**
   * @return the frequency
   */
  public double getFrequency() {
    return frequency;
  }
  
  /**
   * @param volume the volume to set
   */
  public void setVolume(double volume) {
    this.volume = volume;
  }
  
  /**
   * @return the volume
   */
  public double getVolume() {
    return volume;
  }
  
  /**
   * @param form the form to set
   */
  public void setForm(int form) {
    this.form = form;
  }
  
  /**
   * @return the form
   */
  public int getForm() {
    return form;
  }
  
  /**
   * @param note the note to set
   */
  public void setNote(int note) {
    this.note = note;
  }
  
  /**
   * @return the note
   */
  public int getNote() {
    return note;
  }
}




Java Source Code List

jp.kshoji.blemidi.central.BleMidiCallback.java
jp.kshoji.blemidi.central.BleMidiCentralProvider.java
jp.kshoji.blemidi.central.MidiInputDevice.java
jp.kshoji.blemidi.central.MidiOutputDevice.java
jp.kshoji.blemidi.device.MidiInputDevice.java
jp.kshoji.blemidi.device.MidiOutputDevice.java
jp.kshoji.blemidi.listener.OnMidiDeviceAttachedListener.java
jp.kshoji.blemidi.listener.OnMidiDeviceDetachedListener.java
jp.kshoji.blemidi.listener.OnMidiInputEventListener.java
jp.kshoji.blemidi.listener.OnMidiScanStatusListener.java
jp.kshoji.blemidi.peripheral.BleMidiPeripheralProvider.java
jp.kshoji.blemidi.peripheral.MidiInputDevice.java
jp.kshoji.blemidi.peripheral.MidiOutputDevice.java
jp.kshoji.blemidi.sample.CentralActivity.java
jp.kshoji.blemidi.sample.PeripheralActivity.java
jp.kshoji.blemidi.sample.util.SoundMaker.java
jp.kshoji.blemidi.sample.util.Tone.java
jp.kshoji.blemidi.util.BleMidiDeviceUtils.java
jp.kshoji.blemidi.util.BleUtils.java
jp.kshoji.blemidi.util.BleUuidUtils.java
jp.kshoji.blemidi.util.Constants.java
jp.kshoji.blemidi.util.MidiParser.java
jp.kshoji.blemidi.util.ReusableByteArrayOutputStream.java