Introduction to Computing and Programming in Python a Multimedia Approach Mark J. Guzdial - The ebook is available for quick download, easy access to content
Introduction to Computing and Programming in Python a Multimedia Approach Mark J. Guzdial - The ebook is available for quick download, easy access to content
https://ebookultra.com/download/python-programming-an-introduction-to-
computer-science-john-m-zelle/
https://ebookultra.com/download/principles-of-soft-computing-using-
python-programming-1st-edition-gypsy-nandi/
https://ebookultra.com/download/introduction-to-python-for-science-
and-engineering-second-edition-david-j-pine/
https://ebookultra.com/download/an-introduction-to-programming-in-
emacs-lisp-2nd-edition-robert-j-chassell/
Flow based Programming A New Approach To Application
Development 2nd Edition J. Paul Morrison
https://ebookultra.com/download/flow-based-programming-a-new-approach-
to-application-development-2nd-edition-j-paul-morrison/
https://ebookultra.com/download/ubiquitous-multimedia-computing-1st-
edition-qing-li/
https://ebookultra.com/download/functional-programming-in-python-1st-
edition-david-mertz/
https://ebookultra.com/download/data-mining-multimedia-soft-computing-
and-bioinformatics-1st-edition-sushmita-mitra/
Introduction to Computing and Programming in Python a
Multimedia Approach Mark J. Guzdial Digital Instant
Download
Author(s): Mark J. Guzdial
ISBN(s): 9780131176553, 0131176552
Edition: Pap/Cdr
File Details: PDF, 4.61 MB
Year: 2005
Language: english
Introduction to Media Computation:
A Multimedia Cookbook in Python
Mark Guzdial
I Introduction 5
2 Introduction to Programming 19
2.1 Programming is about Naming . . . . . . . . . . . . . . . . . 19
2.1.1 Files and their Names . . . . . . . . . . . . . . . . . . 21
2.2 Programming in Python . . . . . . . . . . . . . . . . . . . . . 22
2.2.1 Programming in JES . . . . . . . . . . . . . . . . . . . 23
2.2.2 Media Computation in JES . . . . . . . . . . . . . . . 23
2.2.3 Making a Recipe . . . . . . . . . . . . . . . . . . . . . 32
II Sounds 43
iii
iv CONTENTS
4 Creating Sounds 97
4.1 Creating an Echo . . . . . . . . . . . . . . . . . . . . . . . . . 98
4.1.1 Creating Multiple Echoes . . . . . . . . . . . . . . . . 99
4.1.2 Additive Synthesis . . . . . . . . . . . . . . . . . . . . 100
V Files 175
VI Text 181
14 Recursion 205
15 Objects 207
16 Java 211
16.1 Java examples . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
vi CONTENTS
List of Figures
vii
viii LIST OF FIGURES
4.1 The top and middle waves are added together to create the
bottom wave . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
4.2 The raw 440 Hz signal on top, then the 440+880+1320 Hz
signal on the bottom . . . . . . . . . . . . . . . . . . . . . . . 110
4.3 FFT of the 440 Hz sound . . . . . . . . . . . . . . . . . . . . 110
4.4 FFT of the combined sound . . . . . . . . . . . . . . . . . . . 110
4.5 The 440 Hz square wave (top) and additive combination of
square waves (bottom) . . . . . . . . . . . . . . . . . . . . . . 111
4.6 FFT’s of the 440 Hz square wave (top) and additive combi-
nation of square waves (bottom) . . . . . . . . . . . . . . . . 111
5.16 Original picture (left) and mirrored along the vertical axis
(right) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
5.17 Flowers in the mediasources folder . . . . . . . . . . . . . . 141
5.18 Collage of flowers . . . . . . . . . . . . . . . . . . . . . . . . . 142
5.19 Increasing reds in the browns . . . . . . . . . . . . . . . . . . 147
5.20 Increasing reds in the browns, within a certain range . . . . . 148
5.21 A picture of a child (Katie), and her background without her 149
5.22 A new background, the moon . . . . . . . . . . . . . . . . . . 149
5.23 Katie on the moon . . . . . . . . . . . . . . . . . . . . . . . . 150
5.24 Mark in front of a blue sheet . . . . . . . . . . . . . . . . . . 150
5.25 Mark on the moon . . . . . . . . . . . . . . . . . . . . . . . . 151
5.26 Mark in the jungle . . . . . . . . . . . . . . . . . . . . . . . . 152
5.27 Color: RGB triplets in a matrix representation . . . . . . . . 159
5.28 Color: The original picture (left) and red-reduced version (right)160
5.29 Color: Overly blue (left) and red increased by 20% (right) . . 160
5.30 Color: Original (left) and blue erased (right) . . . . . . . . . 161
5.31 Color: Lightening and darkening of original picture . . . . . . 161
5.32 Color: Negative of the image . . . . . . . . . . . . . . . . . . 162
5.33 Color: Color picture converted to greyscale . . . . . . . . . . 162
5.34 Color: Increasing reds in the browns . . . . . . . . . . . . . . 163
5.35 Color: Increasing reds in the browns, within a certain range . 164
This book is based on the proposition that very few people actually want to
learn to program. However, most educated people want to use a computer,
and the task that they most want to do with a computer is communicate.
Alan Perlis first made the claim in 1961 that computer science, and program-
ming explicitly, should be part of a liberal education [Greenberger, 1962].
However, what we’ve learned since then is that one doesn’t just “learn to
program.” One learns to program something [Adelson and Soloway, 1985,
Harel and Papert, 1990], and the motivation to do that something can make
the difference between learning to program or not [Bruckman, 2000].
The philosophies which drive the structure of this book include:
• Repetition is good. Variety is good. Marvin Minsky once said, “If you
know something only one way, you don’t know it at all.” The same
ideas come back frequently in this book. The same idea is framed in
multiple ways. I will use metaphor, visualizations, mathematics, and
even computer science to express ideas in enough different ways that
one of the ways will ring true for the individual student.
• The computer is the most amazingly creative device that humans have
ever conceived of. It is literally completely made up of mind-stuff. As
the movie says, “Don’t just dream it, be it.” If you can imagine it,
1
2 LIST OF FIGURES
Typographical notations
Examples of Python code look like this: x = x + 1. Longer examples look
look like this:
def helloWorld():
print "Hello, world!"
When showing something that the user types in with Python’s response,
it will have a similar font and style, but the user’s typing will appear after
a Python prompt (>>>):
>>> print 3 + 4
7
def helloWorld():
print "Hello, world!"
End of Recipe 1
Making it Work Tip: An Example How To
Make It Work
Best practices or techniques that really help are high-
lighted like this.
Acknowledgements
Our sincere thanks go out to · · ·
• Jason Ergle, Claire Bailey, David Raines, and Joshua Sklare who made
JES a reality with amazing quality for such a short amount of time.
Jason and David took JES the next steps, improving installation, de-
bugging, and process support.
• Adam Wilson built the MediaTools that are so useful for exploring
sounds and images and processing video.
• Jeff Pierce for reviewing and advising us on the design of the media
language used in the book.
• Kurt Eiselt who worked hard to make this effort real, convincing others
to take it seriously.
4 LIST OF FIGURES
• Janet Kolodner and Aaron Bobick who were excited and encouraging
about the idea of media computation for students new to computer
science.
• Joan Morton, Chrissy Hendricks, and all the staff of the GVU Center
who made sure that we had what we needed and that the paperwork
was done to make this class come together.
Introduction
5
Chapter 1
Introduction to Media
Computation
7
8 CHAPTER 1. INTRODUCTION TO MEDIA COMPUTATION
• Some computer scientists study how recipes are written: Are there
better or worse ways of doing something? If you’ve ever had to sepa-
rate whites from yolks in eggs, you know that knowing the right way
to do it makes a world of difference. Computer science theoreticians
worry about the fastest and shortest recipes, and the ones that take
up the least amount of space (you can think about it as counter space
— the analogy works). How a recipe works, completely apart from
how it’s written, is called the study of algorithms. Software engi-
neers worry about how large groups can put together recipes that still
work. (The recipe for some programs, like the one that keeps track of
Visa/MasterCard records has literally millions of steps!)
• Can recipes be written for anything? Are there some recipes that
can’t be written? Computer scientists actually do know that there are
recipes that can’t be written. For example, you can’t write a recipe
that can absolutely tell, for any other recipe, if the other recipe will
actually work. How about intelligence? Can we write a recipe that can
think (and how would you tell if you got it right)? Computer scientsts
in theory, intelligent systems, artificial intelligence, and systems worry
about things like this.
• There are even computer scientists who worry about whether peo-
ple like what the recipes produce, like the restauraunt critics for the
newspaper. Some of these are human-computer interface specialists
who worry about whether people like how the recipes work (those
“recipes” that produce an interface that people use, like windows,
buttons, scrollbars, and other elements of what we think about as a
1.1. WHAT IS COMPUTER SCIENCE ABOUT? 9
running program).
The recipe metaphor also works on another level. Everyone knows that
some things in recipe can be changed without changing the result dramat-
ically. You can always increase all the units by a multiplier to make more.
You can always add more garlic or oregano to the spaghetti sauce. But
there are some things that you cannot change in a recipe. If the recipe calls
for baking powder, you may not substitute baking soda. If you’re supposed
to boil the dumplings then saute’ them, the reverse order will probably not
work well.
Similarly, for software recipes. There are usually things you can easily
change: The actual names of things (though you should change names con-
sistently), some of the constants (numbers that appear as plain old numbers,
not as variables), and maybe even some of the data ranges (sections of the
data) being manipulated. But the order of the commands to the computer,
however, almost always has to stay exactly as stated. As we go on, you’ll
learn what can be changed safely, and what can’t.
Computer scientists specify their recipes with programming languages.
Different programming languages are used for different purposes. Some of
them are wildly popular, like Java and C++. Others are more obscure,
like Squeak and T. Others are designed to make computer science ideas
Other documents randomly have
different content
qu’on assimilerait à un petit Etat, s’appeler couramment la Valcorie,
et devenir la source d’une fortune immense pour leur propriétaire.
Celui-ci quittait pour la seconde fois la France, sans que sa
volonté ou même le hasard l’eussent remis en présence de Gaétane.
Pendant qu’il était au loin, les relations de voisinage et de
tradition reprirent entre Valcor et Ferneuse. La marquise fit des
avances à la comtesse, qui ne s’y déroba pas. Au bout de longs
mois, quand Renaud fut de retour, il s’aperçut qu’une véritable
amitié unissait les deux jeunes femmes.
Lorsque Gaétane et lui se rencontrèrent, il y avait près de huit
ans qu’ils ne s’étaient vus, l’âge, à deux mois près, du petit Hervé.
Ce qu’ils éprouvèrent, aucun des deux ne put le deviner chez
l’autre. Ils demeurèrent impénétrables. La fierté scella les lèvres de
la comtesse de Ferneuse. Elle ne sut pas si c’était le respect,
l’indifférence ou la circonspection, qui fermaient celles de son ancien
amant.
Que d’efforts secrets elle devait faire ensuite pour découvrir ce
qu’il y avait derrière ce silence, que ne trahit jamais ni une allusion,
ni un soupir, ni un regard! Cette impassibilité lui donna la force de
rester impassible elle-même. Puis ce fut une autre conviction qui, se
glissant en elle, peu à peu, se fortifiant, s’imposant, la maintint au
niveau d’une prudence capable de ne jamais se démentir.
Cependant son mari mourut.
Gaétane de Ferneuse n’avait pas encore trente ans lorsqu’elle se
trouva veuve. Sa beauté de blonde, éclatante et fine, son charme
impérieux, qui, on le devinait, pouvait se fondre dans la tendresse,
son irréprochable aristocratie et sa fortune, lui attirèrent, dès qu’elle
fut libre, bien des déclarations et des hommages. Nul ne doutait
qu’elle ne pensât à se remarier, à goûter enfin la vie, que les vices,
puis l’infirmité, d’un époux accepté à seize ans, lui avaient rendue
jusque-là si lugubre.
Cependant la comtesse de Ferneuse découragea tous les
prétendants à sa main. Elle semblait n’avoir qu’une passion, une
préoccupation, un but: son fils. Hervé ne la quittait point, et elle ne
quittait point Ferneuse.
Le jeune garçon fut élevé par sa mère et par des précepteurs
ecclésiastiques, dans cette Bretagne aux âpres horizons, près de
l’Océan, parmi les rumeurs, les souffles, les silences, des arbres et
des flots. Cela lui fit une âme mystique, tenace, ardente et fidèle.
Dès son enfance il aima Micheline.
Mme de Ferneuse ne devina ce sentiment que plus tard.
Elle aurait dû en être épouvantée, de la même épouvante
qu’éprouva la marquise de Valcor quand celle-ci crut découvrir, dans
les lettres tombées entre ses mains par un hasard inouï, que
Micheline et Hervé étaient les enfants du même père. Cependant
Gaétane, sans prendre, contre l’horrible danger, les précautions
radicales de la fuite ou d’une révélation, se contenta de combattre
doucement l’amour de son fils, par des moyens indirects. Ces
moyens, une influence maternelle aussi forte que la sienne pouvait
les rendre efficaces. C’étaient des réflexions, des indications, des
répugnances ou des espoirs, tendant à diriger ailleurs l’âme qui,
d’habitude, suivait docilement la sienne. Une amourette s’en fût
trouvée refroidie. Non pas la passion chaste et profonde qui tenait
au cœur du jeune homme autant que sa vie, autant même que sa
religion filiale.
Mme de Ferneuse venait de le comprendre lorsque fut donnée, au
château de Valcor, la fête en l’honneur des dix-huit ans de Micheline.
Elle vint soucieuse à cette soirée.
Et c’était bien la plus grave des conversations qu’elle poursuivait
avec Renaud, quand M. de Plesguen et José Escaldas regardaient, à
l’abri d’un massif, en fumant leurs cigares, ce beau couple aller et
venir lentement, dans la lumineuse fantasmagorie de la floraison
électrique.
Toutefois, par une tactique étrange,—même à ce moment où le
bonheur, l’avenir, l’existence peut-être, de son fils, étaient en jeu,—la
comtesse de Ferneuse n’en appelait pas au souvenir du marquis de
Valcor, pour établir avec lui cette vérité effrayante que leurs enfants
étaient frère et sœur. Elle envisageait tout haut, d’une voix qu’elle
parvenait à rendre paisible, l’hypothèse de leur mariage, et elle
épiait, avec une attention ardente, l’esprit sur le qui-vive, l’œil
aiguisé, le cœur en suspens, ce que Renaud allait exprimer par les
paroles ou la physionomie.
De quel problème cette femme, cette mère, cherchait-elle la
solution?
Qu’éprouva-t-elle quand elle put constater, chez le marquis de
Valcor, le même impassible et impénétrable silence relativement au
passé, et la résolution formelle d’accorder sa fille au jeune comte de
Ferneuse? Puis quand elle pressentit cet autre sentiment, muet
depuis tant d’années, à peine dévoilé ce soir, mais sur lequel
Gaétane ne se trompa pas: l’amour de cet homme pour elle-même,
le désir âprement combattu, mais proche d’une brûlante révolte, qui
le tenait frémissant à ses côtés?
Elle n’eut point le temps de rattacher aux résultats d’une patiente
observation, conduite pas à pas depuis des années, les conclusions
de l’heure présente. Laurence, accourant vers elle, la haine dans les
yeux, l’invective à la bouche, pour la chasser de cette demeure, dont
elle, Gaétane de Ferneuse, croyait enfin détenir le mystère, la rejeta
dans l’abîme des plus tragiques incertitudes. Le cri de Mme de Valcor:
«Micheline, ah! la pauvre petite!» Et son exclamation au sujet
d’Hervé: «Ce misérable enfant!» n’était-ce pas l’éclat de foudre qui
devait transformer en drame l’idylle de ces deux innocents? La
femme de Renaud savait tout. D’accord avec lui, ou devançant ses
tardifs projets, elle brisait les criminelles fiançailles. Hervé devait
donc véritablement la vie à l’homme que Gaétane avait devant elle!
Mère imprudente, à cause d’un mirage insensé, elle avait donc laissé
marcher son fils vers le crime ou le désespoir!
Et cependant!...
Lorsqu’il la rejoignit, ce fils, lorsqu’il lui demanda, dans la
franchise de sa jeune douleur:
—«Madame de Valcor a-t-elle le droit de vous chasser, ma
mère?»
Ce fut sincèrement qu’elle répondit:
—«Je donnerais ma vie pour le savoir!»
Elle doutait de nouveau. Elle ne se croyait pas vaincue. Après
avoir défendu si longtemps, dans le secret de son âme, l’unique
amour de sa vie contre un oubli qu’elle n’admettait pas, contre un
silence qui ressemblait trop à celui de la tombe, contre un parjure
dont elle persistait à croire incapables les lèvres qui s’attachaient
jadis éperdument aux siennes, c’était maintenant l’amour et le
bonheur de son fils qu’elle devait sauver du plus sombre piège. Elle
l’avait entrevu, ce piège. Jusqu’à présent, il lui avait suffi de n’y pas
tomber. Mais aujourd’hui les circonstances la forçaient à le
démasquer aux yeux de tous.
Gaétane de Ferneuse se sentit à hauteur de cette tâche.
Elle avait trop aimé Renaud, elle aimait trop son fils, pour ne pas
entreprendre de lutter contre l’imposture qu’elle soupçonnait.
Un moment troublée par l’intervention inexplicable de Laurence,
la comtesse bientôt s’était reprise. Cette nouvelle complication, si
déconcertante, ne pouvait cependant prévaloir contre des années
d’observation attentive, ni contre l’intuition de femme et d’amante
qui empêchait Gaétane de reconnaître, dans le père de Micheline,
l’amant adoré d’autrefois.
Le cœur d’un homme change-t-il à ce point? Même dans
l’éloignement, les aventures, les périls, les blessures lentes à guérir,
la brutalité des climats et des êtres? Ou n’était-ce pas le même
homme?...
La secrète certitude ne suffisait plus. Il fallait une preuve?
Et cette certitude même, sous quel choc n’oscilla-t-elle pas de
nouveau quand Mme de Ferneuse reçut le billet où, pour la première
fois depuis de longues années d’un invraisemblable silence, Renaud
de Valcor évoquait le passé. Le détail précis de la grotte bouleversa
Gaétane. Pas un être au monde n’avait surpris ce rendez-vous des
amants de jadis.
Mais alors?...
«J’irai,» se dit Mme de Ferneuse.
Et dans quelle fièvre elle attendit l’heure!
Cette fois, devant le miroir du souvenir, nulle comédie ne lui
donnerait le change. Il se rappelait,—ou il savait,—cet homme si
semblable d’aspect, si opposé de cœur, à celui qu’elle avait aimé.
Donc, il allait enfin parler. Et, enfin, elle interrogerait. Elle, qui n’avait
pu livrer son secret, tant qu’elle ne savait pas quel revenant
monstrueux,—âme morte sous les traits si chers, ou simulateur
infernal,—écouterait l’humiliante ou dangereuse évocation.
Maintenant, la vérité éclaterait,—ah! dans le seul son de cette voix,
quand il prononcerait certains mots.
Et Gaétane tremblait de douceur et d’horreur à l’idée de
descendre dans ce mystère, et de délivrer son âme des liens de
doute où elle se débattait depuis tant d’années.
IX
LE PÈRE ET LA FILLE
L’ E X P L I C AT I O N
LE ROMAN DU PRINCE
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com