You are not logged in.

  • Login

1

Wednesday, April 20th 2011, 8:36pm

C: 2 Anweisungen gleichzeitig laufen lassen und 2 andere Fragen.

Hallo. Ich programmiere erst seit 3 Tagen, also bitte Nachsicht, wenn ich mich blöd anstell :D
Ich hab ein kleines Programm geschrieben, das mit den "Fehlermeldungen" von Windows Melodien ergibt, wie das SG1-Intro oder das Badnerlied. Code ganz unten.
Ich habe aber 3 Fragen:



1. Wie kann ich es machen, dann anstatt nur einem Ton mehrere kommen(Mir würden schon 2 reichen)? Müssten halt genau zeitgleich laufen...

2. Bei mir ist x der Änderungsfaktor, wie sich die Dauer der Töne verändert. Bei kleineren Werten als 1 wirds langsamer und bei größeren schneller. Dazu meine Frage, wie kann ich es machen, dass wenn ich zum Beispiel das Badnerlied auswähl, x=2 ist, aber bei Sg1-Intro x=4?
Habe schon das probiert, hat aber nicht funktioniert:

C/C++ Quellcode

1
2
3
4
if(i=='a') //genau das selbe mit der restlichen Auswahl, aber halt dann andere x-Wert
{
x=3;
}


Dann hab ichs noch versucht nach den Befehl im "fertigen" script (ganz unten) direkt nach der Auswahl einzufügen, wie hier zum Beispiel:
(kleiner Ausschnitt)

