|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.examples.modules.minicomposer; import java.io.*; import java.util.*; import org.openide.ErrorManager; import org.openide.util.NbBundle; public final class Score implements Serializable { private static final long serialVersionUID = 76675765298773L; /** Names in text for the tones. */ public static final String[] TONES_SHORT = new String[] { "-", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; private static final String[] KEYS4_TONES_LONG = new String[] { "rest", "c", "c_sharp", "d", "d_sharp", "e", "f", "f_sharp", "g", "g_sharp", "a", "a_sharp", "b" }; /** Display names of the tones. */ public static final String[] TONES_LONG = new String[KEYS4_TONES_LONG.length]; /** Default tone to start with in a GUI. */ public static final int DEFAULT_TONE = 1; /** Names in text for the octaves. */ public static final String[] OCTAVES_SHORT = new String[] { "--", "-", ".", "+", "++" }; private static final String[] KEYS4_OCTAVES_LONG = new String[] { "low", "middle_low", "middle", "middle_high", "high" }; /** Display names of octaves. */ public static final String[] OCTAVES_LONG = new String[KEYS4_OCTAVES_LONG.length]; /** Default octave to display. */ public static final int DEFAULT_OCTAVE = 2; /** Frequency of middle C. */ public static final float MIDDLE_C_HERTZ = 440.0f; /** Position of C in the tone list. */ public static final int WHERE_IS_C_TONE = 1; /** Position of the middle octave in the octave list. */ public static final int WHERE_IS_MIDDLE_OCTAVE = 2; /** Frequency increment of one half-tone. */ public static final float HALF_STEP = (float)Math.pow(2.0, 1.0 / 12.0); /** Names in text for durations. */ public static final String[] DURATIONS_SHORT = new String[] { "1", "2", "4" }; private static final String[] KEYS4_DURATIONS_LONG = new String[] { "quarter", "half", "full" }; /** Display names of durations. */ public static final String[] DURATIONS_LONG = new String[KEYS4_DURATIONS_LONG.length]; /** Lengths of durations in seconds. */ public static final float[] DURATION_SECONDS = new float[] { 0.25f, 0.5f, 1.0f }; /** Index of default duration to select. */ public static final int DEFAULT_DURATION = 0; static { ResourceBundle bundle = NbBundle.getBundle(Score.class); for (int i = 0; i < TONES_LONG.length; i++) TONES_LONG[i] = bundle.getString("TONE_" + KEYS4_TONES_LONG[i]); for (int i = 0; i < OCTAVES_LONG.length; i++) OCTAVES_LONG[i] = bundle.getString("OCTAVE_" + KEYS4_OCTAVES_LONG[i]); for (int i = 0; i < DURATIONS_LONG.length; i++) DURATIONS_LONG[i] = bundle.getString("DURATION_" + KEYS4_DURATIONS_LONG[i]); } /** One note (or rest) in a score. */ public static final class Note implements Serializable, Cloneable { private static final long serialVersionUID = 9674532758L; private final int tone; private final int octave; private final int duration; public Note(int tone, int octave, int duration) { this.tone = tone; this.octave = octave; this.duration = duration; } public int getTone() { return tone; } public int getOctave() { return octave; } public int getDuration() { return duration; } public Note cloneNote() { try { return (Note)clone(); } catch (CloneNotSupportedException cnse) { throw new IllegalStateException(cnse.toString()); } } public String toString() { return "Note@" + System.identityHashCode(this) + "[" + TONES_SHORT[tone] + "/" + OCTAVES_SHORT[octave] + "/" + DURATIONS_SHORT[duration] + "]"; } } private final List notes; // List |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.