This commit is contained in:
Victor 2018-11-14 19:46:58 +02:00
parent 76bdc22597
commit 482c687d65
34 changed files with 978 additions and 1680 deletions

View File

@ -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

View File

@ -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
*****

View File

@ -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 Кабаса
Маракас
Короткий свисток
Длинный свисток
Короткое гуиро
Длинное гуиро
Клавес
Высокая коробочка
Низкая коробочка
Закрытая куика
Открытая куика
Закрытый треугольник
Открытый треугольник
Шейкер
Бубенцы
Бунчук
Кастаньеты
Закрытый сурдо
Открытый сурдо

View File

@ -1,103 +0,0 @@
Новый
Продолжить
О программе
Открыть
Сохранить
Сохранить как
Файл
Настройки
Выход
РМС
Отмена
Сохранить
Ошибка
Ошибка открытия
Список инструментов
Невозможно
Сохранено
Ошибка сохранения
Сохранение
Открытие
Ошибка выбора файла
Ошибка обновления
Ваш телефон не поддерживает необходимые Api
Инструменты
Меню
Назад
Поставить ноту с текущими атрибутами
Для того, чтобы изменить атрибут ноты (напр длину), удалите ноту, если уже поставлена, выберите атрибут (<7>), измените его (<0>,<*>,<#>) и ставьте ноту
Удалить ноту
Откат
Громкость ноты '+'\'-'
Играть с текущей позиции/Стоп
Играть ноту под курсором
Выбрать атрибут ноты
Изменение атрибута
Стоп
Навигация по композиции
Быстрая навигация
Начало выделения
Конец выделения
Копировать
Вставить (раздвинуть)
Вставить (наложить)
Вставить (перезаписать)
Удалить и сдвинуть
Очистить
Играть канал с экрана
Отмена действия
Играть канал
Вернуть дейсвие
Добавить инструмент
Редактировать
Установить инструмент
Удалить инструмент
Темп-бокс
Громкость
Размер
Играть
Играть оригинал
Ok
Назад
Удалить
Выбрать папку
Открытый файл
Пожалуйста, подождите
Обновление списка
Сохранить здесь
Вставить Темп
Удалить Темп
Темп
Время(Мера)
Поиск
Размер
числитель
знаменатель(2 в степени)
Инструменты
Метр = числитель/ (2^знаменатель). Например, используйте 4/4 (numerator=4; denominator=2) или 6/8 (numerator=6; denominator=3)
Дельта-смещение
Воспроизведение
Играть все
Играть с экрана
Весь трэк
Трэк с экрана
Отметить
Конец Отметки
Начало отметки
Снять отметку
Изменение блока
Режим модификации
Копия
Вставить
Раздвинуть
Заменить
Наложить
Очистить буфер
Вернуть
Подсказка
Клавиши
Быстрые Команды
Навигация
Цифрами, иначе джойстиком, при редактировании нот
Иконки, иначе список, в главном меню
****

Binary file not shown.

11
res/lang/about_ua Normal file
View File

@ -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 - ãðàô³êà

View File

@ -51,7 +51,7 @@ Edit
Set instrument Set instrument
Delete instr Delete instr
Tempo box Tempo box
Volume box Volume
Meter Meter
Play Play
Play origin Play origin
@ -96,3 +96,7 @@ Temp directory
New folder New folder
Memory Memory
MidEdit MidEdit
Edit mode
Mark mode
Solo
Channel

View File

@ -7,7 +7,7 @@
Файл Файл
Настройки Настройки
Выход Выход
РМС RMS
Отмена Отмена
Ошибка Ошибка
Ошибка открытия Ошибка открытия
@ -45,7 +45,7 @@
Очистить Очистить
Играть канал с экрана Играть канал с экрана
Играть канал Играть канал
Вернуть дейсвие Вернуть действие
Добавить инструмент Добавить инструмент
Редактировать Редактировать
Установить инструмент Установить инструмент
@ -63,8 +63,8 @@ Ok
Пожалуйста, подождите Пожалуйста, подождите
Высота ноты Высота ноты
Сохранить здесь Сохранить здесь
Вставить Темп Вставить темп
Удалить Темп Удалить темп
Темп Темп
Время (мера) Время (мера)
Позиция Позиция
@ -96,3 +96,7 @@ Ok
Новая папка Новая папка
Память Память
MidEdit MidEdit
Редактирование
Выделение
Соло
Канал

102
res/lang/strings_ua.loc Normal file
View File

@ -0,0 +1,102 @@
Створити
Продовжити
Про програму
Відкрити
Зберегти
Зберегти як
Файл
Установки
Вих
RMS
Відміна
Помилка
Помилка відкриття
Список інструментів
Неможливо
Збережено
Помилка збереження
Збереження
Відкриття
Помилка вибору файлу
Помилка оновлення
Ваш телефон не підтримує необхідні API
Інструменти
Меню
Назад
Поставити ноту з поточними атрибутами
Для того, щоб змінити атрибут ноти (напр довжину), видаліть ноту. Якщо вже поставлена, виберіть атрибут (<7>), змініть його (<0 >,<*>,<#>) і ставте ноту
Видалити ноту
Скасування дії
Гучність ноти '+' \ '-'
Грати з поточної позиції / Стоп
Грати ноту під курсором
Вибрати атрибут ноти
Зміна атрибута
Стоп
Навігація по композиції
Швидка навігація
Початок виділення
Кінець виділення
Копіювати
Вставити (розсунути)
Вставити (накласти)
Вставити (перезаписати)
Видалити і зсунути
Очистити
Грати канал з екрану
Грати канал
Вернути дію
Додати інструмент
Редагувати
Встановити інструмент
Видалити інструмент
Темп-бокс
Гучність
Розмір
Грати
Грати оригінал
Ok
Мова (необхідний рестарт)
Видалити
Мова інструментів
Ширина ноти
Будь ласка, зачекайте
Висота ноти
Зберегти тут
Вставити Темп
Видалити Темп
Темп
Час (міра)
Позиція
Чисельник
Знаменник (2 в ступені)
Метр = чисельник / (2 ^ знаменник). Наприклад, використовуйте 4 / 4 (numerator = 4; denominator = 2) або 6 / 8 (numerator = 6; denominator = 3)
Дельта-зміщення
Відтворення
Грати все
Грати з екрану
Повний трек
Трек з екрану
Відмітити
Зняти відмітку
Редаг. блоку
Режим модифікації
Вставити
Розсунути
Замінити
Накласти
Очистити буфер
Допомога
Клавіші
Швидкі команди
Навігація
Цифрами, інакше джойстиком, при редагуванні нот
Iм'я
Тимчасова папка
Нова папка
Пам'ять
MidEdit
Редагування
Виділення
Соло
Канал

View File

@ -76,9 +76,7 @@ public class Key {
Call = -10; Call = -10;
//Motorola V300, V500, V525 äîëæíû áûòü ñîôòû leftSoftKey = 21;rightSoftKey = 22; //Motorola V300, V500, V525 äîëæíû áûòü ñîôòû leftSoftKey = 21;rightSoftKey = 22;
Platform = "Motorola"; Platform = "Motorola";
} catch (Throwable t2) { //сюда можно вписать ешё платформу мотороллы с классом com.motorola.io.FileConnection } catch (Throwable t2) {}
//но у неё файловая мудацкая
}
} }
} }
} }

View File