C/C++ Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
if(i=='a')
{
x=3;
 
Beep( c, atel );
Beep( d, atel );
Beep( e, atel );
Beep( f, atel );
Beep( g, vtel );
Beep( g, vtel );
.
.
.


3. Wenn ein "If-pfad" durchgespielt ist, kann ich dann auswählen, ob was ich machen will, genau so wie am Anfang. Aber ich mag auch, dass ich noch eine Möglichkeit habe, den Aktuellen Pfad zu stoppen und dann wieder auswählen kann. Wie kann ich das machen?

Momentaner Code:

C/C++ Quellcode

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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
 
int main(int argc, char *argv[])
{
char i;
 
short x;
 
short c;
short cis;
short d;
short dis;
short e;
short f;
short fis;
short g;
short gis;
short a;
short ais;
short h;
short C;
short Cis;
short D;
short Dis;
short E;
short F;
short Fis;
short G;
short Gis;
short A;
short Ais;
short H;
 
short GG;
 
 
c=264;
cis=280;
d=297;
dis=316;
e=330;
f=352;
fis=374;
g=396;
gis=418;
a=440;
ais=467;
h=495;
 
C=c*2;
Cis=cis*2;
D=d*2;
Dis=dis*2;
E=e*2;
F=f*2;
Fis=fis*2;
G=g*2;
Gis=gis*2;
A=a*2;
Ais=ais*2;
H=h*2;
 
GG=g/2;
 
int zdtel;
int sztel;
int atel;
int vtel;
int hbe;
int gze;
 
int psztel;
int patel;
int pvtel;
int phbe;
int pgze;
 
int sztelP;
int atelP;
int vtelP;
int hbeP;
int gzeP;  
 
int Pause8;
int Pause4;
 
int sonder1;
int sonder2;
int sonder3;
int sonder4;
 
 
 
Pause8=5;
Pause4=5;
 
 
patel=225*x;
pvtel=450*x;
phbe=900*x;
pgze=18000*x;
 
zdtel=37*x;
sztel=75*x;
atel=150*x;
vtel=300*x;
hbe=600*x;
gze=1200*x;
 
sztelP=75*x;
atelP=150*x;
vtelP=300*x;
hbeP=600*x;
gzeP=1200*x;
 
sonder1=375*x;
sonder2=300*x;
sonder3=825*x;
sonder4=750*x;
 
 
 
printf("Welches Lied willst du abspielen?\n\n");
printf("<a> Alle meine Entchen?\n");
printf("<b> Stargate SGI Theme?\n");
printf("<c> Badnerlied?\n");
printf("<d> Jack/Sam?\n");
printf("<e>\n");
printf("<f> Exit....\n");
 
i=getch();
 
 
if(i=='a')//Alle meine Entchen
{
 
Beep( c, atel );
Beep( d, atel );
Beep( e, atel );
Beep( f, atel );
Beep( g, vtel );
Beep( g, vtel );
Beep( a, atel );
Beep( a, atel );
Beep( a, atel );
Beep( a, atel );
Beep( g, vtel );
Beep( a, atel );
Beep( a, atel );
Beep( a, atel );
Beep( a, atel );
Beep( g, vtel );
Beep( f, atel );
Beep( f, atel );
Beep( f, atel );
Beep( f, atel );
Beep( e, vtel );
Beep( e, vtel );
Beep( d, atel );
Beep( d, atel );
Beep( d, atel );
Beep( d, atel );
Beep( c, vtel );
 
i=getch();
 
}
 
if(i=='b') //Stargate Sg1-Intro
{
 
 
Beep(g,atel);
Beep(D,phbe);
Beep(G,vtel);
Beep(F,sonder1);
Beep(Dis,sztel);
Beep(D,sztel);
Beep(Dis,sztel);
Beep(D,pvtel);
Beep(D,atel);
Beep(G,vtel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,vtel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(gis,atel);
Beep(gis,atel);
Beep(gis,atel);
Beep(G,vtel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,vtel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,atel);
Beep(Pause8,sonder2);
Beep(G,vtel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,vtel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,sztel);
Beep(g,atel);
Beep(GG,atel);
Beep(d,atel);
Beep(d,atel);
Beep(h,pvtel);
Beep(a,sztel);
Beep(h,sztel);
Beep(C,atel);
Beep(a,atel);
Beep(h,hbe);
Beep(h,sztel);
Beep(C,atel);
Beep(a,atel);
Beep(h,pvtel);
Beep(h,sztel);
Beep(C,atel);
Beep(a,atel);
Beep(h,atel);
Beep(D,atel);
Beep(C,atel);
Beep(h,sztel);
Beep(a,sztel);
Beep(h,sonder4);
Beep(a,atel);
Beep(g,atel);
Beep(dis,atel);
Beep(g,vtel);
Beep(E,pvtel);
Beep(d,sztel);
Beep(e,sztel);
Beep(f,atel);
Beep(d,atel);
Beep(E,sonder3);
Beep(E,sztel);
Beep(F,atel);
Beep(D,atel);
Beep(E,patel);
Beep(E,sztel);
Beep(F,atel);
Beep(D,atel);
Beep(E,patel);
Beep(E,sztel);
Beep(F,atel);
Beep(D,atel);
Beep(E,atel);
Beep(G,atel);
Beep(F,atel);
Beep(E,sztel);
Beep(D,sztel);
Beep(E,hbe);
Beep(g,atel);
Beep(gis,atel);
Beep(C,atel);
Beep(Cis,atel);
Beep(C,sonder1);
Beep(a,zdtel);
Beep(ais,zdtel);
Beep(h,atel);
Beep(Gis,atel);
Beep(Ais,atel);
Beep(H,atel);
Beep(Cis,atel);
Beep(C,sonder1);
Beep(a,zdtel);
Beep(ais,zdtel);
Beep(h,atel);
Beep(Gis,atel);
Beep(Ais,atel);
Beep(H,atel);
Beep(a,vtel);
Beep(F,vtel);
Beep(a,vtel);
Beep(F,vtel);
Beep(A,vtel);
Beep(a,atel);
Beep(a,atel);
Beep(A,vtel);
Beep(a,atel);
Beep(a,atel);
Beep(A,atel);
Beep(a,sztel);
Beep(a,sztel);
Beep(A,sztel);
Beep(A,sztel);
Beep(A,sztel);
Beep(A,gze);
 
i=getch();
 
}
 
if(i=='c')//Badnerlied
{
Beep(g,vtel);
Beep(C,vtel);
Beep(C,vtel);
Beep(g,vtel);
Beep(g,vtel);
Beep(e,vtel);
Beep(g,atel);
Beep(e,atel);
Beep(c,vtel);
Beep(C,vtel);
Beep(C,pvtel);
Beep(C,atel);
Beep(D,pvtel);
Beep(D,atel);
Beep(E,phbe);
Beep(E,vtel);
Beep(a,pvtel);
Beep(a,atel);
Beep(D,pvtel);
Beep(C,atel);
Beep(h,pvtel);
Beep(C,atel);
Beep(D,vtel);
Beep(E,vtel);
Beep(D,pvtel);
Beep(h,atel);
Beep(D,atel);
Beep(C,atel);
Beep(h,atel);
Beep(a,atel);
Beep(g,phbe);
Beep(g,atel);
Beep(D,pvtel);
Beep(C,vtel);
Beep(h,atel);
Beep(C,atel);
Beep(D,atel);
Beep(E,atel);
Beep(F,hbe);
Beep(Pause4,vtel);
Beep(G,vtel);
Beep(E,pvtel);
Beep(D,atel);
Beep(C,patel);
Beep(h,sztel);
Beep(C,atel);
Beep(E,atel);
Beep(D,atel);
Beep(G,patel);
Beep(G,sztel);
Beep(G,patel);
Beep(F,sztel);
Beep(E,patel);
Beep(D,sztel);
Beep(C,sonder3);
Beep(g,sztel);
Beep(C,patel);
Beep(A,sztel);
Beep(G,sonder3);
Beep(E,sztel);
Beep(C,patel);
Beep(E,sztel);
Beep(G,vtel);
Beep(E,patel);
Beep(C,sztel);
Beep(D,vtel);
Beep(E,atel);
Beep(D,atel);
Beep(C,gze);
 
i=getch();
 
   }
 
 
   if(i=='d')//Jack/Sam
   {
   Beep(gis,atel);
   Beep(Cis,atel);
   Beep(E,atel);
   Beep(Dis,hbe);
   Beep(h,atel);
   Beep(gis,atel);
   Beep(Cis,atel);
   Beep(E,atel);
   Beep(Dis,pvtel);
   Beep(E,atel);
   Beep(Gis,atel);
   Beep(Fis,vtel);
   Beep(E,vtel);
   Beep(Dis,pvtel);
   Beep(h,atel);
   Beep(gis,phbe);
   Beep(E,atel);
   Beep(Gis,atel);
   Beep(Fis,vtel);
   Beep(E,vtel);
   Beep(Dis,vtel);
   Beep(H,vtel);
   Beep(Gis,phbe);
   Beep(E,atel);
   Beep(Gis,atel);
   Beep(H,pvtel);
   Beep(Ais,atel);
   Beep(Dis,patel);
   Beep(Dis,atel);
   Beep(Ais,pvtel);
   Beep(Gis,atel);
   Beep(h,pvtel);
   Beep(h,atel);
   Beep(E,vtel);
   Beep(Dis,vtel);
   Beep(Cis,vtel);
   Beep(h,vtel);
   Beep(Cis,gze);
 
   i=getch();
}
 
   if(i=='f')
   {      
  // bis jetzt noch leere Funktion
}
 
if(i=='g')
{
return 0;
}
 
}

Tagging

Social bookmarks