Code/Bug Trouble
Posted: 09 Mar 2011, 02:43
by dudmaster
Hello, It's Dud.
I am having trouble with my AudioEditor program. I wonder what's causing this. Can you guys help?
Code:
-Dud.
I am having trouble with my AudioEditor program. I wonder what's causing this. Can you guys help?
Code:
Code: Select all
int L, Curser, C2, Octave = 200;
int Note[100];
task main() {
SetAbortFlag(0x04);
SetSensorLowspeed(S1);
SetSensorMode(S1, SENSOR_MODE_BOOL);
SetSensorType(S1, SENSOR_TYPE_TOUCH);
SetSensorLowspeed(S2);
SetSensorMode(S2, SENSOR_MODE_BOOL);
SetSensorType(S2, SENSOR_TYPE_TOUCH);
// Initialize
while (true) {
while (0 == Sensor(S1))
{
if (Sensor(S2) == 1)
{
MenuM:
int LinkNumber = 0;
while (false == ButtonCount(BTNCENTER,true))
{
TextOut(0, LCD_LINE1, "Main Menu", true);
LineOut(0, 54, 99, 54);
if (LinkNumber == 0)
{
TextOut(0, LCD_LINE3, "Octave", DRAW_OPT_INVERT);
TextOut(0, LCD_LINE4, "Save");
TextOut(0, LCD_LINE5, "Generate");
TextOut(0, LCD_LINE6, "Back");
}
if (LinkNumber == 1)
{
TextOut(0, LCD_LINE3, "Octave");
TextOut(0, LCD_LINE4, "Save", DRAW_OPT_INVERT);
TextOut(0, LCD_LINE5, "Generate");
TextOut(0, LCD_LINE6, "Back");
}
if (LinkNumber == 2)
{
TextOut(0, LCD_LINE3, "Octave");
TextOut(0, LCD_LINE4, "Save");
TextOut(0, LCD_LINE5, "Generate", DRAW_OPT_INVERT);
TextOut(0, LCD_LINE6, "Back");
}
if (LinkNumber == 3)
{
TextOut(0, LCD_LINE3, "Octave");
TextOut(0, LCD_LINE4, "Save");
TextOut(0, LCD_LINE5, "Generate");
TextOut(0, LCD_LINE6, "Back", DRAW_OPT_INVERT);
}
if (1 == ButtonCount(BTNLEFT,true))
{
if (0 < LinkNumber)
{
LinkNumber = LinkNumber - 1;
}
}
if (1 == ButtonCount(BTNRIGHT,true))
{
if (3 > LinkNumber)
{
LinkNumber = LinkNumber + 1;
}
}
Wait(15);
}
if (LinkNumber == 0)
{
string T;
while (false == ButtonCount(BTNCENTER, true))
{
TextOut(0, LCD_LINE1, "Octave Control", true);
LineOut(0, 54, 99, 54);
T = NumToStr(Octave);
TextOut(0, LCD_LINE3, "O: " + T);
if (1 == ButtonCount(BTNLEFT,true))
{
if (200 < Octave)
{
Octave = Octave - 50;
}
}
if (1 == ButtonCount(BTNRIGHT,true))
{
if (300 > LinkNumber)
{
Octave = Octave + 50;
}
}
Wait(50);
}
}
if (LinkNumber == 1)
{
int Lnk;
while (false == ButtonCount(BTNCENTER,true))
{
TextOut(0, LCD_LINE1, "Save File", true);
LineOut(0, 54, 99, 54);
if (Lnk == 0)
{
TextOut(0, LCD_LINE3, "NXC", DRAW_OPT_INVERT);
TextOut(0, LCD_LINE4, "Track");
TextOut(0, LCD_LINE5, "Back");
}
if (Lnk == 1)
{
TextOut(0, LCD_LINE3, "NXC");
TextOut(0, LCD_LINE4, "Track", DRAW_OPT_INVERT);
TextOut(0, LCD_LINE5, "Back");
}
if (Lnk == 2)
{
TextOut(0, LCD_LINE3, "NXC");
TextOut(0, LCD_LINE4, "Track");
TextOut(0, LCD_LINE5, "Back", DRAW_OPT_INVERT);
}
if (1 == ButtonCount(BTNLEFT,true))
{
if (0 < Lnk)
{
Lnk = Lnk - 1;
}
}
if (1 == ButtonCount(BTNRIGHT,true))
{
if (2 > Lnk)
{
Lnk = Lnk + 1;
}
}
Wait(15);
}
if (Lnk == 0)
{
NXC(Note, "Audio", Octave);
}
if (Lnk == 1)
{
Track(Note, "Audio", Octave);
}
if (Lnk == 2)
{
goto MenuM;
}
}
if (LinkNumber == 2)
{
int LinkNumber;
while (false == ButtonCount(BTNCENTER,true))
{
TextOut(0, LCD_LINE1, "Generate", true);
if (LinkNumber == 0)
{
TextOut(0, LCD_LINE3, "Random", DRAW_OPT_INVERT);
TextOut(0, LCD_LINE4, "Wave");
}
if (LinkNumber == 1)
{
TextOut(0, LCD_LINE3, "Random");
TextOut(0, LCD_LINE4, "Wave", DRAW_OPT_INVERT);
}
if (1 == ButtonCount(BTNLEFT,true))
{
if (0 < LinkNumber)
{
LinkNumber = LinkNumber - 1;
}
}
if (1 == ButtonCount(BTNRIGHT,true))
{
if (1 > LinkNumber)
{
LinkNumber = LinkNumber + 1;
}
}
Wait(15);
}
int Cont = 0, Rand;
ClearScreen();
if (LinkNumber == 0)
{
while (Cont < ArrayLen(Note))
{
Rand = Random(64);
if (Rand == 0)
{
Rand = 1;
}
Note[Cont] = Rand;
LineOut(Cont, 0, Cont, Note[Cont]);
Cont++;
Wait(50);
}
}
// Tests
else
{
int ii = 0, f;
float Syn = 0;
while (ii < ArrayLen(Note))
{
f = trunc(sin(Syn));
Note(ii) = f;
Syn = Syn + 0.1;
ii++;
LineOut(ii, 0, ii, Note[ii]);
Wait(50);
}
}
// End Tests
}
}
LineOut(Curser, (Note[Curser] + 8), Curser, 64, true);
L = 0;
// Render
while (L < 100 && 0 == Sensor(S1))
{
LineOut(L, 0, L, Note[L]);
L++;
}
if (ButtonCount(BTNLEFT, true) && Curser > 0)
{
Curser--;
}
if (ButtonCount(BTNRIGHT, true) && Curser < 99)
{
Curser++;
}
if (ButtonCount(BTNEXIT, true) && Note[Curser] > 0)
{
Note[Curser]--;
}
if (ButtonPressed(BTNCENTER, true) && Note[Curser] < 63)
{
Note[Curser]++;
}
Wait(50);
}
// Play
if (Note[0] > 0)
{
C2 = 0;
while (1 == Sensor(S1))
{
L = 0;
RectOut(0, 0, 100, 64, DRAW_OPT_FILL_SHAPE);
LineOut(C2, (Note[C2] + 8), C2, 64, DRAW_OPT_CLEAR);
while (L < 100 && 1 == Sensor(S1))
{
LineOut(L, 0, L, Note[L], DRAW_OPT_CLEAR);
L++;
}
PlayTone((Note[C2] + Octave), 320);
Wait(50);
C2++;
if (C2 > ArrayLen(Note) - 1 || Note[C2] == 0)
{
C2 = 0;
}
}
}
}
}