This commit is contained in:
Victor 2018-11-14 19:46:45 +02:00
parent bd3ac77767
commit 76bdc22597
31 changed files with 664 additions and 618 deletions

View File

@ -127,7 +127,6 @@ Telephone ring
Helicopter
Applause
Gunshot
Piano
Chromatic percussion
Organ
@ -144,7 +143,6 @@ Synth sfx
Ethnic misc
Percussive
Sfx
Highq
Slap
Scratch push

View File

@ -9,7 +9,7 @@
Клавинет (клавесин 2)
Челеста
Колокольчики (бутылки)
'Музыкальная шкатулка'
Музыкальная шкатулка
Вибрафон
Маримба
Ксилофон
@ -54,7 +54,7 @@
Хор на слог 'а'
Голос на слог 'о'
Синтетический голос
'Удар' (весь оркестр)
Удар (весь оркестр)
Труба
Тромбон
Туба
@ -90,7 +90,7 @@ Charang-гитара
Синтезаторный звук нью-эйдж
Теплый синт-звук
Полисинтезатор
Синт-'хор'
Синт-хор
Воздушный (смычковый синт-звук)
Металлический синт
Ореол
@ -127,7 +127,6 @@ Charang-гитара
Вертолет
Алодисменты
Выстрел
Фортепиано
Хроматиккаа и Перкуссия
Орган
@ -144,7 +143,6 @@ Charang-гитара
Народные
Перкуссия
Звуковые эффекты
Высокое Q
Слэп
Царапанье (от себя)

View File

@ -93,4 +93,6 @@ Navigation
Nums, otherwise keypad, when edit notes
Name
Temp directory
New folder
New folder
Memory
MidEdit

View File

@ -66,8 +66,8 @@ Ok
Вставить Темп
Удалить Темп
Темп
Время(Мера)
Поиск
Времяера)
Позиция
числитель
знаменатель(2 в степени)
Метр = числитель/ (2^знаменатель). Например, используйте 4/4 (numerator=4; denominator=2) или 6/8 (numerator=6; denominator=3)
@ -86,11 +86,13 @@ Ok
Заменить
Наложить
Очистить буфер
Подсказка
Помощь
Клавиши
Быстрые команды
Навигация
Цифрами, иначе джойстиком, при редактировании нот
Имя
Временная папка
Новая папка
Новая папка
Память
MidEdit

BIN
res/test.mid Normal file

Binary file not shown.

View File

