diff --git a/res/bin/en.instr b/res/bin/en.instr deleted file mode 100644 index b13fffd..0000000 --- a/res/bin/en.instr +++ /dev/null @@ -1,208 +0,0 @@ -Drums -Acoustic Grand -Bright Acoustic -Electric Grand -Honky-Tonk -Electric Piano 1 -Electric Piano 2 -Harpsichord -Clav -Celesta -Glockenspiel -Music Box -Vibraphone -Marimba -Xylophone -Tubular Bells -Dulcimer -Drawbar Organ -Percussive Organ -Rock Organ -Church Organ -Reed Organ -Accoridan -Harmonica -Tango Accordian -Acoustic Guitar(nylon) -Acoustic Guitar(steel) -Electric Guitar(jazz) -Electric Guitar(clean) -Electric Guitar(muted) -Overdriven Guitar -Distortion Guitar -Guitar Harmonics -Acoustic Bass -Electric Bass(finger) -Electric Bass(pick) -Fretless Bass -Slap Bass 1 -Slap Bass 2 -Synth Bass 1 -Synth Bass 2 -Violin -Viola -Cello -Contrabass -Tremolo Strings -Pizzicato Strings -Orchestral Strings -Timpani -String Ensemble 1 -String Ensemble 2 -SynthStrings 1 -SynthStrings 2 -Choir Aahs -Voice Oohs -Synth Voice -Orchestra Hit -Trumpet -Trombone -Tuba -Muted Trumpet -French Horn -Brass Section -SynthBrass 1 -SynthBrass 2 -Soprano Sax -Alto Sax -Tenor Sax -Baritone Sax -Oboe -English Horn -Bassoon -Clarinet -Piccolo -Flute -Recorder -Pan Flute -Blown Bottle -Skakuhachi -Whistle -Ocarina -Lead 1 (square) -Lead 2 (sawtooth) -Lead 3 (calliope) -Lead 4 (chiff) -Lead 5 (charang) -Lead 6 (voice) -Lead 7 (fifths) -Lead 8 (bass+lead) -Pad 1 (new age) -Pad 2 (warm) -Pad 3 (polysynth) -Pad 4 (choir) -Pad 5 (bowed) -Pad 6 (metallic) -Pad 7 (halo) -Pad 8 (sweep) -FX 1 (rain) -FX 2 (soundtrack) -FX 3 (crystal) -FX 4 (atmosphere) -FX 5 (brightness) -FX 6 (goblins) -FX 7 (echoes) -FX 8 (sci-fi) -Sitar -Banjo -Shamisen -Koto -Kalimba -Bagpipe -Fiddle -Shanai -Tinkle Bell -Agogo -Steel Drums -Woodblock -Taiko Drum -Melodic Tom -Synth Drum -Reverse Cymbal -Guitar Fret Noise -Breath Noise -Seashore -Bird Tweet -Telephone Ring -Helicopter -Applause -Gunshot - -Piano -Chromatic Percussion -Organ -Guitar -Bass -Strings & Orchestral instruments -Ensemble -Brass -Reed -Pipe -Synth Lead -Synth Pad -Synth SFX -Ethnic Misc -Percussive -SFX - -HighQ -Slap -Scratch Push -Scratch Pull -Sticks -Square Click -Metronome Click -Metronome bell -Acoustic Bass Drum -Bass Drum 1 -Side Stick -Acoustic Snare -Hand Clap -Electric Snare -Low Floor Tom -Closed Hi-Hat -High Floor Tom -Pedal Hi-Hat -Low Tom -Open Hi-Hat -Low-Mid Tom -Hi-Mid Tom -Crash Cymbal 1 -High Tom -Ride Cymbal 1 -Chinese Cymbal -Ride Bell -Tambourine -Splash Cymbal -Cowbell -Crash Cymbal 2 -Vibraslap -Ride Cymbal 2 -Hi Bongo -Low Bongo -Mute Hi Conga -Open Hi Conga -Low Conga -High Timbale -Low Timbale -High Agogo -Low Agogo -Cabasa -Maracas -Short Whistle -Long Whistle -Short Guiro -Long Guiro -Claves -Hi Wood Block -Low Wood Block -Mute Cuica -Open Cuica -Mute Triangle -Open Triangle -Shaker -Jingle Bells -Belltree -Castanets -Mute Surdo -Open Surdo \ No newline at end of file diff --git a/res/bin/en.lang b/res/bin/en.lang deleted file mode 100644 index c7e7bf9..0000000 --- a/res/bin/en.lang +++ /dev/null @@ -1,103 +0,0 @@ -New -Resume -About -Open -Save -Save As -File -Tools -Exit -RMS -Cancel -Save -Error -Opening Error -ListInstruments -Impossible -Saved -Saving Error -Saving -Opening -Chooser error -Update error -Api error -Instruments -Menu -Back -Insert note with current attributes -To change note's attribute (e.g. lenght) delete note, if already insert,choose attribute (<7>), change it (<0>,<*>,<#>) and insert a new note -Delete note -Undo -Note Volume '+'\'-' -Play from current position/Stop -Play note on cursor -Select note's attribute -Change selected note's attribute -Stop play -Navigation on composition -Quick navigation -Mark Begin -Mark End -Copy -Paste Insert -Paste Replace -Paste Overwrite -Delete&Shift -Clean -Play Channel On Screen -Undo -Play Channel All -Redo -Add Instrument -Edit -Set Instrument -Del Instrument -Tempo Box -Volume Box -Meter -Play -Play origin -Ok -Up One Level -Delete -Choose folder -Open file -Please, wait -Updating list -Save in this Folder -Insert Tempo -Delete Tempo -Temp -Time(Measure) -Seek -Meter -numerator -denominator(negative power of two) -Instruments -Meter = numerator/ (2^denominator). For example, use 4/4 (numerator=4; denominator=2) or 6/8 (numerator=6; denominator=3) -Delta -Play/Stop -Play all -Play screen -Track all -Track screen -Mark -Mark Begin -Mark End -UnMark -Modify block -Modify Mode -Copy -Paste -Insert -Replace -Blend -Clean Sel -Redo -Help -Key Map -Quick Commands -Navigation -Nums, otherWise KeyPad, when edit notes: -Icons otherWise List, inMain Menu -***** \ No newline at end of file diff --git a/res/bin/ru.instr b/res/bin/ru.instr deleted file mode 100644 index 51615a1..0000000 --- a/res/bin/ru.instr +++ /dev/null @@ -1,208 +0,0 @@ -Ударные -Рояль -Концертный(осветленный) рояль -Электронный рояль -Расстроенное(таперское) пианино -Электропиано -Электропиано 2 -Клавесин -Клавинет (клавесин 2) -Челеста -Колокольчики (бутылки) -'Музыкальная шкатулка' -Вибрафон -Маримба -Ксилофон -Колокола (трубчатые) -Цимбалы (сантур) -Электронный орган -Орган с перкуссией (с ударной атакой) -Рок-орган -Церковный орган -Деревянный (язычковый) органчик -Аккордеон -Гармоника -'Танго'-аккордеон -Гитара-нейлон -Гитара-сталь -Джазовая электрогитара -Акустическая электрогитара -Засурдиненная (приглушенная) электрогитара -Овердрайв (перегруз) -Дисторшн (исказитель) -Флажолет -Контрабас-пицикато -Бас-гитара пальцевым щипком -Бас-гитара медиатором -Бездадовый бас -Бас-слэп 1 -Бас-слэп 2 -Синт-бас 1 -Синт-бас 2 -Скрипка -Альт -Виолончель -Контрабас -Тремоло струнных -Пицикато струнных -Арфа -Литавры -Струнная группа 1 -Струнная группа 2 -Синтетические струнные 1 -Синтетические струнные 2 -Хор на слог 'а' -Голос на слог 'о' -Синтетический голос -'Удар' (весь оркестр) -Труба -Тромбон -Туба -Труба с сурдиной -Валторна -Медная группа -Синтетические медные 1 -Синтетические медные 2 -Сопрано-саксофон -Альт-саксофон -Тенор-саксофон -Баритон-саксофон -Гобой -Английский рожок -Фагот -Кларнет -Флейта-пикколо -Флейта -Блокфлейта -Пан-флейта -Дуновение в бутылки -Шакухачи -Свисток -Окарина -Соло-гитара (прямоугольная волна) -Соло-гитара (синусоидальная волна) -Calliope-гитара -Chiff-гитара -Charang-гитара -Соло-гитара (голосовой тембр) -Соло-гитара (с квинтовым обертоном) -Бас и соло-гитара -Синтезаторный звук нью-эйдж -Теплый синт-звук -Полисинтезатор -Синт-'хор' -Воздушный (смычковый синт-звук) -Металлический синт -Ореол -Развертывающийся(качающийся) звук -Дождь -Звуковая дорожка -Хрусталь (кристалл) -Атмосфера -Яркость -Гоблины -(Качающееся) эхо -Звездный (SciFi) -Ситар -Банджо -Шамисен -Кото -Калимба -Волынка (Bagpipe) -Уличная скрипка -Санаи (Shanai) -Колокольчик -Агого -Стальные барабаны -Гольцтон (деревянные коробочки) -Таико -Мелодик том -Электронные барабаны -Тарелка 'задом наперед'(реверс) -Свист гитарной струны (шум ладов) -Придыхание -Прибой -Птицы -Телефонный звонок -Вертолет -Алодисменты -Выстрел - -Фортепиано -Хроматиккаа и Перкуссия -Орган -Гитара -Бас -Струнные и Оркестровые -Ансамбль -Медные -Тростник -Труба -Ведущий синтезатор -Ситезатор 2-й голос -Синт-эффекты -Народные -Перкуссия -Звуковые эффекты - -Высокое Q -Слэп -Царапанье (от себя) -Царапанье (к себе) -Барабанные палочки -Электронный метроном -Метроном -Звенящий метроном -Акустический большой барабан -Большой барабан -Удар по ободу -Акустический малый барабан -Хлопок в ладоши -Электрический малый барабан -Низкий напольный томтом -Закрытый хэт -Высокий напольный томтом -Хэт (педалью) -Низкий томтом -Открытый хэт -Низкий средний томтом -Высокий средний томтом -Крэш-тарелка -Высокий томтом -Райд-тарелка -Китайская тарелка -Райд-тарелка (по центральной части) -Бубен -Сплэш-тарелка -Коровий (альпийский) колокольчик -Крэш-тарелка 2 -Вибрирующий слэп -Райд-тарелка 2 -Высокий бонго -Низкий бонго -Закрытый высокий бонго -Открытый высокий бонго -Низкая конга -Высокий тимбал -Низкий тимбал -Высокий агого -Низкий агого -Cabasa Кабаса -Маракас -Короткий свисток -Длинный свисток -Короткое гуиро -Длинное гуиро -Клавес -Высокая коробочка -Низкая коробочка -Закрытая куика -Открытая куика -Закрытый треугольник -Открытый треугольник -Шейкер -Бубенцы -Бунчук -Кастаньеты -Закрытый сурдо -Открытый сурдо \ No newline at end of file diff --git a/res/bin/ru.lang b/res/bin/ru.lang deleted file mode 100644 index 6dde74b..0000000 --- a/res/bin/ru.lang +++ /dev/null @@ -1,103 +0,0 @@ -Новый -Продолжить -О программе -Открыть -Сохранить -Сохранить как -Файл -Настройки -Выход -РМС -Отмена -Сохранить -Ошибка -Ошибка открытия -Список инструментов -Невозможно -Сохранено -Ошибка сохранения -Сохранение -Открытие -Ошибка выбора файла -Ошибка обновления -Ваш телефон не поддерживает необходимые Api -Инструменты -Меню -Назад -Поставить ноту с текущими атрибутами -Для того, чтобы изменить атрибут ноты (напр длину), удалите ноту, если уже поставлена, выберите атрибут (<7>), измените его (<0>,<*>,<#>) и ставьте ноту -Удалить ноту -Откат -Громкость ноты '+'\'-' -Играть с текущей позиции/Стоп -Играть ноту под курсором -Выбрать атрибут ноты -Изменение атрибута -Стоп -Навигация по композиции -Быстрая навигация -Начало выделения -Конец выделения -Копировать -Вставить (раздвинуть) -Вставить (наложить) -Вставить (перезаписать) -Удалить и сдвинуть -Очистить -Играть канал с экрана -Отмена действия -Играть канал -Вернуть дейсвие -Добавить инструмент -Редактировать -Установить инструмент -Удалить инструмент -Темп-бокс -Громкость -Размер -Играть -Играть оригинал -Ok -Назад -Удалить -Выбрать папку -Открытый файл -Пожалуйста, подождите -Обновление списка -Сохранить здесь -Вставить Темп -Удалить Темп -Темп -Время(Мера) -Поиск -Размер -числитель -знаменатель(2 в степени) -Инструменты -Метр = числитель/ (2^знаменатель). Например, используйте 4/4 (numerator=4; denominator=2) или 6/8 (numerator=6; denominator=3) -Дельта-смещение -Воспроизведение -Играть все -Играть с экрана -Весь трэк -Трэк с экрана -Отметить -Конец Отметки -Начало отметки -Снять отметку -Изменение блока -Режим модификации -Копия -Вставить -Раздвинуть -Заменить -Наложить -Очистить буфер -Вернуть -Подсказка -Клавиши -Быстрые Команды -Навигация -Цифрами, иначе джойстиком, при редактировании нот -Иконки, иначе список, в главном меню -**** \ No newline at end of file diff --git a/res/bin/test.mid b/res/bin/test.mid deleted file mode 100644 index d808445..0000000 Binary files a/res/bin/test.mid and /dev/null differ diff --git a/res/lang/about_ua b/res/lang/about_ua new file mode 100644 index 0000000..5bbcd30 --- /dev/null +++ b/res/lang/about_ua @@ -0,0 +1,11 @@ +MidEdit - midi. +: Bingo (http://bing.at.tut.by) +: +Cryingangel (http://midedit.wen.ru) +aNNiMON (http://annimon.com) + +: +Cyber_PUNK - Nokia +maxtr86 - Sony Ericsson +Helion810, Dark_Dancer - - +segOro - \ No newline at end of file diff --git a/res/lang/strings_en.loc b/res/lang/strings_en.loc index 031cba6..4a5d054 100644 --- a/res/lang/strings_en.loc +++ b/res/lang/strings_en.loc @@ -51,7 +51,7 @@ Edit Set instrument Delete instr Tempo box -Volume box +Volume Meter Play Play origin @@ -95,4 +95,8 @@ Name Temp directory New folder Memory -MidEdit \ No newline at end of file +MidEdit +Edit mode +Mark mode +Solo +Channel \ No newline at end of file diff --git a/res/lang/strings_ru.loc b/res/lang/strings_ru.loc index 536de44..473aa5a 100644 --- a/res/lang/strings_ru.loc +++ b/res/lang/strings_ru.loc @@ -7,7 +7,7 @@ Файл Настройки Выход -РМС +RMS Отмена Ошибка Ошибка открытия @@ -45,7 +45,7 @@ Очистить Играть канал с экрана Играть канал -Вернуть дейсвие +Вернуть действие Добавить инструмент Редактировать Установить инструмент @@ -63,8 +63,8 @@ Ok Пожалуйста, подождите Высота ноты Сохранить здесь -Вставить Темп -Удалить Темп +Вставить темп +Удалить темп Темп Время (мера) Позиция @@ -95,4 +95,8 @@ Ok Временная папка Новая папка Память -MidEdit \ No newline at end of file +MidEdit +Редактирование +Выделение +Соло +Канал \ No newline at end of file diff --git a/res/lang/strings_ua.loc b/res/lang/strings_ua.loc new file mode 100644 index 0000000..18754c8 --- /dev/null +++ b/res/lang/strings_ua.loc @@ -0,0 +1,102 @@ +Створити +Продовжити +Про програму +Відкрити +Зберегти +Зберегти як +Файл +Установки +Вихiд +RMS +Відміна +Помилка +Помилка відкриття +Список інструментів +Неможливо +Збережено +Помилка збереження +Збереження +Відкриття +Помилка вибору файлу +Помилка оновлення +Ваш телефон не підтримує необхідні API +Інструменти +Меню +Назад +Поставити ноту з поточними атрибутами +Для того, щоб змінити атрибут ноти (напр довжину), видаліть ноту. Якщо вже поставлена, виберіть атрибут (<7>), змініть його (<0 >,<*>,<#>) і ставте ноту +Видалити ноту +Скасування дії +Гучність ноти '+' \ '-' +Грати з поточної позиції / Стоп +Грати ноту під курсором +Вибрати атрибут ноти +Зміна атрибута +Стоп +Навігація по композиції +Швидка навігація +Початок виділення +Кінець виділення +Копіювати +Вставити (розсунути) +Вставити (накласти) +Вставити (перезаписати) +Видалити і зсунути +Очистити +Грати канал з екрану +Грати канал +Вернути дію +Додати інструмент +Редагувати +Встановити інструмент +Видалити інструмент +Темп-бокс +Гучність +Розмір +Грати +Грати оригінал +Ok +Мова (необхідний рестарт) +Видалити +Мова інструментів +Ширина ноти +Будь ласка, зачекайте +Висота ноти +Зберегти тут +Вставити Темп +Видалити Темп +Темп +Час (міра) +Позиція +Чисельник +Знаменник (2 в ступені) +Метр = чисельник / (2 ^ знаменник). Наприклад, використовуйте 4 / 4 (numerator = 4; denominator = 2) або 6 / 8 (numerator = 6; denominator = 3) +Дельта-зміщення +Відтворення +Грати все +Грати з екрану +Повний трек +Трек з екрану +Відмітити +Зняти відмітку +Редаг. блоку +Режим модифікації +Вставити +Розсунути +Замінити +Накласти +Очистити буфер +Допомога +Клавіші +Швидкі команди +Навігація +Цифрами, інакше джойстиком, при редагуванні нот +Iм'я +Тимчасова папка +Нова папка +Пам'ять +MidEdit +Редагування +Виділення +Соло +Канал \ No newline at end of file diff --git a/src/main/Key.java b/src/main/Key.java index 15ab0c3..02d9c5d 100644 --- a/src/main/Key.java +++ b/src/main/Key.java @@ -76,9 +76,7 @@ public class Key { Call = -10; //Motorola V300, V500, V525 leftSoftKey = 21;rightSoftKey = 22; Platform = "Motorola"; - } catch (Throwable t2) { // com.motorola.io.FileConnection - // - } + } catch (Throwable t2) {} } } } diff --git a/src/main/L.java b/src/main/L.java index 577e707..ea6f486 100644 --- a/src/main/L.java +++ b/src/main/L.java @@ -65,7 +65,7 @@ public class L { setInstrument = 50, delInstrument = 51, tempoBox = 52, - volumeBox = 53, + volume = 53, meter = 54, play = 55, playOrigin = 56, @@ -109,7 +109,11 @@ public class L { tempDir = 94, newFolder = 95, memory = 96, - midedit = 97; + midedit = 97, + editMode = 98, + markMode = 99, + solo = 100, + channel = 101; /** */ diff --git a/src/main/Main.java b/src/main/Main.java index ca88854..ca674da 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -50,18 +50,6 @@ public class Main extends MIDlet { notifyDestroyed(); } - /** - * - * @param text - * @param appearanceMode - * @return - */ - public static Item createStringItem(String text, int appearanceMode) { - StringItem strItem = new StringItem(null, text, appearanceMode); - strItem.setFont(P.smPlain); - return strItem; - } - public MixerModel getModel() { return model; } diff --git a/src/main/text.txt b/src/main/text.txt index 616a3c6..180109d 100644 --- a/src/main/text.txt +++ b/src/main/text.txt @@ -3,11 +3,15 @@ MIDedit 2.1 / 3.0 JEim7 (http://seclub.org/user/nid.php?nid=972825), MidEdit 2.0.5 (http://sunet.dl.sourceforge.net/project/midedit/MideditProject.tgz) . : - .mid, .MID - - . + - . . - . . - , , . . - . - ( ) . + - . + - , . + - , . + - - , . ******** . @@ -15,8 +19,5 @@ Help ******** /, . -- , . . , . - - ++++ - . , , . \ No newline at end of file + . , , , . . \ No newline at end of file diff --git a/src/midedit/AbstractListener.java b/src/midedit/AbstractListener.java index 2992663..04790cc 100644 --- a/src/midedit/AbstractListener.java +++ b/src/midedit/AbstractListener.java @@ -1,14 +1,14 @@ package midedit; /** - * + * * @author user */ public interface AbstractListener { /** - * - * @param itemNum + * + * @param itemNum */ public void actionPerformed(int itemNum); } diff --git a/src/midedit/CompositionForm.java b/src/midedit/CompositionForm.java index d84828e..bb14ccc 100644 --- a/src/midedit/CompositionForm.java +++ b/src/midedit/CompositionForm.java @@ -90,7 +90,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable, private Command setInstrument = new Command(L.str[L.setInstrument], Command.ITEM, 3); private Command delInstrument = new Command(L.str[L.delInstrument], Command.ITEM, 4); private Command temp = new Command(L.str[L.tempoBox], Command.ITEM, 5); - private Command volume = new Command(L.str[L.volumeBox], Command.ITEM, 6); + private Command volume = new Command(L.str[L.volume], Command.ITEM, 6); private Command meter = new Command(L.str[L.meter], Command.ITEM, 7); /** @@ -172,7 +172,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable, } /** - * + * */ public void releaseMem() { if (composition != null) { @@ -392,7 +392,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable, textBoxTemp.append(nomField); final TextField denomField = new TextField(L.str[L.denominator], "" + composition.getDenomE(), 1, TextField.NUMERIC); textBoxTemp.append(denomField); - textBoxTemp.append(Main.createStringItem(L.str[L.meterInfo], 2)); + textBoxTemp.append(createStringItem(L.str[L.meterInfo], 2)); textBoxTemp.addCommand(CompositionForm.ok); textBoxTemp.addCommand(P.comCancel); textBoxTemp.setCommandListener(new CommandListener() { @@ -412,6 +412,18 @@ public class CompositionForm extends Form implements CommandListener, Runnable, control.comBack(); } } + + /** + * + * @param text + * @param appearanceMode + * @return + */ + private Item createStringItem(String text, int appearanceMode) { + StringItem strItem = new StringItem(null, text, appearanceMode); + strItem.setFont(P.smPlain); + return strItem; + } /** * diff --git a/src/midedit/Constants.java b/src/midedit/Constants.java index 0550f9f..4850bf2 100644 --- a/src/midedit/Constants.java +++ b/src/midedit/Constants.java @@ -3,10 +3,8 @@ package midedit; import java.util.Vector; import main.L; -//import java.util.*; -//import java.lang.*; /** - * + * * @author user */ public class Constants { @@ -18,21 +16,10 @@ public class Constants { public static void setTimeConst(int t) { timeConst = t; } - /** - * - * @return - */ -// public static String getInstruments(int i){ -// return (String); -// } /** * */ public static final int INV_CANVAS_CONST = 131; - /** - * - */ - public static final char FILE_DELIM = '/'; /** * */ @@ -55,8 +42,6 @@ public class Constants { * */ public static final int MAX_NOTE_LENGTH = 8; // min == 1/(2^5) - - static VectorArr instrVectorArr = new VectorArr(L.instr, 1, 128); static class VectorArr extends Vector { diff --git a/src/midedit/MidiFile.java b/src/midedit/MidiFile.java index c5fd350..85edbce 100644 --- a/src/midedit/MidiFile.java +++ b/src/midedit/MidiFile.java @@ -4,22 +4,17 @@ import midedit.media.Composition; import midedit.io.AbstractFile; import java.io.*; import main.P; -//import com.siemens.mp.io.File; public class MidiFile implements Waitable { private String outStr; private String url; -// private static File file = null; private static AbstractFile file = null; - //private MixerModel mod; private int seekPos = 0; private int seekLen = 1; private int maxTime = 0; private boolean cancelStatus; -// private final int size = 49; - private final static int sizeMax/*=200000;*/ = 15000; - //private static int temp = 0x123456; + private final static int sizeMax = 15000; private static byte[] MTHD = {0x4D, 0x54, 0x68, 0x64}; private static byte[] MTRK = {0x4d, 0x54, 0x72, 0x6b}; private static byte[] ENDTrk = {0x00, -0x01, 0x2f, 0x00}; @@ -32,20 +27,10 @@ public class MidiFile implements Waitable { 0, -112, 46, 1, 8, -103/*0x90*/, 46/*note height*/, 127,//55 127, -112/*0x80*/, 46, 1, 16, -112, 46/*note height*/, 1,//63 0, -1, 47, 0,}; - //{0x4D,0x54,0x68,0x64,0x0,0x0,0x0,0x6,0x0,0x0,0x0,0x1,0x0,0x60, - //0x4d,0x54,0x72,0x6b,0x0,0x0,0x0,0x26/*length*/,0x0,0xff,0x58,0x04,0x04,0x02,0x18,0x08, - //0x0,0xff,0x51,0x03, /*temp->*/0x21,0xf2,0xf3,/*<-*/ - ///*37>*/0x00,0xc0,0x1a, /*40>*/0x00,0x90,0x2e,0x01, - //0x08,0x99,0x2e,0x7f, 0x7f,0x90,0x2e,0x01, - //0x10,0x90,0x2e,0x01, 0x00,0xff,0x2f,0x00}; private static byte[] bufTmp = new byte[16]; private static int intTmp; private static byte[] bMidi = new byte[sizeMax]; - //public static void setTemp(int noteTime) - //{ temp = noteTime; } - //public static int getTemp() - //{ return temp; } public MidiFile(AbstractFile aFile) { file = aFile; } @@ -64,9 +49,7 @@ public class MidiFile implements Waitable { newarr = new byte[nextLen]; System.arraycopy(bMidi, 0, newarr, 0, bMidi.length); bMidi = newarr; - //System.out.println("bMidi.length="+bMidi.length); } catch (Throwable e) { - //System.out.println(""+e); return false; } return true; @@ -74,7 +57,6 @@ public class MidiFile implements Waitable { public void setFile() { file = P.isRMSMode ? MixerModel.rmsFile : MixerModel.jsr75File; - } public String writeMix(Composition c, int t, boolean forPlay) throws Exception { @@ -85,16 +67,11 @@ public class MidiFile implements Waitable { return writeMixWithName(c, tBeg, forPlay, name, -1, -1); } - //public String writeMixWithName(Composition c,int tBeg, boolean forPlay, String name,int channel)throws Exception{ - //return writeMixWithName(c,tBeg,forPlay,name,channel, -1); - //} public String writeMixWithName(Composition c, int tBeg, boolean forPlay, String name, int channel, int instrument) throws Exception { System.gc(); outStr = name; - //byte[] tnote; int iMidi; // index of b - int i;//,ind; - //Note note; + int i; iMidi = 0; //// begin header ------------------------- @@ -194,7 +171,7 @@ public class MidiFile implements Waitable { file.close(df); return file.getAns(); } catch (IOException e) { - //throw new Exception("IO:writeMixWithName()\n"+e.toString()+"\noutStr="+outStr); + //throw new Exception("IO:writeMixWithName()\noteLine"+e.toString()+"\noutStr="+outStr); throw new Exception("Can't write " + outStr); } finally { //file.close(df); @@ -227,13 +204,13 @@ public class MidiFile implements Waitable { ind += 3; } - //NoteList notes = c.getNoteListByChannel(ch); + //NoteList notes = noteChannel.getNoteListByChannel(ch); /// print notes byte[] volumeExpArr = c.getVolumeExpArr(); - //int iMax = bMidi.length - 200; + //int iMax = bMidi.noteLength - 200; /* seekLen = mix.getLen()+1; seekPos = 1; cancelStatus = false;*/ @@ -317,15 +294,15 @@ public class MidiFile implements Waitable { } else // simple Note { - bMidi[ind] = (byte) (note.c | ((note.v == 0) ? (byte) 0x80 : (byte) 0x90)); + bMidi[ind] = (byte) (note.noteChannel | ((note.noteVolume == 0) ? (byte) 0x80 : (byte) 0x90)); //bMidi[iMidi]=(byte)0x99; // 0x99 -- Note On - bMidi[ind + 1] = note.n; - //bMidi[iMidi+2]=note.v; edit 08.07.2004 - if ((note.v & 0x80) != 0) { - note.v = 0x7f; + bMidi[ind + 1] = note.noteLine; + //bMidi[iMidi+2]=note.noteVolume; edit 08.07.2004 + if ((note.noteVolume & 0x80) != 0) { + note.noteVolume = 0x7f; } - vol = note.v + kVol * (volumeExpArr[note.c] - c.channelVolExpMax / 2); //*( 1<<(volumeExpArr[note.c]/2))/0x10000; + vol = note.noteVolume + kVol * (volumeExpArr[note.noteChannel] - c.channelVolExpMax / 2); //*( 1<<(volumeExpArr[note.noteChannel]/2))/0x10000; if (vol > 127) { vol = 127; } else if (vol < 0) { @@ -374,22 +351,10 @@ public class MidiFile implements Waitable { return /*numBytesToWrite*/; } - public byte[] writeNote(byte instr, byte nn)//+ - { -// outStr = ""+nn+".mid"; - //outStr = "note.mid"; - // mod.msg("length dat ."+dat.length+" "); - //byte[] b = new byte[dat4PlayNote.length]; - //for(int i=0; i"); + } catch (IOException e) { throw new Exception("Can't read:\n" + e.getMessage()); } finally { file.close(df); seekPos = seekLen; } - // mod.msgAll("mix.add ok"); -// Composition c = new Composition(mix); return composition; } private int readTimeDelta(int df) throws IOException { int timeDelta = 0; - //int i=0; byte[] buf = new byte[1]; do { file.read(df, buf, 0, 1); timeDelta = (timeDelta << 7) + (buf[0] & (byte) 0x7f); - //i++; seekPos++; } while ((buf[0] & (byte) 0x80) != 0); @@ -674,7 +595,6 @@ public class MidiFile implements Waitable { } private int readInt(int df, int len) throws IOException { - // byte[] buf = new byte[1]; int t = 0; int i; for (i = 0; i < len; ++i) { @@ -686,12 +606,6 @@ public class MidiFile implements Waitable { } private void skip(int df, int n) throws IOException { - /* if(n>0) - { - byte[] buf = new byte[n]; - file.read(df, bufTmp,0,n); - seekPos += n; - }*/ while (n > 0) { intTmp = (n > bufTmp.length) ? bufTmp.length : n; file.read(df, bufTmp, 0, intTmp); diff --git a/src/midedit/MixerCanvas.java b/src/midedit/MixerCanvas.java index a5bdabe..69d0d2d 100644 --- a/src/midedit/MixerCanvas.java +++ b/src/midedit/MixerCanvas.java @@ -4,6 +4,7 @@ import midedit.media.Composition; import java.util.*; import java.io.*; import javax.microedition.lcdui.*; +import main.Key; import main.L; import main.P; import main.Main; @@ -33,12 +34,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable { private final Runnable playingRunnable = new Runnable() { public void run() { - //System.out.println("getTimeToCanvasConct() = " + composition.getTime2CanvasConst()); - //System.out.println("Thread.currentThread = " + Thread.currentThread()); while (CompositionForm.isPlaying) { try { doSmallRight(); - Thread.sleep(31); + Thread.sleep(52);//31); } catch (InterruptedException ex) { System.out.println("ex = " + ex); } @@ -49,11 +48,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable { /** * * @param ctrl - * @param c + * @param c * @param ch */ public MixerCanvas(Main ctrl, Composition c, int ch) { - //if (Main.IS_MIDP2) setFullScreenMode(true); control = ctrl; composition = c; @@ -71,8 +69,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { runningStatus = true; options = new Options(); status = new Status(); - frameCount = 0; - viewModeDesc("Edit Mode"); + viewModeDesc(L.str[L.editMode]); display.callSerially(this); } @@ -85,7 +82,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { /** * - * @param n + * @param n * @return */ abstract protected byte getLineFromNote(int n); @@ -108,7 +105,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { doKEY_NUM5(); needPaint = true; needPaintStatus = true; - return/*break*/; + return; } else if (ga == LEFT || keyCodePressed == KEY_NUM4) { if (isNumsControl ^ (keyCodePressed == KEY_NUM4)) { doBigLeft(); @@ -142,27 +139,38 @@ public abstract class MixerCanvas extends Canvas implements Runnable { status.resetTimeTune(); return; } - - switch (keyCodePressed) { + if(keyCodePressed == KEY_NUM7 || keyCodePressed == Key.Call) { + status.nextView(); + needPaintStatus = true; + } else if(keyCodePressed == KEY_NUM9 || keyCodePressed == Key.Clear) { + doKEY_NUM9(); + needPaint = true; + needPaintStatus = true; + } if(keyCodePressed == Key.leftSoftKey) { + isOptionsView = true; + options.resetMenu(); + } if(keyCodePressed == Key.rightSoftKey) { + Main.midlet.compositionForm.setComposForm(); + } if(keyCodePressed == Key.Back) { + composition.getUndoableAction().undo(); + needPaintStatus = true; + needPaint = true; + + } if(keyCodePressed == Key.VolPlus) { + status.volumePlus(); + needPaintStatus = true; + } if(keyCodePressed == Key.VolMinus) { + status.volumeMinus(); + needPaintStatus = true; + } else switch (keyCodePressed) { case KEY_NUM1: playFromCurrentPosition(); break; case KEY_NUM3: - model.playNote((byte) ((channel == Constants.DRUMS_CHANNEL) ? -10 : composition.getInstrument(channel)), - (byte) getNoteFromLine(curY)); - break; - - case KEY_NUM7: - case -10: - case -4: - status.nextView(); - needPaintStatus = true; - break; - case KEY_NUM9: - case -8: - doKEY_NUM9(); - needPaint = true; - needPaintStatus = true; + model.playNote( + (byte) ((channel == Constants.DRUMS_CHANNEL) ? -10 : composition.getInstrument(channel)), + (byte) getNoteFromLine(curY) + ); break; case KEY_NUM0: status.action(); @@ -176,32 +184,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable { status.curParamPlus(); needPaintStatus = true; break; - case -6: - case -1: - isOptionsView = true; - options.resetMenu(); - break; - case -7: - case -12: - Main.midlet.compositionForm.setComposForm(); - break; - case -11: - composition.getUndoableAction().undo(); - needPaintStatus = true; - needPaint = true; - break; - case -36: - status.volumePlus(); - needPaintStatus = true; - break; - case -37: - status.volumeMinus(); - needPaintStatus = true; - break; - default: - isOptionsView = true; - options.resetMenu(); - break; } } @@ -220,9 +202,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { needPaintStatus = true; } } - - ; - + private void doSmallRight() { if (curX < nW - 1) { curX++; @@ -234,8 +214,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable { } } - ; - private void doSmallUp() { if (curY > 0) { curY--; @@ -246,8 +224,33 @@ public abstract class MixerCanvas extends Canvas implements Runnable { needPaintStatus = true; } } - - ; + + protected void pointerPressed(int x, int y) { + if(isOptionsView) { + options.pointerPressed(x, y); + return; + } + boolean needDoKey5 = true; + curX = ( (x - wBeg) / wOne); + if(curX >= (nW - nW / 3)) { + curX -= 2*wStep; + xBase += 2*wStep; + needDoKey5 = false; + } else if(curX < wBeg) { + curX += 2*wStep; + xBase -= 2*wStep; + needDoKey5 = false; + } + curY = ( (y - hBeg) / hOne); + if(needDoKey5) doKEY_NUM5(); + needPaint = true; + needPaintStatus = true; + } + + protected void pointerDragged(int x, int y) { + isOptionsView = true; + options.resetMenu(); + } protected void doSmallDown() { if (curY < nH - 1) { @@ -260,8 +263,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable { } } - ; - private void doBigLeft() { wStepMeasure = (composition.getNom() * (32 >> composition.getDenomE())); if (xBase >= wStepMeasure) { @@ -271,8 +272,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable { } } - ; - private void doBigRight() { wStepMeasure = (composition.getNom() * (32 >> composition.getDenomE())); xBase += wStepMeasure; @@ -280,8 +279,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable { needPaintStatus = true; } - ; - private void doBigUp() { if (curY >= hStep) { curY -= hStep; @@ -333,13 +330,13 @@ public abstract class MixerCanvas extends Canvas implements Runnable { } else if (isMarkMode) { if (curNote != null) { - if (curNote.length > 0) { + if (curNote.noteLength > 0) { Note noteTmp; for (noteTmp = curNote.next; noteTmp != null - && (noteTmp.c != curNote.c || noteTmp.n != curNote.n || noteTmp.v != 0); + && (noteTmp.noteChannel != curNote.noteChannel || noteTmp.noteLine != curNote.noteLine || noteTmp.noteVolume != 0); noteTmp = noteTmp.next); - if (noteTmp != null && noteTmp.c == note.c && noteTmp.n == note.n) { + if (noteTmp != null && noteTmp.noteChannel == note.noteChannel && noteTmp.noteLine == note.noteLine) { noteTmp.mark = (byte) (1 - curNote.mark); } } @@ -367,7 +364,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { } if (curNote != null) { - composition.delNote(curNote.noteTime, curNote.c, curNote.n, curNote.v); + composition.delNote(curNote.noteTime, curNote.noteChannel, curNote.noteLine, curNote.noteVolume); } else { composition.delNote(getCurTime(), (byte) channel, (byte) getNoteFromLine(curY), (byte) 127); } @@ -396,11 +393,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { */ protected void keyReleased(int keyCode) { if (keyPressedCount > 0) { - int gameAction = 0; - try { - gameAction = getGameAction(keyCodePressed); - } catch (IllegalArgumentException illegArg) { - } + int gameAction = getGameAction(keyCodePressed); if (keyCodePressed == KEY_NUM4 || keyCodePressed == KEY_NUM6 || keyCodePressed == KEY_NUM2 || keyCodePressed == KEY_NUM8 || keyCodePressed == KEY_POUND || keyCodePressed == KEY_STAR @@ -526,9 +519,9 @@ public abstract class MixerCanvas extends Canvas implements Runnable { g.setGrayScale(0); for (note = composition.getFirstNote(tBeg, channel); note != null && note.noteTime <= tMax; note = note.next) { - if (note.c == channel && note.v != 0) { - if (note.noteTime <= curTimePlus && note.n == curN - && (curTime < note.noteTime + (note.length == 0 ? 1 : note.length))) { + if (note.noteChannel == channel && note.noteVolume != 0) { + if (note.noteTime <= curTimePlus && note.noteLine == curN + && (curTime < note.noteTime + (note.noteLength == 0 ? 1 : note.noteLength))) { curNote = note; if (!isMarkMode) { g.setColor(150, 0, 0); @@ -544,7 +537,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { paintNote(g, note, 0, 0); g.setColor(0); } else { - int col = (256 - note.v); + int col = (256 - note.noteVolume); g.setColor(col, 0, 140); paintNote(g, note, 0, 0); } @@ -560,7 +553,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { for (note = composition.getUndoableAction().getDeletedList().getFirst(); note != null; note = note.next) { - if (note.c == channel && note.v != 0) { + if (note.noteChannel == channel && note.noteVolume != 0) { g.setColor(128, 0, 0); paintNote(g, note, shiftTime, shiftNote); g.setColor(0); @@ -628,7 +621,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { */ protected void paintNote(Graphics g, Note note, int shiftTime, int shiftNote) { xt = getXInPixel(note.noteTime + shiftTime); - yt = getLineFromNote(note.n + shiftNote); + yt = getLineFromNote(note.noteLine + shiftNote); if (xt >= 0 && xt < rollWidth) { if (yt < 0) { yt = -1; @@ -716,17 +709,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable { try { if (runningStatus) { repaint(); - frameCount++; - if (frameCount % 200 == 0) { -// str = " "; - System.gc(); - } Thread.sleep(10); display.callSerially(this); - } } catch (Exception e) { -// errStr = "" + e + "\n"; } } @@ -749,7 +735,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { /** * - * @param noteTime + * @param t * @return */ protected int getXInPixel(int t) { @@ -769,7 +755,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { * @return */ protected byte getCurVol() { - return (byte) status.getVolTune(); + return status.getVolTune(); } /** @@ -808,7 +794,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { isMarkMode = true; model.getBuffer().copy2Buffer(composition, (byte) channel, timeMarkBeg, timeMarkEnd, true); - viewModeDesc("Mark Mode"); + viewModeDesc(L.str[L.markMode]); } note = composition.getFirstNote(timeMarkEnd, channel); } @@ -821,7 +807,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { isMarkMode = false; timeMarkBeg = NOT_MARKED; timeMarkEnd = NOT_MARKED; - viewModeDesc("Edit Mode"); + viewModeDesc(L.str[L.editMode]); } private void viewModeDesc(String desc) { @@ -863,9 +849,8 @@ public abstract class MixerCanvas extends Canvas implements Runnable { private int keyPressedCount, curYPrev, curXPrev, - wStep = 5, + wStep = wOne,//5, wStepMeasure = 32, - frameCount, xt, yt, dx, dy, tBeg, tMax, @@ -1176,16 +1161,16 @@ public abstract class MixerCanvas extends Canvas implements Runnable { m3 = 75; m4 = 100; PrintSmallFont.print(g, note.noteTime * 100 / tick, 2, m1 - xIndent, yIndent, color); - PrintSmallFont.print(g, note.length * 1000 / tick, 3, m2 - xIndent, yIndent, color); + PrintSmallFont.print(g, note.noteLength * 1000 / tick, 3, m2 - xIndent, yIndent, color); if (MixerCanvas.this instanceof NotesCanvas) { - PrintSmallFont.printNote(g, note.n % 12, m3 - xIndent, yIndent, color); - PrintSmallFont.print(g, note.n / 12, 0, m3 - xIndent - 12, yIndent, color); + PrintSmallFont.printNote(g, note.noteLine % 12, m3 - xIndent, yIndent, color); + PrintSmallFont.print(g, note.noteLine / 12, 0, m3 - xIndent - 12, yIndent, color); } else { - PrintSmallFont.print(g, note.n, 0, m3 - xIndent - 12, yIndent, color); + PrintSmallFont.print(g, note.noteLine, 0, m3 - xIndent - 12, yIndent, color); } - PrintSmallFont.print(g, note.v, 0, m4 - xIndent, yIndent, color); + PrintSmallFont.print(g, note.noteVolume, 0, m4 - xIndent, yIndent, color); break; case 0: @@ -1230,10 +1215,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable { } } - PrintSmallFont.print(g, note.length * meterNom / tick, 0, m2, yIndent, color); + PrintSmallFont.print(g, note.noteLength * meterNom / tick, 0, m2, yIndent, color); g.drawLine(m2 + 1, yIndent - 4, m2 + 1, yIndent - 4); g.drawLine(m2 + 1, yIndent - 2, m2 + 1, yIndent - 2); - PrintSmallFont.print(g, note.length % mod, 0, m3, yIndent, color); + PrintSmallFont.print(g, note.noteLength % mod, 0, m3, yIndent, color); PrintSmallFont.print(g, mod, 0, m4, yIndent, color); break; @@ -1241,10 +1226,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable { if (MixerCanvas.this instanceof NotesCanvas) { m3 = 50; m4 = 75; - PrintSmallFont.printNote(g, note.n % 12, m3 - xIndent, yIndent, color); - PrintSmallFont.print(g, note.n / 12, 0, m3 - xIndent - 12, yIndent, color); + PrintSmallFont.printNote(g, note.noteLine % 12, m3 - xIndent, yIndent, color); + PrintSmallFont.print(g, note.noteLine / 12, 0, m3 - xIndent - 12, yIndent, color); - PrintSmallFont.print(g, note.n, 0, m4 - xIndent - 12, yIndent, color); + PrintSmallFont.print(g, note.noteLine, 0, m4 - xIndent - 12, yIndent, color); } else if (MixerCanvas.this instanceof DrumsCanvas) { m1 = 2; g.setFont(P.smPlain); @@ -1260,7 +1245,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { g.drawString(L.str[L.delta], m4 - 18, yIndent + 3, Graphics.BOTTOM | Graphics.RIGHT); } - PrintSmallFont.print(g, note.v, 0, m4 - xIndent, yIndent, color); + PrintSmallFont.print(g, note.noteVolume, 0, m4 - xIndent, yIndent, color); break; } @@ -1488,6 +1473,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable { protected void paint(Graphics g) { menu.paint(g); } + + protected void pointerPressed(int x, int y) { + menu.pointerPressed(x, y); + } private boolean processCommand(int keyCode) { switch (keyCode) { @@ -1545,36 +1534,40 @@ public abstract class MixerCanvas extends Canvas implements Runnable { composition.getUndoableAction().redo(); break; case -10: - if (menu.getPrevMenu() != null) { - menu = menu.getPrevMenu(); - return false; - } + break; default: - int dir = 0; - try { - dir = getGameAction(keyCode); - } catch (IllegalArgumentException illegArg) { - } - switch (dir) { - case Canvas.UP: - menu.up(); + if(keyCode == Key.Call) { + if (menu.getPrevMenu() != null) { + menu = menu.getPrevMenu(); return false; - case Canvas.DOWN: - menu.down(); - return false; - case Canvas.RIGHT: - case Canvas.FIRE: - return menu.actionPerformed(); - case Canvas.LEFT: - case 0: - if (menu.getPrevMenu() != null) { - menu = menu.getPrevMenu(); + } + } else { + int dir = 0; + try { + dir = getGameAction(keyCode); + } catch (IllegalArgumentException illegArg) { + } + switch (dir) { + case Canvas.UP: + menu.up(); return false; - } - break; - default: - return false; + case Canvas.DOWN: + menu.down(); + return false; + case Canvas.RIGHT: + case Canvas.FIRE: + return menu.actionPerformed(); + case Canvas.LEFT: + case 0: + if (menu.getPrevMenu() != null) { + menu = menu.getPrevMenu(); + return false; + } + break; + default: + return false; + } } } return true; @@ -1589,10 +1582,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable { setNeedPaint(); display.callSerially(MixerCanvas.this); } -// private int optXbeg = 8; -// private int optYbeg = 4; -// private int optWidth = (screenWidth - 2 * optXbeg); -// private int optHeight = (screenHeight - 2 * optYbeg); /** * @@ -1629,10 +1618,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable { private void addItem(MenuItem item) { items.addElement(item); - - // - int itemWidth = P.medBold.stringWidth(item.getName())+2; - if(itemWidth > w) w = itemWidth; numLines = hMax / LINE_HEIGHT; if (numLines >= items.size()) { @@ -1667,8 +1652,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable { g.fillRect(0, 0, w, hMax); g.setClip(1, 1, w - 1, hMax - 1); MenuItem item; - int i; - for (i = 0; i < numLinesMaxVisible; i++) { + for (int i = 0; i < numLinesMaxVisible; i++) { if (i == curLine) { g.setColor(160, 160, 224); @@ -1704,6 +1688,27 @@ public abstract class MixerCanvas extends Canvas implements Runnable { } } + + private long time = System.currentTimeMillis(); + + protected void pointerPressed(int x, int y) { + x -= this.x; + y -= this.y; + + if(x > w) { + isOptionsView = false; + return; + } + curLine = y / LINE_HEIGHT; + if(curLine >= items.size()) curLine = items.size() - 1; + else if(curLine < 0) curLine = 0; + + if(System.currentTimeMillis() - time > 800) { + actionPerformed(); + } + time = System.currentTimeMillis(); + setNeedPaint(); + } public boolean actionPerformed() { MenuItem item = (MenuItem) items.elementAt(lineBase + curLine); diff --git a/src/midedit/MixerModel.java b/src/midedit/MixerModel.java index afde83c..125c947 100644 --- a/src/midedit/MixerModel.java +++ b/src/midedit/MixerModel.java @@ -1,6 +1,5 @@ package midedit; -//import java.io.IOException; import midedit.media.Composition; import midedit.media.AbstractPlayer; import midedit.media.JSR135Player; @@ -24,9 +23,8 @@ public class MixerModel extends Thread { */ public final Display display = Main.dsp; private NoteListUtils buffer; - static AbstractFile rmsFile = new RMSFile(), - //localFile,//=rmsFile, - jsr75File;//=rmsFile;// = new JSR75File(); + static AbstractFile rmsFile = new RMSFile(); + static AbstractFile jsr75File; public AbstractPlayer crossPlayer = null; public MixerModel() { diff --git a/src/midedit/Note.java b/src/midedit/Note.java index c0b05b0..3a92ff4 100644 --- a/src/midedit/Note.java +++ b/src/midedit/Note.java @@ -6,25 +6,38 @@ package midedit; */ public class Note { + /** */ + public Note next = null; + /** */ + public Note prev = null; - public byte c, n, v, mark; - public int noteTime, length; - public Note next = null, prev = null; + /** () */ + public int noteTime; + /** */ + public int noteLength; + /** */ + public byte noteChannel; + /** */ + public byte noteLine; + /** */ + public byte noteVolume; + /** */ + public byte mark; /** - * - * @param time - * @param ch - * @param nn - * @param vv - * @param ll + * + * @param time () + * @param channel + * @param line + * @param volume + * @param length */ - public Note(int time, byte ch, byte nn, byte vv, int ll) { - this.noteTime = time; - c = ch; - n = nn; - v = vv; - length = ll; + public Note(int time, byte channel, byte line, byte volume, int length) { + noteTime = time; + noteChannel = channel; + noteLine = line; + noteVolume = volume; + noteLength = length; mark = NoteListUtils.NOTE_NOT_MARKED; } -} +} \ No newline at end of file diff --git a/src/midedit/NoteList.java b/src/midedit/NoteList.java index db64849..b9045d5 100644 --- a/src/midedit/NoteList.java +++ b/src/midedit/NoteList.java @@ -1,304 +1,283 @@ package midedit; - - /** * * @author user */ -public class NoteList -{ - private Note note=null,noteBeg=null; - private Note noteTmp; - private Note noteNew; - private int len=0; - private int timeLastDelOn = -1; - private int timeNoteOff; - private int t; - /** - * - */ - public static final int CHANNEL_LONG_NOTE = -2; +public class NoteList { - /** - * - */ - public NoteList() - {} + private Note note = null, noteBeg = null; + private Note noteTmp; + private Note noteNew; + private int len = 0; + private int timeLastDelOn = -1; + private int timeNoteOff; + private int t; + /** + * + */ + public static final int CHANNEL_LONG_NOTE = -2; - /** - * - * @param noteExist - * @return - */ - public Note add(Note noteExist) - { - if(noteExist==null) - return null; - t = noteExist.noteTime; - len++; - if(noteBeg == null) - noteBeg = note = noteExist; - else - { - noteNew = noteExist; - if(note == null) - note = noteBeg; - if(note.noteTime != t) - { if(t < note.noteTime) - { - for(noteTmp = note; - noteTmp != null && t < noteTmp.noteTime; - noteTmp = noteTmp.prev) - ; - if(noteTmp == null) - { - addInto(null,noteNew,noteBeg); - return noteNew; - } - note = noteTmp; - } - else - { for(noteTmp = note; - noteTmp.next != null && (noteTmp.next.noteTime < t ) ; - noteTmp = noteTmp.next) - ; - note = noteTmp; - } - } - if(noteExist.v!=0) - { - for( ; note.next != null && t == note.next.noteTime ; note = note.next ) - ; - } - else - { - for( ; note.prev != null && t == note.noteTime ; note = note.prev ) - ; - } + /** + * + * @param noteExist + * @return + */ + public Note add(Note noteExist) { + if (noteExist == null) { + return null; + } + t = noteExist.noteTime; + len++; + if (noteBeg == null) { + noteBeg = note = noteExist; + } else { + noteNew = noteExist; + if (note == null) { + note = noteBeg; + } + if (note.noteTime != t) { + if (t < note.noteTime) { + for (noteTmp = note; + noteTmp != null && t < noteTmp.noteTime; + noteTmp = noteTmp.prev); + if (noteTmp == null) { + addInto(null, noteNew, noteBeg); + return noteNew; + } + note = noteTmp; + } else { + for (noteTmp = note; + noteTmp.next != null && (noteTmp.next.noteTime < t); + noteTmp = noteTmp.next); + note = noteTmp; + } + } + if (noteExist.noteVolume != 0) { + for (; note.next != null && t == note.next.noteTime; note = note.next); + } else { + for (; note.prev != null && t == note.noteTime; note = note.prev); + } - addInto(note, noteNew, note.next); - note = noteNew; - } - return note; - } - private void addInto(Note n1, Note note, Note n2) - { - note.next = n2; - if(n2 != null) - n2.prev = note; - note.prev = n1; - if(n1 != null) - n1.next = note; - else - noteBeg = note; - } - - /** - * - * @param noteTime - * @param c - * @param n - * @param v - */ - public void delOne(int t, byte c, byte n, byte v) - { - for(note = searchNoteByTime(t); note != null && note.noteTime <= t; note = note.next) - if(t==note.noteTime && c == note.c && n == note.n && (v!=0 ^ note.v==0)) - { - if (note.next != null) - note.next.prev = note.prev; - if (note.prev != null) - note.prev.next = note.next; - else - noteBeg = note.next; - - note = (note.next != null)? note.next : note.prev; - len--; - return; - } - } - /** - * - * @param delNote - */ - public void delOne(Note delNote) - { - for(note = getFirst(); note != null && note.noteTime <= t; note = note.next) - if(note == delNote) - { - if (note.next != null) - note.next.prev = note.prev; - if (note.prev != null) - note.prev.next = note.next; - else - noteBeg = note.next; - - note = (note.next != null)? note.next : note.prev; - len--; - return; - } - } - /** - * - * @param undo - */ - public void delSelected(UndoableAction undo) - { - for(note = getFirst(); note != null; note = note.next) - if(note.mark == NoteListUtils.NOTE_MARKED) - { - if (note.next != null) - note.next.prev = note.prev; - if (note.prev != null) - note.prev.next = note.next; - else - noteBeg = note.next; - - if(undo!=null && note.v!=0) - { - undo.log2DelNoteList(note.noteTime,note.c,note.n,note.v,note.length); + addInto(note, noteNew, note.next); + note = noteNew; + } + return note; } - len--; - } - } - /** - * - * @param noteTime - * @param tMax - * @param c - * @param n - * @param v - * @param undo - * @return - */ - public int del(int t,int tMax, byte c, byte n, byte v,UndoableAction undo) - { - if(t == tMax) - tMax++; - int tOffMax = tMax; - boolean isdel=false; - timeNoteOff = -1; - - for(note = searchNoteByTime(t); note != null && note.noteTime <= tMax; note = note.next) - if ( (note.c == c || c == (byte)-1) && - (note.noteTime > t || v!=0 && note.noteTime == t) && - (note.noteTime < tMax || v==0 && note.noteTime == tMax) && - (note.n == n || n == (byte)-1) && - ( (v != 0 && (note.v != 0 || note.noteTime - note.length >= t)) || - (v == 0 && (note.v == 0 && timeLastDelOn <= note.noteTime-note.length && note.noteTime-note.length < t )))) - { - if(note.next != null) - note.next.prev = note.prev; - if(note.prev != null) - note.prev.next = note.next; - else - noteBeg = note.next; - - len--; - if( v != 0) - { - if(tOffMax < note.noteTime+note.length) - tOffMax = note.noteTime+note.length; - if(undo!=null && note.v!=0) - { - undo.log2DelNoteList(note.noteTime,note.c,note.n,note.v,note.length); - } + private void addInto(Note n1, Note note, Note n2) { + note.next = n2; + if (n2 != null) { + n2.prev = note; + } + note.prev = n1; + if (n1 != null) { + n1.next = note; + } else { + noteBeg = note; + } } - if(note.v==0) - timeNoteOff = note.noteTime; - isdel = true; - } - if(v!=0 && tOffMax>tMax) - { - timeLastDelOn = t; - del(tMax, tOffMax, c, n, (byte) 0,null); - } - else - timeLastDelOn = -1; - if(isdel == false) - return -2; - return timeNoteOff; - } + /** + * + * @param noteTime + * @param noteChannel + * @param noteLine + * @param noteVolume + */ + public void delOne(int noteTime, byte noteChannel, byte noteLine, byte noteVolume) { + for (note = searchNoteByTime(noteTime); note != null && note.noteTime <= noteTime; note = note.next) { + if (noteTime == note.noteTime && noteChannel == note.noteChannel && noteLine == note.noteLine && (noteVolume != 0 ^ note.noteVolume == 0)) { + if (note.next != null) { + note.next.prev = note.prev; + } + if (note.prev != null) { + note.prev.next = note.next; + } else { + noteBeg = note.next; + } - /** - * - * @param c - * @param n - * @return - */ - public Note searchBack(byte c, byte n) - { - if(note == null) - return null; - for(noteTmp = note; - noteTmp != null && (noteTmp.c!=c || noteTmp.n!=n); - noteTmp = noteTmp.prev) + note = (note.next != null) ? note.next : note.prev; + len--; + return; + } + } + } + + /** + * + * @param delNote + */ + public void delOne(Note delNote) { + for (note = getFirst(); note != null && note.noteTime <= t; note = note.next) { + if (note == delNote) { + if (note.next != null) { + note.next.prev = note.prev; + } + if (note.prev != null) { + note.prev.next = note.next; + } else { + noteBeg = note.next; + } + + note = (note.next != null) ? note.next : note.prev; + len--; + return; + } + } + } + + /** + * + * @param undo + */ + public void delSelected(UndoableAction undo) { + for (note = getFirst(); note != null; note = note.next) { + if (note.mark == NoteListUtils.NOTE_MARKED) { + if (note.next != null) { + note.next.prev = note.prev; + } + if (note.prev != null) { + note.prev.next = note.next; + } else { + noteBeg = note.next; + } + + if (undo != null && note.noteVolume != 0) { + undo.log2DelNoteList(note.noteTime, note.noteChannel, note.noteLine, note.noteVolume, note.noteLength); + } + + len--; + } + } + } + + /** + * + * @param noteTime + * @param tMax + * @param noteChannel + * @param noteLine + * @param noteVolume + * @param undo + * @return + */ + public int del(int noteTime, int tMax, byte noteChannel, byte noteLine, byte noteVolume, UndoableAction undo) { + if (noteTime == tMax) { + tMax++; + } + int tOffMax = tMax; + boolean isdel = false; + timeNoteOff = -1; + + for (note = searchNoteByTime(noteTime); note != null && note.noteTime <= tMax; note = note.next) { + if ((note.noteChannel == noteChannel || noteChannel == (byte) -1) + && (note.noteTime > noteTime || noteVolume != 0 && note.noteTime == noteTime) + && (note.noteTime < tMax || noteVolume == 0 && note.noteTime == tMax) + && (note.noteLine == noteLine || noteLine == (byte) -1) + && ((noteVolume != 0 && (note.noteVolume != 0 || note.noteTime - note.noteLength >= noteTime)) + || (noteVolume == 0 && (note.noteVolume == 0 && timeLastDelOn <= note.noteTime - note.noteLength && note.noteTime - note.noteLength < noteTime)))) { + if (note.next != null) { + note.next.prev = note.prev; + } + if (note.prev != null) { + note.prev.next = note.next; + } else { + noteBeg = note.next; + } + + len--; + if (noteVolume != 0) { + if (tOffMax < note.noteTime + note.noteLength) { + tOffMax = note.noteTime + note.noteLength; + } + if (undo != null && note.noteVolume != 0) { + undo.log2DelNoteList(note.noteTime, note.noteChannel, note.noteLine, note.noteVolume, note.noteLength); + } + } + if (note.noteVolume == 0) { + timeNoteOff = note.noteTime; + } + isdel = true; + } + } + + if (noteVolume != 0 && tOffMax > tMax) { + timeLastDelOn = noteTime; + del(tMax, tOffMax, noteChannel, noteLine, (byte) 0, null); + } else { + timeLastDelOn = -1; + } + if (isdel == false) { + return -2; + } + return timeNoteOff; + } + + /** + * + * @param noteChannel + * @param noteLine + * @return + */ + public Note searchBack(byte noteChannel, byte noteLine) { + if (note == null) { + return null; + } + for (noteTmp = note; + noteTmp != null && (noteTmp.noteChannel != noteChannel || noteTmp.noteLine != noteLine); + noteTmp = noteTmp.prev) ; - return noteTmp; - } - /** - * - * @param noteTime - * @return - */ - public Note searchNoteByTime(int t) - { - if(note == null) - { - if(noteBeg != null) - note = noteBeg; - else - return null; - } - if(t <= note.noteTime) - { - for(noteTmp = note; - noteTmp.prev != null && t <= noteTmp.noteTime; - noteTmp = noteTmp.prev) - ; - if(noteTmp.noteTime= tSrcBeg - || srcNote.v != 0 && srcNote.noteTime + srcNote.length <= tSrcEnd) - && (srcNote.v != 0 || onlyMarkSrc)) { + if (srcNote.noteChannel == chSrc && (srcNote.noteVolume == 0 && srcNote.noteTime - srcNote.noteLength >= tSrcBeg + || srcNote.noteVolume != 0 && srcNote.noteTime + srcNote.noteLength <= tSrcEnd) + && (srcNote.noteVolume != 0 || onlyMarkSrc)) { if (onlyMarkSrc) { srcNote.mark = NOTE_MARKED; } else { t = tDestBeg + ((srcNote.noteTime - tSrcBeg) * destTicksPer4) / srcTicksPer4; - n = srcNote.n; - len = (srcNote.length * destTicksPer4) / srcTicksPer4; - dest.add(new Note(t, chDest, n, srcNote.v, len)); + n = srcNote.noteLine; + len = (srcNote.noteLength * destTicksPer4) / srcTicksPer4; + dest.add(new Note(t, chDest, n, srcNote.noteVolume, len)); if (len > 0) { dest.add(new Note(t + len, chDest, n, (byte) 0, len)); } if (undo != null) { - undo.log2AddNoteList(t, chDest, n, srcNote.v, len); + undo.log2AddNoteList(t, chDest, n, srcNote.noteVolume, len); } } } @@ -182,43 +182,43 @@ public class NoteListUtils { public static void shift(NoteList list, int tBeg, int shiftLen, UndoableAction undo) { Note note = list.searchNoteByTime(0x7fffffff); for (; note != null && note.noteTime >= tBeg; note = note.prev) { - if (note.v == 0 && note.noteTime - note.length < tBeg) { + if (note.noteVolume == 0 && note.noteTime - note.noteLength < tBeg) { Note noteTmp; for (noteTmp = note.prev; - noteTmp != null && (noteTmp.c != note.c || noteTmp.n != note.n); + noteTmp != null && (noteTmp.noteChannel != note.noteChannel || noteTmp.noteLine != note.noteLine); noteTmp = noteTmp.prev) ; - if (noteTmp != null && noteTmp.c == note.c && noteTmp.n == note.n) { + if (noteTmp != null && noteTmp.noteChannel == note.noteChannel && noteTmp.noteLine == note.noteLine) { if (undo != null) { - undo.log2DelNoteList(noteTmp.noteTime, noteTmp.c, noteTmp.n, noteTmp.v, noteTmp.length); + undo.log2DelNoteList(noteTmp.noteTime, noteTmp.noteChannel, noteTmp.noteLine, noteTmp.noteVolume, noteTmp.noteLength); } - noteTmp.length = note.noteTime - noteTmp.noteTime + shiftLen; + noteTmp.noteLength = note.noteTime - noteTmp.noteTime + shiftLen; - if (noteTmp.noteTime + noteTmp.length < tBeg) { - noteTmp.length = tBeg - noteTmp.noteTime; + if (noteTmp.noteTime + noteTmp.noteLength < tBeg) { + noteTmp.noteLength = tBeg - noteTmp.noteTime; } - note.length = noteTmp.length; + note.noteLength = noteTmp.noteLength; if (undo != null) { - undo.log2AddNoteList(noteTmp.noteTime, noteTmp.c, noteTmp.n, noteTmp.v, noteTmp.length); + undo.log2AddNoteList(noteTmp.noteTime, noteTmp.noteChannel, noteTmp.noteLine, noteTmp.noteVolume, noteTmp.noteLength); } } } note.noteTime += shiftLen; if (note.noteTime < tBeg) { - if (undo != null && note.v != 0) { - undo.log2DelNoteList(note.noteTime - shiftLen, note.c, note.n, note.v, note.length); - undo.log2AddNoteList(tBeg, note.c, note.n, note.v, note.length); + if (undo != null && note.noteVolume != 0) { + undo.log2DelNoteList(note.noteTime - shiftLen, note.noteChannel, note.noteLine, note.noteVolume, note.noteLength); + undo.log2AddNoteList(tBeg, note.noteChannel, note.noteLine, note.noteVolume, note.noteLength); } note.noteTime = tBeg; } } if (undo != null) { - undo.logShift(tBeg, shiftLen, list.getFirst().c); + undo.logShift(tBeg, shiftLen, list.getFirst().noteChannel); } } @@ -285,14 +285,14 @@ public class NoteListUtils { byte newN; for (Note note = undo.getDeletedList().getFirst(); note != null; note = note.next) { - if (note.c == channel && note.v != 0) { + if (note.noteChannel == channel && note.noteVolume != 0) { newTime = note.noteTime + shiftTime; if (newTime < 0) { newTime = 0; } - newN = (byte) (note.n + shiftNote); + newN = (byte) (note.noteLine + shiftNote); - tmp = note.v + shiftVol; + tmp = note.noteVolume + shiftVol; if (tmp < 1) { tmp = 1; } else if (tmp > 127) { @@ -300,13 +300,13 @@ public class NoteListUtils { } newVol = (byte) tmp; - dest.add(new Note(newTime, channel, newN, newVol, note.length)); + dest.add(new Note(newTime, channel, newN, newVol, note.noteLength)); - if (note.length > 0) { - dest.add(new Note(newTime + note.length, channel, newN, (byte) 0, note.length)); + if (note.noteLength > 0) { + dest.add(new Note(newTime + note.noteLength, channel, newN, (byte) 0, note.noteLength)); } - if (undo != null && note.v != 0) { - undo.log2AddNoteList(newTime, channel, newN, newVol, note.length); + if (undo != null && note.noteVolume != 0) { + undo.log2AddNoteList(newTime, channel, newN, newVol, note.noteLength); } } diff --git a/src/midedit/NoteLong.java b/src/midedit/NoteLong.java index d6ceb01..80419d7 100644 --- a/src/midedit/NoteLong.java +++ b/src/midedit/NoteLong.java @@ -6,17 +6,17 @@ package midedit; */ public class NoteLong extends Note { + /** */ + public byte[] dat; + /** * - * @param time + * @param time () * @param data */ public NoteLong(int time, byte[] data) { super(time, (byte) NoteList.CHANNEL_LONG_NOTE, (byte) 0, (byte) 0, 0); dat = data; } - /** - * - */ - public byte[] dat; + } diff --git a/src/midedit/NotesCanvas.java b/src/midedit/NotesCanvas.java index ee17a27..82e25f4 100644 --- a/src/midedit/NotesCanvas.java +++ b/src/midedit/NotesCanvas.java @@ -13,7 +13,7 @@ public class NotesCanvas extends MixerCanvas { /** * * @param ctrl - * @param c + * @param c * @param ch */ public NotesCanvas(Main ctrl, Composition c, int ch) { @@ -58,8 +58,8 @@ public class NotesCanvas extends MixerCanvas { int x, h; int dx, t = 1; x = getXInPixel(note.noteTime + shiftTime); - h = getLineFromNote(note.n + shiftNote); - dx = (note.length * wOne) / Constants.timeConst; + h = getLineFromNote(note.noteLine + shiftNote); + dx = (note.noteLength * wOne) / Constants.timeConst; if (dx == 0) { dx = 2; } @@ -76,7 +76,6 @@ public class NotesCanvas extends MixerCanvas { /** * - * @param n * @return */ protected byte getLineFromNote(int n) { diff --git a/src/midedit/PrintSmallFont.java b/src/midedit/PrintSmallFont.java index 1a6577c..7a249bc 100644 --- a/src/midedit/PrintSmallFont.java +++ b/src/midedit/PrintSmallFont.java @@ -1,7 +1,5 @@ package midedit; - - import javax.microedition.lcdui.*; import java.io.*; @@ -9,9 +7,28 @@ import java.io.*; * * @author user */ -public class PrintSmallFont -{ +public class PrintSmallFont { + private static int[] nMax = {100000, 1000, 100, 10, 1, 0}; + private static int[] denom = {1, 10, 100, 1000, 10000, 100000}; + + private static Image[][] digImages; + private static Image[][] notesImages; + + private static final int digLen = 4; + + private static final int noteLen = 11; + private static final int noteLenY = 5; + + private static final int NUM_CHAR = 12; + + private static final int NUM_COLOR = 2; + + private static final int NUM_NOTES = 12; + + private static final int NUM_NOTES_LINE = 6; + + /** * * @param g @@ -22,155 +39,116 @@ public class PrintSmallFont * @param color * @return */ - public static int print(Graphics g,int num,int dot,int x, int y,int color) - { - int xLen=0; - int nt = Math.abs(num); - int dig; - int i; - Image[] imgs = digImages[color]; + public static int print(Graphics g, int num, int dot, int x, int y, int color) { + int xLen = 0; + int nt = Math.abs(num); + int dig; + Image[] imgs = digImages[color]; - while(dot>0 && nt/denom[dot] >= nMax[dot]) - { - dot--; - nt /= 10; - } + while (dot > 0 && nt / denom[dot] >= nMax[dot]) { + dot--; + nt /= 10; + } - if(dot>0) - { - for (i = 0; i < dot; ++i, nt /= 10, xLen += digLen) - { - dig = nt % 10; - g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); - } + if (dot > 0) { + for (int i = 0; i < dot; ++i, nt /= 10, xLen += digLen) { + dig = nt % 10; + g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); + } - g.drawImage(imgs[10], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); - xLen += digLen; - } - do{ - dig = nt % 10; - g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); - nt /= 10; - xLen += digLen; - }while(nt!=0); + g.drawImage(imgs[10], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); + xLen += digLen; + } + do { + dig = nt % 10; + g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); + nt /= 10; + xLen += digLen; + } while (nt != 0); - if(num<0) - { - dig = 11; - g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); - xLen += digLen; - } + if (num < 0) { + dig = 11; + g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); + xLen += digLen; + } - return xLen; - } - /** - * - * @param g - * @param n - * @param x - * @param y - * @param color - * @return - */ - public static int printNote(Graphics g,int n,int x, int y,int color) - { - g.drawImage(notesImages[color][n],x,y,Graphics.RIGHT|Graphics.BOTTOM); - - return noteLen; - } - - static int[] nMax = {100000,1000,100,10,1,0}; - static int[] denom = {1,10,100,1000,10000,100000}; - - static Image[][] digImages; - static Image[][] notesImages; - static private int digLen = 4; - static private int noteLen = 11; - /** - * - */ - static public int noteLenY=5; - /** - * - */ - static public final int NUM_CHAR=12; - /** - * - */ - static public final int NUM_COLOR=2; - /** - * - */ - static public final int NUM_NOTES=12; - /** - * - */ - static public final int NUM_NOTES_LINE=6; - - static{ - try { - Image numbers0 = Image.createImage("/img/nums0m.png"); - Image numbers1 = Image.createImage("/img/nums1m.png"); - Image notes0 = Image.createImage("/img/notes0.png"); - Image notes1 = Image.createImage("/img/notes1.png"); - digImages = new Image[NUM_COLOR][]; - digImages[0] = new Image[NUM_CHAR]; - digImages[1] = new Image[NUM_CHAR]; - - notesImages = new Image[NUM_COLOR][]; - notesImages[0] = new Image[NUM_NOTES]; - notesImages[1] = new Image[NUM_NOTES]; - - - int len = 0; - for(int i = 0; i=0; --i) - switch(order[i]) - { - case ADD_NOTE: - composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime, noteAddDel.c, - noteAddDel.n, noteAddDel.v); - if(noteAddDel.length != 0) - composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime+noteAddDel.length, - noteAddDel.c,noteAddDel.n,(byte)0); - break; - case DEL_NOTE: - composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime,noteAddDel.c, - noteAddDel.n,noteAddDel.v,noteAddDel.length)); - if(noteAddDel.length != 0) - composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime+noteAddDel.length, - noteAddDel.c,noteAddDel.n, (byte)0,noteAddDel.length)); - break; - case DELETE_LIST: - Note noteLocal = dellist.getFirst(); - if(noteLocal!=null) - channel = noteLocal.c; - list = composition.getNoteListByChannel(channel); - for(noteLocal = dellist.getFirst(); noteLocal!=null; noteLocal = noteLocal.next) - { - list.add(new Note(noteLocal.noteTime,noteLocal.c,noteLocal.n,noteLocal.v,noteLocal.length)); - if(noteLocal.length != 0) - list.add(new Note(noteLocal.noteTime+noteLocal.length,noteLocal.c,noteLocal.n,(byte)0,noteLocal.length)); - } - break; - case ADD_LIST: - noteLocal = addlist.getFirst(); - if(noteLocal!=null) - channel = noteLocal.c; + public void prepare() { + order[0] = 0; + indOrder = 0; + dellist = new NoteList(); + addlist = new NoteList(); + } - list = composition.getNoteListByChannel(channel); - for(noteLocal = addlist.getFirst(); noteLocal!=null; noteLocal = noteLocal.next) - { - list.delOne(noteLocal.noteTime,noteLocal.c,noteLocal.n,noteLocal.v); - if(noteLocal.length != 0) - list.delOne(noteLocal.noteTime+noteLocal.length,noteLocal.c,noteLocal.n,(byte)0); - } - break; - case SHIFT_LIST: - NoteListUtils.shift(composition.getNoteListByChannel(channel),shiftBeg,-shiftLen,null); - break; - } - reverseActOrder(); - canUndo = !canUndo; - canRedo = !canRedo; - } + public void logAddNote(Note singleNote) { + channel = singleNote.noteChannel; + clean(); + addAction(ADD_NOTE); + noteAddDel = singleNote; + } - private void reverseActOrder() - { - byte[] newOrder = new byte[NUM_ACT]; - NoteList newAddlist=addlist, newDellist=dellist; - for(int i=0 ; i= 0; --i) { + switch (order[i]) { + case ADD_NOTE: + composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime, noteAddDel.noteChannel, + noteAddDel.noteLine, noteAddDel.noteVolume); + if (noteAddDel.noteLength != 0) { + composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime + noteAddDel.noteLength, + noteAddDel.noteChannel, noteAddDel.noteLine, (byte) 0); + } + break; + case DEL_NOTE: + composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime, noteAddDel.noteChannel, + noteAddDel.noteLine, noteAddDel.noteVolume, noteAddDel.noteLength)); + if (noteAddDel.noteLength != 0) { + composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime + noteAddDel.noteLength, + noteAddDel.noteChannel, noteAddDel.noteLine, (byte) 0, noteAddDel.noteLength)); + } + break; + case DELETE_LIST: + Note noteLocal = dellist.getFirst(); + if (noteLocal != null) { + channel = noteLocal.noteChannel; + } + list = composition.getNoteListByChannel(channel); + for (noteLocal = dellist.getFirst(); noteLocal != null; noteLocal = noteLocal.next) { + list.add(new Note(noteLocal.noteTime, noteLocal.noteChannel, noteLocal.noteLine, noteLocal.noteVolume, noteLocal.noteLength)); + if (noteLocal.noteLength != 0) { + list.add(new Note(noteLocal.noteTime + noteLocal.noteLength, noteLocal.noteChannel, noteLocal.noteLine, (byte) 0, noteLocal.noteLength)); + } + } + break; + case ADD_LIST: + noteLocal = addlist.getFirst(); + if (noteLocal != null) { + channel = noteLocal.noteChannel; + } + + list = composition.getNoteListByChannel(channel); + for (noteLocal = addlist.getFirst(); noteLocal != null; noteLocal = noteLocal.next) { + list.delOne(noteLocal.noteTime, noteLocal.noteChannel, noteLocal.noteLine, noteLocal.noteVolume); + if (noteLocal.noteLength != 0) { + list.delOne(noteLocal.noteTime + noteLocal.noteLength, noteLocal.noteChannel, noteLocal.noteLine, (byte) 0); + } + } + break; + case SHIFT_LIST: + NoteListUtils.shift(composition.getNoteListByChannel(channel), shiftBeg, -shiftLen, null); + break; + } + } + reverseActOrder(); + canUndo = !canUndo; + canRedo = !canRedo; + } + + private void reverseActOrder() { + byte[] newOrder = new byte[NUM_ACT]; + NoteList newAddlist = addlist, newDellist = dellist; + for (int i = 0; i < indOrder; ++i) { + switch (order[indOrder - 1 - i]) { + case ADD_NOTE: + newOrder[i] = DEL_NOTE; + break; + case DEL_NOTE: + newOrder[i] = ADD_NOTE; + break; + case ADD_LIST: + newOrder[i] = DELETE_LIST; + newDellist = addlist; + break; + case DELETE_LIST: + newOrder[i] = ADD_LIST; + newAddlist = dellist; + break; + case SHIFT_LIST: + newOrder[i] = SHIFT_LIST; + shiftLen = -shiftLen; + break; + } + } + addlist = newAddlist; + dellist = newDellist; + order = newOrder; + } + + /** + * + */ + public void undo() { + if (canUndo) { + doAction(); + } + } + + /** + * + */ + public void redo() { + if (canRedo) { + doAction(); + } + } } diff --git a/src/midedit/VolumeForm.java b/src/midedit/VolumeForm.java index 423b2fb..f60ecb6 100644 --- a/src/midedit/VolumeForm.java +++ b/src/midedit/VolumeForm.java @@ -33,7 +33,7 @@ public class VolumeForm extends Form implements CommandListener { * @param back */ public VolumeForm(Composition c, Vector chans, MixerModel m, Displayable back) { - super("Volume"); + super(L.str[L.volume]); composition = c; channels = chans; model = m; @@ -48,12 +48,12 @@ public class VolumeForm extends Form implements CommandListener { soloChecks = new ChoiceGroup[size]; volumeGauges = new Gauge[size]; String[] muteString = new String[1]; - muteString[0] = "Solo"; + muteString[0] = L.str[L.solo]; String gaugeString = ""; boolean[] solo = composition.getSoloList(); for (int i = 0; i < size; ++i) { byte channel = ((Byte) channels.elementAt(i)).byteValue(); - soloChecks[i] = new ChoiceGroup("Channel #" + channel + ":\n" + + soloChecks[i] = new ChoiceGroup(L.str[L.channel] + " #" + channel + ":\n" + Constants.getInstrName(composition.getInstrument(channel) + 1), Choice.MULTIPLE, muteString, null); soloChecks[i].setSelectedIndex(0, solo[channel]); diff --git a/src/midedit/io/JSR75File.java b/src/midedit/io/JSR75File.java index 0e19068..aae3f56 100644 --- a/src/midedit/io/JSR75File.java +++ b/src/midedit/io/JSR75File.java @@ -4,6 +4,7 @@ import java.io.*; import java.util.*; import javax.microedition.io.*; import javax.microedition.io.file.*; +import main.L; import main.Rms; /** @@ -149,7 +150,6 @@ public class JSR75File extends AbstractFile { */ public int open(String fileName, boolean isSaveMode) throws IOException { String fullName; - System.out.println("JSR75File.java : 169 "+fileName); if (fileName.charAt(0) != '/') { try { Enumeration e = FileSystemRegistry.listRoots(); @@ -248,7 +248,7 @@ public class JSR75File extends AbstractFile { * @return */ public String getAns() { - return "save ok"; + return L.str[L.saved]; } } diff --git a/src/midedit/io/RMSFile.java b/src/midedit/io/RMSFile.java index f1781b9..ad2216f 100644 --- a/src/midedit/io/RMSFile.java +++ b/src/midedit/io/RMSFile.java @@ -3,6 +3,7 @@ package midedit.io; import java.io.*; import java.util.Vector; import javax.microedition.rms.*; +import main.L; /** *

Title:

@@ -140,11 +141,7 @@ public class RMSFile extends AbstractFile { return 0; } - -// public int checkFileName(String fileName) throws IOException -// { -// return 0; -// } + public int delete(String fileName) throws IOException { String name = getLastName(fileName); try { @@ -153,17 +150,13 @@ public class RMSFile extends AbstractFile { } return 0; } - /*protected String getPrefix() - { - return ""; - }*/ public String getURL() { return lastPath; } public String getAns() { - return "RMS save ok"; + return "RMS: "+L.str[L.saved]; } public static String getLastName(String fullName) { diff --git a/src/midedit/media/Composition.java b/src/midedit/media/Composition.java index 0591c27..fd2b51e 100644 --- a/src/midedit/media/Composition.java +++ b/src/midedit/media/Composition.java @@ -269,8 +269,8 @@ public class Composition { public void addNoteOff(int tt, byte ch, byte nn) { Note noteTmp = tracks[ch].searchBack(ch, nn); if (noteTmp != null) { - noteTmp.length = tt - noteTmp.noteTime; - tracks[ch].add(new Note(tt, ch, nn, (byte) 0, noteTmp.length)); + noteTmp.noteLength = tt - noteTmp.noteTime; + tracks[ch].add(new Note(tt, ch, nn, (byte) 0, noteTmp.noteLength)); } else { tracks[ch].add(new Note(tt, ch, nn, (byte) 0, 0)); } @@ -465,7 +465,7 @@ public class Composition { for (int i = 0; i < Constants.NCHANNEL; ++i) { Note noteTimeMax = this.getFirstNote(0x7fffffff, i); if (noteTimeMax != null) { - tCur = noteTimeMax.noteTime + noteTimeMax.length; + tCur = noteTimeMax.noteTime + noteTimeMax.noteLength; if (tCur > tMax) { tMax = tCur; } diff --git a/src/ui/FileManager.java b/src/ui/FileManager.java index d58ecf2..6a0ed0d 100644 --- a/src/ui/FileManager.java +++ b/src/ui/FileManager.java @@ -326,7 +326,7 @@ public class FileManager extends Canvas { P.path = pathFile; String openSaveString = Main.midlet.compositionForm.getCompositionName(); - int indBeg = openSaveString.lastIndexOf(midedit.Constants.FILE_DELIM); + int indBeg = openSaveString.lastIndexOf('/'); int indEnd = openSaveString.lastIndexOf('.'); if (indEnd == -1) { indEnd = openSaveString.length(); @@ -397,7 +397,7 @@ public class FileManager extends Canvas { } Main.midlet.compositionForm = null; System.gc(); -// + String openSaveString = pathFile + s; Main.midlet.compositionForm = new CompositionForm(Main.midlet, openSaveString); Main.dsp.setCurrent(Main.midlet.compositionForm); diff --git a/src/ui/Menu.java b/src/ui/Menu.java index 9b07d8f..37a79a1 100644 --- a/src/ui/Menu.java +++ b/src/ui/Menu.java @@ -30,8 +30,6 @@ public class Menu extends Canvas { /** */ private int w, h; - /** , */ - private Displayable pr; /** */ private String[] menu; @@ -75,8 +73,8 @@ public class Menu extends Canvas { public void addNewItems() { menu = new String[] { - L.str[L.create], L.str[L.resume], + L.str[L.create], L.str[L.open], L.str[L.save], L.str[L.saveAs], diff --git a/src/ui/SettingsForm.java b/src/ui/SettingsForm.java index 3830979..29aaa02 100644 --- a/src/ui/SettingsForm.java +++ b/src/ui/SettingsForm.java @@ -9,7 +9,7 @@ import main.*; */ public class SettingsForm extends Form implements CommandListener { - private static final String[] langAppList = {"English", ""}; + private static final String[] langAppList = {"English", "", ""}; private static final String[] langInstrList = {"English", ""}; private static final String[] langChars = {"en", "ru", "ua"}; @@ -80,13 +80,11 @@ public class SettingsForm extends Form implements CommandListener { // Rms.languageApp = langChars[langChoice.getSelectedIndex()]; Rms.languageInstr = langChars[langInstr.getSelectedIndex()]; - //L.readLang(Rms.languageApp, true); - //L.readLang(Rms.languageInstr, false); Rms.tempDir = tempDirField.getString(); - Rms.noteWidth = noteWidthGauge.getValue(); - Rms.noteHeight = noteHeightGauge.getValue(); + Rms.noteWidth = noteWidthGauge.getValue() + 1; + Rms.noteHeight = noteHeightGauge.getValue() + 1; Rms.numKeysEdit = controlChoice.isSelected(0); Main.dsp.setCurrent(previousScreen);