-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBraxLettersAndroid.pde
More file actions
187 lines (147 loc) · 4.69 KB
/
BraxLettersAndroid.pde
File metadata and controls
187 lines (147 loc) · 4.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*Maxim maxim;
// Last letter used.
int lastLetter = 26;
// This will store the audio clips
short[][] AudioClips = new short [lastLetter][];
// Audio Files
String[] audioFileArray = {"LtrA96K.wav","LtrB32K.wav",
"LtrC48K.wav","LtrD16K.wav",
"LtrE.wav","LtrF.wav",
"LtrG.wav","LtrH.wav",
"LtrI.wav","LtrJ.wav",
"LtrK.wav","LtrL.wav",
"LtrM.wav","LtrN.wav",
"LtrO.wav","LtrP.wav",
"LtrQ.wav","LtrR.wav",
"LtrS.wav","LtrT.wav",
"LtrU.wav","LtrV.wav",
"LtrW.wav","LtrX.wav",
"LtrY.wav","LtrZ.wav"};
// Image files
String[] imageArray = {"Letter-A-blue-icon.png","Letter-B-blue-icon.png",
"Letter-C-blue-icon.png","Letter-D-blue-icon.png",
"Letter-E-blue-icon.png","Letter-F-blue-icon.png",
"Letter-G-blue-icon.png" ,"Letter-H-blue-icon.png",
"Letter-I-blue-icon.png","Letter-J-blue-icon.png",
"Letter-K-blue-icon.png","Letter-L-blue-icon.png",
"Letter-M-blue-icon.png", "Letter-N-blue-icon.png",
"Letter-O-blue-icon.png","Letter-P-blue-icon.png",
"Letter-Q-blue-icon.png","Letter-R-blue-icon.png",
"Letter-S-blue-icon.png" ,"Letter-T-blue-icon.png",
"Letter-U-blue-icon.png","Letter-V-blue-icon.png",
"Letter-W-blue-icon.png","Letter-X-blue-icon.png",
"Letter-Y-blue-icon.png" ,"Letter-Z-blue-icon.png"
};
AudioPlayer player;
// this will contain an array of all the letter images
PImage[] Letter = new PImage[lastLetter];
// Index into letters.
boolean random = false; // determine weather or not to generate display letters randomly or incrementally
int start = 0; // start position;
int myIndex=-1; // start index. -1 in case we are incrementing so we can start at A
void displayLetter()
{
if(random) {
int lastIndex = myIndex;
// Get random number between 0 and last letter
// Avoid repeating letters
while(myIndex == lastIndex){
myIndex = int(random (lastLetter));
}
}else{
myIndex++;
if(myIndex > 25){
myIndex = start;
}
}
// Load new letter sound into player
//maxim.reLoadPlayer(player, AudioClips[myIndex]);
player.selectAudioClip(myIndex);
// Play letter sound
player.setLooping(false);
player.volume(1);
player.cue(0);
player.speed(1);
player.play();
}
void setup()
{
orientation(PORTRAIT);
size(displayWidth,displayHeight,OPENGL);
maxim = new Maxim(44100);
player = maxim.createEmptyPlayer();
background(0);
for(int i = 0;i<lastLetter;i++) {
//AudioClips[i] = player.justLoadAudioFile(audioFileArray[i]);
Letter[i] = loadImage(imageArray[i]);
}
player.loadAudioClips(audioFileArray);
displayLetter();
}
void draw()
{
// code that happens every frame
background(0);
// Ensure image is centered
imageMode(CENTER);
// paste letter
image(Letter[myIndex],width/2,height/2,width-10, height-10);
}
void mouseDragged()
{
// code that happens when the mouse moves
// with the button down
}
void mousePressed()
{
// code that happens when the mouse button
// is pressed
// stop player
player.stop();
// clear screen
fill(0);
//rect(width/2, height/2, width, height);
// generate new letter and play sound
displayLetter();
}
void mouseReleased()
{
// code that happens when the mouse button
// is released
}
*/
//***************************************************************************************************************************************
// BraxLetters
// An app to help my 19 month old with his letters
// Written in Processing 2.0 June 2013
// Martin Bruner
//***************************************************************************************************************************************
LetterDisplay letterDisplay;
Maxim maxim;
void setup()
{
orientation(PORTRAIT);
size(displayWidth,displayHeight,OPENGL);
//size(640,960,OPENGL);
letterDisplay = new LetterDisplay(this);
}
void draw()
{
letterDisplay.updateDisplay();
}
void mouseDragged()
{
// code that happens when the mouse moves
// with the button down
}
void mousePressed()
{
// code that happens when the mouse button
// is pressed
letterDisplay.startMovingLetterOut();
}
void mouseReleased()
{
// code that happens when the mouse button
// is released
}