Download presentation
Presentation is loading. Please wait.
Published byJessie Morton Modified over 8 years ago
1
Computer Science 1 Week 11
2
This Week... QBasic While Loops QBasic While Loops Audio Basics Audio Basics
4
Incrementing Variables Added values to variables
5
Incrementing Variables It is very useful to increment variable It is very useful to increment variable basically, you just add or subtract a value this is very common in programming some languages have special notation How? How? assign a variable using itself +/- a value It’s pretty easy to understand, but a little strange
6
LET var = var + 1 General Format Same Variable
7
LET x = 5 LET x = x + 1 PRINT x Increment Example: What Happens? 6
8
6 Increment Example Output
9
LET x = 10 PRINT x LET x = x + 1 PRINT x Increment Example 2 11
10
10 11 Increment Example 2 Output
11
INPUT "Guess:", guess IF guess = 2 THEN LET correct = correct + 1 END IF PRINT "Correct is"; correct Increment Example 3
12
Guess: 5 Correct is 0 Increment Example 3 Output
13
Guess: 2 Correct is 1 Increment Example 3 Output
15
QBasic While Loops While Loops
16
While Statement Repeats a block of statements Repeats a block of statements Condition to loop Condition to loop each time an expression is examined if True, the loop continues Think of it as an If Statement that loops Think of it as an If Statement that loops
17
If Statement vs. While Statement Uses a conditional expression If StatementWhile Statement Executes a block of statements Executes only onceExecutes multiple times
18
DO WHILE condition Statements LOOP While Statement Syntax
19
DO WHILE x <> 10 INPUT "Enter ten:", x LOOP PRINT "Done" While Loop Example
20
Enter ten: 7 Enter ten: 2 Enter ten: 10 Done While Loop Example Output
21
LET x = 10 DO WHILE x <> 10 INPUT "Enter ten:", x LOOP PRINT "Done" While Loop Example 2 Hmmm
22
Done While Loop Example 2 Output
23
INPUT Correct DO WHILE Guess <> Correct INPUT Guess LOOP PRINT "Done" While Loop Example 3
24
x = 1 DO WHILE x <= 5 PRINT x x = x + 1 LOOP While Loop Example 4
25
1234512345 While Loop Example 4 Output
26
QBasic Lab While Loops – Secret Number Game
27
Lab: Secret Number Game Overview: Overview: you will create a game player guess a secret number Objectives: Objectives: input a number from the user use the While Loop display "too high" or "to low"
28
Remember... Turn your program to Turn your program to Lab9 in SacCT You must do your own work You must do your own work If you do not turn in your program, you will not get credit! If you do not turn in your program, you will not get credit!
30
Sequenced Music Sound Using Instructions
31
Sequenced Music Basics Think of it as an audio program Think of it as an audio program it is equivalent to a music sheet! contains notes, tempo, instruments, etc... Computers synthesize the sounds Computers synthesize the sounds Wavetable contains pre-recorded sounds e.g. piano, trumpet, violin, applause not able to create vocals
32
Sequenced Music Basics Advantages Advantages easy to edit – music sheet! takes little space Sequencers Sequencers are used to create sequenced music many allow you to also use waveform audio e.g. FL Studio, Adobe Audition,...
33
MIDI Musical Instrument Digital Interface Musical Instrument Digital Interface way to connect musical instruments to a computer still used today MIDI Files MIDI Files standard also specifies a way to store music data can be used in a webpage Extension: mid or midi Extension: mid or midi
34
Example Sequencer Adobe Audition
35
Waveform Audio How Sound is Represented
36
Waveform Audio Basics Digital representation of sound Digital representation of sound PCM PCM Pulse-Code Modulation data represents the vibrations that we hear Think of it as a "bitmap" of sound Think of it as a "bitmap" of sound anything can be recorded as waveforms however, like bitmaps, editing is difficult
37
Waveform File Types MP3 MP3 acronym for MPEG Level 3 created by Motion Pictures Expert Group excellent compression – lossy can be used for sound and video extension: mp3
38
Waveform File Types Microsoft Wave File Microsoft Wave File lossless compression – tends to be huge extension: wav Windows Media Audio Windows Media Audio lossy compression – competes with MP3 has better security and information features extension:. wma
39
Adding a Waveform to Webpages Embed Tag Embed Tag Background Sound Tag Background Sound Tag Microsoft Extension to HTML
40
Waveform vs. Sequenced Stored as raw data (PCM)Stored as instructions WaveformSequenced Files can be largeFiles tend to be small Difficult to editEasy to edit – music sheet Can store any soundCannot create vocals
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.