Android Open Source - OpenSynth Oscillator Detail View






From Project

Back to project page OpenSynth.

License

The source code is released under:

Apache License

If you think the Android project OpenSynth 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 com.indigo_lab.android.opensynth.view;
//from   w  w w  .  java 2s . c  o  m
import org.thebends.synth.SynthJni;

import com.indigo_lab.android.opensynth.R;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.SeekBar;
import android.widget.Switch;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;

public class OscillatorDetailView extends ControllerView implements OnSeekBarChangeListener, OnCheckedChangeListener {
    private TextView mSemisText;
    private TextView mCentsText;
    private TextView mTotalText;
    private SeekBar mSemisSeekBar;
    private SeekBar mCentsSeekBar;
    private Switch mSyncSwitch;

    public OscillatorDetailView(Context context) {
        this(context, null);
    }

    public OscillatorDetailView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public OscillatorDetailView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle, R.layout.oscillator_detail_view);

        mSemisText = (TextView)findViewById(R.id.osc2_semitones);
        mCentsText = (TextView)findViewById(R.id.osc2_cents);
        mTotalText = (TextView)findViewById(R.id.osc2_total);

        mSemisSeekBar = (SeekBar)findViewById(R.id.semis_seekbar);
        mCentsSeekBar = (SeekBar)findViewById(R.id.cents_seekbar);

        mSemisSeekBar.setOnSeekBarChangeListener(this);
        mSemisSeekBar.setMax(100);
        mSemisSeekBar.setProgress(50);
        mCentsSeekBar.setOnSeekBarChangeListener(this);
        mCentsSeekBar.setMax(100);
        mCentsSeekBar.setProgress(50);

        mSyncSwitch = (Switch)findViewById(R.id.sync_1_2_switch);
        mSyncSwitch.setOnCheckedChangeListener(this);
   }

    @Override
    public void onProgressChanged(SeekBar seekBar, int progress,
            boolean fromUser) {
        setOsc2Shift();
    }

    @Override
    public void onStartTrackingTouch(SeekBar seekBar) {
    }

    @Override
    public void onStopTrackingTouch(SeekBar seekBar) {
    }

    private int getSemitones() {
        float value = ((mSemisSeekBar.getProgress() / 100f) - 0.5f) / 0.5f;
        return Math.round(value * 12);
    }

    private int getCents() {
        float value = ((mCentsSeekBar.getProgress() / 100f) - 0.5f) / 0.5f;
        return Math.round(value * 100);
    }

    private void setOsc2Shift() {
        int osc2Semitones = getSemitones();
        mSemisText.setText(Integer.toString(osc2Semitones));
        int osc2Cents = getCents();
        mCentsText.setText(Integer.toString(osc2Cents));
        int total = osc2Cents + 100 * osc2Semitones;
        mTotalText.setText(Integer.toString(total));
        SynthJni.setOsc2Shift(total);
    }

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        SynthJni.setOscSync(isChecked);
    }
}




Java Source Code List

com.google.synthesizer.android.widgets.piano.BlackPianoKey.java
com.google.synthesizer.android.widgets.piano.NotePianoKey.java
com.google.synthesizer.android.widgets.piano.OctavePianoKey.java
com.google.synthesizer.android.widgets.piano.PianoKey.java
com.google.synthesizer.android.widgets.piano.PianoViewListener.java
com.google.synthesizer.android.widgets.piano.PianoView.java
com.google.synthesizer.android.widgets.piano.WhitePianoKey.java
com.google.synthesizer.core.midi.MidiListener.java
com.google.synthesizer.core.music.Note.java
com.indigo_lab.android.opensynth.OpenSynthActivity.java
com.indigo_lab.android.opensynth.ViewPagerAdapter.java
com.indigo_lab.android.opensynth.view.ArpeggioView.java
com.indigo_lab.android.opensynth.view.ControllerView.java
com.indigo_lab.android.opensynth.view.EnvelopeView.java
com.indigo_lab.android.opensynth.view.FilterEnvelopeView.java
com.indigo_lab.android.opensynth.view.FilterView.java
com.indigo_lab.android.opensynth.view.ImageRadioButton.java
com.indigo_lab.android.opensynth.view.ModulationView.java
com.indigo_lab.android.opensynth.view.OscillatorDetailView.java
com.indigo_lab.android.opensynth.view.OscillatorView.java
com.indigo_lab.android.opensynth.view.RadioButton.java
com.indigo_lab.android.opensynth.view.VolumeEnvelopeView.java
org.thebends.synth.Arpeggio.java
org.thebends.synth.Controller.java
org.thebends.synth.Envelope.java
org.thebends.synth.FilterCutoff.java
org.thebends.synth.Filter.java
org.thebends.synth.FixedParameter.java
org.thebends.synth.KeyStack.java
org.thebends.synth.KeyboardOscillator.java
org.thebends.synth.LFO.java
org.thebends.synth.LagProcessor.java
org.thebends.synth.LowPassFilter.java
org.thebends.synth.MutableParameter.java
org.thebends.synth.Oscillator.java
org.thebends.synth.Parameter.java
org.thebends.synth.ResonantFilter.java
org.thebends.synth.SynthJni.java
org.thebends.synth.SynthTrack.java
org.thebends.synth.Volume.java