@ -65,7 +65,7 @@ public class L {
setInstrument = 50, setInstrument = 50,
delInstrument = 51, delInstrument = 51,
tempoBox = 52, tempoBox = 52,
volumeBox = 53, volume = 53,
meter = 54, meter = 54,
play = 55, play = 55,
playOrigin = 56, playOrigin = 56,
@ -109,7 +109,11 @@ public class L {
tempDir = 94, tempDir = 94,
newFolder = 95, newFolder = 95,
memory = 96, memory = 96,
midedit = 97; midedit = 97,
editMode = 98,
markMode = 99,
solo = 100,
channel = 101;
/** Ìàññèâ òåêñòîâûõ ìåòîê */ /** Ìàññèâ òåêñòîâûõ ìåòîê */

View File

@ -50,18 +50,6 @@ public class Main extends MIDlet {
notifyDestroyed(); 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() { public MixerModel getModel() {
return model; return model;
} }

View File

@ -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) начал делать модификацию. По просьбе JEim7 (http://seclub.org/user/nid.php?nid=972825), на основе исходников MidEdit 2.0.5 (http://sunet.dl.sourceforge.net/project/midedit/MideditProject.tgz) начал делать модификацию.
Изменения: Изменения:
- Сохранение в .mid, а не в .MID - Сохранение в .mid, а не в .MID
- Исправления в локализации. - Исправления в локализации. Добавлен украинский язык.
- Новое графическое меню. Убраны лишние пункты при запуске. - Новое графическое меню. Убраны лишние пункты при запуске.
- Добавлен графический файловый менеджер, показывающий только те файлы, с которыми работает программа. Сделано запоминание последнего пути. - Добавлен графический файловый менеджер, показывающий только те файлы, с которыми работает программа. Сделано запоминание последнего пути.
- Добавлена возможность прослушивания мелодии и создания новой папки в файлменеджере. - Добавлена возможность прослушивания мелодии и создания новой папки в файлменеджере.
- Некоторые экраны (в основном помощи) изменены на графические. - Некоторые экраны (в основном помощи) изменены на графические.
- Добавлено автоопределение клавиатуры телефона.
- Исправил ошибку, при которой после длительной работы в редакторе могли появляться глюки с отрисовкой экрана.
- Исправил ошибку с некорректной скоростью прокрутки курсора при воспроизведении, если был изменен размер ячейки ноты в настройках.
- Кое-где подправил и оптимизировал код, добавил описания.
******** ********
Добавить украинский язык. Добавить украинский язык.
@ -15,8 +19,5 @@ Help
******** ********
Не работает добавить инструмент/заменить, нельзя прослушать инстумент при выборе. Не работает добавить инструмент/заменить, нельзя прослушать инстумент при выборе.
- курсор редактора во время проигрывания бежит быстрее, чем фактически играет композиция. До этого настройки размера длины и ширины ноты были изменены. Возможно, скорость курсора была привязана к определенному размеру ячеек.
++++ ++++
Вот второй тест. Добавлено подтверждение при удалении файла, исправлен сдвиг в текстовых метках ударных, исправлен баг с однотипными иконками при смене языка. Вот второй тест. Добавлено подтверждение при удалении файла, исправлен сдвиг в текстовых метках ударных, исправлен баг с однотипными иконками при смене языка, исправлен курсор при воспроизведении. Другие изменения.

View File

@ -1,14 +1,14 @@
package midedit; package midedit;
/** /**
* * Интерфейс прослушивания событий
* @author user * @author user
*/ */
public interface AbstractListener { public interface AbstractListener {
/** /**
* * Метод вызываемый при возникновении события
* @param itemNum * @param itemNum номер выбранного пункта
*/ */
public void actionPerformed(int itemNum); public void actionPerformed(int itemNum);
} }

View File

@ -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 setInstrument = new Command(L.str[L.setInstrument], Command.ITEM, 3);
private Command delInstrument = new Command(L.str[L.delInstrument], Command.ITEM, 4); 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 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); 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() { public void releaseMem() {
if (composition != null) { if (composition != null) {
@ -392,7 +392,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
textBoxTemp.append(nomField); textBoxTemp.append(nomField);
final TextField denomField = new TextField(L.str[L.denominator], "" + composition.getDenomE(), 1, TextField.NUMERIC); final TextField denomField = new TextField(L.str[L.denominator], "" + composition.getDenomE(), 1, TextField.NUMERIC);
textBoxTemp.append(denomField); 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(CompositionForm.ok);
textBoxTemp.addCommand(P.comCancel); textBoxTemp.addCommand(P.comCancel);
textBoxTemp.setCommandListener(new CommandListener() { textBoxTemp.setCommandListener(new CommandListener() {
@ -413,6 +413,18 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
} }
} }
/**
*
* @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;
}
/** /**
* *
* @param name * @param name

View File

@ -3,10 +3,8 @@ package midedit;
import java.util.Vector; import java.util.Vector;
import main.L; import main.L;
//import java.util.*;
//import java.lang.*;
/** /**
* * Константы
* @author user * @author user
*/ */
public class Constants { public class Constants {
@ -18,21 +16,10 @@ public class Constants {
public static void setTimeConst(int t) { public static void setTimeConst(int t) {
timeConst = t; timeConst = t;
} }
/**
*
* @return
*/
// public static String getInstruments(int i){
// return (String);
// }
/** /**
* *
*/ */
public static final int INV_CANVAS_CONST = 131; 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) public static final int MAX_NOTE_LENGTH = 8; // min == 1/(2^5)
static VectorArr instrVectorArr = new VectorArr(L.instr, 1, 128); static VectorArr instrVectorArr = new VectorArr(L.instr, 1, 128);
static class VectorArr extends Vector { static class VectorArr extends Vector {

View File

@ -4,22 +4,17 @@ import midedit.media.Composition;
import midedit.io.AbstractFile; import midedit.io.AbstractFile;
import java.io.*; import java.io.*;
import main.P; import main.P;
//import com.siemens.mp.io.File;
public class MidiFile implements Waitable { public class MidiFile implements Waitable {
private String outStr; private String outStr;
private String url; private String url;
// private static File file = null;
private static AbstractFile file = null; private static AbstractFile file = null;
//private MixerModel mod;
private int seekPos = 0; private int seekPos = 0;
private int seekLen = 1; private int seekLen = 1;
private int maxTime = 0; private int maxTime = 0;
private boolean cancelStatus; private boolean cancelStatus;
// private final int size = 49; private final static int sizeMax = 15000;
private final static int sizeMax/*=200000;*/ = 15000;
//private static int temp = 0x123456;
private static byte[] MTHD = {0x4D, 0x54, 0x68, 0x64}; private static byte[] MTHD = {0x4D, 0x54, 0x68, 0x64};
private static byte[] MTRK = {0x4d, 0x54, 0x72, 0x6b}; private static byte[] MTRK = {0x4d, 0x54, 0x72, 0x6b};
private static byte[] ENDTrk = {0x00, -0x01, 0x2f, 0x00}; 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 0, -112, 46, 1, 8, -103/*0x90*/, 46/*note height*/, 127,//55
127, -112/*0x80*/, 46, 1, 16, -112, 46/*note height*/, 1,//63 127, -112/*0x80*/, 46, 1, 16, -112, 46/*note height*/, 1,//63
0, -1, 47, 0,}; 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 byte[] bufTmp = new byte[16];
private static int intTmp; private static int intTmp;
private static byte[] bMidi = new byte[sizeMax]; 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) { public MidiFile(AbstractFile aFile) {
file = aFile; file = aFile;
} }
@ -64,9 +49,7 @@ public class MidiFile implements Waitable {
newarr = new byte[nextLen]; newarr = new byte[nextLen];
System.arraycopy(bMidi, 0, newarr, 0, bMidi.length); System.arraycopy(bMidi, 0, newarr, 0, bMidi.length);
bMidi = newarr; bMidi = newarr;
//System.out.println("bMidi.length="+bMidi.length);
} catch (Throwable e) { } catch (Throwable e) {
//System.out.println(""+e);
return false; return false;
} }
return true; return true;
@ -74,7 +57,6 @@ public class MidiFile implements Waitable {
public void setFile() { public void setFile() {
file = P.isRMSMode ? MixerModel.rmsFile : MixerModel.jsr75File; file = P.isRMSMode ? MixerModel.rmsFile : MixerModel.jsr75File;
} }
public String writeMix(Composition c, int t, boolean forPlay) throws Exception { 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); 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 { public String writeMixWithName(Composition c, int tBeg, boolean forPlay, String name, int channel, int instrument) throws Exception {
System.gc(); System.gc();
outStr = name; outStr = name;
//byte[] tnote;
int iMidi; // index of b int iMidi; // index of b
int i;//,ind; int i;
//Note note;
iMidi = 0; iMidi = 0;
//// begin header ------------------------- //// begin header -------------------------
@ -194,7 +171,7 @@ public class MidiFile implements Waitable {
file.close(df); file.close(df);
return file.getAns(); return file.getAns();
} catch (IOException e) { } 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); throw new Exception("Can't write " + outStr);
} finally { } finally {
//file.close(df); //file.close(df);
@ -227,13 +204,13 @@ public class MidiFile implements Waitable {
ind += 3; ind += 3;
} }
//NoteList notes = c.getNoteListByChannel(ch); //NoteList notes = noteChannel.getNoteListByChannel(ch);
/// print notes /// print notes
byte[] volumeExpArr = c.getVolumeExpArr(); byte[] volumeExpArr = c.getVolumeExpArr();
//int iMax = bMidi.length - 200; //int iMax = bMidi.noteLength - 200;
/* seekLen = mix.getLen()+1; /* seekLen = mix.getLen()+1;
seekPos = 1; seekPos = 1;
cancelStatus = false;*/ cancelStatus = false;*/
@ -317,15 +294,15 @@ public class MidiFile implements Waitable {
} else // simple Note } 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[iMidi]=(byte)0x99; // 0x99 -- Note On
bMidi[ind + 1] = note.n; bMidi[ind + 1] = note.noteLine;
//bMidi[iMidi+2]=note.v; edit 08.07.2004 //bMidi[iMidi+2]=note.noteVolume; edit 08.07.2004
if ((note.v & 0x80) != 0) { if ((note.noteVolume & 0x80) != 0) {
note.v = 0x7f; 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) { if (vol > 127) {
vol = 127; vol = 127;
} else if (vol < 0) { } else if (vol < 0) {
@ -374,22 +351,10 @@ public class MidiFile implements Waitable {
return /*numBytesToWrite*/; return /*numBytesToWrite*/;
} }
public byte[] writeNote(byte instr, byte nn)//+ 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<dat4PlayNote.length; ++i){
//b[i] = (byte)dat4PlayNote[i];
//System.out.print (b[i]+",");
//}
byte[] b = dat4PlayNote; byte[] b = dat4PlayNote;
// System.out.println("b[39] = " + b[39]);
// System.out.println("b[45] = " + b[45]);
// System.out.println("b[49] = " + b[49]);
if (instr >= 0) { if (instr >= 0) {
b[39] = (byte) instr; b[39] = instr;
b[41 + 4] = (byte) (0x90); b[41 + 4] = (byte) (0x90);
b[45 + 4] = (byte) (0x80); b[45 + 4] = (byte) (0x80);
} else { } else {
@ -404,21 +369,17 @@ public class MidiFile implements Waitable {
public byte[] writeTest(byte instr) { public byte[] writeTest(byte instr) {
outStr = "test.mid"; outStr = "test.mid";
//int df=0;
InputStream is = getClass().getResourceAsStream("/test.mid"); InputStream is = getClass().getResourceAsStream("/test.mid");
byte b[] = new byte[148]; byte b[] = new byte[148];
try { try {
is.read(b); is.read(b);
} catch (IOException ex) { } catch (IOException ex) {
//ex.printStackTrace();
} }
b[24] = instr; b[24] = instr;
return b; return b;
} }
private /*static*/ byte[] getVarLenRepr(int t) { private byte[] getVarLenRepr(int t) {
// if(noteTime<0)
// mod.msgAll("Repr\nt="+noteTime);
int tt = t; int tt = t;
if (tt < 0) { if (tt < 0) {
tt = 0; tt = 0;
@ -439,48 +400,25 @@ public class MidiFile implements Waitable {
} }
return r; return r;
} }
// public int getTimeFromVLR(byte[] b)
// {
// int time=0;
// for(int i=0; i<b.length; ++i)
// {
// time = (time<<7) + (b[i] & 0x7f);
// }
// return time;
// }
public String getURI() { public String getURI() {
//return "file://"+outStr;
return url; return url;
} }
public Composition readMix(String path) throws Exception { public Composition readMix(String path) throws Exception {
// mod.msgAll("name="+name);
String name = /*file.getPrefix() + */ path; String name = /*file.getPrefix() + */ path;
int gcCount = 0; int gcCount = 0;
System.gc(); System.gc();
Composition composition = new Composition(); Composition composition = new Composition();
//byte[] buf=null;
int df = 0; int df = 0;
try { try {
/*if(file == null)
//file = new File();
file = new SiemensFile();*/
//try
{
if (file.exists(name) < 0) { if (file.exists(name) < 0) {
throw new IOException("File not found"); throw new IOException("File not found");
} }
// File.delete(outStr);
}
//catch (IllegalArgumentException e) {}
df = file.open(name, false); df = file.open(name, false);
seekLen = file.length(df); seekLen = file.length(df);
seekPos = 0; seekPos = 0;
cancelStatus = false; cancelStatus = false;
// if(df==df)
// throw new IOException("df="+df);
int d = 0x4d546864; // MThd int d = 0x4d546864; // MThd
int t = readInt(df, 4); int t = readInt(df, 4);
@ -491,8 +429,6 @@ public class MidiFile implements Waitable {
if (t != 6) { if (t != 6) {
throw new IOException("len MThd=" + t); throw new IOException("len MThd=" + t);
} }
//skip(df,noteTime);
int format = readInt(df, 2); int format = readInt(df, 2);
if (format > 1) { if (format > 1) {
throw new IOException("Format=" + format + "\nthis format don't support"); throw new IOException("Format=" + format + "\nthis format don't support");
@ -508,12 +444,10 @@ public class MidiFile implements Waitable {
for (int indTrk = 0; indTrk < numTrk; ++indTrk) { for (int indTrk = 0; indTrk < numTrk; ++indTrk) {
d = 0x4d54726b; // MTrk d = 0x4d54726b; // MTrk
t = readInt(df, 4); t = readInt(df, 4);
if (t != d) //throw new IOException("(2)Not Found MTrk \n"+"pos=" if (t != d) {
//+seekPos+"/"+seekLen+"\nind="+indTrk+"/"+numTrk+"mtrk="+noteTime);
{
throw new IOException("Track not found"); throw new IOException("Track not found");
} }
t = readInt(df, 4); // length of track t = readInt(df, 4); // noteLength of track
boolean hasMoreNotes = true; boolean hasMoreNotes = true;
int timeDelta, timeAbs = 0; int timeDelta, timeAbs = 0;
int dPrev = 0; int dPrev = 0;
@ -547,8 +481,7 @@ public class MidiFile implements Waitable {
d = readInt(df, 1); d = readInt(df, 1);
boolean isFBN = (d & 0x80) == 0x00; // FBN = first bit null boolean isFBN = (d & 0x80) == 0x00; // FBN = first bit null
if (isFBN) { if (isFBN) {
if (dPrev == 0) //throw new IOException("Default no Repeat tA=" + timeAbs + "\nd=" + d); if (dPrev == 0) {
{
throw new IOException("File corrupted"); throw new IOException("File corrupted");
} }
d1 = dPrev; d1 = dPrev;
@ -571,7 +504,6 @@ public class MidiFile implements Waitable {
} }
composition.addNoteOn(timeAbs, channel, note, composition.addNoteOn(timeAbs, channel, note,
vel, 0/*Constants.timeConst*/, false); vel, 0/*Constants.timeConst*/, false);
//throw new IOException("Note ON tA="+timeAbs);
} else // if(channel != Constants.DRUMS_CHANNEL) } else // if(channel != Constants.DRUMS_CHANNEL)
{ {
composition.addNoteOff(timeAbs, channel, note); composition.addNoteOff(timeAbs, channel, note);
@ -592,8 +524,6 @@ public class MidiFile implements Waitable {
case 0xb0: case 0xb0:
skip(df, 2 - 1); skip(df, 2 - 1);
break; break;
//case 0xd0:
// break;
case 0xe0: case 0xe0:
skip(df, 2 - 1); skip(df, 2 - 1);
break; break;
@ -602,7 +532,7 @@ public class MidiFile implements Waitable {
case 0xff: // meta-events case 0xff: // meta-events
switch (d2) { switch (d2) {
case 0x58: // Time Signature case 0x58: // Time Signature
n = readInt(df, 1); // n == 4 n = readInt(df, 1); // noteLine == 4
datInt = readInt(df, 1); datInt = readInt(df, 1);
datInt2 = readInt(df, 1); datInt2 = readInt(df, 1);
composition.setMeter(datInt, datInt2); composition.setMeter(datInt, datInt2);
@ -622,7 +552,6 @@ public class MidiFile implements Waitable {
default: { default: {
n = readInt(df, 1); n = readInt(df, 1);
skip(df, n); skip(df, n);
// throw new IOException("Default 0xFF tA="+timeAbs+"\nd2="+d2);
} }
} }
break; break;
@ -634,39 +563,31 @@ public class MidiFile implements Waitable {
default: { default: {
n = d2; // readInt(df,1); n = d2; // readInt(df,1);
skip(df, n); skip(df, n);
// throw new IOException("Default tA="+timeAbs+"\nd="+d);
} }
} }
break; break;
default: default:
//throw new IOException("Default(2) tA=" + timeAbs + "\nd=" + d);
throw new IOException("File corrupted"); throw new IOException("File corrupted");
} }
dPrev = d1; dPrev = d1;
Thread.yield(); Thread.yield();
} }
} }
//file.close(df); } catch (IOException e) {
} catch (IOException e) {// mod.msgAll("Open:"+e);
//throw new Exception("<"+e.toString()+">");
throw new Exception("Can't read:\n" + e.getMessage()); throw new Exception("Can't read:\n" + e.getMessage());
} finally { } finally {
file.close(df); file.close(df);
seekPos = seekLen; seekPos = seekLen;
} }
// mod.msgAll("mix.add ok");
// Composition c = new Composition(mix);
return composition; return composition;
} }
private int readTimeDelta(int df) throws IOException { private int readTimeDelta(int df) throws IOException {
int timeDelta = 0; int timeDelta = 0;
//int i=0;
byte[] buf = new byte[1]; byte[] buf = new byte[1];
do { do {
file.read(df, buf, 0, 1); file.read(df, buf, 0, 1);
timeDelta = (timeDelta << 7) + (buf[0] & (byte) 0x7f); timeDelta = (timeDelta << 7) + (buf[0] & (byte) 0x7f);
//i++;
seekPos++; seekPos++;
} while ((buf[0] & (byte) 0x80) != 0); } while ((buf[0] & (byte) 0x80) != 0);
@ -674,7 +595,6 @@ public class MidiFile implements Waitable {
} }
private int readInt(int df, int len) throws IOException { private int readInt(int df, int len) throws IOException {
// byte[] buf = new byte[1];
int t = 0; int t = 0;
int i; int i;
for (i = 0; i < len; ++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 { 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) { while (n > 0) {
intTmp = (n > bufTmp.length) ? bufTmp.length : n; intTmp = (n > bufTmp.length) ? bufTmp.length : n;
file.read(df, bufTmp, 0, intTmp); file.read(df, bufTmp, 0, intTmp);

View File

@ -4,6 +4,7 @@ import midedit.media.Composition;
import java.util.*; import java.util.*;
import java.io.*; import java.io.*;
import javax.microedition.lcdui.*; import javax.microedition.lcdui.*;
import main.Key;
import main.L; import main.L;
import main.P; import main.P;
import main.Main; import main.Main;
@ -33,12 +34,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
private final Runnable playingRunnable = new Runnable() { private final Runnable playingRunnable = new Runnable() {
public void run() { public void run() {
//System.out.println("getTimeToCanvasConct() = " + composition.getTime2CanvasConst());
//System.out.println("Thread.currentThread = " + Thread.currentThread());
while (CompositionForm.isPlaying) { while (CompositionForm.isPlaying) {
try { try {
doSmallRight(); doSmallRight();
Thread.sleep(31); Thread.sleep(52);//31);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
System.out.println("ex = " + ex); System.out.println("ex = " + ex);
} }
@ -53,7 +52,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
* @param ch * @param ch
*/ */
public MixerCanvas(Main ctrl, Composition c, int ch) { public MixerCanvas(Main ctrl, Composition c, int ch) {
//if (Main.IS_MIDP2)
setFullScreenMode(true); setFullScreenMode(true);
control = ctrl; control = ctrl;
composition = c; composition = c;
@ -71,8 +69,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
runningStatus = true; runningStatus = true;
options = new Options(); options = new Options();
status = new Status(); status = new Status();
frameCount = 0; viewModeDesc(L.str[L.editMode]);
viewModeDesc("Edit Mode");
display.callSerially(this); display.callSerially(this);
} }
@ -108,7 +105,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
doKEY_NUM5(); doKEY_NUM5();
needPaint = true; needPaint = true;
needPaintStatus = true; needPaintStatus = true;
return/*break*/; return;
} else if (ga == LEFT || keyCodePressed == KEY_NUM4) { } else if (ga == LEFT || keyCodePressed == KEY_NUM4) {
if (isNumsControl ^ (keyCodePressed == KEY_NUM4)) { if (isNumsControl ^ (keyCodePressed == KEY_NUM4)) {
doBigLeft(); doBigLeft();
@ -142,27 +139,38 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
status.resetTimeTune(); status.resetTimeTune();
return; return;
} }
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;
switch (keyCodePressed) { } if(keyCodePressed == Key.VolPlus) {
status.volumePlus();
needPaintStatus = true;
} if(keyCodePressed == Key.VolMinus) {
status.volumeMinus();
needPaintStatus = true;
} else switch (keyCodePressed) {
case KEY_NUM1: case KEY_NUM1:
playFromCurrentPosition(); playFromCurrentPosition();
break; break;
case KEY_NUM3: case KEY_NUM3:
model.playNote((byte) ((channel == Constants.DRUMS_CHANNEL) ? -10 : composition.getInstrument(channel)), model.playNote(
(byte) getNoteFromLine(curY)); (byte) ((channel == Constants.DRUMS_CHANNEL) ? -10 : composition.getInstrument(channel)),
break; (byte) getNoteFromLine(curY)
);
case KEY_NUM7:
case -10:
case -4:
status.nextView();
needPaintStatus = true;
break;
case KEY_NUM9:
case -8:
doKEY_NUM9();
needPaint = true;
needPaintStatus = true;
break; break;
case KEY_NUM0: case KEY_NUM0:
status.action(); status.action();
@ -176,32 +184,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
status.curParamPlus(); status.curParamPlus();
needPaintStatus = true; needPaintStatus = true;
break; 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;
} }
} }
@ -221,8 +203,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
} }
} }
;
private void doSmallRight() { private void doSmallRight() {
if (curX < nW - 1) { if (curX < nW - 1) {
curX++; curX++;
@ -234,8 +214,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
} }
} }
;
private void doSmallUp() { private void doSmallUp() {
if (curY > 0) { if (curY > 0) {
curY--; curY--;
@ -247,7 +225,32 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
} }
} }
; 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() { protected void doSmallDown() {
if (curY < nH - 1) { if (curY < nH - 1) {
@ -260,8 +263,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
} }
} }
;
private void doBigLeft() { private void doBigLeft() {
wStepMeasure = (composition.getNom() * (32 >> composition.getDenomE())); wStepMeasure = (composition.getNom() * (32 >> composition.getDenomE()));
if (xBase >= wStepMeasure) { if (xBase >= wStepMeasure) {
@ -271,8 +272,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
} }
} }
;
private void doBigRight() { private void doBigRight() {
wStepMeasure = (composition.getNom() * (32 >> composition.getDenomE())); wStepMeasure = (composition.getNom() * (32 >> composition.getDenomE()));
xBase += wStepMeasure; xBase += wStepMeasure;
@ -280,8 +279,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
needPaintStatus = true; needPaintStatus = true;
} }
;
private void doBigUp() { private void doBigUp() {
if (curY >= hStep) { if (curY >= hStep) {
curY -= hStep; curY -= hStep;
@ -333,13 +330,13 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
} else if (isMarkMode) { } else if (isMarkMode) {
if (curNote != null) { if (curNote != null) {
if (curNote.length > 0) { if (curNote.noteLength > 0) {
Note noteTmp; Note noteTmp;
for (noteTmp = curNote.next; noteTmp != null 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); 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); noteTmp.mark = (byte) (1 - curNote.mark);
} }
} }
@ -367,7 +364,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
} }
if (curNote != null) { if (curNote != null) {
composition.delNote(curNote.noteTime, curNote.c, curNote.n, curNote.v); composition.delNote(curNote.noteTime, curNote.noteChannel, curNote.noteLine, curNote.noteVolume);
} else { } else {
composition.delNote(getCurTime(), (byte) channel, (byte) getNoteFromLine(curY), (byte) 127); 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) { protected void keyReleased(int keyCode) {
if (keyPressedCount > 0) { if (keyPressedCount > 0) {
int gameAction = 0; int gameAction = getGameAction(keyCodePressed);
try {
gameAction = getGameAction(keyCodePressed);
} catch (IllegalArgumentException illegArg) {
}
if (keyCodePressed == KEY_NUM4 || keyCodePressed == KEY_NUM6 if (keyCodePressed == KEY_NUM4 || keyCodePressed == KEY_NUM6
|| keyCodePressed == KEY_NUM2 || keyCodePressed == KEY_NUM8 || keyCodePressed == KEY_NUM2 || keyCodePressed == KEY_NUM8
|| keyCodePressed == KEY_POUND || keyCodePressed == KEY_STAR || keyCodePressed == KEY_POUND || keyCodePressed == KEY_STAR
@ -526,9 +519,9 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
g.setGrayScale(0); g.setGrayScale(0);
for (note = composition.getFirstNote(tBeg, channel); for (note = composition.getFirstNote(tBeg, channel);
note != null && note.noteTime <= tMax; note = note.next) { note != null && note.noteTime <= tMax; note = note.next) {
if (note.c == channel && note.v != 0) { if (note.noteChannel == channel && note.noteVolume != 0) {
if (note.noteTime <= curTimePlus && note.n == curN if (note.noteTime <= curTimePlus && note.noteLine == curN
&& (curTime < note.noteTime + (note.length == 0 ? 1 : note.length))) { && (curTime < note.noteTime + (note.noteLength == 0 ? 1 : note.noteLength))) {
curNote = note; curNote = note;
if (!isMarkMode) { if (!isMarkMode) {
g.setColor(150, 0, 0); g.setColor(150, 0, 0);
@ -544,7 +537,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
paintNote(g, note, 0, 0); paintNote(g, note, 0, 0);
g.setColor(0); g.setColor(0);
} else { } else {
int col = (256 - note.v); int col = (256 - note.noteVolume);
g.setColor(col, 0, 140); g.setColor(col, 0, 140);
paintNote(g, note, 0, 0); paintNote(g, note, 0, 0);
} }
@ -560,7 +553,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
for (note = composition.getUndoableAction().getDeletedList().getFirst(); for (note = composition.getUndoableAction().getDeletedList().getFirst();
note != null; note = note.next) { note != null; note = note.next) {
if (note.c == channel && note.v != 0) { if (note.noteChannel == channel && note.noteVolume != 0) {
g.setColor(128, 0, 0); g.setColor(128, 0, 0);
paintNote(g, note, shiftTime, shiftNote); paintNote(g, note, shiftTime, shiftNote);
g.setColor(0); 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) { protected void paintNote(Graphics g, Note note, int shiftTime, int shiftNote) {
xt = getXInPixel(note.noteTime + shiftTime); xt = getXInPixel(note.noteTime + shiftTime);
yt = getLineFromNote(note.n + shiftNote); yt = getLineFromNote(note.noteLine + shiftNote);
if (xt >= 0 && xt < rollWidth) { if (xt >= 0 && xt < rollWidth) {
if (yt < 0) { if (yt < 0) {
yt = -1; yt = -1;
@ -716,17 +709,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
try { try {
if (runningStatus) { if (runningStatus) {
repaint(); repaint();
frameCount++;
if (frameCount % 200 == 0) {
// str = "<gc:" + Runtime.getRuntime().freeMemory() + "> ";
System.gc();
}
Thread.sleep(10); Thread.sleep(10);
display.callSerially(this); display.callSerially(this);
} }
} catch (Exception e) { } catch (Exception e) {
// errStr = "" + e + "\n";
} }
} }
@ -749,7 +735,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
/** /**
* *
* @param noteTime * @param t
* @return * @return
*/ */
protected int getXInPixel(int t) { protected int getXInPixel(int t) {
@ -769,7 +755,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
* @return * @return
*/ */
protected byte getCurVol() { protected byte getCurVol() {
return (byte) status.getVolTune(); return status.getVolTune();
} }
/** /**
@ -808,7 +794,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
isMarkMode = true; isMarkMode = true;
model.getBuffer().copy2Buffer(composition, (byte) channel, timeMarkBeg, timeMarkEnd, true); model.getBuffer().copy2Buffer(composition, (byte) channel, timeMarkBeg, timeMarkEnd, true);
viewModeDesc("Mark Mode"); viewModeDesc(L.str[L.markMode]);
} }
note = composition.getFirstNote(timeMarkEnd, channel); note = composition.getFirstNote(timeMarkEnd, channel);
} }
@ -821,7 +807,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
isMarkMode = false; isMarkMode = false;
timeMarkBeg = NOT_MARKED; timeMarkBeg = NOT_MARKED;
timeMarkEnd = NOT_MARKED; timeMarkEnd = NOT_MARKED;
viewModeDesc("Edit Mode"); viewModeDesc(L.str[L.editMode]);
} }
private void viewModeDesc(String desc) { private void viewModeDesc(String desc) {
@ -863,9 +849,8 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
private int keyPressedCount, private int keyPressedCount,
curYPrev, curYPrev,
curXPrev, curXPrev,
wStep = 5, wStep = wOne,//5,
wStepMeasure = 32, wStepMeasure = 32,
frameCount,
xt, yt, xt, yt,
dx, dy, dx, dy,
tBeg, tMax, tBeg, tMax,
@ -1176,16 +1161,16 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
m3 = 75; m3 = 75;
m4 = 100; m4 = 100;
PrintSmallFont.print(g, note.noteTime * 100 / tick, 2, m1 - xIndent, yIndent, color); 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) { if (MixerCanvas.this instanceof NotesCanvas) {
PrintSmallFont.printNote(g, note.n % 12, m3 - xIndent, yIndent, color); PrintSmallFont.printNote(g, note.noteLine % 12, m3 - xIndent, yIndent, color);
PrintSmallFont.print(g, note.n / 12, 0, m3 - xIndent - 12, yIndent, color); PrintSmallFont.print(g, note.noteLine / 12, 0, m3 - xIndent - 12, yIndent, color);
} else { } 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; break;
case 0: 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 - 4, m2 + 1, yIndent - 4);
g.drawLine(m2 + 1, yIndent - 2, m2 + 1, yIndent - 2); 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); PrintSmallFont.print(g, mod, 0, m4, yIndent, color);
break; break;
@ -1241,10 +1226,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
if (MixerCanvas.this instanceof NotesCanvas) { if (MixerCanvas.this instanceof NotesCanvas) {
m3 = 50; m3 = 50;
m4 = 75; m4 = 75;
PrintSmallFont.printNote(g, note.n % 12, m3 - xIndent, yIndent, color); PrintSmallFont.printNote(g, note.noteLine % 12, m3 - xIndent, yIndent, color);
PrintSmallFont.print(g, note.n / 12, 0, m3 - xIndent - 12, 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) { } else if (MixerCanvas.this instanceof DrumsCanvas) {
m1 = 2; m1 = 2;
g.setFont(P.smPlain); 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); 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; break;
} }
@ -1489,6 +1474,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
menu.paint(g); menu.paint(g);
} }
protected void pointerPressed(int x, int y) {
menu.pointerPressed(x, y);
}
private boolean processCommand(int keyCode) { private boolean processCommand(int keyCode) {
switch (keyCode) { switch (keyCode) {
case KEY_NUM1: case KEY_NUM1:
@ -1545,12 +1534,15 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
composition.getUndoableAction().redo(); composition.getUndoableAction().redo();
break; break;
case -10: case -10:
break;
default:
if(keyCode == Key.Call) {
if (menu.getPrevMenu() != null) { if (menu.getPrevMenu() != null) {
menu = menu.getPrevMenu(); menu = menu.getPrevMenu();
return false; return false;
} }
break; } else {
default:
int dir = 0; int dir = 0;
try { try {
dir = getGameAction(keyCode); dir = getGameAction(keyCode);
@ -1577,6 +1569,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
return false; return false;
} }
} }
}
return true; return true;
} }
@ -1589,10 +1582,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
setNeedPaint(); setNeedPaint();
display.callSerially(MixerCanvas.this); display.callSerially(MixerCanvas.this);
} }
// private int optXbeg = 8;
// private int optYbeg = 4;
// private int optWidth = (screenWidth - 2 * optXbeg);
// private int optHeight = (screenHeight - 2 * optYbeg);
/** /**
* Êëàññ ìåíþ * Êëàññ ìåíþ
@ -1630,10 +1619,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
private void addItem(MenuItem item) { private void addItem(MenuItem item) {
items.addElement(item); items.addElement(item);
// Èçìåíåíèå ðàçìåðà ìåíþ ïîä ïóíêò
int itemWidth = P.medBold.stringWidth(item.getName())+2;
if(itemWidth > w) w = itemWidth;
numLines = hMax / LINE_HEIGHT; numLines = hMax / LINE_HEIGHT;
if (numLines >= items.size()) { if (numLines >= items.size()) {
numLines = items.size(); numLines = items.size();
@ -1667,8 +1652,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
g.fillRect(0, 0, w, hMax); g.fillRect(0, 0, w, hMax);
g.setClip(1, 1, w - 1, hMax - 1); g.setClip(1, 1, w - 1, hMax - 1);
MenuItem item; MenuItem item;
int i; for (int i = 0; i < numLinesMaxVisible; i++) {
for (i = 0; i < numLinesMaxVisible; i++) {
if (i == curLine) { if (i == curLine) {
g.setColor(160, 160, 224); g.setColor(160, 160, 224);
@ -1705,6 +1689,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() { public boolean actionPerformed() {
MenuItem item = (MenuItem) items.elementAt(lineBase + curLine); MenuItem item = (MenuItem) items.elementAt(lineBase + curLine);
if (item instanceof Menu) { if (item instanceof Menu) {

View File

@ -1,6 +1,5 @@
package midedit; package midedit;
//import java.io.IOException;
import midedit.media.Composition; import midedit.media.Composition;
import midedit.media.AbstractPlayer; import midedit.media.AbstractPlayer;
import midedit.media.JSR135Player; import midedit.media.JSR135Player;
@ -24,9 +23,8 @@ public class MixerModel extends Thread {
*/ */
public final Display display = Main.dsp; public final Display display = Main.dsp;
private NoteListUtils buffer; private NoteListUtils buffer;
static AbstractFile rmsFile = new RMSFile(), static AbstractFile rmsFile = new RMSFile();
//localFile,//=rmsFile, static AbstractFile jsr75File;
jsr75File;//=rmsFile;// = new JSR75File();
public AbstractPlayer crossPlayer = null; public AbstractPlayer crossPlayer = null;
public MixerModel() { public MixerModel() {

View File

@ -6,25 +6,38 @@ package midedit;
*/ */
public class Note { public class Note {
/** Ñëåäóþùàÿ íîòà */
public Note next = null;
/** Ïðåäûäóùàÿ íîòà */
public Note prev = null;
public byte c, n, v, mark; /** Âðåìÿ (ïîçèöèÿ) ñ êîòîðîé äîëæíà âîñïðîèçâîäèòñÿ íîòà */
public int noteTime, length; public int noteTime;
public Note next = null, prev = null; /** Äëèíà íîòû */
public int noteLength;
/** Êàíàë íîòû */
public byte noteChannel;
/** Íîìåð ëèíèè */
public byte noteLine;
/** Ãðîìêîñòü */
public byte noteVolume;
/** Âûäåëåíèå */
public byte mark;
/** /**
* * Êîíñòðóêòîð
* @param time * @param time âðåìÿ (ïîçèöèÿ) ñ êîòîðîé äîëæíà âîñïðîèçâîäèòñÿ íîòà
* @param ch * @param channel êàíàë íîòû
* @param nn * @param line íîìåð ëèíèè
* @param vv * @param volume ãðîìêîñòü
* @param ll * @param length äëèíà íîòû
*/ */
public Note(int time, byte ch, byte nn, byte vv, int ll) { public Note(int time, byte channel, byte line, byte volume, int length) {
this.noteTime = time; noteTime = time;
c = ch; noteChannel = channel;
n = nn; noteLine = line;
v = vv; noteVolume = volume;
length = ll; noteLength = length;
mark = NoteListUtils.NOTE_NOT_MARKED; mark = NoteListUtils.NOTE_NOT_MARKED;
} }
} }

View File

@ -1,17 +1,15 @@
package midedit; package midedit;
/** /**
* *
* @author user * @author user
*/ */
public class NoteList public class NoteList {
{
private Note note=null,noteBeg=null; private Note note = null, noteBeg = null;
private Note noteTmp; private Note noteTmp;
private Note noteNew; private Note noteNew;
private int len=0; private int len = 0;
private int timeLastDelOn = -1; private int timeLastDelOn = -1;
private int timeNoteOff; private int timeNoteOff;
private int t; private int t;
@ -20,61 +18,45 @@ public class NoteList
*/ */
public static final int CHANNEL_LONG_NOTE = -2; public static final int CHANNEL_LONG_NOTE = -2;
/**
*
*/
public NoteList()
{}
/** /**
* *
* @param noteExist * @param noteExist
* @return * @return
*/ */
public Note add(Note noteExist) public Note add(Note noteExist) {
{ if (noteExist == null) {
if(noteExist==null)
return null; return null;
}
t = noteExist.noteTime; t = noteExist.noteTime;
len++; len++;
if(noteBeg == null) if (noteBeg == null) {
noteBeg = note = noteExist; noteBeg = note = noteExist;
else } else {
{
noteNew = noteExist; noteNew = noteExist;
if(note == null) if (note == null) {
note = noteBeg; note = noteBeg;
if(note.noteTime != t) }
{ if(t < note.noteTime) if (note.noteTime != t) {
{ if (t < note.noteTime) {
for(noteTmp = note; for (noteTmp = note;
noteTmp != null && t < noteTmp.noteTime; noteTmp != null && t < noteTmp.noteTime;
noteTmp = noteTmp.prev) noteTmp = noteTmp.prev);
; if (noteTmp == null) {
if(noteTmp == null) addInto(null, noteNew, noteBeg);
{
addInto(null,noteNew,noteBeg);
return noteNew; return noteNew;
} }
note = noteTmp; note = noteTmp;
} } else {
else for (noteTmp = note;
{ for(noteTmp = note; noteTmp.next != null && (noteTmp.next.noteTime < t);
noteTmp.next != null && (noteTmp.next.noteTime < t ) ; noteTmp = noteTmp.next);
noteTmp = noteTmp.next)
;
note = noteTmp; note = noteTmp;
} }
} }
if(noteExist.v!=0) if (noteExist.noteVolume != 0) {
{ for (; note.next != null && t == note.next.noteTime; note = note.next);
for( ; note.next != null && t == note.next.noteTime ; note = note.next ) } else {
; for (; note.prev != null && t == note.noteTime; note = note.prev);
}
else
{
for( ; note.prev != null && t == note.noteTime ; note = note.prev )
;
} }
addInto(note, noteNew, note.next); addInto(note, noteNew, note.next);
@ -82,192 +64,199 @@ public class NoteList
} }
return note; return note;
} }
private void addInto(Note n1, Note note, Note n2)
{ private void addInto(Note n1, Note note, Note n2) {
note.next = n2; note.next = n2;
if(n2 != null) if (n2 != null) {
n2.prev = note; n2.prev = note;
}
note.prev = n1; note.prev = n1;
if(n1 != null) if (n1 != null) {
n1.next = note; n1.next = note;
else } else {
noteBeg = note; noteBeg = note;
} }
}
/** /**
* *
* @param noteTime * @param noteTime
* @param c * @param noteChannel
* @param n * @param noteLine
* @param v * @param noteVolume
*/ */
public void delOne(int t, byte c, byte n, byte v) public void delOne(int noteTime, byte noteChannel, byte noteLine, byte noteVolume) {
{ for (note = searchNoteByTime(noteTime); note != null && note.noteTime <= noteTime; note = note.next) {
for(note = searchNoteByTime(t); note != null && note.noteTime <= t; note = note.next) if (noteTime == note.noteTime && noteChannel == note.noteChannel && noteLine == note.noteLine && (noteVolume != 0 ^ note.noteVolume == 0)) {
if(t==note.noteTime && c == note.c && n == note.n && (v!=0 ^ note.v==0)) if (note.next != null) {
{
if (note.next != null)
note.next.prev = note.prev; note.next.prev = note.prev;
if (note.prev != null) }
if (note.prev != null) {
note.prev.next = note.next; note.prev.next = note.next;
else } else {
noteBeg = note.next; noteBeg = note.next;
}
note = (note.next != null)? note.next : note.prev; note = (note.next != null) ? note.next : note.prev;
len--; len--;
return; return;
} }
} }
}
/** /**
* *
* @param delNote * @param delNote
*/ */
public void delOne(Note delNote) public void delOne(Note delNote) {
{ for (note = getFirst(); note != null && note.noteTime <= t; note = note.next) {
for(note = getFirst(); note != null && note.noteTime <= t; note = note.next) if (note == delNote) {
if(note == delNote) if (note.next != null) {
{
if (note.next != null)
note.next.prev = note.prev; note.next.prev = note.prev;
if (note.prev != null) }
if (note.prev != null) {
note.prev.next = note.next; note.prev.next = note.next;
else } else {
noteBeg = note.next; noteBeg = note.next;
}
note = (note.next != null)? note.next : note.prev; note = (note.next != null) ? note.next : note.prev;
len--; len--;
return; return;
} }
} }
}
/** /**
* *
* @param undo * @param undo
*/ */
public void delSelected(UndoableAction undo) public void delSelected(UndoableAction undo) {
{ for (note = getFirst(); note != null; note = note.next) {
for(note = getFirst(); note != null; note = note.next) if (note.mark == NoteListUtils.NOTE_MARKED) {
if(note.mark == NoteListUtils.NOTE_MARKED) if (note.next != null) {
{
if (note.next != null)
note.next.prev = note.prev; note.next.prev = note.prev;
if (note.prev != null) }
if (note.prev != null) {
note.prev.next = note.next; note.prev.next = note.next;
else } else {
noteBeg = note.next; noteBeg = note.next;
}
if(undo!=null && note.v!=0) if (undo != null && note.noteVolume != 0) {
{ undo.log2DelNoteList(note.noteTime, note.noteChannel, note.noteLine, note.noteVolume, note.noteLength);
undo.log2DelNoteList(note.noteTime,note.c,note.n,note.v,note.length);
} }
len--; len--;
} }
} }
}
/** /**
* *
* @param noteTime * @param noteTime
* @param tMax * @param tMax
* @param c * @param noteChannel
* @param n * @param noteLine
* @param v * @param noteVolume
* @param undo * @param undo
* @return * @return
*/ */
public int del(int t,int tMax, byte c, byte n, byte v,UndoableAction undo) public int del(int noteTime, int tMax, byte noteChannel, byte noteLine, byte noteVolume, UndoableAction undo) {
{ if (noteTime == tMax) {
if(t == tMax)
tMax++; tMax++;
}
int tOffMax = tMax; int tOffMax = tMax;
boolean isdel=false; boolean isdel = false;
timeNoteOff = -1; timeNoteOff = -1;
for(note = searchNoteByTime(t); note != null && note.noteTime <= tMax; note = note.next) for (note = searchNoteByTime(noteTime); note != null && note.noteTime <= tMax; note = note.next) {
if ( (note.c == c || c == (byte)-1) && if ((note.noteChannel == noteChannel || noteChannel == (byte) -1)
(note.noteTime > t || v!=0 && note.noteTime == t) && && (note.noteTime > noteTime || noteVolume != 0 && note.noteTime == noteTime)
(note.noteTime < tMax || v==0 && note.noteTime == tMax) && && (note.noteTime < tMax || noteVolume == 0 && note.noteTime == tMax)
(note.n == n || n == (byte)-1) && && (note.noteLine == noteLine || noteLine == (byte) -1)
( (v != 0 && (note.v != 0 || note.noteTime - note.length >= t)) || && ((noteVolume != 0 && (note.noteVolume != 0 || note.noteTime - note.noteLength >= noteTime))
(v == 0 && (note.v == 0 && timeLastDelOn <= note.noteTime-note.length && note.noteTime-note.length < t )))) || (noteVolume == 0 && (note.noteVolume == 0 && timeLastDelOn <= note.noteTime - note.noteLength && note.noteTime - note.noteLength < noteTime)))) {
{ if (note.next != null) {
if(note.next != null)
note.next.prev = note.prev; note.next.prev = note.prev;
if(note.prev != null) }
if (note.prev != null) {
note.prev.next = note.next; note.prev.next = note.next;
else } else {
noteBeg = note.next; noteBeg = note.next;
}
len--; len--;
if( v != 0) if (noteVolume != 0) {
{ if (tOffMax < note.noteTime + note.noteLength) {
if(tOffMax < note.noteTime+note.length) tOffMax = note.noteTime + note.noteLength;
tOffMax = note.noteTime+note.length; }
if(undo!=null && note.v!=0) if (undo != null && note.noteVolume != 0) {
{ undo.log2DelNoteList(note.noteTime, note.noteChannel, note.noteLine, note.noteVolume, note.noteLength);
undo.log2DelNoteList(note.noteTime,note.c,note.n,note.v,note.length);
} }
} }
if(note.v==0) if (note.noteVolume == 0) {
timeNoteOff = note.noteTime; timeNoteOff = note.noteTime;
}
isdel = true; isdel = true;
} }
if(v!=0 && tOffMax>tMax)
{
timeLastDelOn = t;
del(tMax, tOffMax, c, n, (byte) 0,null);
} }
else
if (noteVolume != 0 && tOffMax > tMax) {
timeLastDelOn = noteTime;
del(tMax, tOffMax, noteChannel, noteLine, (byte) 0, null);
} else {
timeLastDelOn = -1; timeLastDelOn = -1;
if(isdel == false) }
if (isdel == false) {
return -2; return -2;
}
return timeNoteOff; return timeNoteOff;
} }
/** /**
* *
* @param c * @param noteChannel
* @param n * @param noteLine
* @return * @return
*/ */
public Note searchBack(byte c, byte n) public Note searchBack(byte noteChannel, byte noteLine) {
{ if (note == null) {
if(note == null)
return null; return null;
for(noteTmp = note; }
noteTmp != null && (noteTmp.c!=c || noteTmp.n!=n); for (noteTmp = note;
noteTmp != null && (noteTmp.noteChannel != noteChannel || noteTmp.noteLine != noteLine);
noteTmp = noteTmp.prev) noteTmp = noteTmp.prev)
; ;
return noteTmp; return noteTmp;
} }
/** /**
* *
* @param noteTime * @param noteTime
* @return * @return
*/ */
public Note searchNoteByTime(int t) public Note searchNoteByTime(int noteTime) {
{ if (note == null) {
if(note == null) if (noteBeg != null) {
{
if(noteBeg != null)
note = noteBeg; note = noteBeg;
else } else {
return null; return null;
} }
if(t <= note.noteTime) }
{ if (noteTime <= note.noteTime) {
for(noteTmp = note; for (noteTmp = note;
noteTmp.prev != null && t <= noteTmp.noteTime; noteTmp.prev != null && noteTime <= noteTmp.noteTime;
noteTmp = noteTmp.prev) noteTmp = noteTmp.prev)
; ;
if(noteTmp.noteTime<t && noteTmp.next!=null) if (noteTmp.noteTime < noteTime && noteTmp.next != null) {
noteTmp = noteTmp.next; noteTmp = noteTmp.next;
note = noteTmp;
} }
else note = noteTmp;
{ } else {
for(noteTmp = note; for (noteTmp = note;
noteTmp.next != null && noteTmp.noteTime < t ; noteTmp.next != null && noteTmp.noteTime < noteTime;
noteTmp = noteTmp.next) noteTmp = noteTmp.next)
; ;
note = noteTmp; note = noteTmp;
@ -279,26 +268,16 @@ public class NoteList
* *
* @return * @return
*/ */
public int getLen() public int getLen() {
{ return len;} return len;
}
/** /**
* *
* @return * @return
*/ */
public Note getFirst() public Note getFirst() {
{
note = noteBeg; note = noteBeg;
return note; return note;
} }
// /**
// *
// * @return
// */
// public Note getNext()
// {
// if(note != null)
// note = note.next;
// return note;
// }
} }

View File

@ -120,7 +120,7 @@ public class NoteListUtils {
if (timeShift == -1) { if (timeShift == -1) {
timeShift = note.noteTime; timeShift = note.noteTime;
} }
dest.add(new Note(note.noteTime - timeShift, note.c, note.n, note.v, note.length)); dest.add(new Note(note.noteTime - timeShift, note.noteChannel, note.noteLine, note.noteVolume, note.noteLength));
} }
} }
@ -149,23 +149,23 @@ public class NoteListUtils {
Note srcNote; Note srcNote;
for (srcNote = src.searchNoteByTime(tSrcBeg); for (srcNote = src.searchNoteByTime(tSrcBeg);
srcNote != null && srcNote.noteTime <= tSrcEnd; srcNote = srcNote.next) { srcNote != null && srcNote.noteTime <= tSrcEnd; srcNote = srcNote.next) {
if (srcNote.c == chSrc && (srcNote.v == 0 && srcNote.noteTime - srcNote.length >= tSrcBeg if (srcNote.noteChannel == chSrc && (srcNote.noteVolume == 0 && srcNote.noteTime - srcNote.noteLength >= tSrcBeg
|| srcNote.v != 0 && srcNote.noteTime + srcNote.length <= tSrcEnd) || srcNote.noteVolume != 0 && srcNote.noteTime + srcNote.noteLength <= tSrcEnd)
&& (srcNote.v != 0 || onlyMarkSrc)) { && (srcNote.noteVolume != 0 || onlyMarkSrc)) {
if (onlyMarkSrc) { if (onlyMarkSrc) {
srcNote.mark = NOTE_MARKED; srcNote.mark = NOTE_MARKED;
} else { } else {
t = tDestBeg t = tDestBeg
+ ((srcNote.noteTime - tSrcBeg) * destTicksPer4) / srcTicksPer4; + ((srcNote.noteTime - tSrcBeg) * destTicksPer4) / srcTicksPer4;
n = srcNote.n; n = srcNote.noteLine;
len = (srcNote.length * destTicksPer4) / srcTicksPer4; len = (srcNote.noteLength * destTicksPer4) / srcTicksPer4;
dest.add(new Note(t, chDest, n, srcNote.v, len)); dest.add(new Note(t, chDest, n, srcNote.noteVolume, len));
if (len > 0) { if (len > 0) {
dest.add(new Note(t + len, chDest, n, (byte) 0, len)); dest.add(new Note(t + len, chDest, n, (byte) 0, len));
} }
if (undo != null) { 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) { public static void shift(NoteList list, int tBeg, int shiftLen, UndoableAction undo) {
Note note = list.searchNoteByTime(0x7fffffff); Note note = list.searchNoteByTime(0x7fffffff);
for (; note != null && note.noteTime >= tBeg; note = note.prev) { 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; Note noteTmp;
for (noteTmp = note.prev; 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) 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) { 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) { if (noteTmp.noteTime + noteTmp.noteLength < tBeg) {
noteTmp.length = tBeg - noteTmp.noteTime; noteTmp.noteLength = tBeg - noteTmp.noteTime;
} }
note.length = noteTmp.length; note.noteLength = noteTmp.noteLength;
if (undo != null) { 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; note.noteTime += shiftLen;
if (note.noteTime < tBeg) { if (note.noteTime < tBeg) {
if (undo != null && note.v != 0) { if (undo != null && note.noteVolume != 0) {
undo.log2DelNoteList(note.noteTime - shiftLen, note.c, note.n, note.v, note.length); undo.log2DelNoteList(note.noteTime - shiftLen, note.noteChannel, note.noteLine, note.noteVolume, note.noteLength);
undo.log2AddNoteList(tBeg, note.c, note.n, note.v, note.length); undo.log2AddNoteList(tBeg, note.noteChannel, note.noteLine, note.noteVolume, note.noteLength);
} }
note.noteTime = tBeg; note.noteTime = tBeg;
} }
} }
if (undo != null) { 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; byte newN;
for (Note note = undo.getDeletedList().getFirst(); for (Note note = undo.getDeletedList().getFirst();
note != null; note = note.next) { note != null; note = note.next) {
if (note.c == channel && note.v != 0) { if (note.noteChannel == channel && note.noteVolume != 0) {
newTime = note.noteTime + shiftTime; newTime = note.noteTime + shiftTime;
if (newTime < 0) { if (newTime < 0) {
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) { if (tmp < 1) {
tmp = 1; tmp = 1;
} else if (tmp > 127) { } else if (tmp > 127) {
@ -300,13 +300,13 @@ public class NoteListUtils {
} }
newVol = (byte) tmp; 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) { if (note.noteLength > 0) {
dest.add(new Note(newTime + note.length, channel, newN, (byte) 0, note.length)); dest.add(new Note(newTime + note.noteLength, channel, newN, (byte) 0, note.noteLength));
} }
if (undo != null && note.v != 0) { if (undo != null && note.noteVolume != 0) {
undo.log2AddNoteList(newTime, channel, newN, newVol, note.length); undo.log2AddNoteList(newTime, channel, newN, newVol, note.noteLength);
} }
} }

View File

@ -6,17 +6,17 @@ package midedit;
*/ */
public class NoteLong extends Note { public class NoteLong extends Note {
/** Данные ноты */
public byte[] dat;
/** /**
* Êîíñòðóêòîð * Êîíñòðóêòîð
* @param time âðåìÿ * @param time время (позиция) с которой должна воспроизводится нота
* @param data äàííûå * @param data äàííûå
*/ */
public NoteLong(int time, byte[] data) { public NoteLong(int time, byte[] data) {
super(time, (byte) NoteList.CHANNEL_LONG_NOTE, (byte) 0, (byte) 0, 0); super(time, (byte) NoteList.CHANNEL_LONG_NOTE, (byte) 0, (byte) 0, 0);
dat = data; dat = data;
} }
/**
*
*/
public byte[] dat;
} }

View File

@ -58,8 +58,8 @@ public class NotesCanvas extends MixerCanvas {
int x, h; int x, h;
int dx, t = 1; int dx, t = 1;
x = getXInPixel(note.noteTime + shiftTime); x = getXInPixel(note.noteTime + shiftTime);
h = getLineFromNote(note.n + shiftNote); h = getLineFromNote(note.noteLine + shiftNote);
dx = (note.length * wOne) / Constants.timeConst; dx = (note.noteLength * wOne) / Constants.timeConst;
if (dx == 0) { if (dx == 0) {
dx = 2; dx = 2;
} }
@ -76,7 +76,6 @@ public class NotesCanvas extends MixerCanvas {
/** /**
* *
* @param n
* @return * @return
*/ */
protected byte getLineFromNote(int n) { protected byte getLineFromNote(int n) {

View File

@ -1,7 +1,5 @@
package midedit; package midedit;
import javax.microedition.lcdui.*; import javax.microedition.lcdui.*;
import java.io.*; import java.io.*;
@ -9,8 +7,27 @@ import java.io.*;
* *
* @author user * @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;
/** /**
* *
@ -22,24 +39,19 @@ public class PrintSmallFont
* @param color * @param color
* @return * @return
*/ */
public static int print(Graphics g,int num,int dot,int x, int y,int color) public static int print(Graphics g, int num, int dot, int x, int y, int color) {
{ int xLen = 0;
int xLen=0;
int nt = Math.abs(num); int nt = Math.abs(num);
int dig; int dig;
int i;
Image[] imgs = digImages[color]; Image[] imgs = digImages[color];
while(dot>0 && nt/denom[dot] >= nMax[dot]) while (dot > 0 && nt / denom[dot] >= nMax[dot]) {
{
dot--; dot--;
nt /= 10; nt /= 10;
} }
if(dot>0) if (dot > 0) {
{ for (int i = 0; i < dot; ++i, nt /= 10, xLen += digLen) {
for (i = 0; i < dot; ++i, nt /= 10, xLen += digLen)
{
dig = nt % 10; dig = nt % 10;
g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM);
} }
@ -47,15 +59,14 @@ public class PrintSmallFont
g.drawImage(imgs[10], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); g.drawImage(imgs[10], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM);
xLen += digLen; xLen += digLen;
} }
do{ do {
dig = nt % 10; dig = nt % 10;
g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM);
nt /= 10; nt /= 10;
xLen += digLen; xLen += digLen;
}while(nt!=0); } while (nt != 0);
if(num<0) if (num < 0) {
{
dig = 11; dig = 11;
g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM); g.drawImage(imgs[dig], x - xLen, y, Graphics.RIGHT | Graphics.BOTTOM);
xLen += digLen; xLen += digLen;
@ -63,6 +74,7 @@ public class PrintSmallFont
return xLen; return xLen;
} }
/** /**
* *
* @param g * @param g
@ -72,42 +84,15 @@ public class PrintSmallFont
* @param color * @param color
* @return * @return
*/ */
public static int printNote(Graphics g,int n,int x, int y,int color) 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);
g.drawImage(notesImages[color][n],x,y,Graphics.RIGHT|Graphics.BOTTOM);
return noteLen; 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{ static {
try { try {
Image numbers0 = Image.createImage("/img/nums0m.png"); Image numbers0 = Image.createImage("/img/nums0m.png");
Image numbers1 = Image.createImage("/img/nums1m.png"); Image numbers1 = Image.createImage("/img/nums1m.png");
@ -123,54 +108,47 @@ public class PrintSmallFont
int len = 0; int len = 0;
for(int i = 0; i<NUM_CHAR; ++i, len+=digLen) for (int i = 0; i < NUM_CHAR; ++i, len += digLen) {
{ digImages[0][i] = Image.createImage(4, 5);
digImages[0][i] = Image.createImage(4,5);
digImages[0][i].getGraphics(). digImages[0][i].getGraphics().
drawImage(numbers0,-len,0,Graphics.LEFT|Graphics.TOP); drawImage(numbers0, -len, 0, Graphics.LEFT | Graphics.TOP);
} }
len = 0; len = 0;
for(int i = 0; i<NUM_CHAR; ++i, len+=digLen) for (int i = 0; i < NUM_CHAR; ++i, len += digLen) {
{ digImages[1][i] = Image.createImage(4, 5);
digImages[1][i] = Image.createImage(4,5);
digImages[1][i].getGraphics(). digImages[1][i].getGraphics().
drawImage(numbers1,-len,0,Graphics.LEFT|Graphics.TOP); drawImage(numbers1, -len, 0, Graphics.LEFT | Graphics.TOP);
} }
len=0; len = 0;
int lenY=0; int lenY = 0;
for(int i = 0; i<NUM_NOTES; ) for (int i = 0; i < NUM_NOTES;) {
{ notesImages[0][i] = Image.createImage(noteLen, noteLenY);
notesImages[0][i] = Image.createImage(noteLen,noteLenY);
notesImages[0][i].getGraphics(). notesImages[0][i].getGraphics().
drawImage(notes0,-len,-lenY,Graphics.LEFT|Graphics.TOP); drawImage(notes0, -len, -lenY, Graphics.LEFT | Graphics.TOP);
len+=noteLen; len += noteLen;
if(++i==NUM_NOTES_LINE) if (++i == NUM_NOTES_LINE) {
{
lenY = noteLenY; lenY = noteLenY;
len = 0; len = 0;
} }
} }
len =0; len = 0;
lenY=0; lenY = 0;
for(int i = 0; i<NUM_NOTES; ) for (int i = 0; i < NUM_NOTES;) {
{ notesImages[1][i] = Image.createImage(noteLen, noteLenY);
notesImages[1][i] = Image.createImage(noteLen,noteLenY);
notesImages[1][i].getGraphics(). notesImages[1][i].getGraphics().
drawImage(notes1,-len,-lenY,Graphics.LEFT|Graphics.TOP); drawImage(notes1, -len, -lenY, Graphics.LEFT | Graphics.TOP);
len+=noteLen; len += noteLen;
if(++i==NUM_NOTES_LINE) if (++i == NUM_NOTES_LINE) {
{
lenY = noteLenY; lenY = noteLenY;
len = 0; len = 0;
} }
} }
} } catch (IOException ex) {
catch (IOException ex) {
} }
} }
} }

View File

@ -42,7 +42,7 @@ public class TempoList extends List implements CommandListener {
this.addCommand(instempo); this.addCommand(instempo);
this.addCommand(deltempo); this.addCommand(deltempo);
this.addCommand(CompositionForm.back); this.addCommand(CompositionForm.back);
this.setCommandListener(this); this.setCommandListener(TempoList.this);
int tmp; int tmp;
NoteLong notelong; NoteLong notelong;
for (Note note = c.getNoteListByChannel(Composition.DEFAULT_CHANNEL).getFirst(); note != null; note = note.next) { for (Note note = c.getNoteListByChannel(Composition.DEFAULT_CHANNEL).getFirst(); note != null; note = note.next) {

View File

@ -2,42 +2,26 @@ package midedit;
import midedit.media.Composition; import midedit.media.Composition;
/** /**
* *
* @author user * @author user
*/ */
public class UndoableAction public class UndoableAction {
{
private NoteList dellist = null;
private NoteList addlist = null;
/**
*
*/
public static final byte DELETE_LIST = 1; public static final byte DELETE_LIST = 1;
/**
*
*/
public static final byte ADD_LIST = 2; public static final byte ADD_LIST = 2;
/**
*
*/
public static final byte SHIFT_LIST = 3; public static final byte SHIFT_LIST = 3;
/**
*
*/
public static final byte ADD_NOTE = 4; public static final byte ADD_NOTE = 4;
/**
*
*/
public static final byte DEL_NOTE = 5; public static final byte DEL_NOTE = 5;
private static final byte NUM_ACT = 3; private static final byte NUM_ACT = 3;
private NoteList dellist = null;
private NoteList addlist = null;
private Note noteAddDel; private Note noteAddDel;
//private Note note;
private int indOrder=0; private int indOrder = 0;
private int shiftBeg; private int shiftBeg;
private int shiftLen; private int shiftLen;
private byte[] order = new byte[NUM_ACT]; private byte[] order = new byte[NUM_ACT];
@ -46,175 +30,124 @@ public class UndoableAction
private boolean canUndo; private boolean canUndo;
private boolean canRedo; private boolean canRedo;
/** public UndoableAction(Composition c) {
*
* @param c
*/
public UndoableAction(Composition c)
{
composition = c; composition = c;
prepare(); prepare();
} }
/**
* public void addAction(byte n) {
* @param n
*/
public void addAction(byte n)
{
order[indOrder++] = n; order[indOrder++] = n;
canUndo = true; canUndo = true;
canRedo = false; canRedo = false;
} }
/** public NoteList getDeletedList() {
*
* @return
*/
public NoteList getDeletedList()
{
return dellist; return dellist;
} }
/** public void clean() {
*
*/
public void clean()
{
dellist = null; dellist = null;
addlist = null; addlist = null;
indOrder = 0; indOrder = 0;
} }
/**
* public void prepare() {
*/ order[0] = 0;
public void prepare()
{
order[0]=0;
indOrder = 0; indOrder = 0;
dellist = new NoteList(); dellist = new NoteList();
addlist = new NoteList(); addlist = new NoteList();
} }
/** public void logAddNote(Note singleNote) {
* channel = singleNote.noteChannel;
* @param singleNote
*/
public void logAddNote(Note singleNote)
{
channel = singleNote.c;
clean(); clean();
addAction(ADD_NOTE); addAction(ADD_NOTE);
noteAddDel = singleNote; noteAddDel = singleNote;
} }
/**
* public void logDelNote(Note singleNote) {
* @param singleNote channel = singleNote.noteChannel;
*/
public void logDelNote(Note singleNote)
{
channel = singleNote.c;
clean(); clean();
addAction(DEL_NOTE); addAction(DEL_NOTE);
noteAddDel = singleNote; noteAddDel = singleNote;
} }
/** public void log2AddNoteList(int t, byte ch, byte n, byte v, int len) {
* addlist.add(new Note(t, ch, n, v, len));
* @param noteTime
* @param ch
* @param n
* @param v
* @param length
*/
public void log2AddNoteList(int t, byte ch, byte n, byte v,int len)
{
addlist.add(new Note(t,ch,n,v,len));
} }
/**
* public void log2DelNoteList(int t, byte ch, byte n, byte v, int len) {
* @param noteTime dellist.add(new Note(t, ch, n, v, len));
* @param ch
* @param n
* @param v
* @param length
*/
public void log2DelNoteList(int t, byte ch, byte n, byte v,int len)
{
dellist.add(new Note(t,ch,n,v,len));
} }
/**
* public void logShift(int timeBeg, int len, byte ch) {
* @param timeBeg
* @param length
* @param ch
*/
public void logShift(int timeBeg,int len,byte ch)
{
channel = ch; channel = ch;
shiftBeg = timeBeg; shiftBeg = timeBeg;
shiftLen = len; shiftLen = len;
} }
private void doAction()
{ private void doAction() {
NoteList list; NoteList list;
for(int i=indOrder-1; i>=0; --i) for (int i = indOrder - 1; i >= 0; --i) {
switch(order[i]) switch (order[i]) {
{
case ADD_NOTE: case ADD_NOTE:
composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime, noteAddDel.c, composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime, noteAddDel.noteChannel,
noteAddDel.n, noteAddDel.v); noteAddDel.noteLine, noteAddDel.noteVolume);
if(noteAddDel.length != 0) if (noteAddDel.noteLength != 0) {
composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime+noteAddDel.length, composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime + noteAddDel.noteLength,
noteAddDel.c,noteAddDel.n,(byte)0); noteAddDel.noteChannel, noteAddDel.noteLine, (byte) 0);
}
break; break;
case DEL_NOTE: case DEL_NOTE:
composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime,noteAddDel.c, composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime, noteAddDel.noteChannel,
noteAddDel.n,noteAddDel.v,noteAddDel.length)); noteAddDel.noteLine, noteAddDel.noteVolume, noteAddDel.noteLength));
if(noteAddDel.length != 0) if (noteAddDel.noteLength != 0) {
composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime+noteAddDel.length, composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime + noteAddDel.noteLength,
noteAddDel.c,noteAddDel.n, (byte)0,noteAddDel.length)); noteAddDel.noteChannel, noteAddDel.noteLine, (byte) 0, noteAddDel.noteLength));
}
break; break;
case DELETE_LIST: case DELETE_LIST:
Note noteLocal = dellist.getFirst(); Note noteLocal = dellist.getFirst();
if(noteLocal!=null) if (noteLocal != null) {
channel = noteLocal.c; channel = noteLocal.noteChannel;
}
list = composition.getNoteListByChannel(channel); list = composition.getNoteListByChannel(channel);
for(noteLocal = dellist.getFirst(); noteLocal!=null; noteLocal = noteLocal.next) for (noteLocal = dellist.getFirst(); noteLocal != null; noteLocal = noteLocal.next) {
{ list.add(new Note(noteLocal.noteTime, noteLocal.noteChannel, noteLocal.noteLine, noteLocal.noteVolume, noteLocal.noteLength));
list.add(new Note(noteLocal.noteTime,noteLocal.c,noteLocal.n,noteLocal.v,noteLocal.length)); if (noteLocal.noteLength != 0) {
if(noteLocal.length != 0) list.add(new Note(noteLocal.noteTime + noteLocal.noteLength, noteLocal.noteChannel, noteLocal.noteLine, (byte) 0, noteLocal.noteLength));
list.add(new Note(noteLocal.noteTime+noteLocal.length,noteLocal.c,noteLocal.n,(byte)0,noteLocal.length)); }
} }
break; break;
case ADD_LIST: case ADD_LIST:
noteLocal = addlist.getFirst(); noteLocal = addlist.getFirst();
if(noteLocal!=null) if (noteLocal != null) {
channel = noteLocal.c; channel = noteLocal.noteChannel;
}
list = composition.getNoteListByChannel(channel); list = composition.getNoteListByChannel(channel);
for(noteLocal = addlist.getFirst(); noteLocal!=null; noteLocal = noteLocal.next) for (noteLocal = addlist.getFirst(); noteLocal != null; noteLocal = noteLocal.next) {
{ list.delOne(noteLocal.noteTime, noteLocal.noteChannel, noteLocal.noteLine, noteLocal.noteVolume);
list.delOne(noteLocal.noteTime,noteLocal.c,noteLocal.n,noteLocal.v); if (noteLocal.noteLength != 0) {
if(noteLocal.length != 0) list.delOne(noteLocal.noteTime + noteLocal.noteLength, noteLocal.noteChannel, noteLocal.noteLine, (byte) 0);
list.delOne(noteLocal.noteTime+noteLocal.length,noteLocal.c,noteLocal.n,(byte)0); }
} }
break; break;
case SHIFT_LIST: case SHIFT_LIST:
NoteListUtils.shift(composition.getNoteListByChannel(channel),shiftBeg,-shiftLen,null); NoteListUtils.shift(composition.getNoteListByChannel(channel), shiftBeg, -shiftLen, null);
break; break;
} }
}
reverseActOrder(); reverseActOrder();
canUndo = !canUndo; canUndo = !canUndo;
canRedo = !canRedo; canRedo = !canRedo;
} }
private void reverseActOrder() private void reverseActOrder() {
{
byte[] newOrder = new byte[NUM_ACT]; byte[] newOrder = new byte[NUM_ACT];
NoteList newAddlist=addlist, newDellist=dellist; NoteList newAddlist = addlist, newDellist = dellist;
for(int i=0 ; i<indOrder; ++i) for (int i = 0; i < indOrder; ++i) {
switch(order[indOrder - 1 - i]) switch (order[indOrder - 1 - i]) {
{
case ADD_NOTE: case ADD_NOTE:
newOrder[i] = DEL_NOTE; newOrder[i] = DEL_NOTE;
break; break;
@ -234,24 +167,27 @@ public class UndoableAction
shiftLen = -shiftLen; shiftLen = -shiftLen;
break; break;
} }
}
addlist = newAddlist; addlist = newAddlist;
dellist = newDellist; dellist = newDellist;
order = newOrder; order = newOrder;
} }
/** /**
* *
*/ */
public void undo() public void undo() {
{ if (canUndo) {
if(canUndo)
doAction(); doAction();
} }
}
/** /**
* *
*/ */
public void redo() public void redo() {
{ if (canRedo) {
if(canRedo)
doAction(); doAction();
} }
}
} }

View File

@ -33,7 +33,7 @@ public class VolumeForm extends Form implements CommandListener {
* @param back * @param back
*/ */
public VolumeForm(Composition c, Vector chans, MixerModel m, Displayable back) { public VolumeForm(Composition c, Vector chans, MixerModel m, Displayable back) {
super("Volume"); super(L.str[L.volume]);
composition = c; composition = c;
channels = chans; channels = chans;
model = m; model = m;
@ -48,12 +48,12 @@ public class VolumeForm extends Form implements CommandListener {
soloChecks = new ChoiceGroup[size]; soloChecks = new ChoiceGroup[size];
volumeGauges = new Gauge[size]; volumeGauges = new Gauge[size];
String[] muteString = new String[1]; String[] muteString = new String[1];
muteString[0] = "Solo"; muteString[0] = L.str[L.solo];
String gaugeString = ""; String gaugeString = "";
boolean[] solo = composition.getSoloList(); boolean[] solo = composition.getSoloList();
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
byte channel = ((Byte) channels.elementAt(i)).byteValue(); 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), Constants.getInstrName(composition.getInstrument(channel) + 1),
Choice.MULTIPLE, muteString, null); Choice.MULTIPLE, muteString, null);
soloChecks[i].setSelectedIndex(0, solo[channel]); soloChecks[i].setSelectedIndex(0, solo[channel]);

View File

@ -4,6 +4,7 @@ import java.io.*;
import java.util.*; import java.util.*;
import javax.microedition.io.*; import javax.microedition.io.*;
import javax.microedition.io.file.*; import javax.microedition.io.file.*;
import main.L;
import main.Rms; import main.Rms;
/** /**
@ -149,7 +150,6 @@ public class JSR75File extends AbstractFile {
*/ */
public int open(String fileName, boolean isSaveMode) throws IOException { public int open(String fileName, boolean isSaveMode) throws IOException {
String fullName; String fullName;
System.out.println("JSR75File.java : 169 "+fileName);
if (fileName.charAt(0) != '/') { if (fileName.charAt(0) != '/') {
try { try {
Enumeration e = FileSystemRegistry.listRoots(); Enumeration e = FileSystemRegistry.listRoots();
@ -248,7 +248,7 @@ public class JSR75File extends AbstractFile {
* @return * @return
*/ */
public String getAns() { public String getAns() {
return "save ok"; return L.str[L.saved];
} }
} }

View File

@ -3,6 +3,7 @@ package midedit.io;
import java.io.*; import java.io.*;
import java.util.Vector; import java.util.Vector;
import javax.microedition.rms.*; import javax.microedition.rms.*;
import main.L;
/** /**
* <p>Title: </p> * <p>Title: </p>
@ -141,10 +142,6 @@ public class RMSFile extends AbstractFile {
return 0; return 0;
} }
// public int checkFileName(String fileName) throws IOException
// {
// return 0;
// }
public int delete(String fileName) throws IOException { public int delete(String fileName) throws IOException {
String name = getLastName(fileName); String name = getLastName(fileName);
try { try {
@ -153,17 +150,13 @@ public class RMSFile extends AbstractFile {
} }
return 0; return 0;
} }
/*protected String getPrefix()
{
return "";
}*/
public String getURL() { public String getURL() {
return lastPath; return lastPath;
} }
public String getAns() { public String getAns() {
return "RMS save ok"; return "RMS: "+L.str[L.saved];
} }
public static String getLastName(String fullName) { public static String getLastName(String fullName) {

View File

@ -269,8 +269,8 @@ public class Composition {
public void addNoteOff(int tt, byte ch, byte nn) { public void addNoteOff(int tt, byte ch, byte nn) {
Note noteTmp = tracks[ch].searchBack(ch, nn); Note noteTmp = tracks[ch].searchBack(ch, nn);
if (noteTmp != null) { if (noteTmp != null) {
noteTmp.length = tt - noteTmp.noteTime; noteTmp.noteLength = tt - noteTmp.noteTime;
tracks[ch].add(new Note(tt, ch, nn, (byte) 0, noteTmp.length)); tracks[ch].add(new Note(tt, ch, nn, (byte) 0, noteTmp.noteLength));
} else { } else {
tracks[ch].add(new Note(tt, ch, nn, (byte) 0, 0)); 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) { for (int i = 0; i < Constants.NCHANNEL; ++i) {
Note noteTimeMax = this.getFirstNote(0x7fffffff, i); Note noteTimeMax = this.getFirstNote(0x7fffffff, i);
if (noteTimeMax != null) { if (noteTimeMax != null) {
tCur = noteTimeMax.noteTime + noteTimeMax.length; tCur = noteTimeMax.noteTime + noteTimeMax.noteLength;
if (tCur > tMax) { if (tCur > tMax) {
tMax = tCur; tMax = tCur;
} }

View File

@ -326,7 +326,7 @@ public class FileManager extends Canvas {
P.path = pathFile; P.path = pathFile;
String openSaveString = Main.midlet.compositionForm.getCompositionName(); String openSaveString = Main.midlet.compositionForm.getCompositionName();
int indBeg = openSaveString.lastIndexOf(midedit.Constants.FILE_DELIM); int indBeg = openSaveString.lastIndexOf('/');
int indEnd = openSaveString.lastIndexOf('.'); int indEnd = openSaveString.lastIndexOf('.');
if (indEnd == -1) { if (indEnd == -1) {
indEnd = openSaveString.length(); indEnd = openSaveString.length();
@ -397,7 +397,7 @@ public class FileManager extends Canvas {
} }
Main.midlet.compositionForm = null; Main.midlet.compositionForm = null;
System.gc(); System.gc();
//
String openSaveString = pathFile + s; String openSaveString = pathFile + s;
Main.midlet.compositionForm = new CompositionForm(Main.midlet, openSaveString); Main.midlet.compositionForm = new CompositionForm(Main.midlet, openSaveString);
Main.dsp.setCurrent(Main.midlet.compositionForm); Main.dsp.setCurrent(Main.midlet.compositionForm);

View File

@ -30,8 +30,6 @@ public class Menu extends Canvas {
/** Ðàçìåð ýêðàíà */ /** Ðàçìåð ýêðàíà */
private int w, h; private int w, h;
/** Ďđĺäűäóůčé ýęđŕí, ęóäŕ áóäĺě âîçâđŕůŕňüń˙ ďđč íŕćŕňčč Íŕçŕä */
private Displayable pr;
/** Ìåíþ */ /** Ìåíþ */
private String[] menu; private String[] menu;
@ -75,8 +73,8 @@ public class Menu extends Canvas {
public void addNewItems() { public void addNewItems() {
menu = new String[] { menu = new String[] {
L.str[L.create],
L.str[L.resume], L.str[L.resume],
L.str[L.create],
L.str[L.open], L.str[L.open],
L.str[L.save], L.str[L.save],
L.str[L.saveAs], L.str[L.saveAs],

View File

@ -9,7 +9,7 @@ import main.*;
*/ */
public class SettingsForm extends Form implements CommandListener { 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[] langInstrList = {"English", "Ðóññêèé"};
private static final String[] langChars = {"en", "ru", "ua"}; 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.languageApp = langChars[langChoice.getSelectedIndex()];
Rms.languageInstr = langChars[langInstr.getSelectedIndex()]; Rms.languageInstr = langChars[langInstr.getSelectedIndex()];
//L.readLang(Rms.languageApp, true);
//L.readLang(Rms.languageInstr, false);
Rms.tempDir = tempDirField.getString(); Rms.tempDir = tempDirField.getString();
Rms.noteWidth = noteWidthGauge.getValue(); Rms.noteWidth = noteWidthGauge.getValue() + 1;
Rms.noteHeight = noteHeightGauge.getValue(); Rms.noteHeight = noteHeightGauge.getValue() + 1;
Rms.numKeysEdit = controlChoice.isSelected(0); Rms.numKeysEdit = controlChoice.isSelected(0);
Main.dsp.setCurrent(previousScreen); Main.dsp.setCurrent(previousScreen);