@ -107,7 +107,9 @@ public class L {
numkeysOptionString = 92,
midiName = 93,
tempDir = 94,
newFolder = 95;
newFolder = 95,
memory = 96,
midedit = 97;
/** Ìàññèâ òåêñòîâûõ ìåòîê */

View File

@ -40,6 +40,7 @@ public class Rms {
dos.writeInt(noteWidth);
dos.writeInt(noteHeight);
dos.writeBoolean(numKeysEdit);
dos.writeUTF(P.path); // ïóòü â ôì
dos.flush();
options = baos.toByteArray();
dos.close();
@ -81,6 +82,7 @@ public class Rms {
noteWidth = dis.readInt();
noteHeight = dis.readInt();
numKeysEdit = dis.readBoolean();
P.path = dis.readUTF();
dis.close();
} catch (Exception ex) {
}

View File

@ -1,15 +1,22 @@
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
- Исправления в локализации.
- Новое графическое меню. Убраны лишние пункты при запуске.
- Добавлен графический файловый менеджер, показывающий только те файлы, с которыми работает программа.
- Добавлен графический файловый менеджер, показывающий только те файлы, с которыми работает программа. Сделано запоминание последнего пути.
- Добавлена возможность прослушивания мелодии и создания новой папки в файлменеджере.
- Некоторые экраны (в основном помощи) изменены на графические.
********
Добавить украинский язык.
Help в aNMPWR
player.realize
********
Не работает добавить инструмент/заменить, нельзя прослушать инстумент при выборе.
- курсор редактора во время проигрывания бежит быстрее, чем фактически играет композиция. До этого настройки размера длины и ширины ноты были изменены. Возможно, скорость курсора была привязана к определенному размеру ячеек.
++++
Вот второй тест. Добавлено подтверждение при удалении файла, исправлен сдвиг в текстовых метках ударных, исправлен баг с однотипными иконками при смене языка.

View File

@ -7,84 +7,118 @@ import javax.microedition.lcdui.*;
import main.L;
import main.P;
import main.Main;
import ui.WaitCanvas;
/**
*
* Ôîðìà óïðàâëåíèÿ êîìïîçèöèÿìè
* @author user
* @author aNNiMON (ìîä)
*/
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 byte seekGaugeCur = 0;
private Main control;
private MixerModel model;
private Display display;
private NotesCanvas notesCanvas;
private DrumsCanvas drumsCanvas;
private MixerCanvas curCanvas;
private ChannelChoiceGroup choiseInstrument;
private Gauge seekingGauge;
/** Ñîñòîÿíèå âîñïðîèçâåäåíèÿ */
public static boolean isPlaying;
/**
* Ôîðìà âûáîðà èíñòðóìåíòîâ
* Èñïîëüçóåòñÿ ïðè äîáàâëåíèè/çàìåíå èíñòðóìåíòà.
* Ñòàòè÷åñêàÿ ïåðåìåííàÿ âçÿòà äëÿ îïòèìèçàöèè, ÷òîáû êàæäûé ðàç íå ãåíåðèðîâàòü.
*/
private static Form listInstrumentsForm;
/** Ýêçìåïëÿð ìèäëåòà */
private Main control;
/** Îáúåêò äèñïëåÿ */
private Display display;
/** Êëàññ ìåíåäæåðà âîñïðîèçâåäåíèÿ */
private MixerModel model;
/** Êîìïîçèöèÿ */
private Composition composition;
/** Ýêðàí ðåäàêòèðîâàíèÿ íîò */
private NotesCanvas notesCanvas;
/** Ýêðàí ðåäàêòèðîâàíèÿ áàðàáàíîâ */
private DrumsCanvas drumsCanvas;
/** Îáùèé ýêðàí ðåäàêòèðîâàíèÿ */
private MixerCanvas curCanvas;
/** Âûáîð èíñòðóìåíòà */
private ChannelChoiceGroup choiñeInstrument;
/** Ïðîïóñê ïðè ðåäàêòèðîâàíèè ìåëîäèè */
private Gauge seekingGauge;
/** Èìÿ ðåäàêòèðóåìîãî ôàéëà */
private String fileName;
public static boolean isPlaying,
isWorking,
isNew = false,
isAdd;
private Command addInstrument = new Command(L.str[L.addInstrument], Command.HELP, 3),
edit = new Command(L.str[L.edit], Command.HELP, 1),
setInstrument = new Command(L.str[L.setInstrument], Command.ITEM, 1),
delInstrument = new Command(L.str[L.delInstrument], Command.ITEM, 2),
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),
rmsMode = new Command(L.str[L.RMS], Command.ITEM, 6),
jsr75Mode = new Command(L.str[L.file], Command.ITEM, 7);
/** Òåêóùåå êîëè÷åñòâî øàãîâ ïðîïóñêà */
private byte seekGaugeCur = 0;
/** Ñîçäà¸ì ëè íîâûé ôàéë */
private boolean isNew = false;
/** Äîáàâèòü èëè çàìåíèòü èíñòðóìåíò */
private boolean isAdd;
/** Êîìàíäû */
public static Command play = new Command(L.str[L.play], Command.ITEM, 1);
public static Command stop = new Command(L.str[L.stop], Command.BACK, 0);
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);
/**
*
*/
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
* Êîíñòðóêòîð
* @param control ýêçìåïëÿð ãëàâíîãî êëàññà
* @throws Exception
*/
public CompositionForm(Main ctrl) throws Exception {
this(ctrl, null);
public CompositionForm(Main control) throws Exception {
this(control, null);
isNew = true;
}
/**
*
* @param ctrl
* @param fName
* Êîíñòðóêòîð
* @param control ýêçìåïëÿð ãëàâíîãî êëàññà
* @param fName èìÿ ôàéëà
* @throws Exception
*/
public CompositionForm(Main ctrl, String fName) throws Exception {
public CompositionForm(Main control, String fName) throws Exception {
super((fName != null) ? fName : "New");
control = ctrl;
this.control = control;
model = control.getModel();
model.crossPlayer.setCommandForm(this);
model.crossPlayer.setCommandForm(CompositionForm.this);
fileName = fName;
curForm = this;
}
/**
*
* Íîâûé ëè ôàéë ñîçäà¸ì
* @return
*/
public boolean isNew() {
@ -92,7 +126,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
}
/**
*
* Óñòàíîâèòü, íîâàÿ ëè êîìïîçèöèÿ
* @param isNewComposition
*/
public void setNew(boolean isNewComposition) {
@ -107,28 +141,19 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
seekGaugeCur = (byte) seekingGauge.getValue();
display.setCurrent(this);
}
/**
*
* @return
*/
// public boolean isntCancel() {
// return isWorking;
// }
//
/**
*
*/
public void run() {
display = main.Main.dsp;
WaitForm waitForm = new WaitForm(L.str[L.opening],//@@@
WaitCanvas waitCanvas = new WaitCanvas(L.str[L.opening],
model.getWaitableFile(),
control.getCurrentlistMenu(),
model);
display.setCurrent(waitForm);
control.getCurrentlistMenu());
display.setCurrent(waitCanvas);
model.resetProgress();
new Thread(waitForm).start();
new Thread(waitCanvas).start();
try {
composition = model.openMix(fileName);
buildContent();
@ -138,13 +163,10 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
display.setCurrent(CompositionForm.this);
}
});
isWorking = true;
} catch (Exception ex) {
Alert a = new Alert(L.str[L.error], L.str[L.openError] + "\n" + ex, null, null);//@@@
a.setTimeout(Alert.FOREVER);
waitForm.cancel();
isWorking = false;
waitCanvas.cancel();
control.setCurrentlistMenu(a);
}
}
@ -159,8 +181,6 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
}
private void buildContent() throws Exception {
//Constants constants = new Constants();
notesCanvas = null;
drumsCanvas = null;
curCanvas = null;
@ -169,14 +189,15 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
String[] instrumentsStrings = composition.getInstrumentsStrings();
if (instrumentsStrings == null) {
throw new Exception("instruments==null");
throw new Exception("instruments == null");
}
choiseInstrument = new ChannelChoiceGroup(L.str[L.menu], instrumentsStrings, this.buildChansList());
if (choiseInstrument == null) {
throw new Exception("choiseInstrument==null");
choiñeInstrument = new ChannelChoiceGroup(L.str[L.menu], instrumentsStrings, this.buildChansList());
if (choiñeInstrument == 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);
this.append(seekingGauge);
this.addCommand(edit);
@ -189,7 +210,6 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
this.addCommand(setInstrument);
this.addCommand(delInstrument);
this.addCommand(back);
//this.addCommand(rmsMode);
this.setCommandListener(this);
P.isRMSMode = true;
}
@ -217,12 +237,6 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
* @param c
* @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) {
String instrName;
int instrumNum;
@ -235,30 +249,30 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
instrName = ((ChoiceGroup) i).getString(((ChoiceGroup) i).getSelectedIndex());
instrumNum = Constants.instrVectorArr.indexOf(instrName)+1;
}
// System.out.println("instrName = " + instrName);
// System.out.println("instrumNum = " + instrumNum);
if (c == play) {
int channel=-1;
int lengthOfChannel=0;
int channel = -1;
int lengthOfChannel = 0;
try {
channel = choiseInstrument.getSelectedChannel();
channel = choiñeInstrument.getSelectedChannel();
lengthOfChannel = composition.tracks[channel].getLen();
} catch (IllegalAccessException ex) {
//ex.printStackTrace();
ex.printStackTrace();
}
//System.out.println ("Channel="+channel+" length="+lengthOfChannel);
if (channel == Constants.DRUMS_CHANNEL || isAdd || lengthOfChannel < 3) {
try {
model.playTest((byte) (instrumNum - 1));
} catch (Exception e) {
e.printStackTrace();
}
} else {
try {
model.playTrack(composition, channel, instrumNum - 1);
} catch (Exception e) {
e.printStackTrace();
try {
model.playTest((byte) (instrumNum - 1));
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
@ -266,7 +280,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
if (isAdd) {
byte channel = composition.addInstrument(instrumNum - 1);
if (channel != -1) {
choiseInstrument.appendChannel(instrName, channel);
choiñeInstrument.appendChannel(instrName, channel);
} else {
Alert a = new Alert(L.str[L.listInstruments], L.str[L.impossible], null, null);
display.setCurrent(a);
@ -277,13 +291,13 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
}
} else {
try {
int channel = choiseInstrument.getSelectedChannel();
int channel = choiñeInstrument.getSelectedChannel();
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);
}
} catch (IllegalAccessException ex) {
//ex.printStackTrace();
ex.printStackTrace();
}
}
display.setCurrent(CompositionForm.this);
@ -296,18 +310,13 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
* @param 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();
if (newVal != seekGaugeCur) {
byte channel=0;
try {
channel = choiseInstrument.getSelectedChannel();
channel = choiñeInstrument.getSelectedChannel();
} catch (IllegalAccessException ex) {
//ex.printStackTrace();
ex.printStackTrace();
}
try {
composition.setCurW(seekingGauge.getValue() * 100 / SEEK_GAUGE_MAX, channel);
@ -319,7 +328,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
try {
model.playMix(composition, 0);
} catch (Exception e) {
msg("" + e);
msg(e.getMessage());
}
} else if (command == P.comCancel) {
model.stopPlay();
@ -329,9 +338,9 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
} else if (command == edit) {
int channel;
try {
channel = choiseInstrument.getSelectedChannel();
channel = choiñeInstrument.getSelectedChannel();
} catch (IllegalAccessException ex) {
channel=-1;
channel = -1;
}
if (channel == -1) {
Alert a = new Alert("CompositionForm", "getChannelFromInstrumName=" + channel, null, null);
@ -364,18 +373,18 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
} else if (command == delInstrument) {
byte channel;
try {
channel = choiseInstrument.getSelectedChannel();
channel = choiñeInstrument.getSelectedChannel();
} catch (IllegalAccessException ex) {
return;
}
choiseInstrument.deleteChannel(choiseInstrument.getSelectedIndex());
choiñeInstrument.deleteChannel(choiñeInstrument.getSelectedIndex());
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) {
TempoList tempos = new TempoList(composition, model, this);
display.setCurrent(tempos);
} 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);
} else if (command == meter) {
Form textBoxTemp = new Form(Constants.getInstrName(72));
@ -415,13 +424,12 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
Thread runner = new Thread() {
public void run() {
WaitForm waitForm = new WaitForm(L.str[L.saving] + "...",
WaitCanvas waitCanvas = new WaitCanvas(L.str[L.saving] + "...",
model.getWaitableFile(),
control.getCurrentlistMenu(),
model);
display.setCurrent(waitForm);
control.getCurrentlistMenu());
display.setCurrent(waitCanvas);
model.resetProgress();
new Thread(waitForm).start();
new Thread(waitCanvas).start();
composition.setName(nameFinal);
try {
String ans = model.saveMix(composition, nameFinal);
@ -431,7 +439,7 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
} catch (Exception ex) {
Alert a = new Alert(L.str[L.error], L.str[L.savingError] + "\n" + ex.getMessage(), null, null);
a.setTimeout(Alert.FOREVER);
waitForm.cancel();
waitCanvas.cancel();
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);
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() {
if (listInstrumentsForm == null) {
ChoiceGroup[] groupsChoiseGroup = new ChoiceGroup[16];
for (int i = 0; i < 16; i++) {
// for (int j = 0; j < 8; j++) {
// listOfElements[j] = j + i * 8 + 1 + ' ' + Constants.getInstrName(j + i * 8 + 1);
// }
String[] listOfElements = new String[8];
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);
ChoiceGroup[] groupsChoiseGroup = new ChoiceGroup[GROUPS_OF_INSTRUMENTS];
for (int i = 0; i < GROUPS_OF_INSTRUMENTS; i++) {
String[] listOfElements = new String[INSTRUMENTS_IN_GROUP];
System.arraycopy(L.instr, i*INSTRUMENTS_IN_GROUP+1, listOfElements,0, INSTRUMENTS_IN_GROUP);
groupsChoiseGroup[i] = new ChoiceGroup(Constants.getInstrName(129 + i), ChoiceGroup.POPUP, listOfElements, null);
groupsChoiseGroup[i].addCommand(play);
groupsChoiseGroup[i].addCommand(ok);
groupsChoiseGroup[i].setItemCommandListener(this);
@ -489,51 +487,53 @@ public class CompositionForm extends Form implements CommandListener, Runnable,
listInstrumentsForm.addCommand(P.comCancel);
listInstrumentsForm.setCommandListener(this);
}
//form.setItemStateListener(this);
return listInstrumentsForm;
}
}
class ChannelChoiceGroup extends ChoiceGroup {
private Vector instrumentsVector;
class ChannelChoiceGroup extends ChoiceGroup {
public ChannelChoiceGroup(String label, String[] stringElements, byte[] chans) {
super(label, Choice.EXCLUSIVE, stringElements, null);
instrumentsVector = new Vector(Constants.NCHANNEL, 1);
for (int i = 0; i < chans.length; ++i) {
instrumentsVector.addElement(new Byte(chans[i]));
private Vector instrumentsVector;
public ChannelChoiceGroup(String label, String[] stringElements, byte[] chans) {
super(label, Choice.EXCLUSIVE, stringElements, null);
instrumentsVector = new Vector(Constants.NCHANNEL, 1);
for (int i = 0; i < chans.length; ++i) {
instrumentsVector.addElement(new Byte(chans[i]));
}
}
public byte getSelectedChannel() throws IllegalAccessException{
try{
Byte b = (Byte) instrumentsVector.elementAt(this.getSelectedIndex());
return b.byteValue();
}catch (ArrayIndexOutOfBoundsException arI){
throw new IllegalAccessException(arI.getMessage());
}
}
public int appendChannel(String stringElement, byte channel) {
if (instrumentsVector.size() < Constants.NCHANNEL) {
instrumentsVector.addElement(new Byte(channel));
return super.append(stringElement, null);
}
return -1;
}
public void deleteChannel(int index) {
instrumentsVector.removeElementAt(index);
super.delete(index);
}
public void setChannel(int index, String stringElement, byte channel) {
instrumentsVector.setElementAt(new Byte(channel), index);
super.set(index, stringElement, null);
}
public Vector getChansVector() {
return instrumentsVector;
}
}
public byte getSelectedChannel() throws IllegalAccessException{
try{
Byte b = (Byte) instrumentsVector.elementAt(this.getSelectedIndex());
return b.byteValue();
}catch (ArrayIndexOutOfBoundsException arI){
throw new IllegalAccessException(arI.getMessage());
}
}
public int appendChannel(String stringElement, byte channel) {
if (instrumentsVector.size() < Constants.NCHANNEL) {
instrumentsVector.addElement(new Byte(channel));
return super.append(stringElement, null);
}
return -1;
}
public void deleteChannel(int index) {
instrumentsVector.removeElementAt(index);
super.delete(index);
}
public void setChannel(int index, String stringElement, byte channel) {
instrumentsVector.setElementAt(new Byte(channel), index);
super.set(index, stringElement, null);
}
public Vector getChansVector() {
return instrumentsVector;
}
}
}

View File

@ -3,117 +3,101 @@ package midedit;
import midedit.media.Composition;
import main.Main;
/**
*
* Êëàññ ðåäàêòèðîâàíèÿ áàðàáàíîâ
* @author user
*/
public class DrumsCanvas extends MixerCanvas
{
public class DrumsCanvas extends MixerCanvas {
/** Ñäâèã òåêñòîâûõ ìåòîê â áàðàáàíàõ */
public static final int drumsShift = Constants.DRUMS_SHIFT;
private byte[] drumsTable = null;
private byte[] drumsTableInverse = null;
/**
*
* @param ctrl
* @param c
*/
public DrumsCanvas(Main ctrl, Composition c) {
super(ctrl, c, Constants.DRUMS_CHANNEL);
prepareConstants();
byte[] b = new byte[Constants.NCHANNEL];
for (int i = 0; i < Constants.NCHANNEL; ++i) {
b[i] = (byte) (drumsShift + i);
}
drumsTable = b;
newDrumsTableInverse();
}
/**
*
*/
public static final int drumsShift = Constants.DRUMS_SHIFT;
private byte[] drumsTable = null;
private byte[] drumsTableInverse = null;
/**
*
* @param ctrl
* @param c
*/
public DrumsCanvas(Main ctrl, Composition c)
{
super(ctrl,c,Constants.DRUMS_CHANNEL);
prepareConstants();
private void prepareConstants() {
if (nH > Constants.DRUMS_LENGTH) {
nH = Constants.DRUMS_LENGTH;
}
hStep = 4;
hMin = drumsShift;
hMax = (drumsShift + Constants.DRUMS_LENGTH - 1);
hBase = hMin;
curY = 0;
}
byte[] b = new byte[Constants.NCHANNEL];
for(int i=0; i<Constants.NCHANNEL; ++i)
b[i]=(byte)(drumsShift+i);
drumsTable = b;
newDrumsTableInverse();
}
/**
*
*/
protected void prepareConstants()
{
if(nH> Constants.DRUMS_LENGTH)
nH = Constants.DRUMS_LENGTH;
hStep = 4;
hMin = drumsShift;
hMax = (drumsShift + Constants.DRUMS_LENGTH-1);
hBase = hMin;
curY = 0;
}
/**
*
* @return
*/
protected boolean doKEY_NUM5()
{
if(super.doKEY_NUM5() == false)
composition.addNoteOn(getCurTime(),(byte)channel,
(byte)getNoteFromLine(curY), (byte)getCurVol(),0,true);
return true;
}
protected void doSmallDown (){
if(hBase+curY < hMax)
super.doSmallDown();
};
/**
*
* @return
*/
protected boolean doKEY_NUM5() {
if (super.doKEY_NUM5() == false) {
composition.addNoteOn(getCurTime(), (byte) channel,
(byte) getNoteFromLine(curY), getCurVol(), 0, true);
}
return true;
}
protected void doSmallDown() {
if (hBase + curY < hMax) {
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() {
drumsTableInverse = new byte[Constants.N_INSTR];
for (int i = 0; i < Constants.N_INSTR; ++i) {
drumsTableInverse[i] = (byte) -1;
}
for (int i = 0; i < Constants.NCHANNEL; ++i) {
drumsTableInverse[drumsTable[i]] = (byte) i;
}
}
*/
public void newDrumsTableInverse()
{
drumsTableInverse = new byte[Constants.N_INSTR];
for(int i=0; i<Constants.N_INSTR; ++i)
drumsTableInverse[i]=(byte)-1;
for(int i=0; i<Constants.NCHANNEL; ++i)
drumsTableInverse[drumsTable[i]]=(byte)i;
}
/**
*
* @param g
*/
protected void paintScale(javax.microedition.lcdui.Graphics g)
{
for(int hh = hBeg; hh < hBeg + rollHeight ; hh+=hOne)
g.fillRect(4, hh, wBeg-5, 1);
}
/**
*
* @param g
*/
protected void paintScale(javax.microedition.lcdui.Graphics g) {
for (int hh = hBeg; hh < hBeg + rollHeight; hh += hOne) {
g.fillRect(4, hh, wBeg - 5, 1);
}
}
/**
*
* @param n
* @return
*/
protected byte getLineFromNote(int n)
{
return (byte)(n - hBase);
}
/**
*
* @param ln
* @return
*/
protected int getNoteFromLine(int ln)
{
return (byte)(hBase + curY);
}
/**
*
* @param n
* @return
*/
protected byte getLineFromNote(int n) {
return (byte) (n - hBase);
}
/**
*
* @param ln
* @return
*/
protected int getNoteFromLine(int ln) {
return (byte) (hBase + curY);
}
}

View File

@ -33,7 +33,7 @@ public class MidiFile implements Waitable {
127, -112/*0x80*/, 46, 1, 16, -112, 46/*note height*/, 1,//63
0, -1, 47, 0,};
//{0x4D,0x54,0x68,0x64,0x0,0x0,0x0,0x6,0x0,0x0,0x0,0x1,0x0,0x60,
//0x4d,0x54,0x72,0x6b,0x0,0x0,0x0,0x26/*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,/*<-*/
///*37>*/0x00,0xc0,0x1a, /*40>*/0x00,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 byte[] bMidi = new byte[sizeMax];
//public static void setTemp(int t)
//{ temp = t; }
//public static void setTemp(int noteTime)
//{ temp = noteTime; }
//public static int getTemp()
//{ return temp; }
public MidiFile(AbstractFile aFile) {
@ -295,11 +295,11 @@ public class MidiFile implements Waitable {
}
/// calc maxTime for set end Note
if (note.t > maxTime) {
maxTime = note.t;
if (note.noteTime > maxTime) {
maxTime = note.noteTime;
}
tnote = getVarLenRepr(note.t - tPrev); // Delta-Time
tnote = getVarLenRepr(note.noteTime - tPrev); // Delta-Time
if (tnote.length == 0) {
throw new Exception("len==0");
}
@ -335,7 +335,7 @@ public class MidiFile implements Waitable {
///////////
ind += 3;
}
tPrev = note.t;
tPrev = note.noteTime;
seekPos++;
Thread.yield();
}
@ -378,7 +378,7 @@ public class MidiFile implements Waitable {
{
// outStr = ""+nn+".mid";
//outStr = "note.mid";
// mod.msg("len dat ."+dat.length+" ");
// mod.msg("length dat ."+dat.length+" ");
//byte[] b = new byte[dat4PlayNote.length];
//for(int i=0; i<dat4PlayNote.length; ++i){
//b[i] = (byte)dat4PlayNote[i];
@ -405,7 +405,7 @@ public class MidiFile implements Waitable {
public byte[] writeTest(byte instr) {
outStr = "test.mid";
//int df=0;
InputStream is = getClass().getResourceAsStream("/bin/test.mid");
InputStream is = getClass().getResourceAsStream("/test.mid");
byte b[] = new byte[148];
try {
is.read(b);
@ -417,8 +417,8 @@ public class MidiFile implements Waitable {
}
private /*static*/ byte[] getVarLenRepr(int t) {
// if(t<0)
// mod.msgAll("Repr\nt="+t);
// if(noteTime<0)
// mod.msgAll("Repr\nt="+noteTime);
int tt = t;
if (tt < 0) {
tt = 0;
@ -492,7 +492,7 @@ public class MidiFile implements Waitable {
throw new IOException("len MThd=" + t);
}
//skip(df,t);
//skip(df,noteTime);
int format = readInt(df, 2);
if (format > 1) {
throw new IOException("Format=" + format + "\nthis format don't support");
@ -509,7 +509,7 @@ public class MidiFile implements Waitable {
d = 0x4d54726b; // MTrk
t = readInt(df, 4);
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");
}

View File

@ -183,7 +183,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
break;
case -7:
case -12:
CompositionForm.curForm.setComposForm();
Main.midlet.compositionForm.setComposForm();
break;
case -11:
composition.getUndoableAction().undo();
@ -333,7 +333,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
} else if (isMarkMode) {
if (curNote != null) {
if (curNote.len > 0) {
if (curNote.length > 0) {
Note noteTmp;
for (noteTmp = curNote.next; noteTmp != null
&& (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) {
composition.delNote(curNote.t, curNote.c, curNote.n, curNote.v);
composition.delNote(curNote.noteTime, curNote.c, curNote.n, curNote.v);
} else {
composition.delNote(getCurTime(), (byte) channel, (byte) getNoteFromLine(curY), (byte) 127);
}
@ -430,11 +430,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
keyPressedCount++;
} else {
int gameAction = 0;
try {
gameAction = getGameAction(keyCodePressed);
} catch (IllegalArgumentException illegArg) {
}
int gameAction = getGameAction(keyCodePressed);
if (keyCodePressed == KEY_NUM4 || keyCodePressed == KEY_NUM6
|| gameAction == LEFT || gameAction == RIGHT || gameAction == UP || gameAction == DOWN
|| keyCodePressed == KEY_NUM2 || keyCodePressed == KEY_NUM8
@ -529,10 +525,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
curNote = null;
g.setGrayScale(0);
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.t <= curTimePlus && note.n == curN
&& (curTime < note.t + (note.len == 0 ? 1 : note.len))) {
if (note.noteTime <= curTimePlus && note.n == curN
&& (curTime < note.noteTime + (note.length == 0 ? 1 : note.length))) {
curNote = note;
if (!isMarkMode) {
g.setColor(150, 0, 0);
@ -631,7 +627,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
* @param 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);
if (xt >= 0 && xt < rollWidth) {
if (yt < 0) {
@ -744,7 +740,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
/**
*
* @param t
* @param noteTime
* @return
*/
private int getX(int t) {
@ -753,7 +749,7 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
/**
*
* @param t
* @param noteTime
* @return
*/
protected int getXInPixel(int t) {
@ -1179,8 +1175,8 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
m2 = 50;
m3 = 75;
m4 = 100;
PrintSmallFont.print(g, note.t * 100 / tick, 2, m1 - xIndent, yIndent, color);
PrintSmallFont.print(g, note.len * 1000 / tick, 3, m2 - xIndent, yIndent, color);
PrintSmallFont.print(g, note.noteTime * 100 / tick, 2, m1 - xIndent, yIndent, color);
PrintSmallFont.print(g, note.length * 1000 / tick, 3, m2 - xIndent, yIndent, color);
if (MixerCanvas.this instanceof NotesCanvas) {
PrintSmallFont.printNote(g, note.n % 12, m3 - xIndent, yIndent, color);
@ -1198,13 +1194,13 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
m3 = 55;
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 - 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 - 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);
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 - 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);
break;
@ -1463,14 +1459,13 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
MenuItem exitItem = new MenuItem(L.str[L.back], 0) {
public boolean actionPerformed() {
CompositionForm.curForm.setComposForm();
Main.midlet.compositionForm.setComposForm();
return true;
}
};
mainMenu.addItem(exitItem);
menu = mainMenu;
}
private String createString(String[] strings) {
@ -1492,10 +1487,6 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
protected void paint(Graphics g) {
menu.paint(g);
}
public void run() {
}
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 optHeight = (screenHeight - 2 * optYbeg);
/**
* Êëàññ ìåíþ
*/
private class Menu extends MenuItem {
private Vector items = null;
@ -1636,6 +1630,10 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
private void addItem(MenuItem item) {
items.addElement(item);
// Èçìåíåíèå ðàçìåðà ìåíþ ïîä ïóíêò
int itemWidth = P.medBold.stringWidth(item.getName())+2;
if(itemWidth > w) w = itemWidth;
numLines = hMax / LINE_HEIGHT;
if (numLines >= items.size()) {
numLines = items.size();
@ -1651,7 +1649,8 @@ public abstract class MixerCanvas extends Canvas implements Runnable {
g.translate(x, y);
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.drawRect(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 {
/** Íàçâàíèå ïóíêòà */
private String name;
/** Êîä êëàâèøè */
private int keyCode;
// public MenuItem() {
// }
private MenuItem(String str, int key) {
name = str;
/**
* Êîíñòðóêòîð
* @param name íàçâàíèå ïóíòêà
* @param key êîä êëàâèøè
*/
private MenuItem(String name, int key) {
this.name = name;
keyCode = key;
}
/**
* Ïîëó÷èòü èìÿ
* @return èìÿ ïóíêòà
*/
protected String getName() {
return name;
}
/**
* Âûïîëíèòü îïåðàöèþ
* @return óñïåøíîñòü
*/
public boolean actionPerformed() {
return processCommand(keyCode);
}

View File

@ -23,10 +23,6 @@ public class MixerModel extends Thread {
* Îáúåêò äèñïëåÿ
*/
public final Display display = Main.dsp;
/**
*
*/
//public final MixerModel thisModel;
private NoteListUtils buffer;
static AbstractFile rmsFile = new RMSFile(),
//localFile,//=rmsFile,
@ -35,15 +31,12 @@ public class MixerModel extends Thread {
public MixerModel() {
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) {
jsr75File = new JSR75File();
} else {
jsr75File = rmsFile;
}
if (crossPlayer == null) {
try {
Class.forName("javax.microedition.media.Player");
crossPlayer = new JSR135Player();
@ -53,11 +46,7 @@ public class MixerModel extends Thread {
} catch (Exception e) {
Alert a = new Alert(L.str[L.apiError], L.str[L.apiError] + ":\n" + e.getMessage(), null, null);
display.setCurrent(a);
}
mfile = new MidiFile(getLocalFile());
buffer = new NoteListUtils();
}
@ -70,24 +59,13 @@ public class MixerModel extends Thread {
return buffer;
}
// /**
// *
// * @param c
// * @param count
// * @throws Exception
// */
// public void playMix(Composition c, int count) throws Exception {
// playMix(c, 0, 0);
// }
/**
*
* @param c
* @param count
* @param t
* @throws Exception
*/
public void playMix(Composition c, int t) throws Exception {
crossPlayer.close();
getLocalFile().close(0);
setLocalFile();
@ -100,23 +78,17 @@ public class MixerModel extends Thread {
*
* @param instrum
* @param nn
* @param vv
*/
public void playNote(byte instrum, byte nn) {
try {
crossPlayer.close();
crossPlayer.playTest(mfile.writeNote(instrum, nn));
} catch (Exception e) {
CompositionForm.msg("MixerModel: 134: playNote " + e.getMessage());
CompositionForm.msg("MixerModel: 91: playNote " + e.getMessage());
}
}
public void playTest(byte instrum) {
crossPlayer.close();
mfile.writeTest(instrum);
crossPlayer.playTest(mfile.writeTest(instrum));
@ -125,7 +97,6 @@ public class MixerModel extends Thread {
/**
*
* @param c
* @param count
* @param t
* @param channel
* @param instrument
@ -143,7 +114,6 @@ public class MixerModel extends Thread {
/**
*
* @param c
* @param count
* @param t
* @param channel
* @throws Exception
@ -156,14 +126,10 @@ public class MixerModel extends Thread {
*
*/
public void stopPlay() {
crossPlayer.close();
if(crossPlayer != null)
crossPlayer.close();
}
/**
*
*/
public void run() {
}
/**
*
@ -192,8 +158,7 @@ public class MixerModel extends Thread {
public Composition openMix(String name) throws Exception {
Composition c;
if (name != null) {
c = mfile.readMix(
name);
c = mfile.readMix(name);
c.setName(name);
} else {
c = new Composition();

View File

@ -1,29 +1,30 @@
package midedit;
/**
*
* Íîòà
* @author user
*/
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 nn
* @param vv
* @param ll
*/
public byte c, n, v, mark;
public int t, len;
public Note next = null, prev = null;
public Note(int tt, byte ch, byte nn, byte vv, int ll) {
t = tt;
public Note(int time, byte ch, byte nn, byte vv, int ll) {
this.noteTime = time;
c = ch;
n = nn;
v = vv;
len = ll;
length = ll;
mark = NoteListUtils.NOTE_NOT_MARKED;
}
}

View File

@ -35,7 +35,7 @@ public class NoteList
{
if(noteExist==null)
return null;
t = noteExist.t;
t = noteExist.noteTime;
len++;
if(noteBeg == null)
noteBeg = note = noteExist;
@ -44,11 +44,11 @@ public class NoteList
noteNew = noteExist;
if(note == null)
note = noteBeg;
if(note.t != t)
{ if(t < note.t)
if(note.noteTime != t)
{ if(t < note.noteTime)
{
for(noteTmp = note;
noteTmp != null && t < noteTmp.t;
noteTmp != null && t < noteTmp.noteTime;
noteTmp = noteTmp.prev)
;
if(noteTmp == null)
@ -60,7 +60,7 @@ public class NoteList
}
else
{ for(noteTmp = note;
noteTmp.next != null && (noteTmp.next.t < t ) ;
noteTmp.next != null && (noteTmp.next.noteTime < t ) ;
noteTmp = noteTmp.next)
;
note = noteTmp;
@ -68,12 +68,12 @@ public class NoteList
}
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
{
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 n
* @param v
*/
public void delOne(int t, byte c, byte n, byte v)
{
for(note = searchNoteByTime(t); note != null && note.t <= t; note = note.next)
if(t==note.t && c == note.c && n == note.n && (v!=0 ^ note.v==0))
for(note = searchNoteByTime(t); note != null && note.noteTime <= t; note = note.next)
if(t==note.noteTime && c == note.c && n == note.n && (v!=0 ^ note.v==0))
{
if (note.next != null)
note.next.prev = note.prev;
@ -124,7 +124,7 @@ public class NoteList
*/
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.next != null)
@ -157,7 +157,7 @@ public class NoteList
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--;
@ -165,7 +165,7 @@ public class NoteList
}
/**
*
* @param t
* @param noteTime
* @param tMax
* @param c
* @param n
@ -181,13 +181,13 @@ public class NoteList
boolean isdel=false;
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) &&
(note.t > t || v!=0 && note.t == t) &&
(note.t < tMax || v==0 && note.t == tMax) &&
(note.noteTime > t || v!=0 && note.noteTime == t) &&
(note.noteTime < tMax || v==0 && note.noteTime == tMax) &&
(note.n == n || n == (byte)-1) &&
( (v != 0 && (note.v != 0 || note.t - note.len >= t)) ||
(v == 0 && (note.v == 0 && timeLastDelOn <= note.t-note.len && note.t-note.len < t ))))
( (v != 0 && (note.v != 0 || note.noteTime - note.length >= t)) ||
(v == 0 && (note.v == 0 && timeLastDelOn <= note.noteTime-note.length && note.noteTime-note.length < t ))))
{
if(note.next != null)
note.next.prev = note.prev;
@ -199,15 +199,15 @@ public class NoteList
len--;
if( v != 0)
{
if(tOffMax < note.t+note.len)
tOffMax = note.t+note.len;
if(tOffMax < note.noteTime+note.length)
tOffMax = note.noteTime+note.length;
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)
timeNoteOff = note.t;
timeNoteOff = note.noteTime;
isdel = true;
}
@ -242,7 +242,7 @@ public class NoteList
}
/**
*
* @param t
* @param noteTime
* @return
*/
public Note searchNoteByTime(int t)
@ -254,20 +254,20 @@ public class NoteList
else
return null;
}
if(t <= note.t)
if(t <= note.noteTime)
{
for(noteTmp = note;
noteTmp.prev != null && t <= noteTmp.t;
noteTmp.prev != null && t <= noteTmp.noteTime;
noteTmp = noteTmp.prev)
;
if(noteTmp.t<t && noteTmp.next!=null)
if(noteTmp.noteTime<t && noteTmp.next!=null)
noteTmp = noteTmp.next;
note = noteTmp;
}
else
{
for(noteTmp = note;
noteTmp.next != null && noteTmp.t < t ;
noteTmp.next != null && noteTmp.noteTime < t ;
noteTmp = noteTmp.next)
;
note = noteTmp;

View File

@ -86,14 +86,14 @@ public class NoteListUtils {
undo.addAction(UndoableAction.DELETE_LIST);
undo.addAction(UndoableAction.SHIFT_LIST);
undo.addAction(UndoableAction.ADD_LIST);
int bufLen = bufferList.searchNoteByTime(0x7fffffff).t;
int bufLen = bufferList.searchNoteByTime(0x7fffffff).noteTime;
shift(dest, timeBeg,
(bufLen * newTicksPer4) / bufticksPer4, undo);
retVal = bufLen;
} else if (attr == REPLACE) {
undo.addAction(UndoableAction.DELETE_LIST);
undo.addAction(UndoableAction.ADD_LIST);
int bufLen = bufferList.searchNoteByTime(0x7fffffff).t;
int bufLen = bufferList.searchNoteByTime(0x7fffffff).noteTime;
dest.del(timeBeg, timeBeg
+ (bufLen * newTicksPer4) / bufticksPer4,
channel, (byte) -1, (byte) 127, undo);
@ -118,9 +118,9 @@ public class NoteListUtils {
for (; note != null; note = note.next) {
if (note.mark == NOTE_MARKED) {
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;
Note srcNote;
for (srcNote = src.searchNoteByTime(tSrcBeg);
srcNote != null && srcNote.t <= tSrcEnd; srcNote = srcNote.next) {
if (srcNote.c == chSrc && (srcNote.v == 0 && srcNote.t - srcNote.len >= tSrcBeg
|| srcNote.v != 0 && srcNote.t + srcNote.len <= tSrcEnd)
srcNote != null && srcNote.noteTime <= tSrcEnd; srcNote = srcNote.next) {
if (srcNote.c == chSrc && (srcNote.v == 0 && srcNote.noteTime - srcNote.length >= tSrcBeg
|| srcNote.v != 0 && srcNote.noteTime + srcNote.length <= tSrcEnd)
&& (srcNote.v != 0 || onlyMarkSrc)) {
if (onlyMarkSrc) {
srcNote.mark = NOTE_MARKED;
} else {
t = tDestBeg
+ ((srcNote.t - tSrcBeg) * destTicksPer4) / srcTicksPer4;
+ ((srcNote.noteTime - tSrcBeg) * destTicksPer4) / srcTicksPer4;
n = srcNote.n;
len = (srcNote.len * destTicksPer4) / srcTicksPer4;
len = (srcNote.length * destTicksPer4) / srcTicksPer4;
dest.add(new Note(t, chDest, n, srcNote.v, len));
if (len > 0) {
@ -181,8 +181,8 @@ public class NoteListUtils {
*/
public static void shift(NoteList list, int tBeg, int shiftLen, UndoableAction undo) {
Note note = list.searchNoteByTime(0x7fffffff);
for (; note != null && note.t >= tBeg; note = note.prev) {
if (note.v == 0 && note.t - note.len < tBeg) {
for (; note != null && note.noteTime >= tBeg; note = note.prev) {
if (note.v == 0 && note.noteTime - note.length < tBeg) {
Note noteTmp;
for (noteTmp = note.prev;
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 (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) {
noteTmp.len = tBeg - noteTmp.t;
if (noteTmp.noteTime + noteTmp.length < tBeg) {
noteTmp.length = tBeg - noteTmp.noteTime;
}
note.len = noteTmp.len;
note.length = noteTmp.length;
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;
if (note.t < tBeg) {
note.noteTime += shiftLen;
if (note.noteTime < tBeg) {
if (undo != null && note.v != 0) {
undo.log2DelNoteList(note.t - shiftLen, note.c, note.n, note.v, note.len);
undo.log2AddNoteList(tBeg, 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.length);
}
note.t = tBeg;
note.noteTime = tBeg;
}
}
if (undo != null) {
@ -286,7 +286,7 @@ public class NoteListUtils {
for (Note note = undo.getDeletedList().getFirst();
note != null; note = note.next) {
if (note.c == channel && note.v != 0) {
newTime = note.t + shiftTime;
newTime = note.noteTime + shiftTime;
if (newTime < 0) {
newTime = 0;
}
@ -300,13 +300,13 @@ public class NoteListUtils {
}
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) {
dest.add(new Note(newTime + note.len, channel, newN, (byte) 0, note.len));
if (note.length > 0) {
dest.add(new Note(newTime + note.length, channel, newN, (byte) 0, note.length));
}
if (undo != null && note.v != 0) {
undo.log2AddNoteList(newTime, channel, newN, newVol, note.len);
undo.log2AddNoteList(newTime, channel, newN, newVol, note.length);
}
}

View File

@ -1,26 +1,22 @@
package midedit;
/**
*
* Äëèíà íîòû
* @author user
*/
public class NoteLong extends Note
{
public class NoteLong extends Note {
/**
* Êîíñòðóêòîð
* @param time âðåìÿ
* @param data äàííûå
*/
public NoteLong(int time, byte[] data) {
super(time, (byte) NoteList.CHANNEL_LONG_NOTE, (byte) 0, (byte) 0, 0);
dat = data;
}
/**
*
* @param t
* @param d
*/
public NoteLong(int t,byte[] d)
{
super(t,(byte)NoteList.CHANNEL_LONG_NOTE,(byte)0,(byte)0,0);
dat = d;
}
/**
*
*/
public byte[] dat;
public byte[] dat;
}

View File

@ -57,9 +57,9 @@ public class NotesCanvas extends MixerCanvas {
protected void paintNote(Graphics g, Note note, int shiftTime, int shiftNote) {
int x, h;
int dx, t = 1;
x = getXInPixel(note.t + shiftTime);
x = getXInPixel(note.noteTime + shiftTime);
h = getLineFromNote(note.n + shiftNote);
dx = (note.len * wOne) / Constants.timeConst;
dx = (note.length * wOne) / Constants.timeConst;
if (dx == 0) {
dx = 2;
}

View File

@ -66,8 +66,8 @@ public class TempoList extends List implements CommandListener {
int tempBPM;
int mod = (composition.getTicksPer4() << 2) >> (composition.getDenomE());
tempBPM = Composition.getTempBeatPerMin(tempMsPer4);
return "" + note.t / tick + ":" + (note.t * meterNom / tick) % meterNom + ":"
+ note.t % mod + " - " + tempBPM;
return "" + note.noteTime / tick + ":" + (note.noteTime * meterNom / tick) % meterNom + ":"
+ note.noteTime % mod + " - " + tempBPM;
}
@ -96,7 +96,7 @@ public class TempoList extends List implements CommandListener {
int ind;
for (ind = 0; ind < tempNotes.size(); ++ind) {
note = (NoteLong) tempNotes.elementAt(ind);
if (note.t > time) {
if (note.noteTime > time) {
break;
}
}
@ -145,7 +145,7 @@ public class TempoList extends List implements CommandListener {
int mod = (composition.getTicksPer4() << 2) >> (composition.getDenomE());
int tempBPM = Composition.getTempBeatPerMin(tmp);
int time = notelong.t / tick;
int time = notelong.noteTime / tick;
editNum = ind;

View File

@ -120,11 +120,11 @@ public class UndoableAction
/**
*
* @param t
* @param noteTime
* @param ch
* @param n
* @param v
* @param len
* @param length
*/
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 n
* @param v
* @param len
* @param length
*/
public void log2DelNoteList(int t, byte ch, byte n, byte v,int len)
{
@ -145,7 +145,7 @@ public class UndoableAction
/**
*
* @param timeBeg
* @param len
* @param length
* @param ch
*/
public void logShift(int timeBeg,int len,byte ch)
@ -161,18 +161,18 @@ public class UndoableAction
switch(order[i])
{
case ADD_NOTE:
composition.getNoteListByChannel(channel).delOne(noteAddDel.t, noteAddDel.c,
composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime, noteAddDel.c,
noteAddDel.n, noteAddDel.v);
if(noteAddDel.len != 0)
composition.getNoteListByChannel(channel).delOne(noteAddDel.t+noteAddDel.len,
if(noteAddDel.length != 0)
composition.getNoteListByChannel(channel).delOne(noteAddDel.noteTime+noteAddDel.length,
noteAddDel.c,noteAddDel.n,(byte)0);
break;
case DEL_NOTE:
composition.getNoteListByChannel(channel).add(new Note(noteAddDel.t,noteAddDel.c,
noteAddDel.n,noteAddDel.v,noteAddDel.len));
if(noteAddDel.len != 0)
composition.getNoteListByChannel(channel).add(new Note(noteAddDel.t+noteAddDel.len,
noteAddDel.c,noteAddDel.n, (byte)0,noteAddDel.len));
composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime,noteAddDel.c,
noteAddDel.n,noteAddDel.v,noteAddDel.length));
if(noteAddDel.length != 0)
composition.getNoteListByChannel(channel).add(new Note(noteAddDel.noteTime+noteAddDel.length,
noteAddDel.c,noteAddDel.n, (byte)0,noteAddDel.length));
break;
case DELETE_LIST:
Note noteLocal = dellist.getFirst();
@ -181,9 +181,9 @@ public class UndoableAction
list = composition.getNoteListByChannel(channel);
for(noteLocal = dellist.getFirst(); noteLocal!=null; noteLocal = noteLocal.next)
{
list.add(new Note(noteLocal.t,noteLocal.c,noteLocal.n,noteLocal.v,noteLocal.len));
if(noteLocal.len != 0)
list.add(new Note(noteLocal.t+noteLocal.len,noteLocal.c,noteLocal.n,(byte)0,noteLocal.len));
list.add(new Note(noteLocal.noteTime,noteLocal.c,noteLocal.n,noteLocal.v,noteLocal.length));
if(noteLocal.length != 0)
list.add(new Note(noteLocal.noteTime+noteLocal.length,noteLocal.c,noteLocal.n,(byte)0,noteLocal.length));
}
break;
case ADD_LIST:
@ -194,9 +194,9 @@ public class UndoableAction
list = composition.getNoteListByChannel(channel);
for(noteLocal = addlist.getFirst(); noteLocal!=null; noteLocal = noteLocal.next)
{
list.delOne(noteLocal.t,noteLocal.c,noteLocal.n,noteLocal.v);
if(noteLocal.len != 0)
list.delOne(noteLocal.t+noteLocal.len,noteLocal.c,noteLocal.n,(byte)0);
list.delOne(noteLocal.noteTime,noteLocal.c,noteLocal.n,noteLocal.v);
if(noteLocal.length != 0)
list.delOne(noteLocal.noteTime+noteLocal.length,noteLocal.c,noteLocal.n,(byte)0);
}
break;
case SHIFT_LIST:

View File

@ -4,6 +4,7 @@ package midedit;
import midedit.media.Composition;
import java.util.*;
import javax.microedition.lcdui.*;
import main.L;
import main.Main;
import main.P;
@ -13,6 +14,7 @@ import main.P;
*/
public class VolumeForm extends Form implements CommandListener {
private Command playOrig = new Command(L.str[L.playOrigin], Command.ITEM, 1);
private Gauge[] volumeGauges;
private ChoiceGroup[] soloChecks;
private Vector channels = null;
@ -61,7 +63,7 @@ public class VolumeForm extends Form implements CommandListener {
this.append(" ");
}
this.addCommand(CompositionForm.play);
this.addCommand(CompositionForm.playOrig);
this.addCommand(playOrig);
this.addCommand(CompositionForm.ok);
this.addCommand(P.comCancel);
this.setCommandListener(this);
@ -87,7 +89,7 @@ public class VolumeForm extends Form implements CommandListener {
} catch (Exception ex) {
}
} else if (command == CompositionForm.playOrig) {
} else if (command == playOrig) {
restoreVolumesArr();
try {
model.playMix(composition, MixerCanvas.xBase * Constants.timeConst);

View File

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

View File

@ -1,24 +1,24 @@
package midedit;
/**
*
* Интерфейс статуса операций
* @author user
*/
public interface Waitable {
/**
*
* @return
* Получить текущее состояние
* @return процент выполненной задачи
*/
public int getCurPercent();
/**
*
* Отмена операции
*/
public void cancel();
/**
*
* Сброс операции
*/
public void reset();
}

View File

@ -86,16 +86,15 @@ public class Composition {
* @return
*/
public String[] getInstrumentsStrings() {
// String[] allInstrums = Constants.instruments;
int size = 0;
for (int i = 0; i < Constants.NCHANNEL; ++i) {
for (int i = 0; i < Constants.NCHANNEL; i++) {
if (instruments[i] != NOTHING) {
size++;
}
}
String[] ss = new String[size];
int j = 0;
for (int i = 0; i < Constants.NCHANNEL; ++i) {
for (int i = 0; i < Constants.NCHANNEL; i++) {
if (instruments[i] != NOTHING) {
ss[j++] = Constants.getInstrName(instruments[i] + 1);
}
@ -270,8 +269,8 @@ public class Composition {
public void addNoteOff(int tt, byte ch, byte nn) {
Note noteTmp = tracks[ch].searchBack(ch, nn);
if (noteTmp != null) {
noteTmp.len = tt - noteTmp.t;
tracks[ch].add(new Note(tt, ch, nn, (byte) 0, noteTmp.len));
noteTmp.length = tt - noteTmp.noteTime;
tracks[ch].add(new Note(tt, ch, nn, (byte) 0, noteTmp.length));
} else {
tracks[ch].add(new Note(tt, ch, nn, (byte) 0, 0));
}
@ -329,7 +328,7 @@ public class Composition {
/**
*
* @param t
* @param noteTime
* @param ch
* @return
*/
@ -383,7 +382,7 @@ public class Composition {
/**
*
* @param t
* @param noteTime
*/
public void setTicksPer4(int t) {
ticksPer4 = t;
@ -441,7 +440,7 @@ public class Composition {
if (percent == 0) {
timeNew = 0;
} else {
timeNew = this.getFirstNote(this.getLastTime() * percent / 100, ch).t;
timeNew = this.getFirstNote(this.getLastTime() * percent / 100, ch).noteTime;
MixerCanvas.curX = 0;
}
MixerCanvas.xBase = (short) (timeNew / Constants.timeConst);
@ -466,7 +465,7 @@ public class Composition {
for (int i = 0; i < Constants.NCHANNEL; ++i) {
Note noteTimeMax = this.getFirstNote(0x7fffffff, i);
if (noteTimeMax != null) {
tCur = noteTimeMax.t + noteTimeMax.len;
tCur = noteTimeMax.noteTime + noteTimeMax.length;
if (tCur > tMax) {
tMax = tCur;
}

View File

@ -5,14 +5,20 @@ import javax.microedition.media.*;
import java.io.*;
/**
*
* Класс воспроизведения мидишек
* @author user
*/
public class JSR135Player extends AbstractPlayer implements PlayerListener {
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)) {
setIsPlaying(true);
return;
@ -23,6 +29,11 @@ public class JSR135Player extends AbstractPlayer implements PlayerListener {
return;
}
/**
* Воспроизведение мелодии по указанному пути
* @param path путь к файлу
* @throws Exception не удалось воспроизвести
*/
public void play(String path) throws Exception {
if (player != null) {
player.close();
@ -30,23 +41,14 @@ public class JSR135Player extends AbstractPlayer implements PlayerListener {
InputStream is = MixerModel.getLocalFile().getInputStreambyURL(path);
player = Manager.createPlayer(is, "audio/midi");
player.addPlayerListener(this);
player.realize();
player.start();
}
protected void stop() throws Exception {
if (player != null) {
player.stop();
}
}
public void close() {
if (player != null) {
player.close();
}
player = null;
}
/**
* Воспроизведение мелодии
* @param writeTest массив байт midi-мелодии
*/
public void playTest(byte[] writeTest) {
ByteArrayInputStream is = new ByteArrayInputStream(writeTest);
if (player != null) {
@ -56,11 +58,34 @@ public class JSR135Player extends AbstractPlayer implements PlayerListener {
try {
player = Manager.createPlayer(is, "audio/midi");
player.addPlayerListener(this);
player.realize();
player.start();
} catch (IOException ex) {
//ex.printStackTrace();
ex.printStackTrace();
} 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();
}
}

View File

@ -13,7 +13,7 @@ public class PreviewPlayer implements PlayerListener {
private boolean isPlaying = false;
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)) {
isPlaying = true;
return;
@ -21,7 +21,6 @@ public class PreviewPlayer implements PlayerListener {
if (event.equals(STOPPED) || event.equals(CLOSED) || event.equals(END_OF_MEDIA)) {
isPlaying = false;
}
return;
}
public void play(String path) throws Exception {

View File

@ -70,6 +70,9 @@ public class FileManager extends Canvas {
/** Îòîáðàæàòü ëè ìåíþ */
private boolean showMenu;
/** Ïîäòâåðæäåíèå ïðè óäàëåíèè ôàéëà */
private boolean isDelete;
/**
* Êîíñòðóêòîð äëÿ îòêðûòèÿ ôàéëîâ
* @param s ñòàðòîâûé ïóòü ê ïàïêå
@ -87,6 +90,7 @@ public class FileManager extends Canvas {
fontCashe = FWCashe.getCache(P.smBold);
CursorY = startPrintFile = curFiles = numFiles = 0;
showMenu = false;
isDelete = false;
loadImages();
// Ñïèñîê ïóíêòîâ ìåíþ
@ -132,7 +136,7 @@ public class FileManager extends Canvas {
if (menu[0].equals(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 {
if (numFiles > 0) {
// Ïóíêòû ïðè îòêðûòèè
@ -254,7 +258,7 @@ public class FileManager extends Canvas {
// Âûáðàííûé ïóíêò ìåíþ
final String cur = menu[selected];
// Âûáðàííûé ïóíêò â ñïèñêå ôàéëîâ
final String fileSelected = data[curFiles];
final String fileSelected = (numFiles > 0) ? data[curFiles] : "";
curMenu = 0;
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("/")) {
String fileToDelete = fileSelected;
if(!P.isRMSMode) fileToDelete = pathFile + fileSelected;
@ -297,9 +302,22 @@ public class FileManager extends Canvas {
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])) {
// Îòìåíà
if(isDelete) {
// Îòìåíà ïðè ïîïûòêå óäàëèòü ôàéë
isDelete = false;
setMenu();
return;
}
// Îòìåíà â îáùåì ìåíþ
P.path = pathFile;
if(menu[0].equals(L.str[L.saveInThisFolder])) Main.dsp.setCurrent(previousDisplayable);
else Main.dsp.setCurrent(Main.midlet.menu);
@ -425,7 +443,8 @@ public class FileManager extends Canvas {
case UP: cursorUp(); break;
case FIRE:
case RIGHT:
nextDir(data[curFiles]);
if (numFiles > 0)
nextDir(data[curFiles]);
break;
}
switch (i) {

View File

@ -100,7 +100,7 @@ public class Menu extends Canvas {
g.setColor(P.backgrnd);
g.fillRect(0, 0, w, h);
String title = "MidEdit. "+Key.Platform;
String title = L.str[L.midedit] + ". "+Key.Platform;
UI.drawTitle(g, title);
UI.drawSoftBar(g, L.str[L.ok], L.str[L.exit]);

View File

@ -80,8 +80,8 @@ public class SettingsForm extends Form implements CommandListener {
// ßçûêè
Rms.languageApp = langChars[langChoice.getSelectedIndex()];
Rms.languageInstr = langChars[langInstr.getSelectedIndex()];
L.readLang(Rms.languageApp, true);
L.readLang(Rms.languageInstr, false);
//L.readLang(Rms.languageApp, true);
//L.readLang(Rms.languageInstr, false);
Rms.tempDir = tempDirField.getString();

View File

@ -57,20 +57,30 @@ public class UI {
}
/**
* Îòðèñîâêà ñîñòîÿíèÿ ïî ìàññèâó (â ýôôåòêàõ)
* Îòðèñîâêà ïðîãðåññà
* @param g êîíòåêñò ãðàôèêè
* @param cur òåêóùåå ñîñòîÿíèå
* @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 h = g.getClipHeight();
int sw = w / 20;
int sh = h - h / 20;
g.setColor(0x00);
g.drawRect(w - 2 * sw - 1, h/25 - 1, sw + 1, sh + 1);
int curr = (cur * sh) / all;
drawRect(g, P.colup, P.coldn, w - 2 * sw, (h/25 + (sh - curr)), sw, sh - (sh - curr));
final int w2 = w / 2;
if (all != 0) {
final int barWidth = (cur * w) / all;
final int barY = h / 2 + h / 16;
drawRect(g, P.colup, P.coldn, 0, barY, barWidth, h / 16);
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
View 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);
}
}
}