05
This commit is contained in:
parent
bd3ac77767
commit
76bdc22597
@ -127,7 +127,6 @@ Telephone ring
|
|||||||
Helicopter
|
Helicopter
|
||||||
Applause
|
Applause
|
||||||
Gunshot
|
Gunshot
|
||||||
|
|
||||||
Piano
|
Piano
|
||||||
Chromatic percussion
|
Chromatic percussion
|
||||||
Organ
|
Organ
|
||||||
@ -144,7 +143,6 @@ Synth sfx
|
|||||||
Ethnic misc
|
Ethnic misc
|
||||||
Percussive
|
Percussive
|
||||||
Sfx
|
Sfx
|
||||||
|
|
||||||
Highq
|
Highq
|
||||||
Slap
|
Slap
|
||||||
Scratch push
|
Scratch push
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
Клавинет (клавесин 2)
|
Клавинет (клавесин 2)
|
||||||
Челеста
|
Челеста
|
||||||
Колокольчики (бутылки)
|
Колокольчики (бутылки)
|
||||||
'Музыкальная шкатулка'
|
Музыкальная шкатулка
|
||||||
Вибрафон
|
Вибрафон
|
||||||
Маримба
|
Маримба
|
||||||
Ксилофон
|
Ксилофон
|
||||||
@ -54,7 +54,7 @@
|
|||||||
Хор на слог 'а'
|
Хор на слог 'а'
|
||||||
Голос на слог 'о'
|
Голос на слог 'о'
|
||||||
Синтетический голос
|
Синтетический голос
|
||||||
'Удар' (весь оркестр)
|
Удар (весь оркестр)
|
||||||
Труба
|
Труба
|
||||||
Тромбон
|
Тромбон
|
||||||
Туба
|
Туба
|
||||||
@ -90,7 +90,7 @@ Charang-гитара
|
|||||||
Синтезаторный звук нью-эйдж
|
Синтезаторный звук нью-эйдж
|
||||||
Теплый синт-звук
|
Теплый синт-звук
|
||||||
Полисинтезатор
|
Полисинтезатор
|
||||||
Синт-'хор'
|
Синт-хор
|
||||||
Воздушный (смычковый синт-звук)
|
Воздушный (смычковый синт-звук)
|
||||||
Металлический синт
|
Металлический синт
|
||||||
Ореол
|
Ореол
|
||||||
@ -127,7 +127,6 @@ Charang-гитара
|
|||||||
Вертолет
|
Вертолет
|
||||||
Алодисменты
|
Алодисменты
|
||||||
Выстрел
|
Выстрел
|
||||||
|
|
||||||
Фортепиано
|
Фортепиано
|
||||||
Хроматиккаа и Перкуссия
|
Хроматиккаа и Перкуссия
|
||||||
Орган
|
Орган
|
||||||
@ -144,7 +143,6 @@ Charang-гитара
|
|||||||
Народные
|
Народные
|
||||||
Перкуссия
|
Перкуссия
|
||||||
Звуковые эффекты
|
Звуковые эффекты
|
||||||
|
|
||||||
Высокое Q
|
Высокое Q
|
||||||
Слэп
|
Слэп
|
||||||
Царапанье (от себя)
|
Царапанье (от себя)
|
||||||
|
@ -94,3 +94,5 @@ Nums, otherwise keypad, when edit notes
|
|||||||
Name
|
Name
|
||||||
Temp directory
|
Temp directory
|
||||||
New folder
|
New folder
|
||||||
|
Memory
|
||||||
|
MidEdit
|
@ -66,8 +66,8 @@ Ok
|
|||||||
Вставить Темп
|
Вставить Темп
|
||||||
Удалить Темп
|
Удалить Темп
|
||||||
Темп
|
Темп
|
||||||
Время(Мера)
|
Время (мера)
|
||||||
Поиск
|
Позиция
|
||||||
числитель
|
числитель
|
||||||
знаменатель(2 в степени)
|
знаменатель(2 в степени)
|
||||||
Метр = числитель/ (2^знаменатель). Например, используйте 4/4 (numerator=4; denominator=2) или 6/8 (numerator=6; denominator=3)
|
Метр = числитель/ (2^знаменатель). Например, используйте 4/4 (numerator=4; denominator=2) или 6/8 (numerator=6; denominator=3)
|
||||||
@ -86,7 +86,7 @@ Ok
|
|||||||
Заменить
|
Заменить
|
||||||
Наложить
|
Наложить
|
||||||
Очистить буфер
|
Очистить буфер
|
||||||
Подсказка
|
Помощь
|
||||||
Клавиши
|
Клавиши
|
||||||
Быстрые команды
|
Быстрые команды
|
||||||
Навигация
|
Навигация
|
||||||
@ -94,3 +94,5 @@ Ok
|
|||||||
Имя
|
Имя
|
||||||
Временная папка
|
Временная папка
|
||||||
Новая папка
|
Новая папка
|
||||||
|
Память
|
||||||
|
MidEdit
|
BIN
res/test.mid
Normal file
BIN
res/test.mid
Normal file
Binary file not shown.
@ -107,7 +107,9 @@ public class L {
|
|||||||
numkeysOptionString = 92,
|
numkeysOptionString = 92,
|
||||||
midiName = 93,
|
midiName = 93,
|
||||||
tempDir = 94,
|
tempDir = 94,
|
||||||
newFolder = 95;
|
newFolder = 95,
|
||||||
|
memory = 96,
|
||||||
|
midedit = 97;
|
||||||
|
|
||||||
|
|
||||||
/** Ìàññèâ òåêñòîâûõ ìåòîê */
|
/** Ìàññèâ òåêñòîâûõ ìåòîê */
|
||||||
|
@ -40,6 +40,7 @@ public class Rms {
|
|||||||
dos.writeInt(noteWidth);
|
dos.writeInt(noteWidth);
|
||||||
dos.writeInt(noteHeight);
|
dos.writeInt(noteHeight);
|
||||||
dos.writeBoolean(numKeysEdit);
|
dos.writeBoolean(numKeysEdit);
|
||||||
|
dos.writeUTF(P.path); // ïóòü â ôì
|
||||||
dos.flush();
|
dos.flush();
|
||||||
options = baos.toByteArray();
|
options = baos.toByteArray();
|
||||||
dos.close();
|
dos.close();
|
||||||
@ -81,6 +82,7 @@ public class Rms {
|
|||||||
noteWidth = dis.readInt();
|
noteWidth = dis.readInt();
|
||||||
noteHeight = dis.readInt();
|
noteHeight = dis.readInt();
|
||||||
numKeysEdit = dis.readBoolean();
|
numKeysEdit = dis.readBoolean();
|
||||||
|
P.path = dis.readUTF();
|
||||||
dis.close();
|
dis.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,22 @@
|
|||||||
MIDedit 2.1 / 3.0
|
MIDedit 2.1 / 3.0
|
||||||
|
|
||||||
По просьбе одного человека, на основе исходников 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
|
||||||
- Исправления в локализации.
|
- Исправления в локализации.
|
||||||
- Новое графическое меню. Убраны лишние пункты при запуске.
|
- Новое графическое меню. Убраны лишние пункты при запуске.
|
||||||
- Добавлен графический файловый менеджер, показывающий только те файлы, с которыми работает программа.
|
- Добавлен графический файловый менеджер, показывающий только те файлы, с которыми работает программа. Сделано запоминание последнего пути.
|
||||||
- Добавлена возможность прослушивания мелодии и создания новой папки в файлменеджере.
|
- Добавлена возможность прослушивания мелодии и создания новой папки в файлменеджере.
|
||||||
- Некоторые экраны (в основном помощи) изменены на графические.
|
- Некоторые экраны (в основном помощи) изменены на графические.
|
||||||
|
|
||||||
********
|
********
|
||||||
Добавить украинский язык.
|
Добавить украинский язык.
|
||||||
Help в aNMPWR
|
Help в aNMPWR
|
||||||
player.realize
|
********
|
||||||
|
Не работает добавить инструмент/заменить, нельзя прослушать инстумент при выборе.
|
||||||
|
|
||||||
|
- курсор редактора во время проигрывания бежит быстрее, чем фактически играет композиция. До этого настройки размера длины и ширины ноты были изменены. Возможно, скорость курсора была привязана к определенному размеру ячеек.
|
||||||
|
|
||||||
|
|
||||||
|
++++
|
||||||
|
Вот второй тест. Добавлено подтверждение при удалении файла, исправлен сдвиг в текстовых метках ударных, исправлен баг с однотипными иконками при смене языка.
|
@ -7,84 +7,118 @@ import javax.microedition.lcdui.*;
|
|||||||
import main.L;
|
import main.L;
|
||||||
import main.P;
|
import main.P;
|
||||||
import main.Main;
|
import main.Main;
|
||||||
|
import ui.WaitCanvas;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Ôîðìà óïðàâëåíèÿ êîìïîçèöèÿìè
|
||||||
* @author user
|
* @author user
|
||||||
|
* @author aNNiMON (ìîä)
|
||||||
*/
|
*/
|
||||||
public class CompositionForm extends Form implements CommandListener, Runnable, ItemCommandListener {
|
public class CompositionForm extends Form implements CommandListener, Runnable, ItemCommandListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Êîëè÷åñòâî ãðóïï èñíòðóìåíòîâ.
|
||||||
|
* Èñïîëüçóåòñÿ â ôîðìå âûáîðà ïðè äîáàâëåíèè/çàìåíå èíñòðóìåíòà
|
||||||
*/
|
*/
|
||||||
public static CompositionForm curForm;
|
private static final int GROUPS_OF_INSTRUMENTS = 16;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Êîëè÷åñòâî èíñòðóìåíòîâ íà ãðóïïó.
|
||||||
|
* Èñïîëüçóåòñÿ â ôîðìå âûáîðà ïðè äîáàâëåíèè/çàìåíå èíñòðóìåíòà
|
||||||
|
*/
|
||||||
|
private static final int INSTRUMENTS_IN_GROUP = 8;
|
||||||
|
|
||||||
|
/** Ìàêñèìàëüíîå êîëè÷åñòâî øàãîâ ïðîïóñêà */
|
||||||
private static final byte SEEK_GAUGE_MAX = 10;
|
private static final byte SEEK_GAUGE_MAX = 10;
|
||||||
private byte seekGaugeCur = 0;
|
|
||||||
private Main control;
|
|
||||||
private MixerModel model;
|
/** Ñîñòîÿíèå âîñïðîèçâåäåíèÿ */
|
||||||
private Display display;
|
public static boolean isPlaying;
|
||||||
private NotesCanvas notesCanvas;
|
|
||||||
private DrumsCanvas drumsCanvas;
|
|
||||||
private MixerCanvas curCanvas;
|
/**
|
||||||
private ChannelChoiceGroup choiseInstrument;
|
* Ôîðìà âûáîðà èíñòðóìåíòîâ
|
||||||
private Gauge seekingGauge;
|
* Èñïîëüçóåòñÿ ïðè äîáàâëåíèè/çàìåíå èíñòðóìåíòà.
|
||||||
|
* Ñòàòè÷åñêàÿ ïåðåìåííàÿ âçÿòà äëÿ îïòèìèçàöèè, ÷òîáû êàæäûé ðàç íå ãåíåðèðîâàòü.
|
||||||
|
*/
|
||||||
private static Form listInstrumentsForm;
|
private static Form listInstrumentsForm;
|
||||||
|
|
||||||
|
/** Ýêçìåïëÿð ìèäëåòà */
|
||||||
|
private Main control;
|
||||||
|
|
||||||
|
/** Îáúåêò äèñïëåÿ */
|
||||||
|
private Display display;
|
||||||
|
|
||||||
|
/** Êëàññ ìåíåäæåðà âîñïðîèçâåäåíèÿ */
|
||||||
|
private MixerModel model;
|
||||||
|
|
||||||
|
/** Êîìïîçèöèÿ */
|
||||||
private Composition composition;
|
private Composition composition;
|
||||||
|
|
||||||
|
/** Ýêðàí ðåäàêòèðîâàíèÿ íîò */
|
||||||
|
private NotesCanvas notesCanvas;
|
||||||
|
/** Ýêðàí ðåäàêòèðîâàíèÿ áàðàáàíîâ */
|
||||||
|
private DrumsCanvas drumsCanvas;
|
||||||
|
/** Îáùèé ýêðàí ðåäàêòèðîâàíèÿ */
|
||||||
|
private MixerCanvas curCanvas;
|
||||||
|
|
||||||
|
/** Âûáîð èíñòðóìåíòà */
|
||||||
|
private ChannelChoiceGroup choiñeInstrument;
|
||||||
|
|
||||||
|
/** Ïðîïóñê ïðè ðåäàêòèðîâàíèè ìåëîäèè */
|
||||||
|
private Gauge seekingGauge;
|
||||||
|
|
||||||
|
/** Èìÿ ðåäàêòèðóåìîãî ôàéëà */
|
||||||
private String fileName;
|
private String fileName;
|
||||||
public static boolean isPlaying,
|
|
||||||
isWorking,
|
/** Òåêóùåå êîëè÷åñòâî øàãîâ ïðîïóñêà */
|
||||||
isNew = false,
|
private byte seekGaugeCur = 0;
|
||||||
isAdd;
|
|
||||||
private Command addInstrument = new Command(L.str[L.addInstrument], Command.HELP, 3),
|
/** Ñîçäà¸ì ëè íîâûé ôàéë */
|
||||||
edit = new Command(L.str[L.edit], Command.HELP, 1),
|
private boolean isNew = false;
|
||||||
setInstrument = new Command(L.str[L.setInstrument], Command.ITEM, 1),
|
/** Äîáàâèòü èëè çàìåíèòü èíñòðóìåíò */
|
||||||
delInstrument = new Command(L.str[L.delInstrument], Command.ITEM, 2),
|
private boolean isAdd;
|
||||||
temp = new Command(L.str[L.tempoBox], Command.ITEM, 3),
|
|
||||||
volume = new Command(L.str[L.volumeBox], Command.ITEM, 4),
|
/** Êîìàíäû */
|
||||||
meter = new Command(L.str[L.meter], Command.ITEM, 5),
|
public static Command play = new Command(L.str[L.play], Command.ITEM, 1);
|
||||||
rmsMode = new Command(L.str[L.RMS], Command.ITEM, 6),
|
public static Command stop = new Command(L.str[L.stop], Command.BACK, 0);
|
||||||
jsr75Mode = new Command(L.str[L.file], Command.ITEM, 7);
|
public static Command back = new Command(L.str[L.back], Command.BACK, 2);
|
||||||
|
public static Command ok = new Command(L.str[L.ok], Command.ITEM, 1);
|
||||||
|
|
||||||
|
private Command edit = new Command(L.str[L.edit], Command.ITEM, 1);
|
||||||
|
private Command addInstrument = new Command(L.str[L.addInstrument], Command.ITEM, 2);
|
||||||
|
private Command setInstrument = new Command(L.str[L.setInstrument], Command.ITEM, 3);
|
||||||
|
private Command delInstrument = new Command(L.str[L.delInstrument], Command.ITEM, 4);
|
||||||
|
private Command temp = new Command(L.str[L.tempoBox], Command.ITEM, 5);
|
||||||
|
private Command volume = new Command(L.str[L.volumeBox], Command.ITEM, 6);
|
||||||
|
private Command meter = new Command(L.str[L.meter], Command.ITEM, 7);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Êîíñòðóêòîð
|
||||||
*/
|
* @param control ýêçìåïëÿð ãëàâíîãî êëàññà
|
||||||
public static Command play = new Command(L.str[L.play], Command.ITEM, 1),
|
|
||||||
playOrig = new Command(L.str[L.playOrigin], Command.ITEM, 1),
|
|
||||||
stop = new Command(L.str[L.stop], Command.BACK, 0),
|
|
||||||
back = new Command(L.str[L.back], Command.BACK, 2),
|
|
||||||
//cancel = new Command("Cancel",Command.BACK,1),
|
|
||||||
ok = new Command(L.str[L.ok], Command.ITEM, 1);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param ctrl
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public CompositionForm(Main ctrl) throws Exception {
|
public CompositionForm(Main control) throws Exception {
|
||||||
this(ctrl, null);
|
this(control, null);
|
||||||
isNew = true;
|
isNew = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Êîíñòðóêòîð
|
||||||
* @param ctrl
|
* @param control ýêçìåïëÿð ãëàâíîãî êëàññà
|
||||||
* @param fName
|
* @param fName èìÿ ôàéëà
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public CompositionForm(Main ctrl, String fName) throws Exception {
|
public CompositionForm(Main control, String fName) throws Exception {
|
||||||
super((fName != null) ? fName : "New");
|
super((fName != null) ? fName : "New");
|
||||||
control = ctrl;
|
this.control = control;
|
||||||
model = control.getModel();
|
model = control.getModel();
|
||||||
model.crossPlayer.setCommandForm(this);
|
model.crossPlayer.setCommandForm(CompositionForm.this);
|
||||||
fileName = fName;
|
fileName = fName;
|
||||||
curForm = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Íîâûé ëè ôàéë ñîçäà¸ì
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isNew() {
|
public boolean isNew() {
|
||||||
@ -92,7 +126,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Óñòàíîâèòü, íîâàÿ ëè êîìïîçèöèÿ
|
||||||
* @param isNewComposition
|
* @param isNewComposition
|
||||||
*/
|
*/
|
||||||
public void setNew(boolean isNewComposition) {
|
public void setNew(boolean isNewComposition) {
|
||||||
@ -108,27 +142,18 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
display.setCurrent(this);
|
display.setCurrent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
// public boolean isntCancel() {
|
|
||||||
// return isWorking;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
display = main.Main.dsp;
|
display = main.Main.dsp;
|
||||||
|
|
||||||
WaitForm waitForm = new WaitForm(L.str[L.opening],//@@@
|
WaitCanvas waitCanvas = new WaitCanvas(L.str[L.opening],
|
||||||
model.getWaitableFile(),
|
model.getWaitableFile(),
|
||||||
control.getCurrentlistMenu(),
|
control.getCurrentlistMenu());
|
||||||
model);
|
display.setCurrent(waitCanvas);
|
||||||
display.setCurrent(waitForm);
|
|
||||||
model.resetProgress();
|
model.resetProgress();
|
||||||
new Thread(waitForm).start();
|
new Thread(waitCanvas).start();
|
||||||
try {
|
try {
|
||||||
composition = model.openMix(fileName);
|
composition = model.openMix(fileName);
|
||||||
buildContent();
|
buildContent();
|
||||||
@ -138,13 +163,10 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
display.setCurrent(CompositionForm.this);
|
display.setCurrent(CompositionForm.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
isWorking = true;
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Alert a = new Alert(L.str[L.error], L.str[L.openError] + "\n" + ex, null, null);//@@@
|
Alert a = new Alert(L.str[L.error], L.str[L.openError] + "\n" + ex, null, null);//@@@
|
||||||
a.setTimeout(Alert.FOREVER);
|
a.setTimeout(Alert.FOREVER);
|
||||||
waitForm.cancel();
|
waitCanvas.cancel();
|
||||||
isWorking = false;
|
|
||||||
control.setCurrentlistMenu(a);
|
control.setCurrentlistMenu(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,8 +181,6 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void buildContent() throws Exception {
|
private void buildContent() throws Exception {
|
||||||
|
|
||||||
//Constants constants = new Constants();
|
|
||||||
notesCanvas = null;
|
notesCanvas = null;
|
||||||
drumsCanvas = null;
|
drumsCanvas = null;
|
||||||
curCanvas = null;
|
curCanvas = null;
|
||||||
@ -172,11 +192,12 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
throw new Exception("instruments == null");
|
throw new Exception("instruments == null");
|
||||||
}
|
}
|
||||||
|
|
||||||
choiseInstrument = new ChannelChoiceGroup(L.str[L.menu], instrumentsStrings, this.buildChansList());
|
choiñeInstrument = new ChannelChoiceGroup(L.str[L.menu], instrumentsStrings, this.buildChansList());
|
||||||
if (choiseInstrument == null) {
|
if (choiñeInstrument == null) {
|
||||||
throw new Exception("choiseInstrument==null");
|
throw new Exception("choiñeInstrument == null");
|
||||||
}
|
}
|
||||||
this.append(choiseInstrument);
|
|
||||||
|
this.append(choiñeInstrument);
|
||||||
seekingGauge = new Gauge(L.str[L.seek], true, SEEK_GAUGE_MAX, 0);
|
seekingGauge = new Gauge(L.str[L.seek], true, SEEK_GAUGE_MAX, 0);
|
||||||
this.append(seekingGauge);
|
this.append(seekingGauge);
|
||||||
this.addCommand(edit);
|
this.addCommand(edit);
|
||||||
@ -189,7 +210,6 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
this.addCommand(setInstrument);
|
this.addCommand(setInstrument);
|
||||||
this.addCommand(delInstrument);
|
this.addCommand(delInstrument);
|
||||||
this.addCommand(back);
|
this.addCommand(back);
|
||||||
//this.addCommand(rmsMode);
|
|
||||||
this.setCommandListener(this);
|
this.setCommandListener(this);
|
||||||
P.isRMSMode = true;
|
P.isRMSMode = true;
|
||||||
}
|
}
|
||||||
@ -217,12 +237,6 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
* @param c
|
* @param c
|
||||||
* @param i
|
* @param i
|
||||||
*/
|
*/
|
||||||
//public void itemStateChanged(Item item){
|
|
||||||
//System.out.println ("itemStateChanged");
|
|
||||||
//if (item instanceof Choice){
|
|
||||||
// int instNum = ((Choice) item).getSelectedIndex();
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
public void commandAction(Command c, Item i) {
|
public void commandAction(Command c, Item i) {
|
||||||
String instrName;
|
String instrName;
|
||||||
int instrumNum;
|
int instrumNum;
|
||||||
@ -235,30 +249,30 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
instrName = ((ChoiceGroup) i).getString(((ChoiceGroup) i).getSelectedIndex());
|
instrName = ((ChoiceGroup) i).getString(((ChoiceGroup) i).getSelectedIndex());
|
||||||
instrumNum = Constants.instrVectorArr.indexOf(instrName)+1;
|
instrumNum = Constants.instrVectorArr.indexOf(instrName)+1;
|
||||||
}
|
}
|
||||||
// System.out.println("instrName = " + instrName);
|
|
||||||
// System.out.println("instrumNum = " + instrumNum);
|
|
||||||
if (c == play) {
|
if (c == play) {
|
||||||
int channel = -1;
|
int channel = -1;
|
||||||
int lengthOfChannel = 0;
|
int lengthOfChannel = 0;
|
||||||
try {
|
try {
|
||||||
channel = choiseInstrument.getSelectedChannel();
|
channel = choiñeInstrument.getSelectedChannel();
|
||||||
lengthOfChannel = composition.tracks[channel].getLen();
|
lengthOfChannel = composition.tracks[channel].getLen();
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException ex) {
|
||||||
//ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
//System.out.println ("Channel="+channel+" length="+lengthOfChannel);
|
|
||||||
if (channel == Constants.DRUMS_CHANNEL || isAdd || lengthOfChannel < 3) {
|
if (channel == Constants.DRUMS_CHANNEL || isAdd || lengthOfChannel < 3) {
|
||||||
try {
|
try {
|
||||||
model.playTest((byte) (instrumNum - 1));
|
model.playTest((byte) (instrumNum - 1));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
model.playTrack(composition, channel, instrumNum - 1);
|
model.playTrack(composition, channel, instrumNum - 1);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
try {
|
try {
|
||||||
model.playTest((byte) (instrumNum - 1));
|
model.playTest((byte) (instrumNum - 1));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,7 +280,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
if (isAdd) {
|
if (isAdd) {
|
||||||
byte channel = composition.addInstrument(instrumNum - 1);
|
byte channel = composition.addInstrument(instrumNum - 1);
|
||||||
if (channel != -1) {
|
if (channel != -1) {
|
||||||
choiseInstrument.appendChannel(instrName, channel);
|
choiñeInstrument.appendChannel(instrName, channel);
|
||||||
} else {
|
} else {
|
||||||
Alert a = new Alert(L.str[L.listInstruments], L.str[L.impossible], null, null);
|
Alert a = new Alert(L.str[L.listInstruments], L.str[L.impossible], null, null);
|
||||||
display.setCurrent(a);
|
display.setCurrent(a);
|
||||||
@ -277,13 +291,13 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
int channel = choiseInstrument.getSelectedChannel();
|
int channel = choiñeInstrument.getSelectedChannel();
|
||||||
if (channel != -1 && channel != Constants.DRUMS_CHANNEL) {
|
if (channel != -1 && channel != Constants.DRUMS_CHANNEL) {
|
||||||
choiseInstrument.setChannel(choiseInstrument.getSelectedIndex(), instrName, (byte) channel);
|
choiñeInstrument.setChannel(choiñeInstrument.getSelectedIndex(), instrName, (byte) channel);
|
||||||
composition.setInstrument(channel, instrumNum - 1);
|
composition.setInstrument(channel, instrumNum - 1);
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException ex) {
|
||||||
//ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
display.setCurrent(CompositionForm.this);
|
display.setCurrent(CompositionForm.this);
|
||||||
@ -296,18 +310,13 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
* @param displayable
|
* @param displayable
|
||||||
*/
|
*/
|
||||||
public void commandAction(Command command, Displayable displayable) {
|
public void commandAction(Command command, Displayable displayable) {
|
||||||
// System.out.println("displayable = " + displayable);
|
|
||||||
// System.out.println("command = " + command);
|
|
||||||
// if (command!=delInstrument) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
int newVal = seekingGauge.getValue();
|
int newVal = seekingGauge.getValue();
|
||||||
if (newVal != seekGaugeCur) {
|
if (newVal != seekGaugeCur) {
|
||||||
byte channel=0;
|
byte channel=0;
|
||||||
try {
|
try {
|
||||||
channel = choiseInstrument.getSelectedChannel();
|
channel = choiñeInstrument.getSelectedChannel();
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException ex) {
|
||||||
//ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
composition.setCurW(seekingGauge.getValue() * 100 / SEEK_GAUGE_MAX, channel);
|
composition.setCurW(seekingGauge.getValue() * 100 / SEEK_GAUGE_MAX, channel);
|
||||||
@ -319,7 +328,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
try {
|
try {
|
||||||
model.playMix(composition, 0);
|
model.playMix(composition, 0);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
msg("" + e);
|
msg(e.getMessage());
|
||||||
}
|
}
|
||||||
} else if (command == P.comCancel) {
|
} else if (command == P.comCancel) {
|
||||||
model.stopPlay();
|
model.stopPlay();
|
||||||
@ -329,7 +338,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
} else if (command == edit) {
|
} else if (command == edit) {
|
||||||
int channel;
|
int channel;
|
||||||
try {
|
try {
|
||||||
channel = choiseInstrument.getSelectedChannel();
|
channel = choiñeInstrument.getSelectedChannel();
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException ex) {
|
||||||
channel = -1;
|
channel = -1;
|
||||||
}
|
}
|
||||||
@ -364,18 +373,18 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
} else if (command == delInstrument) {
|
} else if (command == delInstrument) {
|
||||||
byte channel;
|
byte channel;
|
||||||
try {
|
try {
|
||||||
channel = choiseInstrument.getSelectedChannel();
|
channel = choiñeInstrument.getSelectedChannel();
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException ex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
choiseInstrument.deleteChannel(choiseInstrument.getSelectedIndex());
|
choiñeInstrument.deleteChannel(choiñeInstrument.getSelectedIndex());
|
||||||
composition.setInstrument(channel, Composition.NOTHING);
|
composition.setInstrument(channel, Composition.NOTHING);
|
||||||
composition.delNotes(0, 0x7fffffff, (byte) channel, (byte) -1, (byte) 127);
|
composition.delNotes(0, 0x7fffffff, channel, (byte) -1, (byte) 127);
|
||||||
} else if (command == temp) {
|
} else if (command == temp) {
|
||||||
TempoList tempos = new TempoList(composition, model, this);
|
TempoList tempos = new TempoList(composition, model, this);
|
||||||
display.setCurrent(tempos);
|
display.setCurrent(tempos);
|
||||||
} else if (command == volume) {
|
} else if (command == volume) {
|
||||||
VolumeForm volForm = new VolumeForm(composition, choiseInstrument.getChansVector(), model, this);
|
VolumeForm volForm = new VolumeForm(composition, choiñeInstrument.getChansVector(), model, this);
|
||||||
display.setCurrent(volForm);
|
display.setCurrent(volForm);
|
||||||
} else if (command == meter) {
|
} else if (command == meter) {
|
||||||
Form textBoxTemp = new Form(Constants.getInstrName(72));
|
Form textBoxTemp = new Form(Constants.getInstrName(72));
|
||||||
@ -415,13 +424,12 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
Thread runner = new Thread() {
|
Thread runner = new Thread() {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
WaitForm waitForm = new WaitForm(L.str[L.saving] + "...",
|
WaitCanvas waitCanvas = new WaitCanvas(L.str[L.saving] + "...",
|
||||||
model.getWaitableFile(),
|
model.getWaitableFile(),
|
||||||
control.getCurrentlistMenu(),
|
control.getCurrentlistMenu());
|
||||||
model);
|
display.setCurrent(waitCanvas);
|
||||||
display.setCurrent(waitForm);
|
|
||||||
model.resetProgress();
|
model.resetProgress();
|
||||||
new Thread(waitForm).start();
|
new Thread(waitCanvas).start();
|
||||||
composition.setName(nameFinal);
|
composition.setName(nameFinal);
|
||||||
try {
|
try {
|
||||||
String ans = model.saveMix(composition, nameFinal);
|
String ans = model.saveMix(composition, nameFinal);
|
||||||
@ -431,7 +439,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Alert a = new Alert(L.str[L.error], L.str[L.savingError] + "\n" + ex.getMessage(), null, null);
|
Alert a = new Alert(L.str[L.error], L.str[L.savingError] + "\n" + ex.getMessage(), null, null);
|
||||||
a.setTimeout(Alert.FOREVER);
|
a.setTimeout(Alert.FOREVER);
|
||||||
waitForm.cancel();
|
waitCanvas.cancel();
|
||||||
control.setCurrentlistMenu(a);
|
control.setCurrentlistMenu(a);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -457,26 +465,16 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
Alert a = new Alert(L.str[L.error], L.str[L.error] + "\n" + s, null, AlertType.ERROR);
|
Alert a = new Alert(L.str[L.error], L.str[L.error] + "\n" + s, null, AlertType.ERROR);
|
||||||
Main.dsp.setCurrent(a);
|
Main.dsp.setCurrent(a);
|
||||||
}
|
}
|
||||||
/*Form tabsInstruments (){
|
|
||||||
MyItem []groupsOfElements = new MyItem [16];
|
|
||||||
String [] groupOfElements = new String [8];
|
|
||||||
int numElementsInGroup = 8,
|
|
||||||
numIcosOnScreen = MyItem.SCREEN_WIDTH/32;
|
|
||||||
StringItem instruments[] = new StringItem [128];
|
|
||||||
return null;
|
|
||||||
}*/
|
|
||||||
private Form getListOfInstruments() {
|
private Form getListOfInstruments() {
|
||||||
if (listInstrumentsForm == null) {
|
if (listInstrumentsForm == null) {
|
||||||
ChoiceGroup[] groupsChoiseGroup = new ChoiceGroup[16];
|
ChoiceGroup[] groupsChoiseGroup = new ChoiceGroup[GROUPS_OF_INSTRUMENTS];
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < GROUPS_OF_INSTRUMENTS; i++) {
|
||||||
// for (int j = 0; j < 8; j++) {
|
String[] listOfElements = new String[INSTRUMENTS_IN_GROUP];
|
||||||
// listOfElements[j] = j + i * 8 + 1 + ' ' + Constants.getInstrName(j + i * 8 + 1);
|
System.arraycopy(L.instr, i*INSTRUMENTS_IN_GROUP+1, listOfElements,0, INSTRUMENTS_IN_GROUP);
|
||||||
// }
|
|
||||||
String[] listOfElements = new String[8];
|
groupsChoiseGroup[i] = new ChoiceGroup(Constants.getInstrName(129 + i), ChoiceGroup.POPUP, listOfElements, null);
|
||||||
System.arraycopy(L.instr, i*8+1, listOfElements,0, 8);
|
|
||||||
groupsChoiseGroup[i] = new ChoiceGroup(Constants.getInstrName(129 + i), 4, listOfElements, null);
|
|
||||||
//for (int j=0; j<8; j++)
|
|
||||||
//groupsOfElements[i].setFont(j,Main.SMALL_FONT);
|
|
||||||
groupsChoiseGroup[i].addCommand(play);
|
groupsChoiseGroup[i].addCommand(play);
|
||||||
groupsChoiseGroup[i].addCommand(ok);
|
groupsChoiseGroup[i].addCommand(ok);
|
||||||
groupsChoiseGroup[i].setItemCommandListener(this);
|
groupsChoiseGroup[i].setItemCommandListener(this);
|
||||||
@ -489,10 +487,10 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
|
|||||||
listInstrumentsForm.addCommand(P.comCancel);
|
listInstrumentsForm.addCommand(P.comCancel);
|
||||||
listInstrumentsForm.setCommandListener(this);
|
listInstrumentsForm.setCommandListener(this);
|
||||||
}
|
}
|
||||||
//form.setItemStateListener(this);
|
|
||||||
return listInstrumentsForm;
|
return listInstrumentsForm;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class ChannelChoiceGroup extends ChoiceGroup {
|
class ChannelChoiceGroup extends ChoiceGroup {
|
||||||
|
|
||||||
@ -537,3 +535,5 @@ class ChannelChoiceGroup extends ChoiceGroup {
|
|||||||
return instrumentsVector;
|
return instrumentsVector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,106 +3,92 @@ package midedit;
|
|||||||
import midedit.media.Composition;
|
import midedit.media.Composition;
|
||||||
import main.Main;
|
import main.Main;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Êëàññ ðåäàêòèðîâàíèÿ áàðàáàíîâ
|
||||||
* @author user
|
* @author user
|
||||||
*/
|
*/
|
||||||
public class DrumsCanvas extends MixerCanvas
|
public class DrumsCanvas extends MixerCanvas {
|
||||||
{
|
|
||||||
/**
|
/** Ñäâèã òåêñòîâûõ ìåòîê â áàðàáàíàõ */
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static final int drumsShift = Constants.DRUMS_SHIFT;
|
public static final int drumsShift = Constants.DRUMS_SHIFT;
|
||||||
private byte[] drumsTable = null;
|
private byte[] drumsTable = null;
|
||||||
private byte[] drumsTableInverse = null;
|
private byte[] drumsTableInverse = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param ctrl
|
* @param ctrl
|
||||||
* @param c
|
* @param c
|
||||||
*/
|
*/
|
||||||
public DrumsCanvas(Main ctrl, Composition c)
|
public DrumsCanvas(Main ctrl, Composition c) {
|
||||||
{
|
|
||||||
super(ctrl, c, Constants.DRUMS_CHANNEL);
|
super(ctrl, c, Constants.DRUMS_CHANNEL);
|
||||||
prepareConstants();
|
prepareConstants();
|
||||||
|
|
||||||
byte[] b = new byte[Constants.NCHANNEL];
|
byte[] b = new byte[Constants.NCHANNEL];
|
||||||
for(int i=0; i<Constants.NCHANNEL; ++i)
|
for (int i = 0; i < Constants.NCHANNEL; ++i) {
|
||||||
b[i] = (byte) (drumsShift + i);
|
b[i] = (byte) (drumsShift + i);
|
||||||
|
}
|
||||||
drumsTable = b;
|
drumsTable = b;
|
||||||
newDrumsTableInverse();
|
newDrumsTableInverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected void prepareConstants()
|
private void prepareConstants() {
|
||||||
{
|
if (nH > Constants.DRUMS_LENGTH) {
|
||||||
if(nH> Constants.DRUMS_LENGTH)
|
|
||||||
nH = Constants.DRUMS_LENGTH;
|
nH = Constants.DRUMS_LENGTH;
|
||||||
|
}
|
||||||
hStep = 4;
|
hStep = 4;
|
||||||
hMin = drumsShift;
|
hMin = drumsShift;
|
||||||
hMax = (drumsShift + Constants.DRUMS_LENGTH - 1);
|
hMax = (drumsShift + Constants.DRUMS_LENGTH - 1);
|
||||||
hBase = hMin;
|
hBase = hMin;
|
||||||
curY = 0;
|
curY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected boolean doKEY_NUM5()
|
protected boolean doKEY_NUM5() {
|
||||||
{
|
if (super.doKEY_NUM5() == false) {
|
||||||
if(super.doKEY_NUM5() == false)
|
|
||||||
composition.addNoteOn(getCurTime(), (byte) channel,
|
composition.addNoteOn(getCurTime(), (byte) channel,
|
||||||
(byte)getNoteFromLine(curY), (byte)getCurVol(),0,true);
|
(byte) getNoteFromLine(curY), getCurVol(), 0, true);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doSmallDown() {
|
protected void doSmallDown() {
|
||||||
if(hBase+curY < hMax)
|
if (hBase + curY < hMax) {
|
||||||
super.doSmallDown();
|
super.doSmallDown();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param val
|
|
||||||
public void setCurInstrument(int val)
|
|
||||||
{
|
|
||||||
int n = val + DrumsTable.SHIFT;
|
|
||||||
for(int i=0; i<nH; ++i)
|
|
||||||
if(drumsTable[i]==n)
|
|
||||||
return;
|
|
||||||
drumsTableInverse[drumsTable[curY]] = (byte)-1;
|
|
||||||
drumsTableInverse[n] = (byte)curY;
|
|
||||||
drumsTable[curY] = (byte)n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
private void newDrumsTableInverse() {
|
||||||
public void newDrumsTableInverse()
|
|
||||||
{
|
|
||||||
drumsTableInverse = new byte[Constants.N_INSTR];
|
drumsTableInverse = new byte[Constants.N_INSTR];
|
||||||
for(int i=0; i<Constants.N_INSTR; ++i)
|
for (int i = 0; i < Constants.N_INSTR; ++i) {
|
||||||
drumsTableInverse[i] = (byte) -1;
|
drumsTableInverse[i] = (byte) -1;
|
||||||
for(int i=0; i<Constants.NCHANNEL; ++i)
|
}
|
||||||
|
for (int i = 0; i < Constants.NCHANNEL; ++i) {
|
||||||
drumsTableInverse[drumsTable[i]] = (byte) i;
|
drumsTableInverse[drumsTable[i]] = (byte) i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param g
|
* @param g
|
||||||
*/
|
*/
|
||||||
protected void paintScale(javax.microedition.lcdui.Graphics g)
|
protected void paintScale(javax.microedition.lcdui.Graphics g) {
|
||||||
{
|
for (int hh = hBeg; hh < hBeg + rollHeight; hh += hOne) {
|
||||||
for(int hh = hBeg; hh < hBeg + rollHeight ; hh+=hOne)
|
|
||||||
g.fillRect(4, hh, wBeg - 5, 1);
|
g.fillRect(4, hh, wBeg - 5, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param n
|
* @param n
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected byte getLineFromNote(int n)
|
protected byte getLineFromNote(int n) {
|
||||||
{
|
|
||||||
return (byte) (n - hBase);
|
return (byte) (n - hBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,9 +97,7 @@ protected void doSmallDown (){
|
|||||||
* @param ln
|
* @param ln
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected int getNoteFromLine(int ln)
|
protected int getNoteFromLine(int ln) {
|
||||||
{
|
|
||||||
return (byte) (hBase + curY);
|
return (byte) (hBase + curY);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class MidiFile implements Waitable {
|
|||||||
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,0x68,0x64,0x0,0x0,0x0,0x6,0x0,0x0,0x0,0x1,0x0,0x60,
|
||||||
//0x4d,0x54,0x72,0x6b,0x0,0x0,0x0,0x26/*len*/,0x0,0xff,0x58,0x04,0x04,0x02,0x18,0x08,
|
//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,/*<-*/
|
//0x0,0xff,0x51,0x03, /*temp->*/0x21,0xf2,0xf3,/*<-*/
|
||||||
///*37>*/0x00,0xc0,0x1a, /*40>*/0x00,0x90,0x2e,0x01,
|
///*37>*/0x00,0xc0,0x1a, /*40>*/0x00,0x90,0x2e,0x01,
|
||||||
//0x08,0x99,0x2e,0x7f, 0x7f,0x90,0x2e,0x01,
|
//0x08,0x99,0x2e,0x7f, 0x7f,0x90,0x2e,0x01,
|
||||||
@ -42,8 +42,8 @@ public class MidiFile implements Waitable {
|
|||||||
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 t)
|
//public static void setTemp(int noteTime)
|
||||||
//{ temp = t; }
|
//{ temp = noteTime; }
|
||||||
//public static int getTemp()
|
//public static int getTemp()
|
||||||
//{ return temp; }
|
//{ return temp; }
|
||||||
public MidiFile(AbstractFile aFile) {
|
public MidiFile(AbstractFile aFile) {
|
||||||
@ -295,11 +295,11 @@ public class MidiFile implements Waitable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// calc maxTime for set end Note
|
/// calc maxTime for set end Note
|
||||||
if (note.t > maxTime) {
|
if (note.noteTime > maxTime) {
|
||||||
maxTime = note.t;
|
maxTime = note.noteTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
tnote = getVarLenRepr(note.t - tPrev); // Delta-Time
|
tnote = getVarLenRepr(note.noteTime - tPrev); // Delta-Time
|
||||||
if (tnote.length == 0) {
|
if (tnote.length == 0) {
|
||||||
throw new Exception("len==0");
|
throw new Exception("len==0");
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ public class MidiFile implements Waitable {
|
|||||||
///////////
|
///////////
|
||||||
ind += 3;
|
ind += 3;
|
||||||
}
|
}
|
||||||
tPrev = note.t;
|
tPrev = note.noteTime;
|
||||||
seekPos++;
|
seekPos++;
|
||||||
Thread.yield();
|
Thread.yield();
|
||||||
}
|
}
|
||||||
@ -378,7 +378,7 @@ public class MidiFile implements Waitable {
|
|||||||
{
|
{
|
||||||
// outStr = ""+nn+".mid";
|
// outStr = ""+nn+".mid";
|
||||||
//outStr = "note.mid";
|
//outStr = "note.mid";
|
||||||
// mod.msg("len dat ."+dat.length+" ");
|
// mod.msg("length dat ."+dat.length+" ");
|
||||||
//byte[] b = new byte[dat4PlayNote.length];
|
//byte[] b = new byte[dat4PlayNote.length];
|
||||||
//for(int i=0; i<dat4PlayNote.length; ++i){
|
//for(int i=0; i<dat4PlayNote.length; ++i){
|
||||||
//b[i] = (byte)dat4PlayNote[i];
|
//b[i] = (byte)dat4PlayNote[i];
|
||||||
@ -405,7 +405,7 @@ public class MidiFile implements Waitable {
|
|||||||
public byte[] writeTest(byte instr) {
|
public byte[] writeTest(byte instr) {
|
||||||
outStr = "test.mid";
|
outStr = "test.mid";
|
||||||
//int df=0;
|
//int df=0;
|
||||||
InputStream is = getClass().getResourceAsStream("/bin/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);
|
||||||
@ -417,8 +417,8 @@ public class MidiFile implements Waitable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private /*static*/ byte[] getVarLenRepr(int t) {
|
private /*static*/ byte[] getVarLenRepr(int t) {
|
||||||
// if(t<0)
|
// if(noteTime<0)
|
||||||
// mod.msgAll("Repr\nt="+t);
|
// mod.msgAll("Repr\nt="+noteTime);
|
||||||
int tt = t;
|
int tt = t;
|
||||||
if (tt < 0) {
|
if (tt < 0) {
|
||||||
tt = 0;
|
tt = 0;
|
||||||
@ -492,7 +492,7 @@ public class MidiFile implements Waitable {
|
|||||||
throw new IOException("len MThd=" + t);
|
throw new IOException("len MThd=" + t);
|
||||||
}
|
}
|
||||||
|
|
||||||
//skip(df,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");
|
||||||
@ -509,7 +509,7 @@ public class MidiFile implements Waitable {
|
|||||||
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) //throw new IOException("(2)Not Found MTrk \n"+"pos="
|
||||||
//+seekPos+"/"+seekLen+"\nind="+indTrk+"/"+numTrk+"mtrk="+t);
|
//+seekPos+"/"+seekLen+"\nind="+indTrk+"/"+numTrk+"mtrk="+noteTime);
|
||||||
{
|
{
|
||||||
throw new IOException("Track not found");
|
throw new IOException("Track not found");
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
break;
|
break;
|
||||||
case -7:
|
case -7:
|
||||||
case -12:
|
case -12:
|
||||||
CompositionForm.curForm.setComposForm();
|
Main.midlet.compositionForm.setComposForm();
|
||||||
break;
|
break;
|
||||||
case -11:
|
case -11:
|
||||||
composition.getUndoableAction().undo();
|
composition.getUndoableAction().undo();
|
||||||
@ -333,7 +333,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
} else if (isMarkMode) {
|
} else if (isMarkMode) {
|
||||||
if (curNote != null) {
|
if (curNote != null) {
|
||||||
|
|
||||||
if (curNote.len > 0) {
|
if (curNote.length > 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.c != curNote.c || noteTmp.n != curNote.n || noteTmp.v != 0);
|
||||||
@ -367,7 +367,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (curNote != null) {
|
if (curNote != null) {
|
||||||
composition.delNote(curNote.t, curNote.c, curNote.n, curNote.v);
|
composition.delNote(curNote.noteTime, curNote.c, curNote.n, curNote.v);
|
||||||
} else {
|
} else {
|
||||||
composition.delNote(getCurTime(), (byte) channel, (byte) getNoteFromLine(curY), (byte) 127);
|
composition.delNote(getCurTime(), (byte) channel, (byte) getNoteFromLine(curY), (byte) 127);
|
||||||
}
|
}
|
||||||
@ -430,11 +430,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
keyPressedCount++;
|
keyPressedCount++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
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
|
||||||
|| gameAction == LEFT || gameAction == RIGHT || gameAction == UP || gameAction == DOWN
|
|| gameAction == LEFT || gameAction == RIGHT || gameAction == UP || gameAction == DOWN
|
||||||
|| keyCodePressed == KEY_NUM2 || keyCodePressed == KEY_NUM8
|
|| keyCodePressed == KEY_NUM2 || keyCodePressed == KEY_NUM8
|
||||||
@ -529,10 +525,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
curNote = null;
|
curNote = null;
|
||||||
g.setGrayScale(0);
|
g.setGrayScale(0);
|
||||||
for (note = composition.getFirstNote(tBeg, channel);
|
for (note = composition.getFirstNote(tBeg, channel);
|
||||||
note != null && note.t <= tMax; note = note.next) {
|
note != null && note.noteTime <= tMax; note = note.next) {
|
||||||
if (note.c == channel && note.v != 0) {
|
if (note.c == channel && note.v != 0) {
|
||||||
if (note.t <= curTimePlus && note.n == curN
|
if (note.noteTime <= curTimePlus && note.n == curN
|
||||||
&& (curTime < note.t + (note.len == 0 ? 1 : note.len))) {
|
&& (curTime < note.noteTime + (note.length == 0 ? 1 : note.length))) {
|
||||||
curNote = note;
|
curNote = note;
|
||||||
if (!isMarkMode) {
|
if (!isMarkMode) {
|
||||||
g.setColor(150, 0, 0);
|
g.setColor(150, 0, 0);
|
||||||
@ -631,7 +627,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
* @param shiftNote
|
* @param shiftNote
|
||||||
*/
|
*/
|
||||||
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.t + shiftTime);
|
xt = getXInPixel(note.noteTime + shiftTime);
|
||||||
yt = getLineFromNote(note.n + shiftNote);
|
yt = getLineFromNote(note.n + shiftNote);
|
||||||
if (xt >= 0 && xt < rollWidth) {
|
if (xt >= 0 && xt < rollWidth) {
|
||||||
if (yt < 0) {
|
if (yt < 0) {
|
||||||
@ -744,7 +740,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param t
|
* @param noteTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int getX(int t) {
|
private int getX(int t) {
|
||||||
@ -753,7 +749,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param t
|
* @param noteTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected int getXInPixel(int t) {
|
protected int getXInPixel(int t) {
|
||||||
@ -1179,8 +1175,8 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
m2 = 50;
|
m2 = 50;
|
||||||
m3 = 75;
|
m3 = 75;
|
||||||
m4 = 100;
|
m4 = 100;
|
||||||
PrintSmallFont.print(g, note.t * 100 / tick, 2, m1 - xIndent, yIndent, color);
|
PrintSmallFont.print(g, note.noteTime * 100 / tick, 2, m1 - xIndent, yIndent, color);
|
||||||
PrintSmallFont.print(g, note.len * 1000 / tick, 3, m2 - xIndent, yIndent, color);
|
PrintSmallFont.print(g, note.length * 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.n % 12, m3 - xIndent, yIndent, color);
|
||||||
@ -1198,13 +1194,13 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
m3 = 55;
|
m3 = 55;
|
||||||
m4 = 70;
|
m4 = 70;
|
||||||
|
|
||||||
PrintSmallFont.print(g, note.t / tick, 0, m1, yIndent, color);
|
PrintSmallFont.print(g, note.noteTime / tick, 0, m1, yIndent, color);
|
||||||
g.drawLine(m1 + 1, yIndent - 4, m1 + 1, yIndent - 4);
|
g.drawLine(m1 + 1, yIndent - 4, m1 + 1, yIndent - 4);
|
||||||
g.drawLine(m1 + 1, yIndent - 2, m1 + 1, yIndent - 2);
|
g.drawLine(m1 + 1, yIndent - 2, m1 + 1, yIndent - 2);
|
||||||
PrintSmallFont.print(g, (note.t * meterNom / tick) % meterNom, 0, m2, yIndent, color);
|
PrintSmallFont.print(g, (note.noteTime * meterNom / tick) % meterNom, 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.t % mod, 0, m3, yIndent, color);
|
PrintSmallFont.print(g, note.noteTime % mod, 0, m3, yIndent, color);
|
||||||
PrintSmallFont.print(g, mod, 0, m4, yIndent, color);
|
PrintSmallFont.print(g, mod, 0, m4, yIndent, color);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1234,10 +1230,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintSmallFont.print(g, note.len * meterNom / tick, 0, m2, yIndent, color);
|
PrintSmallFont.print(g, note.length * 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.len % mod, 0, m3, yIndent, color);
|
PrintSmallFont.print(g, note.length % mod, 0, m3, yIndent, color);
|
||||||
PrintSmallFont.print(g, mod, 0, m4, yIndent, color);
|
PrintSmallFont.print(g, mod, 0, m4, yIndent, color);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1463,14 +1459,13 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
MenuItem exitItem = new MenuItem(L.str[L.back], 0) {
|
MenuItem exitItem = new MenuItem(L.str[L.back], 0) {
|
||||||
|
|
||||||
public boolean actionPerformed() {
|
public boolean actionPerformed() {
|
||||||
CompositionForm.curForm.setComposForm();
|
Main.midlet.compositionForm.setComposForm();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mainMenu.addItem(exitItem);
|
mainMenu.addItem(exitItem);
|
||||||
|
|
||||||
menu = mainMenu;
|
menu = mainMenu;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createString(String[] strings) {
|
private String createString(String[] strings) {
|
||||||
@ -1492,10 +1487,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
|
|
||||||
protected void paint(Graphics g) {
|
protected void paint(Graphics g) {
|
||||||
menu.paint(g);
|
menu.paint(g);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean processCommand(int keyCode) {
|
private boolean processCommand(int keyCode) {
|
||||||
@ -1603,6 +1594,9 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
// private int optWidth = (screenWidth - 2 * optXbeg);
|
// private int optWidth = (screenWidth - 2 * optXbeg);
|
||||||
// private int optHeight = (screenHeight - 2 * optYbeg);
|
// private int optHeight = (screenHeight - 2 * optYbeg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Êëàññ ìåíþ
|
||||||
|
*/
|
||||||
private class Menu extends MenuItem {
|
private class Menu extends MenuItem {
|
||||||
|
|
||||||
private Vector items = null;
|
private Vector items = null;
|
||||||
@ -1636,6 +1630,10 @@ 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();
|
||||||
@ -1651,7 +1649,8 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
g.translate(x, y);
|
g.translate(x, y);
|
||||||
|
|
||||||
g.setColor(P.colup);
|
g.setColor(P.colup);
|
||||||
g.fillRect(0, 1, w, LINE_HEIGHT - 1);
|
ui.UI.drawRect(g, P.colup, P.coldn, 0, 1, w, LINE_HEIGHT - 1);
|
||||||
|
// g.fillRect(0, 1, w, LINE_HEIGHT - 1);
|
||||||
g.setColor(0);
|
g.setColor(0);
|
||||||
g.drawRect(0, 1, w - 1, LINE_HEIGHT - 1);
|
g.drawRect(0, 1, w - 1, LINE_HEIGHT - 1);
|
||||||
g.setClip(0, 1, w - 1, LINE_HEIGHT - 1);
|
g.setClip(0, 1, w - 1, LINE_HEIGHT - 1);
|
||||||
@ -1759,22 +1758,39 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ïóíêò ìåíþ
|
||||||
|
*/
|
||||||
class MenuItem {
|
class MenuItem {
|
||||||
|
|
||||||
|
/** Íàçâàíèå ïóíêòà */
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
/** Êîä êëàâèøè */
|
||||||
private int keyCode;
|
private int keyCode;
|
||||||
|
|
||||||
// public MenuItem() {
|
/**
|
||||||
// }
|
* Êîíñòðóêòîð
|
||||||
private MenuItem(String str, int key) {
|
* @param name íàçâàíèå ïóíòêà
|
||||||
name = str;
|
* @param key êîä êëàâèøè
|
||||||
|
*/
|
||||||
|
private MenuItem(String name, int key) {
|
||||||
|
this.name = name;
|
||||||
keyCode = key;
|
keyCode = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ïîëó÷èòü èìÿ
|
||||||
|
* @return èìÿ ïóíêòà
|
||||||
|
*/
|
||||||
protected String getName() {
|
protected String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Âûïîëíèòü îïåðàöèþ
|
||||||
|
* @return óñïåøíîñòü
|
||||||
|
*/
|
||||||
public boolean actionPerformed() {
|
public boolean actionPerformed() {
|
||||||
return processCommand(keyCode);
|
return processCommand(keyCode);
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,6 @@ public class MixerModel extends Thread {
|
|||||||
* Îáúåêò äèñïëåÿ
|
* Îáúåêò äèñïëåÿ
|
||||||
*/
|
*/
|
||||||
public final Display display = Main.dsp;
|
public final Display display = Main.dsp;
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
//public final MixerModel thisModel;
|
|
||||||
private NoteListUtils buffer;
|
private NoteListUtils buffer;
|
||||||
static AbstractFile rmsFile = new RMSFile(),
|
static AbstractFile rmsFile = new RMSFile(),
|
||||||
//localFile,//=rmsFile,
|
//localFile,//=rmsFile,
|
||||||
@ -35,15 +31,12 @@ public class MixerModel extends Thread {
|
|||||||
|
|
||||||
public MixerModel() {
|
public MixerModel() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
//System.out.println("microedition.io.file.FileConnection.version="+System.getProperty("microedition.io.file.FileConnection.version"));
|
|
||||||
if (System.getProperty("microedition.io.file.FileConnection.version") != null) {
|
if (System.getProperty("microedition.io.file.FileConnection.version") != null) {
|
||||||
jsr75File = new JSR75File();
|
jsr75File = new JSR75File();
|
||||||
} else {
|
} else {
|
||||||
jsr75File = rmsFile;
|
jsr75File = rmsFile;
|
||||||
}
|
}
|
||||||
if (crossPlayer == null) {
|
if (crossPlayer == null) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("javax.microedition.media.Player");
|
Class.forName("javax.microedition.media.Player");
|
||||||
crossPlayer = new JSR135Player();
|
crossPlayer = new JSR135Player();
|
||||||
@ -53,11 +46,7 @@ public class MixerModel extends Thread {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Alert a = new Alert(L.str[L.apiError], L.str[L.apiError] + ":\n" + e.getMessage(), null, null);
|
Alert a = new Alert(L.str[L.apiError], L.str[L.apiError] + ":\n" + e.getMessage(), null, null);
|
||||||
display.setCurrent(a);
|
display.setCurrent(a);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mfile = new MidiFile(getLocalFile());
|
mfile = new MidiFile(getLocalFile());
|
||||||
buffer = new NoteListUtils();
|
buffer = new NoteListUtils();
|
||||||
}
|
}
|
||||||
@ -70,24 +59,13 @@ public class MixerModel extends Thread {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// *
|
|
||||||
// * @param c
|
|
||||||
// * @param count
|
|
||||||
// * @throws Exception
|
|
||||||
// */
|
|
||||||
// public void playMix(Composition c, int count) throws Exception {
|
|
||||||
// playMix(c, 0, 0);
|
|
||||||
// }
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param c
|
* @param c
|
||||||
* @param count
|
|
||||||
* @param t
|
* @param t
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public void playMix(Composition c, int t) throws Exception {
|
public void playMix(Composition c, int t) throws Exception {
|
||||||
|
|
||||||
crossPlayer.close();
|
crossPlayer.close();
|
||||||
getLocalFile().close(0);
|
getLocalFile().close(0);
|
||||||
setLocalFile();
|
setLocalFile();
|
||||||
@ -100,23 +78,17 @@ public class MixerModel extends Thread {
|
|||||||
*
|
*
|
||||||
* @param instrum
|
* @param instrum
|
||||||
* @param nn
|
* @param nn
|
||||||
* @param vv
|
|
||||||
*/
|
*/
|
||||||
public void playNote(byte instrum, byte nn) {
|
public void playNote(byte instrum, byte nn) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
crossPlayer.close();
|
crossPlayer.close();
|
||||||
|
|
||||||
crossPlayer.playTest(mfile.writeNote(instrum, nn));
|
crossPlayer.playTest(mfile.writeNote(instrum, nn));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CompositionForm.msg("MixerModel: 134: playNote " + e.getMessage());
|
CompositionForm.msg("MixerModel: 91: playNote " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playTest(byte instrum) {
|
public void playTest(byte instrum) {
|
||||||
|
|
||||||
|
|
||||||
crossPlayer.close();
|
crossPlayer.close();
|
||||||
mfile.writeTest(instrum);
|
mfile.writeTest(instrum);
|
||||||
crossPlayer.playTest(mfile.writeTest(instrum));
|
crossPlayer.playTest(mfile.writeTest(instrum));
|
||||||
@ -125,7 +97,6 @@ public class MixerModel extends Thread {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param c
|
* @param c
|
||||||
* @param count
|
|
||||||
* @param t
|
* @param t
|
||||||
* @param channel
|
* @param channel
|
||||||
* @param instrument
|
* @param instrument
|
||||||
@ -143,7 +114,6 @@ public class MixerModel extends Thread {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param c
|
* @param c
|
||||||
* @param count
|
|
||||||
* @param t
|
* @param t
|
||||||
* @param channel
|
* @param channel
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@ -156,14 +126,10 @@ public class MixerModel extends Thread {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void stopPlay() {
|
public void stopPlay() {
|
||||||
|
if(crossPlayer != null)
|
||||||
crossPlayer.close();
|
crossPlayer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void run() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -192,8 +158,7 @@ public class MixerModel extends Thread {
|
|||||||
public Composition openMix(String name) throws Exception {
|
public Composition openMix(String name) throws Exception {
|
||||||
Composition c;
|
Composition c;
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
c = mfile.readMix(
|
c = mfile.readMix(name);
|
||||||
name);
|
|
||||||
c.setName(name);
|
c.setName(name);
|
||||||
} else {
|
} else {
|
||||||
c = new Composition();
|
c = new Composition();
|
||||||
|
@ -1,29 +1,30 @@
|
|||||||
package midedit;
|
package midedit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Íîòà
|
||||||
* @author user
|
* @author user
|
||||||
*/
|
*/
|
||||||
public class Note {
|
public class Note {
|
||||||
|
|
||||||
|
|
||||||
|
public byte c, n, v, mark;
|
||||||
|
public int noteTime, length;
|
||||||
|
public Note next = null, prev = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param tt
|
* @param time
|
||||||
* @param ch
|
* @param ch
|
||||||
* @param nn
|
* @param nn
|
||||||
* @param vv
|
* @param vv
|
||||||
* @param ll
|
* @param ll
|
||||||
*/
|
*/
|
||||||
public byte c, n, v, mark;
|
public Note(int time, byte ch, byte nn, byte vv, int ll) {
|
||||||
public int t, len;
|
this.noteTime = time;
|
||||||
public Note next = null, prev = null;
|
|
||||||
|
|
||||||
public Note(int tt, byte ch, byte nn, byte vv, int ll) {
|
|
||||||
t = tt;
|
|
||||||
c = ch;
|
c = ch;
|
||||||
n = nn;
|
n = nn;
|
||||||
v = vv;
|
v = vv;
|
||||||
len = ll;
|
length = ll;
|
||||||
mark = NoteListUtils.NOTE_NOT_MARKED;
|
mark = NoteListUtils.NOTE_NOT_MARKED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class NoteList
|
|||||||
{
|
{
|
||||||
if(noteExist==null)
|
if(noteExist==null)
|
||||||
return null;
|
return null;
|
||||||
t = noteExist.t;
|
t = noteExist.noteTime;
|
||||||
len++;
|
len++;
|
||||||
if(noteBeg == null)
|
if(noteBeg == null)
|
||||||
noteBeg = note = noteExist;
|
noteBeg = note = noteExist;
|
||||||
@ -44,11 +44,11 @@ public class NoteList
|
|||||||
noteNew = noteExist;
|
noteNew = noteExist;
|
||||||
if(note == null)
|
if(note == null)
|
||||||
note = noteBeg;
|
note = noteBeg;
|
||||||
if(note.t != t)
|
if(note.noteTime != t)
|
||||||
{ if(t < note.t)
|
{ if(t < note.noteTime)
|
||||||
{
|
{
|
||||||
for(noteTmp = note;
|
for(noteTmp = note;
|
||||||
noteTmp != null && t < noteTmp.t;
|
noteTmp != null && t < noteTmp.noteTime;
|
||||||
noteTmp = noteTmp.prev)
|
noteTmp = noteTmp.prev)
|
||||||
;
|
;
|
||||||
if(noteTmp == null)
|
if(noteTmp == null)
|
||||||
@ -60,7 +60,7 @@ public class NoteList
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ for(noteTmp = note;
|
{ for(noteTmp = note;
|
||||||
noteTmp.next != null && (noteTmp.next.t < t ) ;
|
noteTmp.next != null && (noteTmp.next.noteTime < t ) ;
|
||||||
noteTmp = noteTmp.next)
|
noteTmp = noteTmp.next)
|
||||||
;
|
;
|
||||||
note = noteTmp;
|
note = noteTmp;
|
||||||
@ -68,12 +68,12 @@ public class NoteList
|
|||||||
}
|
}
|
||||||
if(noteExist.v!=0)
|
if(noteExist.v!=0)
|
||||||
{
|
{
|
||||||
for( ; note.next != null && t == note.next.t ; note = note.next )
|
for( ; note.next != null && t == note.next.noteTime ; note = note.next )
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for( ; note.prev != null && t == note.t ; note = note.prev )
|
for( ; note.prev != null && t == note.noteTime ; note = note.prev )
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,15 +96,15 @@ public class NoteList
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param t
|
* @param noteTime
|
||||||
* @param c
|
* @param c
|
||||||
* @param n
|
* @param n
|
||||||
* @param v
|
* @param v
|
||||||
*/
|
*/
|
||||||
public void delOne(int t, byte c, byte n, byte v)
|
public void delOne(int t, byte c, byte n, byte v)
|
||||||
{
|
{
|
||||||
for(note = searchNoteByTime(t); note != null && note.t <= t; note = note.next)
|
for(note = searchNoteByTime(t); note != null && note.noteTime <= t; note = note.next)
|
||||||
if(t==note.t && c == note.c && n == note.n && (v!=0 ^ note.v==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;
|
||||||
@ -124,7 +124,7 @@ public class NoteList
|
|||||||
*/
|
*/
|
||||||
public void delOne(Note delNote)
|
public void delOne(Note delNote)
|
||||||
{
|
{
|
||||||
for(note = getFirst(); note != null && note.t <= 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)
|
||||||
@ -157,7 +157,7 @@ public class NoteList
|
|||||||
|
|
||||||
if(undo!=null && note.v!=0)
|
if(undo!=null && note.v!=0)
|
||||||
{
|
{
|
||||||
undo.log2DelNoteList(note.t,note.c,note.n,note.v,note.len);
|
undo.log2DelNoteList(note.noteTime,note.c,note.n,note.v,note.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
len--;
|
len--;
|
||||||
@ -165,7 +165,7 @@ public class NoteList
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param t
|
* @param noteTime
|
||||||
* @param tMax
|
* @param tMax
|
||||||
* @param c
|
* @param c
|
||||||
* @param n
|
* @param n
|
||||||
@ -181,13 +181,13 @@ public class NoteList
|
|||||||
boolean isdel=false;
|
boolean isdel=false;
|
||||||
timeNoteOff = -1;
|
timeNoteOff = -1;
|
||||||
|
|
||||||
for(note = searchNoteByTime(t); note != null && note.t <= tMax; note = note.next)
|
for(note = searchNoteByTime(t); note != null && note.noteTime <= tMax; note = note.next)
|
||||||
if ( (note.c == c || c == (byte)-1) &&
|
if ( (note.c == c || c == (byte)-1) &&
|
||||||
(note.t > t || v!=0 && note.t == t) &&
|
(note.noteTime > t || v!=0 && note.noteTime == t) &&
|
||||||
(note.t < tMax || v==0 && note.t == tMax) &&
|
(note.noteTime < tMax || v==0 && note.noteTime == tMax) &&
|
||||||
(note.n == n || n == (byte)-1) &&
|
(note.n == n || n == (byte)-1) &&
|
||||||
( (v != 0 && (note.v != 0 || note.t - note.len >= t)) ||
|
( (v != 0 && (note.v != 0 || note.noteTime - note.length >= t)) ||
|
||||||
(v == 0 && (note.v == 0 && timeLastDelOn <= note.t-note.len && note.t-note.len < t ))))
|
(v == 0 && (note.v == 0 && timeLastDelOn <= note.noteTime-note.length && note.noteTime-note.length < t ))))
|
||||||
{
|
{
|
||||||
if(note.next != null)
|
if(note.next != null)
|
||||||
note.next.prev = note.prev;
|
note.next.prev = note.prev;
|
||||||
@ -199,15 +199,15 @@ public class NoteList
|
|||||||
len--;
|
len--;
|
||||||
if( v != 0)
|
if( v != 0)
|
||||||
{
|
{
|
||||||
if(tOffMax < note.t+note.len)
|
if(tOffMax < note.noteTime+note.length)
|
||||||
tOffMax = note.t+note.len;
|
tOffMax = note.noteTime+note.length;
|
||||||
if(undo!=null && note.v!=0)
|
if(undo!=null && note.v!=0)
|
||||||
{
|
{
|
||||||
undo.log2DelNoteList(note.t,note.c,note.n,note.v,note.len);
|
undo.log2DelNoteList(note.noteTime,note.c,note.n,note.v,note.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(note.v==0)
|
if(note.v==0)
|
||||||
timeNoteOff = note.t;
|
timeNoteOff = note.noteTime;
|
||||||
isdel = true;
|
isdel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ public class NoteList
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param t
|
* @param noteTime
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Note searchNoteByTime(int t)
|
public Note searchNoteByTime(int t)
|
||||||
@ -254,20 +254,20 @@ public class NoteList
|
|||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(t <= note.t)
|
if(t <= note.noteTime)
|
||||||
{
|
{
|
||||||
for(noteTmp = note;
|
for(noteTmp = note;
|
||||||
noteTmp.prev != null && t <= noteTmp.t;
|
noteTmp.prev != null && t <= noteTmp.noteTime;
|
||||||
noteTmp = noteTmp.prev)
|
noteTmp = noteTmp.prev)
|
||||||
;
|
;
|
||||||
if(noteTmp.t<t && noteTmp.next!=null)
|
if(noteTmp.noteTime<t && noteTmp.next!=null)
|
||||||
noteTmp = noteTmp.next;
|
noteTmp = noteTmp.next;
|
||||||
note = noteTmp;
|
note = noteTmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(noteTmp = note;
|
for(noteTmp = note;
|
||||||
noteTmp.next != null && noteTmp.t < t ;
|
noteTmp.next != null && noteTmp.noteTime < t ;
|
||||||
noteTmp = noteTmp.next)
|
noteTmp = noteTmp.next)
|
||||||
;
|
;
|
||||||
note = noteTmp;
|
note = noteTmp;
|
||||||
|
@ -86,14 +86,14 @@ public class NoteListUtils {
|
|||||||
undo.addAction(UndoableAction.DELETE_LIST);
|
undo.addAction(UndoableAction.DELETE_LIST);
|
||||||
undo.addAction(UndoableAction.SHIFT_LIST);
|
undo.addAction(UndoableAction.SHIFT_LIST);
|
||||||
undo.addAction(UndoableAction.ADD_LIST);
|
undo.addAction(UndoableAction.ADD_LIST);
|
||||||
int bufLen = bufferList.searchNoteByTime(0x7fffffff).t;
|
int bufLen = bufferList.searchNoteByTime(0x7fffffff).noteTime;
|
||||||
shift(dest, timeBeg,
|
shift(dest, timeBeg,
|
||||||
(bufLen * newTicksPer4) / bufticksPer4, undo);
|
(bufLen * newTicksPer4) / bufticksPer4, undo);
|
||||||
retVal = bufLen;
|
retVal = bufLen;
|
||||||
} else if (attr == REPLACE) {
|
} else if (attr == REPLACE) {
|
||||||
undo.addAction(UndoableAction.DELETE_LIST);
|
undo.addAction(UndoableAction.DELETE_LIST);
|
||||||
undo.addAction(UndoableAction.ADD_LIST);
|
undo.addAction(UndoableAction.ADD_LIST);
|
||||||
int bufLen = bufferList.searchNoteByTime(0x7fffffff).t;
|
int bufLen = bufferList.searchNoteByTime(0x7fffffff).noteTime;
|
||||||
dest.del(timeBeg, timeBeg
|
dest.del(timeBeg, timeBeg
|
||||||
+ (bufLen * newTicksPer4) / bufticksPer4,
|
+ (bufLen * newTicksPer4) / bufticksPer4,
|
||||||
channel, (byte) -1, (byte) 127, undo);
|
channel, (byte) -1, (byte) 127, undo);
|
||||||
@ -118,9 +118,9 @@ public class NoteListUtils {
|
|||||||
for (; note != null; note = note.next) {
|
for (; note != null; note = note.next) {
|
||||||
if (note.mark == NOTE_MARKED) {
|
if (note.mark == NOTE_MARKED) {
|
||||||
if (timeShift == -1) {
|
if (timeShift == -1) {
|
||||||
timeShift = note.t;
|
timeShift = note.noteTime;
|
||||||
}
|
}
|
||||||
dest.add(new Note(note.t - timeShift, note.c, note.n, note.v, note.len));
|
dest.add(new Note(note.noteTime - timeShift, note.c, note.n, note.v, note.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -148,17 +148,17 @@ public class NoteListUtils {
|
|||||||
byte n;
|
byte n;
|
||||||
Note srcNote;
|
Note srcNote;
|
||||||
for (srcNote = src.searchNoteByTime(tSrcBeg);
|
for (srcNote = src.searchNoteByTime(tSrcBeg);
|
||||||
srcNote != null && srcNote.t <= tSrcEnd; srcNote = srcNote.next) {
|
srcNote != null && srcNote.noteTime <= tSrcEnd; srcNote = srcNote.next) {
|
||||||
if (srcNote.c == chSrc && (srcNote.v == 0 && srcNote.t - srcNote.len >= tSrcBeg
|
if (srcNote.c == chSrc && (srcNote.v == 0 && srcNote.noteTime - srcNote.length >= tSrcBeg
|
||||||
|| srcNote.v != 0 && srcNote.t + srcNote.len <= tSrcEnd)
|
|| srcNote.v != 0 && srcNote.noteTime + srcNote.length <= tSrcEnd)
|
||||||
&& (srcNote.v != 0 || onlyMarkSrc)) {
|
&& (srcNote.v != 0 || onlyMarkSrc)) {
|
||||||
if (onlyMarkSrc) {
|
if (onlyMarkSrc) {
|
||||||
srcNote.mark = NOTE_MARKED;
|
srcNote.mark = NOTE_MARKED;
|
||||||
} else {
|
} else {
|
||||||
t = tDestBeg
|
t = tDestBeg
|
||||||
+ ((srcNote.t - tSrcBeg) * destTicksPer4) / srcTicksPer4;
|
+ ((srcNote.noteTime - tSrcBeg) * destTicksPer4) / srcTicksPer4;
|
||||||
n = srcNote.n;
|
n = srcNote.n;
|
||||||
len = (srcNote.len * destTicksPer4) / srcTicksPer4;
|
len = (srcNote.length * destTicksPer4) / srcTicksPer4;
|
||||||
dest.add(new Note(t, chDest, n, srcNote.v, len));
|
dest.add(new Note(t, chDest, n, srcNote.v, len));
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
@ -181,8 +181,8 @@ 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.t >= tBeg; note = note.prev) {
|
for (; note != null && note.noteTime >= tBeg; note = note.prev) {
|
||||||
if (note.v == 0 && note.t - note.len < tBeg) {
|
if (note.v == 0 && note.noteTime - note.length < 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.c != note.c || noteTmp.n != note.n);
|
||||||
@ -191,30 +191,30 @@ public class NoteListUtils {
|
|||||||
|
|
||||||
if (noteTmp != null && noteTmp.c == note.c && noteTmp.n == note.n) {
|
if (noteTmp != null && noteTmp.c == note.c && noteTmp.n == note.n) {
|
||||||
if (undo != null) {
|
if (undo != null) {
|
||||||
undo.log2DelNoteList(noteTmp.t, noteTmp.c, noteTmp.n, noteTmp.v, noteTmp.len);
|
undo.log2DelNoteList(noteTmp.noteTime, noteTmp.c, noteTmp.n, noteTmp.v, noteTmp.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
noteTmp.len = note.t - noteTmp.t + shiftLen;
|
noteTmp.length = note.noteTime - noteTmp.noteTime + shiftLen;
|
||||||
|
|
||||||
if (noteTmp.t + noteTmp.len < tBeg) {
|
if (noteTmp.noteTime + noteTmp.length < tBeg) {
|
||||||
noteTmp.len = tBeg - noteTmp.t;
|
noteTmp.length = tBeg - noteTmp.noteTime;
|
||||||
}
|
}
|
||||||
note.len = noteTmp.len;
|
note.length = noteTmp.length;
|
||||||
|
|
||||||
if (undo != null) {
|
if (undo != null) {
|
||||||
undo.log2AddNoteList(noteTmp.t, noteTmp.c, noteTmp.n, noteTmp.v, noteTmp.len);
|
undo.log2AddNoteList(noteTmp.noteTime, noteTmp.c, noteTmp.n, noteTmp.v, noteTmp.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
note.t += shiftLen;
|
note.noteTime += shiftLen;
|
||||||
if (note.t < tBeg) {
|
if (note.noteTime < tBeg) {
|
||||||
if (undo != null && note.v != 0) {
|
if (undo != null && note.v != 0) {
|
||||||
undo.log2DelNoteList(note.t - shiftLen, note.c, note.n, note.v, note.len);
|
undo.log2DelNoteList(note.noteTime - shiftLen, note.c, note.n, note.v, note.length);
|
||||||
undo.log2AddNoteList(tBeg, note.c, note.n, note.v, note.len);
|
undo.log2AddNoteList(tBeg, note.c, note.n, note.v, note.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
note.t = tBeg;
|
note.noteTime = tBeg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (undo != null) {
|
if (undo != null) {
|
||||||
@ -286,7 +286,7 @@ public class NoteListUtils {
|
|||||||
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.c == channel && note.v != 0) {
|
||||||
newTime = note.t + shiftTime;
|
newTime = note.noteTime + shiftTime;
|
||||||
if (newTime < 0) {
|
if (newTime < 0) {
|
||||||
newTime = 0;
|
newTime = 0;
|
||||||
}
|
}
|
||||||
@ -300,13 +300,13 @@ public class NoteListUtils {
|
|||||||
}
|
}
|
||||||
newVol = (byte) tmp;
|
newVol = (byte) tmp;
|
||||||
|
|
||||||
dest.add(new Note(newTime, channel, newN, newVol, note.len));
|
dest.add(new Note(newTime, channel, newN, newVol, note.length));
|
||||||
|
|
||||||
if (note.len > 0) {
|
if (note.length > 0) {
|
||||||
dest.add(new Note(newTime + note.len, channel, newN, (byte) 0, note.len));
|
dest.add(new Note(newTime + note.length, channel, newN, (byte) 0, note.length));
|
||||||
}
|
}
|
||||||
if (undo != null && note.v != 0) {
|
if (undo != null && note.v != 0) {
|
||||||
undo.log2AddNoteList(newTime, channel, newN, newVol, note.len);
|
undo.log2AddNoteList(newTime, channel, newN, newVol, note.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,19 @@
|
|||||||
package midedit;
|
package midedit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Äëèíà íîòû
|
||||||
* @author user
|
* @author user
|
||||||
*/
|
*/
|
||||||
public class NoteLong extends Note
|
public class NoteLong extends Note {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
*
|
* Êîíñòðóêòîð
|
||||||
* @param t
|
* @param time âðåìÿ
|
||||||
* @param d
|
* @param data äàííûå
|
||||||
*/
|
*/
|
||||||
public NoteLong(int t,byte[] d)
|
public NoteLong(int time, byte[] data) {
|
||||||
{
|
super(time, (byte) NoteList.CHANNEL_LONG_NOTE, (byte) 0, (byte) 0, 0);
|
||||||
super(t,(byte)NoteList.CHANNEL_LONG_NOTE,(byte)0,(byte)0,0);
|
dat = data;
|
||||||
dat = d;
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -57,9 +57,9 @@ public class NotesCanvas extends MixerCanvas {
|
|||||||
protected void paintNote(Graphics g, Note note, int shiftTime, int shiftNote) {
|
protected void paintNote(Graphics g, Note note, int shiftTime, int shiftNote) {
|
||||||
int x, h;
|
int x, h;
|
||||||
int dx, t = 1;
|
int dx, t = 1;
|
||||||
x = getXInPixel(note.t + shiftTime);
|
x = getXInPixel(note.noteTime + shiftTime);
|
||||||
h = getLineFromNote(note.n + shiftNote);
|
h = getLineFromNote(note.n + shiftNote);
|
||||||
dx = (note.len * wOne) / Constants.timeConst;
|
dx = (note.length * wOne) / Constants.timeConst;
|
||||||
if (dx == 0) {
|
if (dx == 0) {
|
||||||
dx = 2;
|
dx = 2;
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,8 @@ public class TempoList extends List implements CommandListener {
|
|||||||
int tempBPM;
|
int tempBPM;
|
||||||
int mod = (composition.getTicksPer4() << 2) >> (composition.getDenomE());
|
int mod = (composition.getTicksPer4() << 2) >> (composition.getDenomE());
|
||||||
tempBPM = Composition.getTempBeatPerMin(tempMsPer4);
|
tempBPM = Composition.getTempBeatPerMin(tempMsPer4);
|
||||||
return "" + note.t / tick + ":" + (note.t * meterNom / tick) % meterNom + ":"
|
return "" + note.noteTime / tick + ":" + (note.noteTime * meterNom / tick) % meterNom + ":"
|
||||||
+ note.t % mod + " - " + tempBPM;
|
+ note.noteTime % mod + " - " + tempBPM;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ public class TempoList extends List implements CommandListener {
|
|||||||
int ind;
|
int ind;
|
||||||
for (ind = 0; ind < tempNotes.size(); ++ind) {
|
for (ind = 0; ind < tempNotes.size(); ++ind) {
|
||||||
note = (NoteLong) tempNotes.elementAt(ind);
|
note = (NoteLong) tempNotes.elementAt(ind);
|
||||||
if (note.t > time) {
|
if (note.noteTime > time) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ public class TempoList extends List implements CommandListener {
|
|||||||
|
|
||||||
int mod = (composition.getTicksPer4() << 2) >> (composition.getDenomE());
|
int mod = (composition.getTicksPer4() << 2) >> (composition.getDenomE());
|
||||||
int tempBPM = Composition.getTempBeatPerMin(tmp);
|
int tempBPM = Composition.getTempBeatPerMin(tmp);
|
||||||
int time = notelong.t / tick;
|
int time = notelong.noteTime / tick;
|
||||||
|
|
||||||
editNum = ind;
|
editNum = ind;
|
||||||
|
|
||||||
|
@ -120,11 +120,11 @@ public class UndoableAction
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param t
|
* @param noteTime
|
||||||
* @param ch
|
* @param ch
|
||||||
* @param n
|
* @param n
|
||||||
* @param v
|
* @param v
|
||||||
* @param len
|
* @param length
|
||||||
*/
|
*/
|
||||||
public void log2AddNoteList(int t, byte ch, byte n, byte v,int len)
|
public void log2AddNoteList(int t, byte ch, byte n, byte v,int len)
|
||||||
{
|
{
|
||||||
@ -132,11 +132,11 @@ public class UndoableAction
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param t
|
* @param noteTime
|
||||||
* @param ch
|
* @param ch
|
||||||
* @param n
|
* @param n
|
||||||
* @param v
|
* @param v
|
||||||
* @param len
|
* @param length
|
||||||
*/
|
*/
|
||||||
public void log2DelNoteList(int t, byte ch, byte n, byte v,int len)
|
public void log2DelNoteList(int t, byte ch, byte n, byte v,int len)
|
||||||
{
|
{
|
||||||
@ -145,7 +145,7 @@ public class UndoableAction
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param timeBeg
|
* @param timeBeg
|
||||||
* @param len
|
* @param length
|
||||||
* @param ch
|
* @param ch
|
||||||
*/
|
*/
|
||||||
public void logShift(int timeBeg,int len,byte ch)
|
public void logShift(int timeBeg,int len,byte ch)
|
||||||
@ -161,18 +161,18 @@ public class UndoableAction
|
|||||||
switch(order[i])
|
switch(order[i])
|
||||||
{
|
{
|
||||||
case ADD_NOTE:
|
case ADD_NOTE:
|
||||||
composition.getNoteListByChannel(channel).delOne(noteAddDel.t, noteAddDel.c,
|
composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime, noteAddDel.c,
|
||||||
noteAddDel.n, noteAddDel.v);
|
noteAddDel.n, noteAddDel.v);
|
||||||
if(noteAddDel.len != 0)
|
if(noteAddDel.length != 0)
|
||||||
composition.getNoteListByChannel(channel).delOne(noteAddDel.t+noteAddDel.len,
|
composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime+noteAddDel.length,
|
||||||
noteAddDel.c,noteAddDel.n,(byte)0);
|
noteAddDel.c,noteAddDel.n,(byte)0);
|
||||||
break;
|
break;
|
||||||
case DEL_NOTE:
|
case DEL_NOTE:
|
||||||
composition.getNoteListByChannel(channel).add(new Note(noteAddDel.t,noteAddDel.c,
|
composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime,noteAddDel.c,
|
||||||
noteAddDel.n,noteAddDel.v,noteAddDel.len));
|
noteAddDel.n,noteAddDel.v,noteAddDel.length));
|
||||||
if(noteAddDel.len != 0)
|
if(noteAddDel.length != 0)
|
||||||
composition.getNoteListByChannel(channel).add(new Note(noteAddDel.t+noteAddDel.len,
|
composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime+noteAddDel.length,
|
||||||
noteAddDel.c,noteAddDel.n, (byte)0,noteAddDel.len));
|
noteAddDel.c,noteAddDel.n, (byte)0,noteAddDel.length));
|
||||||
break;
|
break;
|
||||||
case DELETE_LIST:
|
case DELETE_LIST:
|
||||||
Note noteLocal = dellist.getFirst();
|
Note noteLocal = dellist.getFirst();
|
||||||
@ -181,9 +181,9 @@ public class UndoableAction
|
|||||||
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.t,noteLocal.c,noteLocal.n,noteLocal.v,noteLocal.len));
|
list.add(new Note(noteLocal.noteTime,noteLocal.c,noteLocal.n,noteLocal.v,noteLocal.length));
|
||||||
if(noteLocal.len != 0)
|
if(noteLocal.length != 0)
|
||||||
list.add(new Note(noteLocal.t+noteLocal.len,noteLocal.c,noteLocal.n,(byte)0,noteLocal.len));
|
list.add(new Note(noteLocal.noteTime+noteLocal.length,noteLocal.c,noteLocal.n,(byte)0,noteLocal.length));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ADD_LIST:
|
case ADD_LIST:
|
||||||
@ -194,9 +194,9 @@ public class UndoableAction
|
|||||||
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.t,noteLocal.c,noteLocal.n,noteLocal.v);
|
list.delOne(noteLocal.noteTime,noteLocal.c,noteLocal.n,noteLocal.v);
|
||||||
if(noteLocal.len != 0)
|
if(noteLocal.length != 0)
|
||||||
list.delOne(noteLocal.t+noteLocal.len,noteLocal.c,noteLocal.n,(byte)0);
|
list.delOne(noteLocal.noteTime+noteLocal.length,noteLocal.c,noteLocal.n,(byte)0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SHIFT_LIST:
|
case SHIFT_LIST:
|
||||||
|
@ -4,6 +4,7 @@ package midedit;
|
|||||||
import midedit.media.Composition;
|
import midedit.media.Composition;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.microedition.lcdui.*;
|
import javax.microedition.lcdui.*;
|
||||||
|
import main.L;
|
||||||
import main.Main;
|
import main.Main;
|
||||||
import main.P;
|
import main.P;
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ import main.P;
|
|||||||
*/
|
*/
|
||||||
public class VolumeForm extends Form implements CommandListener {
|
public class VolumeForm extends Form implements CommandListener {
|
||||||
|
|
||||||
|
private Command playOrig = new Command(L.str[L.playOrigin], Command.ITEM, 1);
|
||||||
private Gauge[] volumeGauges;
|
private Gauge[] volumeGauges;
|
||||||
private ChoiceGroup[] soloChecks;
|
private ChoiceGroup[] soloChecks;
|
||||||
private Vector channels = null;
|
private Vector channels = null;
|
||||||
@ -61,7 +63,7 @@ public class VolumeForm extends Form implements CommandListener {
|
|||||||
this.append(" ");
|
this.append(" ");
|
||||||
}
|
}
|
||||||
this.addCommand(CompositionForm.play);
|
this.addCommand(CompositionForm.play);
|
||||||
this.addCommand(CompositionForm.playOrig);
|
this.addCommand(playOrig);
|
||||||
this.addCommand(CompositionForm.ok);
|
this.addCommand(CompositionForm.ok);
|
||||||
this.addCommand(P.comCancel);
|
this.addCommand(P.comCancel);
|
||||||
this.setCommandListener(this);
|
this.setCommandListener(this);
|
||||||
@ -87,7 +89,7 @@ public class VolumeForm extends Form implements CommandListener {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (command == CompositionForm.playOrig) {
|
} else if (command == playOrig) {
|
||||||
restoreVolumesArr();
|
restoreVolumesArr();
|
||||||
try {
|
try {
|
||||||
model.playMix(composition, MixerCanvas.xBase * Constants.timeConst);
|
model.playMix(composition, MixerCanvas.xBase * Constants.timeConst);
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
package midedit;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import javax.microedition.lcdui.*;
|
|
||||||
import javax.microedition.lcdui.Command;
|
|
||||||
import javax.microedition.lcdui.Displayable;
|
|
||||||
import main.P;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author user
|
|
||||||
*/
|
|
||||||
public class WaitForm extends Form implements Runnable, CommandListener
|
|
||||||
{
|
|
||||||
private Gauge percentBar;
|
|
||||||
private Gauge memoryBar;
|
|
||||||
Runtime r;
|
|
||||||
int total;
|
|
||||||
int curPercent;
|
|
||||||
Waitable activity;
|
|
||||||
Displayable next;
|
|
||||||
MixerModel model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param title
|
|
||||||
* @param act
|
|
||||||
* @param n
|
|
||||||
* @param mod
|
|
||||||
*/
|
|
||||||
public WaitForm(String title,Waitable act, Displayable n,MixerModel mod)
|
|
||||||
{
|
|
||||||
super("MidEdit");
|
|
||||||
activity = act;
|
|
||||||
next = n;
|
|
||||||
model = mod;
|
|
||||||
r = Runtime.getRuntime();
|
|
||||||
total = (int)r.totalMemory();
|
|
||||||
percentBar = new Gauge(title,false,100,0);
|
|
||||||
memoryBar = new Gauge("Memory",false,100,(total-(int)r.freeMemory())*100/total);
|
|
||||||
append(percentBar);
|
|
||||||
append(memoryBar);
|
|
||||||
this.addCommand(P.comCancel);
|
|
||||||
this.setCommandListener(this);
|
|
||||||
}
|
|
||||||
private void setPercent(int percent)
|
|
||||||
{
|
|
||||||
percentBar.setValue(percent);
|
|
||||||
memoryBar.setValue((total-(int)r.freeMemory())*100/total);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
curPercent = 0;
|
|
||||||
while(curPercent<100)
|
|
||||||
{
|
|
||||||
setPercent(activity.getCurPercent());
|
|
||||||
Thread.sleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param command
|
|
||||||
* @param displayable
|
|
||||||
*/
|
|
||||||
public void commandAction(Command command, Displayable displayable)
|
|
||||||
{
|
|
||||||
cancel();
|
|
||||||
model.display.setCurrent(next);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void cancel()
|
|
||||||
{
|
|
||||||
activity.cancel();
|
|
||||||
curPercent = 100;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +1,24 @@
|
|||||||
package midedit;
|
package midedit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Интерфейс статуса операций
|
||||||
* @author user
|
* @author user
|
||||||
*/
|
*/
|
||||||
public interface Waitable {
|
public interface Waitable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Получить текущее состояние
|
||||||
* @return
|
* @return процент выполненной задачи
|
||||||
*/
|
*/
|
||||||
public int getCurPercent();
|
public int getCurPercent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Отмена операции
|
||||||
*/
|
*/
|
||||||
public void cancel();
|
public void cancel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Сброс операции
|
||||||
*/
|
*/
|
||||||
public void reset();
|
public void reset();
|
||||||
}
|
}
|
||||||
|
@ -86,16 +86,15 @@ public class Composition {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String[] getInstrumentsStrings() {
|
public String[] getInstrumentsStrings() {
|
||||||
// String[] allInstrums = Constants.instruments;
|
|
||||||
int size = 0;
|
int size = 0;
|
||||||
for (int i = 0; i < Constants.NCHANNEL; ++i) {
|
for (int i = 0; i < Constants.NCHANNEL; i++) {
|
||||||
if (instruments[i] != NOTHING) {
|
if (instruments[i] != NOTHING) {
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String[] ss = new String[size];
|
String[] ss = new String[size];
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 0; i < Constants.NCHANNEL; ++i) {
|
for (int i = 0; i < Constants.NCHANNEL; i++) {
|
||||||
if (instruments[i] != NOTHING) {
|
if (instruments[i] != NOTHING) {
|
||||||
ss[j++] = Constants.getInstrName(instruments[i] + 1);
|
ss[j++] = Constants.getInstrName(instruments[i] + 1);
|
||||||
}
|
}
|
||||||
@ -270,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.len = tt - noteTmp.t;
|
noteTmp.length = tt - noteTmp.noteTime;
|
||||||
tracks[ch].add(new Note(tt, ch, nn, (byte) 0, noteTmp.len));
|
tracks[ch].add(new Note(tt, ch, nn, (byte) 0, noteTmp.length));
|
||||||
} else {
|
} else {
|
||||||
tracks[ch].add(new Note(tt, ch, nn, (byte) 0, 0));
|
tracks[ch].add(new Note(tt, ch, nn, (byte) 0, 0));
|
||||||
}
|
}
|
||||||
@ -329,7 +328,7 @@ public class Composition {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param t
|
* @param noteTime
|
||||||
* @param ch
|
* @param ch
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -383,7 +382,7 @@ public class Composition {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param t
|
* @param noteTime
|
||||||
*/
|
*/
|
||||||
public void setTicksPer4(int t) {
|
public void setTicksPer4(int t) {
|
||||||
ticksPer4 = t;
|
ticksPer4 = t;
|
||||||
@ -441,7 +440,7 @@ public class Composition {
|
|||||||
if (percent == 0) {
|
if (percent == 0) {
|
||||||
timeNew = 0;
|
timeNew = 0;
|
||||||
} else {
|
} else {
|
||||||
timeNew = this.getFirstNote(this.getLastTime() * percent / 100, ch).t;
|
timeNew = this.getFirstNote(this.getLastTime() * percent / 100, ch).noteTime;
|
||||||
MixerCanvas.curX = 0;
|
MixerCanvas.curX = 0;
|
||||||
}
|
}
|
||||||
MixerCanvas.xBase = (short) (timeNew / Constants.timeConst);
|
MixerCanvas.xBase = (short) (timeNew / Constants.timeConst);
|
||||||
@ -466,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.t + noteTimeMax.len;
|
tCur = noteTimeMax.noteTime + noteTimeMax.length;
|
||||||
if (tCur > tMax) {
|
if (tCur > tMax) {
|
||||||
tMax = tCur;
|
tMax = tCur;
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,20 @@ import javax.microedition.media.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Класс воспроизведения мидишек
|
||||||
* @author user
|
* @author user
|
||||||
*/
|
*/
|
||||||
public class JSR135Player extends AbstractPlayer implements PlayerListener {
|
public class JSR135Player extends AbstractPlayer implements PlayerListener {
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
public void playerUpdate(Player player, java.lang.String event, java.lang.Object eventData) {
|
/**
|
||||||
|
* Событие при обновлении состояния плеера
|
||||||
|
* @param player сам плеер
|
||||||
|
* @param event событие
|
||||||
|
* @param eventData данные события
|
||||||
|
*/
|
||||||
|
public void playerUpdate(Player player, String event, Object eventData) {
|
||||||
if (event.equals(STARTED)) {
|
if (event.equals(STARTED)) {
|
||||||
setIsPlaying(true);
|
setIsPlaying(true);
|
||||||
return;
|
return;
|
||||||
@ -23,6 +29,11 @@ public class JSR135Player extends AbstractPlayer implements PlayerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Воспроизведение мелодии по указанному пути
|
||||||
|
* @param path путь к файлу
|
||||||
|
* @throws Exception не удалось воспроизвести
|
||||||
|
*/
|
||||||
public void play(String path) throws Exception {
|
public void play(String path) throws Exception {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.close();
|
player.close();
|
||||||
@ -30,23 +41,14 @@ public class JSR135Player extends AbstractPlayer implements PlayerListener {
|
|||||||
InputStream is = MixerModel.getLocalFile().getInputStreambyURL(path);
|
InputStream is = MixerModel.getLocalFile().getInputStreambyURL(path);
|
||||||
player = Manager.createPlayer(is, "audio/midi");
|
player = Manager.createPlayer(is, "audio/midi");
|
||||||
player.addPlayerListener(this);
|
player.addPlayerListener(this);
|
||||||
|
player.realize();
|
||||||
player.start();
|
player.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void stop() throws Exception {
|
/**
|
||||||
if (player != null) {
|
* Воспроизведение мелодии
|
||||||
player.stop();
|
* @param writeTest массив байт midi-мелодии
|
||||||
}
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
if (player != null) {
|
|
||||||
player.close();
|
|
||||||
}
|
|
||||||
player = null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playTest(byte[] writeTest) {
|
public void playTest(byte[] writeTest) {
|
||||||
ByteArrayInputStream is = new ByteArrayInputStream(writeTest);
|
ByteArrayInputStream is = new ByteArrayInputStream(writeTest);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
@ -56,11 +58,34 @@ public class JSR135Player extends AbstractPlayer implements PlayerListener {
|
|||||||
try {
|
try {
|
||||||
player = Manager.createPlayer(is, "audio/midi");
|
player = Manager.createPlayer(is, "audio/midi");
|
||||||
player.addPlayerListener(this);
|
player.addPlayerListener(this);
|
||||||
|
player.realize();
|
||||||
player.start();
|
player.start();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
//ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
} catch (MediaException ex) {
|
} catch (MediaException ex) {
|
||||||
//ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Остановить плеер
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
protected void stop() throws Exception {
|
||||||
|
if (player != null) {
|
||||||
|
player.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Закрыть плеер и освободить память
|
||||||
|
*/
|
||||||
|
public void close() {
|
||||||
|
if (player != null) {
|
||||||
|
player.close();
|
||||||
|
}
|
||||||
|
player = null;
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class PreviewPlayer implements PlayerListener {
|
|||||||
private boolean isPlaying = false;
|
private boolean isPlaying = false;
|
||||||
private Player player;
|
private Player player;
|
||||||
|
|
||||||
public void playerUpdate(Player player, java.lang.String event, java.lang.Object eventData) {
|
public void playerUpdate(Player player, String event, Object eventData) {
|
||||||
if (event.equals(STARTED)) {
|
if (event.equals(STARTED)) {
|
||||||
isPlaying = true;
|
isPlaying = true;
|
||||||
return;
|
return;
|
||||||
@ -21,7 +21,6 @@ public class PreviewPlayer implements PlayerListener {
|
|||||||
if (event.equals(STOPPED) || event.equals(CLOSED) || event.equals(END_OF_MEDIA)) {
|
if (event.equals(STOPPED) || event.equals(CLOSED) || event.equals(END_OF_MEDIA)) {
|
||||||
isPlaying = false;
|
isPlaying = false;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void play(String path) throws Exception {
|
public void play(String path) throws Exception {
|
||||||
|
@ -70,6 +70,9 @@ public class FileManager extends Canvas {
|
|||||||
/** Îòîáðàæàòü ëè ìåíþ */
|
/** Îòîáðàæàòü ëè ìåíþ */
|
||||||
private boolean showMenu;
|
private boolean showMenu;
|
||||||
|
|
||||||
|
/** Ïîäòâåðæäåíèå ïðè óäàëåíèè ôàéëà */
|
||||||
|
private boolean isDelete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Êîíñòðóêòîð äëÿ îòêðûòèÿ ôàéëîâ
|
* Êîíñòðóêòîð äëÿ îòêðûòèÿ ôàéëîâ
|
||||||
* @param s ñòàðòîâûé ïóòü ê ïàïêå
|
* @param s ñòàðòîâûé ïóòü ê ïàïêå
|
||||||
@ -87,6 +90,7 @@ public class FileManager extends Canvas {
|
|||||||
fontCashe = FWCashe.getCache(P.smBold);
|
fontCashe = FWCashe.getCache(P.smBold);
|
||||||
CursorY = startPrintFile = curFiles = numFiles = 0;
|
CursorY = startPrintFile = curFiles = numFiles = 0;
|
||||||
showMenu = false;
|
showMenu = false;
|
||||||
|
isDelete = false;
|
||||||
|
|
||||||
loadImages();
|
loadImages();
|
||||||
// Ñïèñîê ïóíêòîâ ìåíþ
|
// Ñïèñîê ïóíêòîâ ìåíþ
|
||||||
@ -132,7 +136,7 @@ public class FileManager extends Canvas {
|
|||||||
if (menu[0].equals(L.str[L.saveInThisFolder])) {
|
if (menu[0].equals(L.str[L.saveInThisFolder])) {
|
||||||
// Ïóíêòû ïðè ñîõðàíåíèè
|
// Ïóíêòû ïðè ñîõðàíåíèè
|
||||||
vt.addElement(L.str[L.saveInThisFolder]);
|
vt.addElement(L.str[L.saveInThisFolder]);
|
||||||
if(!P.isRMSMode) vt.addElement(L.str[L.newFolder]);
|
if(!P.isRMSMode && (!P.path.equals("/"))) vt.addElement(L.str[L.newFolder]);
|
||||||
} else {
|
} else {
|
||||||
if (numFiles > 0) {
|
if (numFiles > 0) {
|
||||||
// Ïóíêòû ïðè îòêðûòèè
|
// Ïóíêòû ïðè îòêðûòèè
|
||||||
@ -254,7 +258,7 @@ public class FileManager extends Canvas {
|
|||||||
// Âûáðàííûé ïóíêò ìåíþ
|
// Âûáðàííûé ïóíêò ìåíþ
|
||||||
final String cur = menu[selected];
|
final String cur = menu[selected];
|
||||||
// Âûáðàííûé ïóíêò â ñïèñêå ôàéëîâ
|
// Âûáðàííûé ïóíêò â ñïèñêå ôàéëîâ
|
||||||
final String fileSelected = data[curFiles];
|
final String fileSelected = (numFiles > 0) ? data[curFiles] : "";
|
||||||
|
|
||||||
curMenu = 0;
|
curMenu = 0;
|
||||||
showMenu = false;
|
showMenu = false;
|
||||||
@ -286,7 +290,8 @@ public class FileManager extends Canvas {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cur.equals(L.str[L.delete])) {
|
else if (cur.equals(L.str[L.ok])) {
|
||||||
|
System.out.println(fileSelected);
|
||||||
if(!fileSelected.endsWith("/")) {
|
if(!fileSelected.endsWith("/")) {
|
||||||
String fileToDelete = fileSelected;
|
String fileToDelete = fileSelected;
|
||||||
if(!P.isRMSMode) fileToDelete = pathFile + fileSelected;
|
if(!P.isRMSMode) fileToDelete = pathFile + fileSelected;
|
||||||
@ -297,9 +302,22 @@ public class FileManager extends Canvas {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
isDelete = false;
|
||||||
|
}
|
||||||
|
else if (cur.equals(L.str[L.delete])) {
|
||||||
|
menu = new String[] {L.str[L.cancel], L.str[L.ok]};
|
||||||
|
showMenu = true;
|
||||||
|
isDelete = true;
|
||||||
}
|
}
|
||||||
else if (cur.equals( L.str[L.cancel])) {
|
else if (cur.equals( L.str[L.cancel])) {
|
||||||
// Îòìåíà
|
// Îòìåíà
|
||||||
|
if(isDelete) {
|
||||||
|
// Îòìåíà ïðè ïîïûòêå óäàëèòü ôàéë
|
||||||
|
isDelete = false;
|
||||||
|
setMenu();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Îòìåíà â îáùåì ìåíþ
|
||||||
P.path = pathFile;
|
P.path = pathFile;
|
||||||
if(menu[0].equals(L.str[L.saveInThisFolder])) Main.dsp.setCurrent(previousDisplayable);
|
if(menu[0].equals(L.str[L.saveInThisFolder])) Main.dsp.setCurrent(previousDisplayable);
|
||||||
else Main.dsp.setCurrent(Main.midlet.menu);
|
else Main.dsp.setCurrent(Main.midlet.menu);
|
||||||
@ -425,6 +443,7 @@ public class FileManager extends Canvas {
|
|||||||
case UP: cursorUp(); break;
|
case UP: cursorUp(); break;
|
||||||
case FIRE:
|
case FIRE:
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
|
if (numFiles > 0)
|
||||||
nextDir(data[curFiles]);
|
nextDir(data[curFiles]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ public class Menu extends Canvas {
|
|||||||
g.setColor(P.backgrnd);
|
g.setColor(P.backgrnd);
|
||||||
g.fillRect(0, 0, w, h);
|
g.fillRect(0, 0, w, h);
|
||||||
|
|
||||||
String title = "MidEdit. "+Key.Platform;
|
String title = L.str[L.midedit] + ". "+Key.Platform;
|
||||||
UI.drawTitle(g, title);
|
UI.drawTitle(g, title);
|
||||||
UI.drawSoftBar(g, L.str[L.ok], L.str[L.exit]);
|
UI.drawSoftBar(g, L.str[L.ok], L.str[L.exit]);
|
||||||
|
|
||||||
|
@ -80,8 +80,8 @@ 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.languageApp, true);
|
||||||
L.readLang(Rms.languageInstr, false);
|
//L.readLang(Rms.languageInstr, false);
|
||||||
|
|
||||||
Rms.tempDir = tempDirField.getString();
|
Rms.tempDir = tempDirField.getString();
|
||||||
|
|
||||||
|
@ -57,20 +57,30 @@ public class UI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Îòðèñîâêà ñîñòîÿíèÿ ïî ìàññèâó (â ýôôåòêàõ)
|
* Îòðèñîâêà ïðîãðåññà
|
||||||
* @param g êîíòåêñò ãðàôèêè
|
* @param g êîíòåêñò ãðàôèêè
|
||||||
* @param cur òåêóùåå ñîñòîÿíèå
|
* @param cur òåêóùåå ñîñòîÿíèå
|
||||||
* @param all âñåãî
|
* @param all âñåãî
|
||||||
|
* @param str êîììåíòàðèé
|
||||||
*/
|
*/
|
||||||
public static void drawStatusBar(Graphics g, int cur, int all) {
|
public static void drawProgressBar(Graphics g, int cur, int all, String str) {
|
||||||
int w = g.getClipWidth();
|
int w = g.getClipWidth();
|
||||||
int h = g.getClipHeight();
|
int h = g.getClipHeight();
|
||||||
int sw = w / 20;
|
final int w2 = w / 2;
|
||||||
int sh = h - h / 20;
|
if (all != 0) {
|
||||||
g.setColor(0x00);
|
final int barWidth = (cur * w) / all;
|
||||||
g.drawRect(w - 2 * sw - 1, h/25 - 1, sw + 1, sh + 1);
|
final int barY = h / 2 + h / 16;
|
||||||
int curr = (cur * sh) / all;
|
drawRect(g, P.colup, P.coldn, 0, barY, barWidth, h / 16);
|
||||||
drawRect(g, P.colup, P.coldn, w - 2 * sw, (h/25 + (sh - curr)), sw, sh - (sh - curr));
|
String value = String.valueOf((cur * 100) / all) + "%";
|
||||||
|
g.setColor(P.fmtextnc);
|
||||||
|
g.drawString(value, w2, barY, Graphics.TOP | Graphics.HCENTER);
|
||||||
|
g.setColor(P.fmtextcur);
|
||||||
|
g.drawString(value, w2 + 1, barY + 1, Graphics.TOP | Graphics.HCENTER);
|
||||||
|
}
|
||||||
|
if (str != null || str.length() != 0) {
|
||||||
|
g.setColor(P.fmtextcur);
|
||||||
|
g.drawString(str, w2 + 1, h / 2 + 1, Graphics.BOTTOM | Graphics.HCENTER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
107
src/ui/WaitCanvas.java
Normal file
107
src/ui/WaitCanvas.java
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* aNNiMON 2011
|
||||||
|
* For more info visit http://annimon.com/
|
||||||
|
*/
|
||||||
|
package ui;
|
||||||
|
|
||||||
|
import javax.microedition.lcdui.*;
|
||||||
|
import main.Key;
|
||||||
|
import main.L;
|
||||||
|
import main.P;
|
||||||
|
import midedit.Waitable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Êëàññ ñòàòóñà îïåðàöèè
|
||||||
|
* @author aNNiMON
|
||||||
|
*/
|
||||||
|
public class WaitCanvas extends Canvas implements Runnable {
|
||||||
|
|
||||||
|
/** Ìàêñèìàëüíîå êîë-âî ïðîöåíòîâ */
|
||||||
|
private static final int MAX_PERCENT = 100;
|
||||||
|
|
||||||
|
|
||||||
|
/** Èíôîðìàöèÿ î ñâîáîäíîé ïàìÿòè */
|
||||||
|
private Runtime runtime;
|
||||||
|
|
||||||
|
/** Êëàññ àêòèâíîñòè, êîòîðûé âîçâðàùàåò ãîòîâíîñòü ïðîöåññà */
|
||||||
|
private Waitable activity;
|
||||||
|
|
||||||
|
/** Ýêðàí, êóäà íóæíî ïåðåéòè ïî îêîí÷àíèþ ïðîöåññà */
|
||||||
|
private Displayable nextDisplayable;
|
||||||
|
|
||||||
|
/** Çàãîëîâîê îïåðàöèè */
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/** Ðàçìåð ýêðàíà */
|
||||||
|
private int w, h;
|
||||||
|
|
||||||
|
/** Îáùåå êîëè÷åñòâî ïàìÿòè */
|
||||||
|
private int totalMemory;
|
||||||
|
/** Òåêóùåå ñîñòîÿíèå (â ïðîöåíòàõ) */
|
||||||
|
private int curPercent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Êîíñòðóêòîð
|
||||||
|
* @param title çàãîëîâîê îïåðàöèè
|
||||||
|
* @param act êëàññ àêòèâíîñòè
|
||||||
|
* @param displayable ýêðàí, êîòîðûé ïîêàæåì ïîñëå îêîí÷àíèÿ
|
||||||
|
*/
|
||||||
|
public WaitCanvas(String title, Waitable act, Displayable displayable) {
|
||||||
|
setFullScreenMode(true);
|
||||||
|
w = getWidth();
|
||||||
|
h = getHeight();
|
||||||
|
this.title = title;
|
||||||
|
activity = act;
|
||||||
|
nextDisplayable = displayable;
|
||||||
|
runtime = Runtime.getRuntime();
|
||||||
|
totalMemory = (int) runtime.totalMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
g.setColor(P.backgrnd);
|
||||||
|
g.fillRect(0, 0, w, h);
|
||||||
|
UI.drawTitle(g, title);
|
||||||
|
UI.drawSoftBar(g, "", L.str[L.cancel]);
|
||||||
|
|
||||||
|
// Îòðèñîâêà ïðîãðåññà
|
||||||
|
final int memoryPercent = (totalMemory - (int) runtime.freeMemory()) * MAX_PERCENT / totalMemory;
|
||||||
|
String memory = L.str[L.memory] + " " + String.valueOf(memoryPercent) + "%";
|
||||||
|
UI.drawProgressBar(g, curPercent, MAX_PERCENT, memory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
curPercent = 0;
|
||||||
|
while (curPercent < MAX_PERCENT) {
|
||||||
|
curPercent = activity.getCurPercent();
|
||||||
|
repaint();
|
||||||
|
Thread.sleep(500);
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Îòìåíà îïåðàöèè
|
||||||
|
*/
|
||||||
|
public void cancel() {
|
||||||
|
activity.cancel();
|
||||||
|
curPercent = MAX_PERCENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void sizeChanged(int w, int h) {
|
||||||
|
this.w = getWidth();
|
||||||
|
this.h = getHeight();
|
||||||
|
super.sizeChanged(w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void keyPressed(int key) {
|
||||||
|
if(key == Key.rightSoftKey) {
|
||||||
|
cancel();
|
||||||
|
main.Main.dsp.setCurrent(nextDisplayable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user