100% found this document useful (12 votes)
80 views

Learning Iphone Programming From Xcode To App Store 1st Edition Alasdair Allan 2024 Scribd Download

Xcode

Uploaded by

zeniteabinat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (12 votes)
80 views

Learning Iphone Programming From Xcode To App Store 1st Edition Alasdair Allan 2024 Scribd Download

Xcode

Uploaded by

zeniteabinat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

Get ebook downloads in full at ebookname.

com

Learning iPhone Programming From Xcode to App


Store 1st Edition Alasdair Allan

https://ebookname.com/product/learning-iphone-programming-
from-xcode-to-app-store-1st-edition-alasdair-allan/

OR CLICK BUTTON

DOWNLOAD EBOOK

Explore and download more ebook at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Learning iOS Programming From Xcode to App Store Third


Edition Alasdair Allan

https://ebookname.com/product/learning-ios-programming-from-
xcode-to-app-store-third-edition-alasdair-allan/

Building iPhone Apps with HTML CSS and JavaScript


Making App Store Apps Without Objective C or Cocoa 1st
Edition Jonathan Stark

https://ebookname.com/product/building-iphone-apps-with-html-css-
and-javascript-making-app-store-apps-without-objective-c-or-
cocoa-1st-edition-jonathan-stark/

Learning iPhone Game Programming A Hands on Guide to


Building Your First iPhone Game 1st Edition Michael
Daley

https://ebookname.com/product/learning-iphone-game-programming-a-
hands-on-guide-to-building-your-first-iphone-game-1st-edition-
michael-daley/

Straight A s Are Not Enough Learning With Your Brain


Turned On 1st Edition Judy Fishel

https://ebookname.com/product/straight-a-s-are-not-enough-
learning-with-your-brain-turned-on-1st-edition-judy-fishel/
Basics Architectural Photography 1st Edition Michael
Heinrich

https://ebookname.com/product/basics-architectural-
photography-1st-edition-michael-heinrich/

Modeling Performance Measurement 2005th Edition Wade D.


Cook

https://ebookname.com/product/modeling-performance-
measurement-2005th-edition-wade-d-cook/

The Concept of Education International Library of the


Philosophy of Education Volume 17 1st Edition R. S.
Peters

https://ebookname.com/product/the-concept-of-education-
international-library-of-the-philosophy-of-education-
volume-17-1st-edition-r-s-peters/

Listening Is an Act of Love A Celebration of American


Life from the StoryCorps Project 1st Edition Dave Isay

https://ebookname.com/product/listening-is-an-act-of-love-a-
celebration-of-american-life-from-the-storycorps-project-1st-
edition-dave-isay/

Interpreting and the Politics of Recognition The IATIS


Yearbook 1st Edition Christopher Stone

https://ebookname.com/product/interpreting-and-the-politics-of-
recognition-the-iatis-yearbook-1st-edition-christopher-stone/
Principles of Foundation Engineering Si Edition Braja
M. Das

https://ebookname.com/product/principles-of-foundation-
engineering-si-edition-braja-m-das/
Learning iPhone Programming
Learning iPhone Programming

Alasdair Allan

Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo


Learning iPhone Programming
by Alasdair Allan

Copyright © 2010 Alasdair Allan. All rights reserved.


Printed in the United States of America.

Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.

O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: 800-998-9938 or [email protected].

Editor: Brian Jepson Indexer: Seth Maislin


Production Editor: Sarah Schneider Cover Designer: Karen Montgomery
Copyeditor: Audrey Doyle Interior Designer: David Futato
Proofreader: Kiel Van Horn Illustrator: Robert Romano

Printing History:
March 2010: First Edition.

O’Reilly and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Learning iPhone
Programming, the image of a lapwing, and related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.

TM

This book uses RepKover™, a durable and flexible lay-flat binding.

ISBN: 978-0-596-80643-9

[M]

1267461377
Table of Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi

1. Why Go Native? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
The Pros and Cons 1
Why Write Native Applications? 2
The Release Cycle 3
Build It and They Will Come 4

2. Becoming a Developer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Registering As an iPhone Developer 5
Enrolling in the iPhone Developer Program 7
The Apple Developer Connection 8
Installing the iPhone SDK 8
Preparing Your iPhone or iPod touch 11
Creating a Development Certificate 12
Getting the UDID of Your Development Device 14
Creating an App ID 15
Creating a Mobile Provisioning Profile 16
Making Your Device Available for Development 17

3. Your First iPhone App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19


Objective-C Basics 19
Object-Oriented Programming 19
The Objective-C Object Model 21
The Basics of Objective-C Syntax 23
Creating a Project 23
Exploring the Project in Xcode 25
Our Project in Interface Builder 32
Adding Code 34
Connecting the Outlets in Interface Builder 36
Putting the Application on Your iPhone 37

v
4. Coding in Objective-C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Declaring and Defining Classes 41
Declaring a Class with the Interface 41
Defining a Class with the Implementation 42
Object Typing 43
Properties 44
Synthesizing Properties 45
The Dot Syntax 45
Declaring Methods 45
Calling Methods 46
Calling Methods on nil 47
Memory Management 47
Creating Objects 47
The Autorelease Pool 48
The alloc, retain, copy, and release Cycle 48
The dealloc Method 50
Responding to Memory Warnings 50
Fundamental iPhone Design Patterns 50
The Model-View-Controller Pattern 51
Views and View Controllers 51
The Delegates and DataSource Pattern 52
Conclusion 53

5. Table-View-Based Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Simplifying the Template Classes 55
Creating a Table View 58
Organizing and Navigating Your Source Code 61
Connecting the Outlets 62
Building a Model 65
Adding Images to Your Projects 71
Connecting the Controller to the Model 73
Mocking Up Functionality with Alert Windows 74
Adding Navigation Controls to the Application 75
Adding a City View 79
Edit Mode 85
Deleting a City Entry 89
Adding a City Entry 90
The “Add New City...” Interface 93
Capturing the City Data 100

6. Other View Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107


Utility Applications 107
Making the Battery Monitoring Application 108

vi | Table of Contents
Tab Bar Applications 119
Refactoring the Template 120
Adding Another Tab Bar Item 122
Finishing Up 124
Modal View Controllers 125
Modifying the City Guide Application 126
The Image Picker View Controller 133
Adding the Image Picker to the City Guide Application 133

7. Connecting to the Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145


Detecting Network Status 145
Apple’s Reachability Class 145
Embedding a Web Browser in Your App 150
A Simple Web View Controller 150
Displaying Static HTML Files 159
Getting Data Out of a UIWebView 160
Sending Email 161
Getting Data from the Internet 166
Synchronous Requests 166
Asynchronous Requests 167
Using Web Services 168

8. Handling Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191


Data Entry 191
UITextField and Its Delegate 191
UITextView and Its Delegate 193
Parsing XML 195
Parsing XML with libxml2 196
Parsing XML with NSXMLParser 197
Parsing JSON 199
The Twitter Search Service 201
The Twitter Trends Application 202
Regular Expressions 213
Introduction to Regular Expressions 213
Storing Data 217
Using Flat Files 217
Storing Information in an SQL Database 218
Core Data 224

9. Distributing Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225


Adding Missing Features 225
Adding an Icon 225
Adding a Launch Image 227

Table of Contents | vii


Changing the Display Name 231
Enabling Rotation 232
Building and Signing 233
Ad Hoc Distribution 233
Developer-to-Developer Distribution 240
App Store Distribution 240
Submitting to the App Store 241
The App Store Resource Center 244
Reasons for Rejection 244

10. Using Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249


Hardware Support 249
Determining Available Hardware Support 249
Setting Required Hardware Capabilities 251
Using the Camera 253
The Core Location Framework 254
Location-Dependent Weather 256
Using the Accelerometer 266
Writing an Accelerometer Application 268
Using the Digital Compass 272
Accessing the Proximity Sensor 274
Using Vibration 275

11. Geolocation and Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277


User Location 277
Annotating Maps 285

12. Integrating Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295


Application Preferences 295
Accessing Global Preferences 305
Custom URL Schemes 305
Using Custom Schemes 305
Registering Custom Schemes 306
Media Playback 310
Using the Address Book 314
Interactive People Picking 315
Programmatic People Picking 319

13. Other Native Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321


PhoneGap 321
Download and Installation 322
Building a PhoneGap Project 323
MonoTouch 325

viii | Table of Contents


Download and Installation 325
Building a MonoTouch Project 327

14. Going Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335


Cocoa and Objective-C 335
The iPhone SDK 335
Web Applications 336
Core Data 336
Push Notifications 337
In-App Purchase 338
Core Animation 339
Game Kit 339
Writing Games 339
Look and Feel 340
Hardware Accessories 340

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343

Table of Contents | ix
Preface

The arrival of the iPhone changed everything. Or, at the very least, it changed the
direction of software development for mobile platforms, which is a pretty big thing. It
spawned an entire generation of copycat devices and shook an entire multibillion-dollar
industry to its knees. Despite this, it still fits in your pocket.

Who Should Read This Book?


This book gives a rapid introduction to programming for the iPhone and iPod touch
for those with some programming experience. If you are developing on the Mac for the
first time, drawn to the platform because of the iPhone, or alternatively you are an
experienced Mac programmer making the transition to the iPhone, this book is for you.

What Should You Already Know?


The book assumes some knowledge of C, or at least passing knowledge of a C-derived
language. Additionally, while I do give a crash course, some familiarity with object-
oriented programming concepts would be helpful.

What Will You Learn?


This book will guide you through developing your first application for the iPhone, from
opening Xcode for the first time to submitting your application to the App Store. You’ll
learn about Objective-C and the core frameworks needed to develop for the iPhone by
writing applications that use them, giving you a basic framework for building your own
applications independently.

xi
What’s in This Book?
Here’s a short summary of the chapters in this book and what you’ll find inside:
Chapter 1, Why Go Native?
This chapter discusses the need for native applications and compares building
native applications to building web applications.
Chapter 2, Becoming a Developer
This chapter walks you through the process of registering as an iPhone developer
and setting up your work environment, from installing Xcode and the iPhone SDK
to generating the developer certificates you’ll need to build your applications and
deploy them onto your own iPhone or iPod touch.
Chapter 3, Your First iPhone App
This chapter allows you to get hands-on as quickly as possible and walks you
through building your first Hello World application, including how to deploy and
run the application on your iPhone or iPod touch.
Chapter 4, Coding in Objective-C
This chapter provides a crash course in the basics of the Objective-C language, and
if you’re familiar with another C-derived language (and perhaps with object-
oriented programming), it should be enough to get you up and running with
Objective-C and the Cocoa Touch frameworks.
Chapter 5, Table-View-Based Applications
The UITableView and associated classes are perhaps the most commonly used
classes when building user interfaces for iPhone or iPod touch applications. Due
to the nature of the applications, these classes can be used to solve a large cross
section of problems, and as a result they appear almost everywhere. In this chapter,
we dive fairly deeply into the table view classes.
Chapter 6, Other View Controllers
After discussing the table view controller in detail, we discuss some of the other
view controllers and classes that will become useful when building your applica-
tions: simple two-screen views, single-screen tabbed views, modal view controllers,
and a view controller for selecting video and images.
Chapter 7, Connecting to the Network
This chapter discusses connecting to the Internet, browsing the Web, sending
email, and retrieving information.
Chapter 8, Handling Data
This chapter discusses how to handle data input, both from the application user
and programmatically, and how to parse XML and JSON documents. The chapter
also covers storing data in flat files and storing data with the SQLite database
engine.

xii | Preface
Chapter 9, Distributing Your Application
This chapter talks about how to add some final polish to your application and
walks you through the process of building your application for distribution, either
via ad hoc distribution or for the App Store.
Chapter 10, Using Sensors
This chapter discusses how to determine what hardware is available and illustrates
how to deal with the major sensors on the iPhone and iPod touch: the
accelerometer, magnetometer, camera, and GPS.
Chapter 11, Geolocation and Mapping
This chapter walks you through the process of building applications that make use
of the Core Location and MapKit frameworks.
Chapter 12, Integrating Your Application
This chapter shows you some of the tricks to integrate your application with the
iPhone’s software ecosystem, how to present user preferences with Settings Bun-
dles, and how to use custom URL schemes to launch your application. It also
discusses how to make use of the Media Player and Address Book.
Chapter 13, Other Native Platforms
This chapter deals with the PhoneGap and MonoTouch platforms for building
native applications for the iPhone and iPod touch that can be sold on the App Store.
The chapter then walks you through the installation process and building your first
Hello World application for both platforms.
Chapter 14, Going Further
This chapter provides a collection of pointers to more advanced material on the
topics we covered in the book, and material covering some of those topics that we
didn’t manage to talk about in the book.

Conventions Used in This Book


The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions
Constant width
Used for program listings, as well as within paragraphs to refer to program elements
such as variable or function names, databases, data types, environment variables,
statements, and keywords
Constant width bold
Shows commands or other text that should be typed literally by the user
Constant width italic
Shows text that should be replaced with user-supplied values or by values deter-
mined by context

Preface | xiii
This icon signifies a tip, suggestion, or general note.

This icon signifies a warning or caution.

Using Code Examples


This book is here to help you get your job done. In general, you may use the code in
this book in your programs and documentation. You do not need to contact us for
permission unless you’re reproducing a significant portion of the code. For example,
writing a program that uses several chunks of code from this book does not require
permission. Selling or distributing a CD-ROM of examples from O’Reilly books does
require permission. Answering a question by citing this book and quoting example
code does not require permission. Incorporating a significant amount of example code
from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: “Learning iPhone Programming, by Alasdair
Allan. Copyright 2010 Alasdair Allan, 978-0-596-80643-9.”
If you feel your use of code examples falls outside fair use or the permission given here,
feel free to contact us at [email protected].

How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at:
http://oreilly.com/catalog/9780596806439
Supplementary materials are also available at:
http://www.learningiphoneprogramming.com/

xiv | Preface
To comment or ask technical questions about this book, send email to:
[email protected]
For more information about our books, conferences, Resource Centers, and the
O’Reilly Network, see our website at:
http://www.oreilly.com

Safari® Books Online


Safari Books Online is an on-demand digital library that lets you easily
search over 7,500 technology and creative reference books and videos to
find the answers you need quickly.
With a subscription, you can read any page and watch any video from our library online.
Read books on your cell phone and mobile devices. Access new titles before they are
available for print, and get exclusive access to manuscripts in development and post
feedback for the authors. Copy and paste code samples, organize your favorites, down-
load chapters, bookmark key sections, create notes, print out pages, and benefit from
tons of other time-saving features.
O’Reilly Media has uploaded this book to the Safari Books Online service. To have full
digital access to this book and others on similar topics from O’Reilly and other pub-
lishers, sign up for free at http://my.safaribooksonline.com.

Acknowledgments
Books do not write themselves, but a book is also not the work of just a single person,
despite what it may say on the front cover. I’d like to thank my editor, Brian Jepson.
His hard work and constant prodding made the book better than it might otherwise
have been. I’d also like to offer more than thanks to my long-suffering wife, Gemma
Hobson. Without her support, encouragement, and willingness to make those small
(and sometimes larger) sacrifices that an author’s spouse has to make, this book
wouldn’t be in your hands today. Thank you. Finally to my son, Alex, who is as yet too
young to do more than chew on the cover, daddy’s home. I can only hope for your sake
that O’Reilly uses tasty paper.

Preface | xv
CHAPTER 1
Why Go Native?

When the iPhone was introduced, there was no native SDK. Apple claimed that one
wasn’t needed and that applications for the device should be built as web applications
using JavaScript, CSS, and HTML. This didn’t go down well with the developer com-
munity; they wanted direct access to the hardware and integration with Apple’s own
applications.
Only a few months after the iPhone’s release, the open source community had accom-
plished something that many thought impossible. Despite Apple locking the device
down, developers had gained access, reverse-engineered the SDK, and gone on to build
a free open source tool chain that allowed them to build native applications for the
device. At one point, it was estimated that more than one-third of the iPhones on the
market had been “jail broken” by their users, allowing them to run these unsanctioned
third-party applications.
This open source development effort is ongoing today, and if you want to know more,
I recommend iPhone Open Application Development, Second Edition by Jonathan
Zdziarski (O’Reilly). However, the book you hold in your hands isn’t about the open
source “hacker” SDK, because in March 2008 Apple publicly changed its mind and
released the first version of the native SDK to a waiting developer community. Whether
this release was in response to this effort, or perhaps because it was (the notoriously
secretive) Apple’s plan all along, we’ll probably never know.

The Pros and Cons


When the native SDK was introduced, a number of people in the industry argued that
it was actually a step backward for developers. They felt that web-based applications,
especially once home screen icons for these applications arrived on the 1.1.3 firmware,
were good enough. By writing code specifically for the iPhone in Objective-C, you were
making it more difficult to port your applications, and porting a web application more
or less consisted of simply restyling it using a new CSS template.

1
It seemed that the users of the applications disagreed. It’s arguable why this is the case,
but it’s very hard to make native-looking web applications that can be reused across
many different platforms, though it is possible. Just as applications on the Mac desktop
that have been ported from Windows tend to stand out like a sore thumb by not quite
working as the user expects, web applications, especially those that are intended to be
used across different platforms, tend to do the same.
If you integrate your application into the iPhone ecosphere, make use of the possibilities
that the phone offers, and optimize your user interface (UI) for the device, the user
experience is much improved. It’s also really hard to write web applications that work
well when you need to design for a smaller screen, implying as it does a simpler UI and
less exposed functionality, without using native controls.

Why Write Native Applications?


The obvious reason to use the native SDK is to do things that you can’t do on the Web.
The first generation of augmented reality applications is a case in point; these needed
close integration with the iPhone’s onboard sensors (e.g., GPS, accelerometer, digital
compass, and camera) and wouldn’t have been possible without that access. Although
the iPhone’s Safari browser supports the new geolocation capabilities HTML 5 pro
vides, this doesn’t alleviate the problem entirely. It’s doubtful that all platform-specific
hardware is going to get the same sort of treatment, so it’s unlikely that you will see the
arrival of augmented reality web applications.

If you are coming from a web development background, you may be


interested in the cross-platform PhoneGap framework. This framework
provides native wrapper classes and allows you to build native applica-
tions in HTML/JavaScript on a range of mobile platforms. One of the
platforms it targets is the iPhone. I talk about PhoneGap, and the other
alternative native development platforms for the iPhone, in Chapter 13.

Sometimes it’s not about doing things that can’t be done; it’s about doing things faster,
and doing client-side error handling. For instance, the Apple iTunes and App Store
applications that are provided with the iPhone are actually web applications wrapped
inside native applications. Just like the iTunes Store on the Mac, the main display you
see is a web page, but the surrounding infrastructure is a native application. This means
that while the application can’t do a lot without an Internet connection, it can at least
start up.
But those are extreme examples. A lot of the applications in the App Store combine
remote data and native interfaces. Without access to the network, some of the UI is
generally disabled. However, native applications can be built to degrade gracefully
when the device’s network connection disappears or if it was never present in the first

2 | Chapter 1: Why Go Native?


place. The user can still use the bits of the application that don’t need a network con-
nection to work.
Sometimes it’s also about what an application doesn’t need. If it doesn’t need a network
connection, the idea that your phone needs to be connected to the network to use it,
sucking extra battery power in the process, is wasteful. Even when it is connected, the
device isn’t always connected to a fast Internet connection. Anything you can do to
minimize the amount of data you need to suck down the data connection will improve
users’ interaction with your application. That means generating your UI locally, and
populating it with data pulled from the Internet.
Network performance will affect the user’s perception of speed; rendering your UI
while a web request is made to populate it allows your application to remain responsive
to user interaction even while it’s waiting for the network. That can only be a good
thing.
I haven’t even mentioned game development yet, and with Apple pitching the iPod
touch as “the funnest iPod ever,” that’s important. You cannot develop the sorts of
games now starting to appear on the App Store using web-based technologies. While
this book covers the basics of how to program for the iPhone or iPod touch, if you
want to delve deeply into game programming on the platform, I recommend iPhone
Game Development by Paul Zirkle and Joe Hogue (O’Reilly).

The Release Cycle


Paul Graham, one of my favorite dispensers of wisdom, argues that the arrival of web-
based software has changed not just the user experience, but the developer experience
as well:
One of the most important changes in this new world is the way you do releases. In the
desktop software business, doing a release is a huge trauma, in which the whole company
sweats and strains to push out a single, giant piece of code. Obvious comparisons suggest
themselves, both to the process and the resulting product.
—From “The Other Road Ahead” by Paul Graham
He is exactly right. Working in the cloud, you rarely make a software release in the old
sense of the word. Despite the benefits, I must admit I actually somewhat miss the “big
push” where, usually with a great deal of trepidation, you roll out a new, improved
version of a piece of software. However, one problem with writing native applications
is that we’ve made a return to the release cycle.
With web-based software you can make incremental releases, fixing bugs when and if
they occur. Native applications are far more like desktop software.
I cover the details of how to submit applications to the App Store in Chapter 10. How-
ever, you should prepare yourself now for some amount of pain. The review process is
notoriously opaque, and it can (and does) take time. Plus, each of your applications

The Release Cycle | 3


must go through it, not just when you initially submit it to the store, but also for each
new version you release. Typically, it can take up to 14 days from submitting your
application for it to be approved (or rejected) by the review team, although it can take
much longer. Based on my experience, although some of my applications have sailed
through the submission process in only a couple of days, I have had applications in the
review process for up to four months before receiving approval.

Build It and They Will Come


Of course, the big advantage, even with today’s crowded App Store, is exposure. If
nobody can find your application, nobody can pay for it, and the Web is a big place.
One big advantage a native application has over a web application is that it’s easier for
potential users to find, and much easier to pay for when they find it. That is, if you can
get people to pay for web applications at all. People don’t impulse-subscribe to a web
service; they impulse-buy from the App Store.
However, don’t assume that if you build it, users will appear. Unless you’re really lucky
and your application goes viral, you still need to market your application. The App
Store may be a lot smaller than the Web, but it’s still a pretty big place.
Marketing your application is like marketing any product; you need to make use of the
tools available and your contacts to get news of your software to your target market.
Apple provides promotional codes for your application (although at the time of this
writing, these work only on the U.S. App Store) that will give free downloads of your
applications. Many developers reach out to high-profile blogs or the many application
catalog sites and offer them review copies in hopes that they will publicize the appli-
cation. If it’s well designed and useful, they might well be interested in reviewing it.
Produce a screencast showing how your application works and how to use it. Also,
applications with good support resources (such as forums and trouble-ticket systems)
sell more copies. Applications with good design stand out in the store and sell more
copies.
Good design often means that you do things “the Apple way.” Integrate your applica-
tion well with the other applications on the phone. Don’t reinvent the wheel: use the
standard widgets and UI elements familiar to iPhone users.

4 | Chapter 1: Why Go Native?


CHAPTER 2
Becoming a Developer

Before you start writing code, you need to do some housekeeping. First, you’ll need to
install Xcode, Apple’s development environment, as well as the iPhone SDK. Both of
these are available directly from Apple, although you may already have Xcode on your
Mac OS X install DVD. However, before you can install the iPhone SDK, you’ll have
to register with Apple as a developer. If you enroll in one of the developer programs,
you’ll also need to create, download, and install a number of certificates and profiles
to allow you to deploy your applications onto your iPhone or iPod touch. Let’s get these
housekeeping tasks out of the way now so that you can get to the interesting bit—the
code—as quickly as you can.

Developing applications for the iPhone requires an Intel Mac running


Mac OS X 10.5 (Leopard) or later.

Registering As an iPhone Developer


Before you can develop for the iPhone, you need to become a registered iPhone devel-
oper so that you can download and install the iPhone SDK. This will give you access
to the SDK and allow you to build and test your applications in iPhone Simulator.
If you take it a step further and enroll in the iPhone Developer Standard or Enterprise
Program (both of these have a yearly fee), you’ll be able to test applications on your
own iPhone or iPod touch. We will discuss how to enroll in these programs in the next
section.
If you choose the free account, you won’t be able to install your applications onto your
own iPhone or iPod touch, nor will you be able to sell applications on Apple’s App
Store (Standard Program) or distribute them to people within your own company
(Enterprise Program). If you stick with a free account, you also won’t have access to
prerelease versions of the iPhone SDK or the iPhone OS.
You can sign up at http://developer.apple.com/iphone/.

5
If you are an existing Apple Developer Connection (ADC) member, or
if you have an iTunes or MobileMe account, you can use your existing
Apple ID to register as an iPhone developer. However, if you intend to
sell software commercially, you may want to create a new identity for
use with the program to keep it separate from your existing Apple ID.

You’ll initially be asked to either choose an existing Apple ID or create a new one. If
you create a new one, you’ll be asked for some details (e.g., email and physical ad-
dresses); if you choose an existing Apple ID, you’ll still need to confirm some of these
details, although they should be filled in with the most recent information Apple has.
You’ll also be asked to provide a professional profile, indicating what sort of applica-
tions you’ll be developing and whether you also develop for other mobile platforms.
Finally, you’ll need to agree to the developer license. After you do, a verification code
may be sent to the email address you registered with Apple, although this doesn’t hap-
pen in all cases. However, if this happens to you, the final step of registering as an
iPhone developer will be to verify your email address.

Apple Websites
You’ll use four main websites as part of the iPhone development process:
The iPhone Dev Center
This site is where you can get access to the latest versions of the iPhone SDK, along
with background technical information, API documentation, sample code, and
instructional videos. You need to be a registered iPhone developer to access the site.
The Developer Program Portal
This site is where you can generate and manage the certificates, provisioning pro-
files, approved devices, and other housekeeping tasks necessary to test your ap-
plications on the iPhone and iPod touch and prepare them for distribution. You’ll
need to be both a registered iPhone developer and enrolled in one of the iPhone
Developer Programs to access this site.
The App Store Resource Center
This site provides help and advice on how to distribute your application on the
App Store, including preparing your app for submission, understanding the App
Store approval process, and learning how to manage your apps on the App Store.
You’ll need to be both a registered iPhone developer and enrolled in the iPhone
Developer Standard Program to access this site.
iTunes Connect
This site provides you with the tools to manage your applications on the iTunes
App Store and your contracts with Apple. You’ll need to be both a registered
iPhone developer and enrolled in the iPhone Developer Standard Program to access
this site.

6 | Chapter 2: Becoming a Developer


Enrolling in the iPhone Developer Program
If you intend to sell your applications on the App Store, or you just want to be able to
deploy them onto your own iPhone or iPod touch, you’ll also need to enroll in the
iPhone Developer Program. If you’ve not already registered as an iPhone developer,
you can do that during this process.

Your iPhone Developer Program membership lasts for 1 year and can
be renewed starting 60 days before the expiration date of your existing
membership. If you do not renew your membership, your ability to dis-
tribute your applications will be curtailed. In addition, your developer
and distribution certificates will be revoked. Finally, any applications
you have on the iTunes App Store will be removed.

You have two options when enrolling in the iPhone Developer Program. Most people
will want to register for the Standard Program, which costs $99 per year. This will allow
you to create free—or, once you’ve filled out some paperwork, commercial—
applications for the iPhone and iPod touch, and distribute them either via the App Store
or via the ad hoc distribution channel where you provide both the application binary
and a provisioning certificate to the end user.

Ad hoc distribution allows you to distribute your application directly to


your users, bypassing the App Store. However, distribution is limited
to just 100 devices during the course of your one-year membership and,
at least for the end user, is more complicated than distributing your
application via the App Store. It’s mainly intended for beta testing pro-
grams, and it isn’t a substitute for publishing your application to the
store. If you need to conduct large-scale rollouts to a specific group of
users and you want to avoid the App Store, you should probably look
at the Enterprise Program.

The more expensive Enterprise Program, at $299, is intended for companies with more
than 500 employees that wish to create applications for in-house distribution. While
this program allows you to distribute your applications inside your own company, it
does not allow you to publish them for sale on the App Store. If you’re thinking about
selling your applications to the public, you need the Standard Program.
An iPhone Developer University Program is also available, but this is designed specif-
ically for higher education institutes looking to introduce iPhone development into
their curricula. Unless you’re an academic at such an institute, it’s unlikely that this
program will be applicable to you.

Enrolling in the iPhone Developer Program | 7


The Apple Developer Connection
As well as enrolling as a member of the iPhone Developer Program, you may also wish
to register as a member of the Apple Developer Connection. Doing so is a good idea if
you’re serious about developing with the Mac, and all but the free membership tiers
will give you access to the Software Seeding Program, which provides prerelease copies
of both the Mac OS X operating system and Apple’s developer tools. You can sign up
for ADC at either http://developer.apple.com or https://connect.apple.com.
Three membership plans are available: a free online membership, the $500 Select
membership, and the Premier membership that costs several thousand dollars (al-
though it also includes a ticket to the Apple Worldwide Developers Conference).

Installing the iPhone SDK


Once you have registered as an iPhone developer, you can log in to the iPhone Dev
Center and download the iPhone SDK.

At the time of this writing, Apple combined the iPhone SDK and Xcode
into a single download. It is possible that in future releases you may
need to install Xcode first, and then install the iPhone SDK from a sep-
arate installer.

Newer prerelease beta versions of the SDK may be available to those enrolled in the
iPhone Developer Program; however, the current stable version will be available even
if you choose not to pay to enroll in the program.
The combined download of the Xcode development tools and the iPhone SDK is around
2.5 GB in size. The combined bundle will be downloaded as a disk image file. After it
downloads, the image should automatically mount; double-click on the iPhone SDK
and Tools package file to install the SDK, as shown in Figure 2-1.
The installer will ask you to agree to the terms of the software license agreement before
prompting you to install the software. You should install it in the suggested location,
and the default installation options will include everything you need to develop appli-
cations for the iPhone or iPod touch. However, you’ll need at least 5.9 GB of free space
on your disk to install the Xcode developer tools and the iPhone SDK.
After installation, you can check that everything has gone OK by starting Xcode, which
will have been installed in the /Developer/Application folder on your machine. Project
templates should be available for the iPhone OS, as shown in Figure 2-2.
You now have everything you need to write applications and test them in the simulator.

8 | Chapter 2: Becoming a Developer


Figure 2-1. Installing the Xcode development tools and the iPhone SDK
If you want to test your code on an actual iPhone, you will need to enroll
in either the Standard or Enterprise iPhone Developer Program. How-
ever, the amount of time it takes to be accepted into the program varies,
so after you enroll and have been accepted, you should bookmark this
page and finish the steps in this chapter. You can use iPhone Simulator
for the examples in this book while you wait to be accepted.

While the simulator is very good, it’s not perfect. Code runs much faster on the simu-
lator than it does on the device. If you’re dealing with applications that have a com-
plicated UI or consume a great deal of processor power, the difference in performance
between the simulator and the device could become important. On several occasions
I’ve had to go back and rewrite my code and refactor the way in which my UI functions;
when I tested my application on the simulator it worked fine, but on real hardware it
just ran too slowly. You can also allocate much more memory in the simulator than is
available on the real hardware.
Additionally, some frameworks are available to you in the simulator—notably the
NSPredicate and NSXMLDocument classes—that just don’t exist on the device. Code that
uses these missing classes will compile and run on the simulator, but not on the device.
As well as regularly building your application in iPhone Simulator, it’s therefore a good
idea to do regular device builds. If you accidentally use one of these “missing” classes,
it will show up as a link error at compile time for such a build. After all, you don’t want
to get too far down the road of developing your application only to discover (hours, or

Installing the iPhone SDK | 9


Figure 2-2. The Xcode New Project window
worse yet, days later) that you’re using classes or frameworks that aren’t actually
present on the device.

Both NSPredicate and NSXMLDocument are commonly used classes. For


instance, NSXMLDocument is the class most people programming in
Objective-C on the Mac (rather than the iPhone) would use to perform
an XQuery on an XML document. The lack of NSXMLDocument is some-
thing that most developers notice quite quickly.

While I’ve seen some complaints that the simulator can sometimes be slightly off on
pixel alignment of UIKit elements, I’ve not yet come across this myself. However, when
using lower-level graphics libraries, such as OpenGL ES, the renderer used on the
iPhone and iPod touch is slightly different from the one used in the simulator, so when
a scene is displayed on the simulator it may not be identical to the actual device at the
pixel level.
Additionally, the simulator has some built-in limitations. For instance, if your appli-
cation’s UI is designed to respond to touch events with more than two fingers, you
can’t test it in the simulator.

10 | Chapter 2: Becoming a Developer


While it doesn’t allow you to simulate gestures requiring many fingers,
iPhone Simulator does allow you to test applications that require two-
finger (multitouch) touch gestures. You can use Option-click (for pinch)
or Option-Shift-click (for drag) while using the mouse to get two
“fingers.”

Furthermore, you will not have access to the accelerometer, GPS, Bluetooth, or digital
compass when running your application in the simulator. If your application relies on
these hardware features, you have no choice but to test it on your device.

Preparing Your iPhone or iPod touch


Before you can install applications onto your iPhone or iPod touch, you must follow a
number of steps, and you’ll need to do so in the order shown in Figure 2-3.

Figure 2-3. The workflow for creating certificates and mobile provisioning profiles

So, if you have enrolled in either the Standard or Enterprise iPhone Developer Program,
now is the time to generate the appropriate certificates and provisioning profiles so that
you will be able to deploy the test application from the next chapter onto your device.

Certificates and Provisioning Profiles


You must have a development certificate for Xcode to sign your application binaries.
This certificate also identifies you as a developer. When you build your iPhone appli-
cation, Xcode will look in your Mac OS X keychain for this certificate and the corre-
sponding certificate from Apple, called the WWDR Intermediate certificate, which
you’ll also need to download from the Developer Portal.
Provisioning profiles associate a development certificate, and hence a developer, with
a hardware device and an iPhone application ID, which is a unique identifier for your
application. To install an application that you’ve signed with your development
certificate onto your iPhone or iPod touch, you need to install the associated provi-
sioning profile onto your device.

Preparing Your iPhone or iPod touch | 11


Creating a Development Certificate
The first thing you need is a development certificate and Apple’s WWDR Intermediate
certificate. To request a development certificate from the Developer Portal, you need
to generate a certificate-signing request (CSR) using the Keychain Access application.
You can find the Keychain Access application in the /Applications/Utilities folder.
Launch the application and select Keychain Access→Preferences from the menu. Go to
the Certificates Preferences pane to confirm that the Online Certificate Status Protocol
(OCSP) and Certificate Revocation List (CRL) options are turned off, as shown in
Figure 2-4.

Figure 2-4. The Certificates tab of the Keychain Access application’s Preferences pane

Next, select Certificate Assistant→Request a Certificate from a Certificate Authority


from the Keychain Access menu, and enter the email address that you selected as your
Apple ID during the sign-up process along with your name, as shown in Figure 2-5.
Click the “Saved to disk” and the “Let me specify key pair information” radio buttons
and then click Continue. You’ll be prompted for a filename for your certificate request.
Accept the defaults (a key size of 2,048 bits using the RSA algorithm) and click Con-
tinue. The application will proceed to generate a CSR file and save it to disk. The file
will be saved to the location you specified when you were prompted to choose a file-
name (the default is usually your desktop).
Next, log in to the iPhone Dev Center and click on the link to the iPhone Developer
Program Portal. This will take you to the main portal used to manage certificates and
devices associated with your developer program account.
Click the Certificates link, then go to the Development tab and click Request Certifi-
cate. Follow the instructions to upload your CSR file to the portal.
If you joined the iPhone Developer Program as an individual, you now need to approve
your own certificate request, again in the Development tab in the Certificates section
of the portal (simply click Approve). If you are part of a development team, your nom-
inated team admin must do this for you.

12 | Chapter 2: Becoming a Developer


Figure 2-5. The Keychain Access.app Certificate Assistant

If you don’t see the Download option appear after you click Approve,
click the Development tab link to refresh the page, and it should appear.

Once you do this, you need to download your personal certificate and the WWDR
Intermediate certificate and install them in your Mac OS X keychain.
Still in the Development tab, click the Download button to download your personal
certificate. Next, right-click on the link to the WWDR Intermediate certificate and save
the linked file to disk.
Once both of these certificates have downloaded to your local machine, you need to
install them in your Mac OS X keychain. Double-click on the certificate files to install
them into your keychain. This will activate the Keychain Access application and ask
you to confirm that you want to add the certificates to your Mac OS X keychain.

Preparing Your iPhone or iPod touch | 13


If you have more than one keychain, you need to make sure the certifi-
cates are installed in the default keychain, normally called login. The
default keychain is highlighted in bold in the list of keychains at the top
left of the Keychain Access.app application. It’s normally best to keep
the login keychain the default, but if this is not the case you can make
it the default by selecting the File→Make Keychain “login” Default op-
tion from the menu bar. If the certificates are not installed into the de-
fault keychain, Xcode will be unable to find them, and hence will be
unable to sign binaries with them. This means you will not be able to
install your applications onto your iPhone or iPod touch.

You can check that the two certificates have been correctly installed in your keychain
by clicking on the Certificates category in the Keychain Access application. You should
see both your own developer certificate and Apple’s WWDR certificate in the login
keychain, as shown in Figure 2-6.

Figure 2-6. The Keychain Access application showing the newly installed certificates necessary for
Xcode to sign your binaries and deploy them onto your iPhone

Getting the UDID of Your Development Device


Plug the iPhone or iPod touch you intend to use for development into your Mac. Open
Xcode and select the Window→Organizer item from the menu bar. The Organizer
window will open, showing the list of connected devices (see Figure 2-7).
You’ll need the unique device identifier (UDID) of your development device so that
you can create a mobile provisioning profile for this device. Right-click or Ctrl-click on
the 40-character string labeled Identifier (see Figure 2-7) and select Copy.

14 | Chapter 2: Becoming a Developer


Figure 2-7. The Xcode Organizer window
Return to the iPhone Developer Program Portal, click Devices, and select the Manage
tab. Next, click Add Devices. Enter the device name in the appropriate box and the
UDID in the box labeled Device ID, and click Submit. You have now registered your
device.

Creating an App ID
To install your application onto your iPhone or iPod touch, you will need to create an
App ID. This is a unique identifier that the iPhone uses to grant your application access
to its section of the keychain, limiting the application’s access to usernames, passwords,
and certificates used by other applications.
The App ID is also used as part of the mobile provisioning profile. The mobile provi-
sioning profile is different from the certificate you generated earlier. Certificates stay in
the keychain on your Mac and are used by Xcode to digitally sign the iPhone application
binaries. The mobile provisioning profile you’re about to generate is tied to one or more
devices and is transferred by Xcode onto your iPhone or iPod touch. This allows the
applications you create to run on that device.
Go to the App IDs section of the iPhone Developer Program Portal, select the Manage
tab, and click on New App ID. Enter a name for your App ID; this should be a human-
readable name used to refer to this particular App ID. It’s entirely arbitrary what you
use as the name for the App ID. Since this is your first App ID, for the Bundle Seed ID
select Generate New.
Finally, enter a Bundle Identifier. This must be unique, and most developers use a
reversed version of their domain name so that this is the case. For instance, my domain
name is babilim.co.uk, so I entered uk.co.babilim.* as my Bundle Identifier.

Preparing Your iPhone or iPod touch | 15


The asterisk (*) that appears at the end of my Bundle Identifier is the
wildcard symbol. Using a * in the Bundle Identifier means you will be
able to use this App ID for multiple applications. If you did not use a
wildcard here, you’d have to generate a new App ID for each of your
applications, and a new provisioning profile for each of these applica-
tions, before you could deploy your application onto your iPhone or
iPod touch. Using a wildcard means you can generate a single mobile
provisioning profile that will allow you to deploy multiple applications
onto your developer device.
Technically, this means that all the applications created using this Bun-
dle Identifier will share the same portion of the keychain on your iPhone.
I discuss the implications of this later. Using a wildcard in the Bundle
Identifier also means that the applications you create using this App ID,
and the mobile provisioning profile(s) associated with it, will not be able
to use the Apple Push Notification and in-app purchase services.

Click Submit. The portal will now generate a new 10-character Bundle Seed ID and
prepend it to the Bundle Identifier you provided. This is your App ID.
You need to make a note of your Bundle Identifier as you’ll need to supply it to Xcode,
as described near the end of Chapter 3, to allow you to deploy the application you are
developing onto your iPhone or iPod touch.

Creating a Mobile Provisioning Profile


Now you’re ready to create a mobile provisioning profile. Go to the Provisioning section
of the iPhone Developer Program Portal, select the Development tab, and click on New
Profile.
Enter a profile name. While it’s more or less arbitrary what you put here, I recommend
using “Developer Profile” somewhere in the name. You may be generating a number
of provisioning profiles, including ones later on for distribution (both ad hoc and to
the App Store), so it’s helpful to know that this profile is to be used for development.
Check the relevant certificate box: if you’re an independent developer, you’ll have
only one choice here, the certificate you generated earlier using the Keychain Access
application.
Select the App ID you generated in the previous section, and then select the develop-
ment device (or devices if you have more than one available) for which this profile will
be valid. As I mentioned before, Xcode will transfer the provisioning profile onto your
iPhone or iPod touch, and application binaries built by Xcode using a provisioning
profile will run successfully only on devices for which this profile is valid. If you don’t
select the correct device here, your code will not run on it. Don’t worry, though: you
can add additional devices to the profile at any time, but you’ll need to regenerate a
provisioning profile inside the Program Portal.

16 | Chapter 2: Becoming a Developer


Click Submit to generate the new mobile provisioning profile that you’ll use during
development. I discuss provisioning profiles needed for distributing your applications
later in the book. The status will appear as pending; click the Development tab to reload
it until it is no longer pending.
When the profile is ready, click Download and download the provisioning profile to
your Mac. You can install it in a number of ways, but the easiest way is to drag
the .mobileprovision file you downloaded onto the Xcode icon in the dock. This will
install it in Xcode and make it available for development.

Making Your Device Available for Development


The final step before you can start coding is to make your device available for devel-
opment. Return to Xcode and click Window→Organizer from the menu. Select your
development device from the lefthand pane and click Use for Development. If Xcode
doesn’t manage to correctly register your device, you may have to disconnect and re-
connect your iPhone or iPod touch so that Xcode can find it correctly. If that fails to
work, you should try turning your device off and then on again. Depending on the
version of the SDK you installed and the version of the OS currently on your device,
you may have to restore your device from the Organizer window inside Xcode. In the
process, you’ll lose any data you have on it. If this is necessary, you can back up your
data by syncing with iTunes as normal before restoring the OS using Xcode. After the
restore, return to iTunes and restore your data.
If you can afford the extra cost, I recommend using a separate device for development
than you use as your day-to-day iPod or phone. In the future, you may wish to install
prerelease versions of the iPhone operating system onto your development device, and
by definition, these are always unstable. If you’re relying on your iPhone to keep you
in touch, you may not want to use it for development.
Once you’ve installed the profiles, you can verify that Xcode has correctly stored them
by opening the Library folder in your home directory and looking in MobileDevice/
Provisioning Profiles. The next time you sync your development device with iTunes
(and you should probably do that now), the mobile provisioning profile will be installed
onto it.
You can verify that the profile has been installed by going to Settings→General→Profile
on your iPhone and iPod touch and checking that the profile has been correctly installed
and verified, as shown in Figure 2-8.
You can now confirm that everything has worked correctly by noting the status light
next to your device in the Xcode Organizer window. If Xcode has managed to connect
to the device, and it is correctly enabled for development, the status light next to the
listing on the lefthand pane will be green. You’ll also see your mobile provisioning
profile listed in the center box in the main pane, as shown in Figure 2-9.

Preparing Your iPhone or iPod touch | 17


Exploring the Variety of Random
Documents with Different Content
considerazioni sensate e nuove sulla declamazione musicale e nelle
quali difende le teorie di Gluck.

*
* *
L'opera musicale drammatica cominciò in Germania più tardi che in
Italia e fu piuttosto frutto dell'imitazione straniera che dell'iniziativa
nazionale. Le produzioni drammatiche precedenti al Seicento si
limitavano ai Misteri e alle Moralità, alle feste carnevalesche, alle
farse di Hans Sachs ed altri poeti popolari ed a spettacoli e balletti
dati con grande sfarzo alle diverse corti dei principi di Germania.
L'opera fiorentina ed il nuovo stile rappresentativo trovarono però
imitatori molto prima che in Francia. Già nel 1627 Enrico Schütz, il
grande musicista luterano antecessore di Bach, aveva composta la
musica della Dafne di Rinuccini, tradotta da Opitz. Questo dramma
per musica fu dato a Torgau il 10 aprile 1627 in occasione delle
nozze del Landgravio di Essen con Luisa Eleonora di Sassonia.
Quantunque la musica ne sia perduta, è da ritenersi secondo le
notizie conservateci, che fosse scritta ad imitazione di quella di Peri.
E sembra pure che Schütz abbia musicato l'Orfeo di Rinuccini. Invece
ci è restata la musica di un Singspiel Seelewig (1644) di Teofilo
Staden, una specie di allegoria simile alla Rappresentazione di anima
e corpo di Emilio Cavalieri, un'opera affatto lontana dalle tendenze
della Camerata fiorentina e solo d'interesse storico.
Ma il nuovo genere non seppe attecchire, sia perchè i tempi erano
difficili e la Germania era tormentata dalla tremenda guerra dei
trent'anni, sia che mancassero gl'ingegni musicali che si volessero
applicare al nuovo genere. C'era poi un altro motivo che rendeva
difficile lo svilupparsi dell'opera nazionale. La lingua italiana era
allora di moda nelle infinite corti di Germania come lo divenne poi la
francese. Il pubblico stava in disparte e non prendeva alcun
interesse alle cose artistiche; i teatri rimasero fino alla metà del
secolo scorso con poche eccezioni riservati alla corte, ai cortigiani ed
agli invitati. Era dunque naturale che i principi si rivolgessero all'Italia
e chiamassero alle loro corti artisti italiani. Ognuna di queste aveva
un poeta di corte che doveva montare sul suo Pegaso in ogni
occasione voluta da circostanze esteriori. (Zeno e Metastasio a
Vienna, Mauro ad Hannover, Pallavicino a Dresda, Terzago a Monaco,
ecc.). I direttori erano italiani (Lotti, Caldara, Steffani, Porpora,
Iomelli, Bononcini, ecc.), italiani i cantanti (Bordoni, Cuzzoni, Lotti,
Durastanti, Senesino, Farinelli, Carestini, ecc.), italiani persino i
pittori, decoratori ed architetti. Soltanto i suonatori erano in parte
tedeschi e francesi.
Fra le corti di Germania, che videro fiorire l'opera italiana sono
specialmente da nominarsi Vienna, Dresda, Berlino e Monaco. La
corte di Vienna s'era sempre distinta quale protettrice della musica
ed ormai nel 1642 vi si eseguì l'Egisto di Cavalli. Gli imperatori
Leopoldo I, Giuseppe I e Carlo VI, buoni musicisti, preferivano la
musica italiana e cercarono con ogni modo di attirare alle loro corti i
migliori artisti italiani. Caldara e Conti assieme allo stiriano Giovanni
Fux segnano l'epoca del maggior fiore dell'opera a Vienna. Fux
(1660-1741) è tuttora noto per il suo celebre trattato Gradus ad
Parnassum (1725) e per musiche da chiesa più che per le sue opere
teatrali, nelle quali imitò gli italiani. Quasi tutti poi i più celebri
compositori italiani dell'epoca, cominciando da Cavalli, Cesti fino a
Porpora e Salieri andarono a Vienna e scrissero per quel teatro di
corte.
Non inferiore a Vienna nel culto dell'opera italiana fu Dresda. Anche
in questa città v'era un'intiera colonia artistica d'italiani, che
dominava esclusivamente il teatro. L'opera italiana vi fu inaugurata
formalmente nel 1662 col Paride di Giovanni Bontempi, scolaro di
Mazzocchi e collega di Schütz. Suo successore fu pure un italiano,
Carlo Pallavicini, buon compositore. Salito al trono Federico Augusto
I (1694), vero mecenate delle arti, cominciò una nuova era di lusso e
splendore e Dresda mai vide maggior numero di celebri artisti nelle
sue mura, fra i quali Lotti, Vittoria Tesi, il Senesino, e sopra tutti
Giovanni Adolfo Hasse e sua moglie, la famosa cantatrice Faustina
Bordoni.
Quantunque Hasse abbia avuto i natali in Germania (Bergedorf,
1699) egli appartiene interamente alla scuola napoletana ed è
compositore italiano. Da principio cantante ad Amburgo e Brunswick,
venne poi a Napoli (1724), dove si perfezionò nella composizione alla
scuola di Porpora e quindi di Alessandro Scarlatti, che lo prese ad
amare. Una sua opera, Sesostrate (1726), destò unanime applauso
ed egli già nel 1727 fu nominato direttore al Conservatorio degli
incurabili a Venezia, dove conobbe e sposò Faustina. La fama delle
sue opere oltrepassò ben presto le Alpi e pochi anni dopo venne
chiamato a Dresda (1731), dove con piccoli intervalli di tempo, fra i
quali un breve soggiorno a Londra, passò la maggior parte della sua
vita. Negli ultimi anni si recò a Venezia, dove morì nel 1783.
Hasse fu compositore fecondissimo. Dotato di grande fantasia e di
ricchezza melodica, egli dominava perfettamente la forma ed era
sommo nel trattare la voce. Ma egli non si eleva sopra i migliori
autori italiani dell'epoca, seguendo anch'egli la pratica che al bel
canto sacrificava la verità drammatica. Egli non fu e non volle essere
un riformatore ma seguì l'andazzo del tempo. Egli non copia alcuno
degli italiani ma imita tutti, togliendone da tutti il meglio, per cui egli
non è originale ma piuttosto la personificazione dello stile
drammatico, diremmo quasi astratto, italiano del secolo XVIII. Hasse
visse onorato e meritò tanto pel suo ingegno che per il suo carattere
integro il nome di Caro Sassone, che in Italia gli si diede. Colla
partenza di Hasse da Dresda (1756) e dopo la morte di Augusto III,
l'opera italiana a Dresda decadde rapidamente, durando però al
meno sporadicamente fino al 1842 (Morlacchi).
In Berlino troviamo cantanti italiani (Pasquino Grassi e Giovanni
Alberto Maglio) già nel 1656. La prima opera si diede nel 1700 e fu
la festa dell'imeneo di Attilio Ariosti, alla quale negli anni posteriori
fecero seguito delle altre finchè nel 1742 venne aperto da Federico
II il nuovo teatro con Cesare e Cleopatra di Graun. Federico il grande
era musicista appassionato e buon suonatore di flauto. Egli
prediligeva la musica italiana e non voleva saperne di cantanti
tedeschi. «Piuttosto sentir un'aria cantata da un cavallo, che una
tedesca come prima donna», soleva egli dire.
Il miglior compositore dell'epoca fu Carlo Enrico Graun (1701-1759),
che dominò colle sue opere il repertorio fino alla sua morte. Graun
appartiene pure alla scuola italiana. Scrisse 36 opere e molta musica
da chiesa, fra cui l'oratorio la Morte di Gesù, che ancor oggi si
eseguisce, opera priva di grandezza e religiosità e scritta nello stile
teatrale. Graun fu scrittore melodioso e facile, ma non ebbe nè
originalità nè potenza drammatica.
Grande influenza sulle cose musicali ebbe pure alla corte di Federico
il suo maestro di flauto Giovanni Quanz, che fu in Italia alla scuola di
Gasperini e scrisse un'infinità di composizioni per flauto ad uso del
re. Degni di menzione sono pure Francesco Benda, boemo (1709-
1786), celebre violinista, fondatore della scuola germanica, il
creatore del melodramma (declamazione con accompagnamento di
musica), e la celebre cantatrice Gertrude Elisabetta Mara per la quale
Federico ebbe a ricredersi degli artisti tedeschi. Coll'avanzarsi dell'età
venne a cessare l'interesse di Federico per l'opera, che priva del suo
più potente appoggio rapidamente decadde.
A Monaco gli Italiani erano diventati già per tempo padroni del
campo. La corte di Alberto V aveva veduto commedie italiane (1568)
per le quali aveva scritto madrigali Orlando di Lasso che in una
rappresentazione aveva egli stesso rappresentato la parte di nobile
veneziano (Pantalone dei Bisognosi). Il primo vero dramma per
musica fu la Ninfa ritrosa (1654) di autore sconosciuto. Fra tutti i
maestri di quel tempo si incontra un sol nome tedesco, Gaspare Kerl,
scolaro di Carissimi e celebre organista. Egli scrisse pure opere
teatrali andate perdute. A Kerl successero Ercole Bernabei, Giovanni
Bernabei, Agostino Steffani, Albinoni, Porta, Bernasconi. L'opera
italiana cessò nel 1787.
La patria dell'opera tedesca nazionale fu Amburgo, la libera città
anseatica, dove la musica era sempre stata in onore e dove
accorrevano gli artisti, sicuri di trovare un pubblico intelligente ed
appassionato per l'arte. Quantunque l'opera italiana fosse ben presto
giunta in Amburgo e vi avesse destato grande interesse e plauso,
pure l'elemento nazionale si fece vivo di buon'ora e molti furono i
tentativi di imitazione con tendenze nazionali e sostituzione della
lingua tedesca all'italiana. La prima opera tedesca che si diede ad
Amburgo fu Adamo ed Eva, musicata da Giovanni Theile (2 gennaio
1678). Dapprincipio essa non fu che una copia dell'italiana, ed i
soggetti si toglievano dalla mitologia, dalla storia antica e dalle
leggende sacre o dalla Bibbia. Ma il pubblico prendeva poco
interesse a quelle rappresentazioni eroiche, nelle quali esso non
trovava l'impronta nazionale ed i soggetti gli erano del tutto estranei
e punto simpatici. Ed allora nacque la reazione, dapprincipio
modesta, introducendovi l'elemento nazionale e comico e riducendo
il tutto ad una parodia di cattivo gusto. Poi l'elemento nazionale
prende il sopravento ed ai soggetti eroici e sacri si sostituiscono
azioni tolte dalla vita contemporanea, che univano il tragico al
comico, il sublime al triviale. Per sfortuna poi mai epoca fu sì povera
di buoni poeti ed i musicisti dovevano contentarsi di mettere in
musica versi che peggiori non ponno pensarsi, azioni che sono
un'ibrida congiunzioni di sciocchezze, sfacciataggini e trivialità, il
tutto condito da motti salaci in una lingua barbara ed un gergo da
piazza. La meschinità di tali produzioni drammatiche si cercava
nascondere sotto lo sfarzo delle scene, dei vestiari e dei balletti, per i
quali si spendevano somme favolose, e si cercava cancellare
l'impressione penosa d'una scena tragica con una comica della
specie più scurrile, come nell'opera di Dedekind Gesù morente, dove
Satana raccoglie in un canestro le budella di Giuda e col cestello in
mano canta un'aria.
Molto migliori dei meschini e prosaici poeti di quell'epoca furono i
maestri che posero in musica i loro tristi parti. Fra questi merita
speciale menzione Giovanni Kusser (1657-1727), musicista di
talento, il quale influì sulla nuova opera tanto colle sue opere che
colle sue cognizioni pratiche e che pel primo liberò la scena da tutta
la marmaglia di cantanti e cantatrici, tolti dal più basso volgo, che
nulla sapevano di musica e vi sostituì buoni elementi.
Ma quegli che per il suo grande ingegno, se a questo avesse unito
serietà di propositi e veri criteri artistici, sarebbe stato chiamato ad
ispirare nuova vita all'opera tedesca e metterla sul vero cammino, fu
Reinhard Keiser (1674-1739). Dotato d'inesauribile vena melodica e
vivissima fantasia egli era nato per la musica drammatica e per la
scena. Le sue numerose opere si distinguono per ricchezza e facilità
di melodia, per varietà di forma e per verità d'espressione ed egli si
innalza qualche volta a grandi altezze in scene eminentemente
drammatiche come nell'Ottavia. Le forme che usa sono piccole e
simili alla canzone popolare, ma caratteristiche e sempre adatte alle
parole. Se egli non fu capace di impedire il rapido decadimento della
giovine opera, si fu perchè gli mancava la fermezza del carattere e
seguiva l'andazzo del tempo, poco curandosi degli alti ideali, pur che
la sorte gli arridesse pel momento ed egli potesse menare vita
brillante e spensierata. Eppure ad onta dei suoi molti difetti, la sua
musica ancor oggi ha un fare sì spontaneo e naturale, è sì fresca e
melodica che bisogna meravigliarsi come in un'epoca di tali
aberrazioni del gusto potessero sbocciare fiori sì gentili.
Altra figura interessante del tempo fu Giovanni Mattheson (1681-
1764), un miscuglio d'umorista e pedante, cantante, musicista e
scrittore. Le composizioni di Mattheson sono intieramente
dimenticate, giacchè esse sono scritte nel gusto dei loro tempi e
mancano di vera ispirazione, ma non lo sono molti dei suoi infiniti
scritti d'arte e di polemica musicale, nei quali si palesa lo spirito
battagliero, ardito e mordace dello scrittore ed in mezzo a molto
ciarpame ed a frasi antiquate ed ampollose sono nascosti nuovi
pensieri ed è messa la base dell'estetica musicale moderna. (Il
perfetto direttore (1739), il patriota musicista, la porta d'onore, la
critica musicale).
L'ultimo musicista della prima epoca dell'opera d'Amburgo, dopo il
quale questa andò rapidamente decadendo, fu Giorgio Filippo
Telemann (1681-1767), artista strano, che d'ogni stile s'appropriò
qualche cosa, ma che per la manìa di essere originale ad ogni costo
cadde in mille ricercatezze e puerilità artistiche. La sua fecondità fu
prodigiosa; scrisse oltre circa 40 opere e 600 ouvertures, 44
passioni, 12 annate di musica da chiesa ed un'infinità d'altre
composizioni.
Prima di chiudere questo periodo ci resta a rammentare Händel, che
nel 1703 a 19 anni si recò ad Amburgo onde arricchire le sue
cognizioni e studiarvi l'opera. Quantunque egli abbia scritto qualche
opera per Amburgo (Almira, Nerone) e vi abbia fatto parlare di sè,
pure egli non esercitò alcuna influenza sul suo indirizzo, inquantochè
si tenne piuttosto in disparte come osservatore e pure profittando di
quello che egli ad onta della falsa strada per cui si era messa l'opera,
da questa potea apprendere, non era ancor giunto a quel grado di
maturità artistica, che per ciò era necessario. Nel 1740 arriva ad
Amburgo una compagnia d'opera italiana coll'impresario Angelo
Mingotti e l'opera nazionale tedesca, che negli ultimi anni aveva
menato un'esistenza stentata, venne a finire.
In Inghilterra la musica drammatica fu quasi sempre senza carattere
nazionale. Quantunque non sia giustificata l'opinione generalmente
diffusa della mancanza di talento musicale degli Inglesi, non è da
negarsi, che la musica in Inghilterra fu sempre influenzata dagli
stranieri, che attirati dall'idea di gloria e dalla speranza di ricchi
guadagni vi trapiantarono la musica dei loro paesi. Le prime notizie
che ci sono conservate sulla musica in Inghilterra arrivano al 600
dopo Cristo, quando papa Vitaliano mandò in Gallia e Britannia
Giovanni e Teodoro ad insegnare il canto gregoriano che in poco
tempo raggiunse grande diffusione. Dopo un lungo silenzio la storia
fa menzione di Giov. Dunstaple del quale già parlammo ed a lui
seguono molti altri musicisti pratici e teoretici, che ebbero molta
parte allo sviluppo dell'armonia e contrappunto. Verso la fine del
secolo XVI poi troviamo in Inghilterra molti musicisti, che si
occuparono specialmente del madrigale, raggiungendo in questo
genere le migliori opere degli italiani contemporanei. I più noti fra
questi sono William Bird ( † 1623), Tommaso Morley (1557-1604),
John Bull (1563-1628) e Orlando Gibbons (1583-1625). Molti
madrigali di quell'epoca sono stati ultimamente pubblicati e eseguiti
con plauso per la leggiadria dello stile, le bizzarrie ritmiche, gli
scherzi armonici e la freschezza di melodia.
Quel tempo vide pure il fiore della musica istrumentale che la regina
vergine Elisabetta preferiva e molti furono i suonatori specialmente
di virginale (specie di spinetta) che ebbero grande fama anche in
altri paesi. L'importanza di questo ramo della musica inglese è assai
grande per la storia della musica istrumentale e lo sviluppo delle sue
forme. I principali rappresentanti ne sono Hugh Aston ed i nominati
Bird e Bull. Noi troviamo nelle loro opere, che si pubblicarono negli
ultimi anni, un'assoluta indipendenza dallo stile corale, una tecnica
assai perfezionata nella mano sinistra, armonia quasi moderna e
nuove forme come per es. la variazione.
Il dramma musicale venne all'Inghilterra dall'Italia e vi fu portato da
Tommaso Lupo, Angelo Notari ed Alfonso Ferrabosco. Bisogna però
rammentare che Roberto Jones pubblicava ormai nel 1601 due libri
di songs and ayres (canti ad 1-4 voci con e senza istrumenti) scritti
nello stile recitativo delle Nuove musiche di Caccini e che qualche
cosa di simile all'opera erano le cosidette Masques con cori, danze
ed in genere musica istrumentale.
Delle prime opere di maestri inglesi (Lawes, Colman, Lock, ecc.)
sono conservati soltanto i titoli. Nel 1673 venne Cambert in
Inghilterra e vi introdusse la musica francese, che trovò tosto molti
fautori fra i quali il re Carlo II.
In quel tempo (1658) nasceva a Londra Enrico Purcell, il maggior
genio musicale che l'Inghilterra mai ebbe. Purcell ha molti punti di
somiglianza con Mozart. I suoi successi datano ormai dal suo
diciottesimo anno e le sue opere giovanili (p. es. Didone ed Enea)
mostrano maturità di studi, sicurezza di stile e di forma. Egli scrisse
una quantità di musica per azioni teatrali, da chiesa ed istrumentali,
tutte ricche di facile melodia, di ampiezza di stile e magistrale
fattura. Il maggior difetto della sua musica è quello di essere troppo
esangue e di restare quasi sempre allo stato di schizzo per quanto
geniale. Egli si formò alla scuola degli Italiani senza però rinunciare
alla sua personalità spiccata ma altresì senza raggiungerli. Egli
prelude però ormai ad Händel specialmente colla sua maniera di
innestare il coro all'azione e di concepire il quadro musicale.
Purcell non trovò chi raccogliesse il suo retaggio. Morto a 37 anni,
venne ben presto dimenticato dal pubblico che preferiva i piccanti
ritmi delle canzoni francesi alla verità drammatica delle sue opere ed
alla grandiosità dei suoi cori.
Dopo la morte di Cambert (1677) sono di nuovo gli italiani che
predominano e contendono la palma ad Händel, mentre gli ultimi
tentativi di un'opera nazionale (Beggar's Opéra di Gay 1727) cadono
sotto il livello dei più meschini prodotti.

LETTERATURA

H. M. Schletterer — Studien zur französischen Musik, Berlin, 1884-


85.
Nuitter et Thoinan — Les origines de l'opéra français, Paris, 1886.
Prunières — Lully. 1910.
Pougin A. — Les vrais créateurs de l'opéra français, Paris, 1881.
R. Rolland — Le premier opéra joué a Paris e Notes sur Lully in
Musiciens d'autrefois, Paris, 1908.
L. de la Laurencie — Lully, 1910.
Prunières — L'opéra italien en France avant Lully, Paris, 1913.
Laloy L. — Rameau, Paris, 1908.
L. de la Laurencie — Rameau, Paris, 1908.
I. Iansen — I. I. Rousseau als Musiker, 1884.
Brenet — Gretry: Sa vie et ses oeuvres, 1884.
H. Cuzzon — Gretry, Paris, 1908.
Le opere principali di Lully, Rameau e Gretry furono pubblicate
nuovamente nei Chefs d'Oeuvres class. de l'Opéra français, ecc.
O. Lindner — Die erste stehende deutsche Oper, Berlin, 1855.
L. Meinardus — Rückbliche auf die Anfänge der deutschen Oper,
Amburgo, 1878.
H. Kretschmar — Das erste Jahrhundert der deutschen Oper
Sammelbände der intern. Musik Gesell., III, 2.
H. Schmidt — Matheson, Lipsia, 1897.
I. Valletta — La musica in Inghilterra — Riv. musicale italiana, vol.
5º.
W. Nagel — Geschichte der Musik in England, Strassburgo, 1894-
1897.
CAPITOLO XII.
Martin Lutero e la musica protestante. Bach e
Händel.

Nessuna nazione possiede sì ricco patrimonio di canzoni popolari


quanto la tedesca. I musicisti non potevano ignorare tutta questa
fioritura di canti ed è per questo che nelle loro opere si mostra più
che in quelle degli altri maestri stranieri una certa inclinazione alla
forma chiusa della canzone e che il canto fermo non si toglie di
preferenza dal canto gregoriano. Mentre nei paesi romani si
mantenne il canto liturgico latino e la comunità quasi mai partecipa
al canto, noi troviamo cantici sacri in lingua tedesca ormai poco dopo
il Mille. E ciò era naturale, perchè e ignota era la lingua latina e
troppo diverso il canto gregoriano da quello popolare. Così vedemmo
già parlando della canzone popolare, come il popolo tedesco
trasformava i canti latini della chiesa, ora conservandone qualche
brano, ora trasformando e ritmo e melodia alla guisa di canzone
popolare (Kyrleise). Questi canti dapprima usati durante le
processioni ed i misteri furono poi introdotti nella chiesa stessa e si
ammisero benchè a malincuore dalla liturgia fra l'Epistola ed il
Vangelo.
Tale stato di cose si cambiò intieramente colla riforma di Lutero, che
ha per la Germania lo stesso significato del Rinascimento in Italia.
Questi due avvenimenti segnano nella storia della musica la fine del
Medio Evo ed il principio di una nuova epoca. La riforma fu
d'importanza capitale per la musica sacra tedesca e la musica
tedesca in genere, giacchè Bach e Händel basano intieramente sulla
musica della chiesa protestante e perchè le loro opere non si
possono concepire senza la riforma che diede loro quell'austerità e
maschia grandezza, che le distingue da quelle delle altre scuole.
La chiesa riformata ammette il canto della comunità nella lingua del
popolo. Esso non poteva essere dunque che la canzone popolare
modificata per gli scopi della chiesa, perchè soltanto questo è il
canto del popolo. Prima condizione era perciò di togliere la melodia
dal tenore e darla al soprano onde renderla palese ed
accompagnarla non con contrappunti ma nota per nota con armonie,
con accordi.
Martin Lutero (1483-1546) comprese l'importanza della musica per
l'opera della riforma e le dedicò tanto più le sue cure, che egli stesso
ne era appassionato cultore. «La musica, egli scrive nei suoi
sermoni, è un dono di Dio e non degli uomini. Essa mette in fuga il
diavolo e rende gli uomini ilari. Essa fa dimenticare l'ira, l'impudicizia
e tutti i vizî. Io le dò il primo e più alto posto dopo la teologia».
Lutero tradusse ed adattò i canti della comunità assieme ai suoi
fedeli amici Rupff e Walther, scelse le melodie, sia togliendole dalle
canzoni popolari, sia trasformando il canto gregoriano, sia
trovandone di nuove e pubblicò nel 1524 la prima raccolta
Enchiridion. Stabilì il tipo del corale protestante che fino ad oggi
rimase lo stesso, perchè non fu la moda che ne dettò le regole.
L'esempio fruttò e ben presto si moltiplicarono e diffusero i nuovi
canti, sicchè un Gesuita ebbe a dire che i canti di Lutero hanno
mandato in perdizione più anime che i suoi scritti e sermoni. E difatti
si potevano bruciare le bibbie ed i libri, mettere al rogo i propagatori
della nuova fede ma non soffocare quei canti che s'innalzavano
dovunque, che eccitavano il coraggio nelle battaglie e che erano
ormai divenuti canti patriottici politici.
La vera storia della musica tedesca comincia dopo la Riforma, perchè
i musicisti anteriori a quest'epoca non sono che imitatori dei
fiamminghi. Soltanto ora si desta il sentimento nazionale e come la
Riforma non pretendeva l'annichilimento dell'individuo, così entra
nell'arte per altre strade che in Italia l'individualismo, che rimase una
delle prime doti della musica tedesca.
Noi ci contenteremo di enumerare alcuni dei maestri tedeschi
anteriori a Bach, che sono e numerosi ed importanti come lo
mostrano le loro opere, che furono intieramente dimenticate e che
oggi si tornano a pubblicare. Ancor sotto l'influsso degli Olandesi sta
Enrico Isaak (Arrigo tedesco) di Praga (?) che fu alla corte di Lorenzo
il Magnifico e poi di Massimiliano († 1517). Le sue canzoni tedesche
a più voci segnano ormai lo spegnersi dell'egemonia fiamminga.
Enrico Fink di Pirna († 1588), Stefano Mahu, Giorgio Rhaw, Martino
Agricola, appartengono già alla scuola protestante, come pure
Lodovico Senfl di Basilea, scolaro di Isaak, l'autore prediletto di
Lutero, musicista di vero genio.
Questi autori si servono della forma del motetto per gli scopi della
musica da chiesa protestante, abbandonano i contrappunti
complicati ed usano di preferenza quello a nota contra notam, donde
derivano gli accordi. Luca Osiander fu il primo a pubblicare cinquanta
canzoni sacre e salmi (1586) secondo la nuova maniera. Superiori di
gran lunga a questi sono: Adamo Gumpoldzhaimer (1560), Leo
Hasler (1564-1612), scolaro di Andrea Gabrieli, noto in Italia sotto il
nome di Gianleone e Giovanni Eccard (1553- 1611), ambedue ispirati
e potenti.
Mentre in Germania prendeva piede la Riforma, l'Italia aveva veduto
nascere Palestrina e formarsi la scuola dei grandi musicisti romani e
veneti. I Tedeschi sempre avidi di sapere ed imparare non potevano
ignorare gl'immensi progressi dell'arte musicale in Italia e da questo
tempo data quella pacifica immigrazione di musicisti tedeschi in
Italia, replicandosi quanto era successo prima coi fiamminghi. E
quasi a favorire questo pellegrinaggio sorgeva ai confini d'Italia, bella
in mezzo alle onde, Venezia, la città incantata, le cui flotte si
spingevano fin ai più lontani mari ed i cui cittadini avevano vaste
relazioni di commercio oltre le Alpi, la città dove una scuola musicale
che aveva veduto fiorire i più grandi ingegni, continuava le sue
gloriose tradizioni ed i cui templi ricchi di mosaici e di dipinti dei più
celebri maestri, risuonavano di sacri e dolcissimi concenti, che
riempivano d'ammirazione i forestieri venuti per affari di mercatura in
Italia. Augusta e Norimberga vi mandavano i figli dei patrizi ad
apprendere il commercio ed il modo di vivere; nel 1506 i Tedeschi
aveano fabbricato in vicinanza di Rialto il loro fondaco, che facevano
adornare di dipinti da Giorgione e da Tiziano.
Da Gallus (1550) e Meiland fino a Schütz, una coorte di musicisti
scende in Germania per visitare le scuole dei celebri maestri italiani.
La rimembranza di quei tempi resta incancellabile anche dopo il
ritorno in patria e rivive nelle loro composizioni, che ad onta del
carattere nazionale portano l'impronta dei maestri italiani. Coloro poi
ai quali non era concesso veder adempiuto il maggior voto della loro
vita, ed apprendere e perfezionarsi nell'arte dei suoni dalla bocca del
maestro, cercavano indirettamente collo studio delle opere di
avvicinarsi ai loro ideali o frequentavano la scuola di maestri che
furono in Italia. Alla scuola di Carissimi in Roma venne quel Gaspare
Kerl, famoso compositore di musica da chiesa ed organista, che
vedemmo alla corte di Monaco rivaleggiare cogli italiani e pure a
Roma studiò con Frescobaldi Giovanni Froberger (1612), del quale
faremo cenno in seguito. Soltanto indirettamente sotto l'influsso
degli Italiani, seppure di un influsso quantunque indiretto si possa
parlare, stanno i musicisti contemporanei, che nacquero e vissero
nella Germania del Nord, quali Melchiore Frank, autore di molti corali
ancor oggi in uso; Andrea Hammerschmidt (1611-1675), felice
imitatore dei maestri italiani; i due membri della grande famiglia
Bach, Giovanni Michele e lo zio di Sebastiano, Giovanni Cristoforo,
eccellenti organisti e compositori; Giovanni Pachelbel di Norimberga
(1653), celebre organista e scrittore di musica d'organo, Michele
Prätorius (1571-1621) di Turingia, passionato ammiratore dei maestri
italiani, dottissimo musicista ed autore della celebre opera Syntagma
musicum, specie di enciclopedia musicale in tre volumi (1615-1620),
di grandissimo interesse per la teoria e la storia dei musicisti e degli
istrumenti. Il secondo libro contiene il Theatrum musicum
istrumentorum, in cui sono descritti e disegnati tutti gli strumenti
allora in uso; Giovanni Ermanno Schein (1586-1630), uno dei primi
autori di musica istrumentale veramente ispirata ed interessante
(banchetto musicale, ecc.); Samuele Scheidt (1587-1654) celebre
organista e scrittore di musica d'organo e da chiesa in genere.
La caratteristica di questi maestri è da cercarsi nel fatto che quasi
tutti furono organisti e che dall'organo ebbero il loro sviluppo. Essi
sono i diretti precursori di Bach, essendo rintracciabile nelle loro
composizioni più che in tutte le altre dei musicisti della Germania
meridionale quell'austero sentimento proprio della Riforma, che è
una delle caratteristiche principali di Bach.
Molti di questi musicisti uscirono dalla scuola dei celebri organisti
Swelink (1540), scolaro di Zarlino e Gabrieli e Reinken (1623), la
fama del qual ultimo fu tale che il giovane Bach intraprese un viaggio
pedestre fino ad Amburgo per poterlo sentire. Maggiore di Swelink e
Reinken fu Dietrich Buxtehude, nato a Helsingor nel 1637, organista
a Lubecca, la di cui virtuosità era fenomenale e le cui composizioni si
avvicinano per grandiosità, varietà d'effetti, sapienza ed elevatezza a
quelle di Bach, che fu talmente preso del suo modo di suonare e
delle sue composizioni, che dimenticati i doveri che lo attendevano
ad Arnstadt, si fermò per tre mesi a Lubecca (1705).
A quella guisa che le composizioni della scuola romana basavano sul
canto Gregoriano, così il fondamento della musica dei compositori
della Germania settentrionale è il corale, che se non raggiunge la
grandezza ed infinita semplicità tipica del canto gregoriano, pure
nella sua melodica purezza, espressione e sentimento ha qualche
cosa di più umano, di più commovente di questo ed è senza dubbio
più individuale e corrispondente all'idea d'indipendenza della fede,
propria del Protestantesimo. Gli organisti germanici servendosi del
corale, ispirarono nuova vita alla musica d'organo e la resero capace
d'esprimere tutte quelle aspirazioni e sentimenti che la parola non
può esprimere. Nella loro musica la melodia non è che la pietra che
serve alla costruzione dell'edifizio architettonico e maestoso e si
palesa solamente nei giri armonici fra le arti contrappuntistiche e le
fioriture, richiamando quasi l'attenzione dei fedeli al corale prima e
dopo cantato.
L'anello di congiunzione fra la scuola degli organisti di Germania e
Bach ed il più grande e più geniale dei suoi antecessori fu senza
dubbio Enrico Schütz (1585-1672) (Sagittarius), quantunque
dovessero passare ancora cento anni prima della nascita del grande
cantore di Lipsia. Dapprima destinato alla carriera legale, si dedicò
alla musica per il suo talento pronunciatissimo e venne alla scuola di
Giovanni Gabrieli, dove stette tre anni fino alla morte del maestro.
Ritornato in patria divenne direttore di cappella a Dresda, dove
rimase sino alla morte.
L'importanza di Schütz è assai grande, essendo egli stato il primo ad
ispirare alla musica germanica un nuovo alito di vita ed a liberarla
dal formalismo, unendo alla dolcezza e maestà dello stile
palestriniano e veneziano il nervo e la vigoria delle melodie
germaniche. Le sue opere hanno una certa somiglianza con quelle di
Carissimi, ma egli è più profondo e grande nei cori, mentre l'Italiano
gli è superiore nell'espressione drammatica degli ariosi e dei
recitativi. Le principali sono le Symphoniae sacrae, composizioni per
voci (3-6) con istrumenti, scritte ad imitazione di quelle di Gabrieli,
fra le quali stupende la Conversione di Paolo, la Storia della
Risurrezione e le Sette parole del Redentore, specie di oratorî, scritti
con tendenze musicali riformatrici e felice connubio di stili diversi che
già di molto si avvicinano alle opere insuperabili di Bach, e
finalmente le Quattro Passioni secondo gli Evangelisti, per voci sole, i
cori delle quali (turbae) sono grandiosi per espressione drammatica,
per il sentimento tragico e per verità, quali li troviamo nella Passione
di S. Matteo di Bach. Schütz finì la sua lunga vita quasi nell'obblìo e
le sue opere furono presto dimenticate, tanto che è difficile arguire
se esse fossero state note a Bach e Händel. Oggi però per merito di
Spitta, che pubblicò molte delle sue opere, egli è ritornato in onore e
le Sette parole si eseguiscono di spesso.
L'egemonia della Germania nella musica da chiesa comincia ormai
con Schütz. I tedeschi impararono ben presto dagli italiani quello che
mancava alla loro musica e vi aggiunsero la profondità intima
dell'espressione e la ricchezza dell'armonia, unite ad una certa
rudezza, che sente la forza.
Mentre in Germania l'opera italiana si diffondeva sempre più,
nasceva in un'oscura città di Turingia, in Eisenach, ai 21 marzo del
1685, Giovanni Sebastiano Bach, uno dei maggiori geni musicali, che
mai il mondo conobbe. Bach apparteneva ad una famiglia, che per
sei generazioni fornì la Germania di musicisti, fra i quali alcuni, come
gli zii di Sebastiano, Giovanni Cristoforo e Giovanni Michele, ebbero
grande fama. Perduto il padre all'età di dieci anni, venne collocato
presso il fratello maggiore Giovanni Cristoforo, organista di Ohrdruff,
che gli insegnò i primi rudimenti della musica, e fu lì, che studiando
al chiaro di luna le composizioni d'organo di Pachelbel, Frescobaldi
ed altri maestri, le quali il fratello non gli voleva permettere di
studiare, contrasse il germe di quella malattia di occhi, che negli
ultimi anni della sua vita lo rese cieco. Da Ohrdruff passò a
Luneburgo come cantante del coro, quindi a Weimar, dopo la
mutazione della voce quale suonatore d'orchestra. Passati alcuni
anni in diverse città (Arnstadt, Mühlhausen, Cöthen), ora come
organista, ora come violinista, ottenne finalmente, dopo la morte di
Kuhnau, il posto di cantore (direttore) alla scuola di S. Tommaso in
Lipsia (1723) che occupò fino alla morte (28 luglio 1750).
Sebastiano Bach nacque di famiglia povera e modesta, si ammogliò
due volte ed ebbe ventun figli. Le sue aspirazioni non furono mai
alte, nè egli cercò la gloria. Dopo i suoi trionfi come organista e
pianista a Dresda ed a Berlino, ritornò alla sua casa e continuò le sue
occupazioni senza inorgoglire, quasi inconscio del suo portentoso
genio. Passò la vita in mezzo alla sua famiglia, severo con sè ed i
suoi, ligio al dovere ed alla religione dei suoi padri. I suoi
contemporanei non intuirono la sua grandezza. Nato in un'epoca in
cui la Germania non aveva ideali, in cui la vita di pensiero era
meschina o nulla ed il pedantismo e la gretteria regnavano, non si
vide in Bach che un eccellente virtuoso d'organo e poco più che un
buon e diligente direttore di cappella. Più volte egli ebbe a sostenere
lotte accanite coi suoi superiori per futili lagnanze e per questioni
indegne che gli amareggiarono l'esistenza.
Dopo morto, le sue composizioni andarono dimenticate ed in parte
perdute; gli ultimi rampolli della sua famiglia caddero in miseria, e
come si obliò il luogo ove giaceva sepolto, così si scordò il suo nome,
sicchè quando Marx e Mendelssohn esumarono la sua grandiosa
Passione di S. Matteo e ritornarono alla luce le sue maggiori opere,
sembrò essere cosa incredibile che un simil genio avesse potuto per
tanto tempo essere disconosciuto e quasi dimenticato. Oggi si può
però parlare d'una vera rinascita bachiana, perchè la musica di Bach
s'accorda in certo modo cogli ideali moderni d'estetica musicale e
colla tendenza alla polifonia e fu appunto quando dominava
l'omofonia, che Bach fu dimenticato per più d'un secolo.
Dinanzi alla grandiosità delle sue opere la penna sfugge di mano e
rifiuta il suo ufficio. Goethe scrisse di lui: «Quando penso a Bach, ho
l'impressione, che l'eterna armonia si diverta con sè stessa forse
come sarà successo nel seno di Dio prima della creazione». E
Wagner: «Se si vuole comprendere la meravigliosa singolarità, forza
ed importanza dello spirito tedesco con un solo ed incomparabile
esempio, basta studiare la personalità quasi inconcepibile ed
incomprensibile di Sebastiano Bach in un'epoca in cui il popolo
tedesco era pressochè annientato».
Il genio di Bach si può intuire, non esprimere a parole. Come
Palestrina, egli sta sul confine di due epoche, e mentre chiude l'una,
inizia l'altra. Anche egli non fu riformatore nel senso stretto della
parola, nè trovò nuove forme, ma le sussistenti perfezionò e
perfezionandole le rese tali che nuove appaiono. Come Palestrina
incarna la musica sacra cattolica, così Bach è il rappresentante della
musica protestante. La sua musica vocale è esclusivamente religiosa
ed interpreta la dogmatica protestante, ma egli le ispira sentimenti
più umani ed intimi di quello che la severa ortodossia antecedente
avesse saputo. Se in Palestrina troviamo rappresentato l'elemento
divino che s'abbassa fino all'umanità, in Bach domina l'elemento
umano che si libera dai ceppi e dalle miserie terrene, si eleva al
cielo, gli confida i suoi dolori, le sue angoscie e vi trova il conforto e
la pace dopo la lotta.
Il suo carattere inclina al misticismo, per cui la sua musica è
precipuamente riflessiva, profonda ed esigente che l'uditore vi si
immedesimi. Non sempre giustificato è però il voler sottolineare il
sentimento religioso di Bach, che egli possedeva più per tradizione
che per riflesso. Bach è portato altresì al lirismo ed in lui si trovano
gli elementi del romanticismo; perciò era naturale che egli coltivasse
anche la musica istrumentale, che più si adatta ad esprimere la
profondità del pensiero. La musica di Bach non fu popolare ai tempi
del maestro, perchè egli si elevava troppo sopra gli altri per venir
intieramente compreso e popolare non lo è oggi nè mai lo diverrà.
Ma invece si può ben con sicurezza affermare, che molte delle sue
opere saranno imperiture come alcune dell'antichità nella letteratura,
pittura e scoltura, perchè per quanto cambieranno e la vita di
pensiero e le forme dell'espressione, l'alito geniale che vi ispirò il
maestro, non può per il tempo che passa spegnersi.
Nella musica vocale Bach segnò traccia imperitura. I suoi numerosi
corali a quattro voci sono monumenti insuperabili di melodia ed
espressione profonda; molti gli servono di tema per costruire
grandiose concezioni polifoniche. Ma dove Bach sembrò attingere ad
una fonte inesauribile fu nelle cantate, che sono più di trecento,
quasi tutte su poesie di carattere religioso da eseguirsi dopo la
predica dell'ufficio protestante. Esse mantengono la forma
concertata di prima (introduzione istrumentale, coro, recitativi, arie,
duetti, corale). La plasticità dei temi si presta a tutte le combinazioni,
senza che l'unità sia perduta; l'opera grande e maestosa sorge
naturalmente e quasi necessariamente, nel mentre ogni parte è
individualmente concepita. La differenza che passa fra quelle di Bach
e dei suoi antecessori e contemporanei è grande, perchè fu egli il
primo a riconoscere l'importanza delle forme dell'opera italiana e
servirsene combinandole collo stile della musica d'organo,
raggiungendo così l'unità e creando una nuova musica da chiesa di
spiccato carattere protestante, che fu anche l'ultima non essendo la
posteriore che una semplice imitazione della sua.
Il contrappunto di Bach basa a differenza dei maestri anteriori
sull'armonia e le singole voci sono sempre condotte melodicamente.
La tonalità è la moderna e non è che la scala minore discendente
colla sesta maggiore che a noi riesce un po' strana ed arcaica.
Fra le sue opere vocali le maggiori sono la Passione secondo S.
Matteo, la Messa in si minore, l'Oratorio di Natale, il Magnificat a
cinque voci. La Passione suddetta (15 aprile 1729), una delle tre
conservateci, segna un immenso progresso in confronto delle
anteriori e delle contemporanee e come il testo è depurato dalle
aberrazioni ed ingenuità di prima, così la musica si eleva ad altezze,
quali Bach stesso di rado seppe raggiungere. E se anche in questa
sublime opera il contrasto fra l'elemento sacro e mondano o
drammatico le tolgono l'unità, ciò deve ascriversi non all'autore ma
al genere di composizione, per cui lo vediamo spegnersi con Bach e
sostituirvisi l'oratorio, nel quale l'elemento sacro e mondano si
confondono in uno e formano un nuovo stile.
Nella musica istrumentale fu Bach che introdusse, come nessuno
prima di lui seppe fare, le forme della musica polifonica vocale. Egli
non creò la Sonata, la Suite, la Partita, la Fuga, ecc., ma tutti questi
generi modificò e rinnovò in modo che fra le sue composizioni e le
anteriori o contemporanee la somiglianza è poca o nessuna. La sua
orchestrazione invece è semplice, quantunque non manchino
specialmente nelle arie concertate tratti felici e nuovi impasti e
combinazioni, che egli imparò senza dubbio dalle opere di Steffani.
Fra la quantità delle sue opere istrumentali basti il nominare il suo
Clavicembalo ben temperato, quella raccolta aurea di 48 preludî e
fughe per cembalo, in cui Bach si palesa non solo sapiente teorico
ma altresì poeta musicale, servendo la forma del preludio e della
fuga ad esprimere sentimenti svariati ed affetti e facendo la
profondità del pensiero e la bellezza melodica dimenticare la
sapienza. Altre notissime sono la fantasia cromatica, il Concerto in re
minore per pianoforte, la suite in re maggiore per orchestra, il
Concerto italiano, le toccate e fughe, le sonate per piano e violino, le
sei sonate per violino solo, i concerti brandeburghesi, ecc.
Bach fu sommo organista e come tale fu riconosciuto anche dai
contemporanei. Le sue improvvisazioni attiravano la folla ed il
celebre organista Reinken dopo averlo sentito in Amburgo (1721), gli
rivolse le memorabili parole: «Credevo che quest'arte fosse morta,
ma vedo che essa ancor vive in voi». Bach non fu del resto soltanto
sommo organista ma altresì sommo nelle sue composizioni per
organo ancor oggi insuperate. E difatti chi ha mai più superate le sue
toccate e fughe, i suoi preludî ai corali nei quali la profondità e la
ricchezza melodica e tematica sono inesauribili?
L'infinita ammirazione delle opere di Bach non deve però accecarci al
punto di non riconoscere che non tutte raggiungono l'ideale della
perfezione e che anch'egli, ciò che del resto è più che naturale se si
considera la sua immensa produzione, molte volte lasciò correre la
mano, fidandosi della sua prodigiosa sicurezza di maneggiare le
forme più ardue del contrappunto. Allora anche Bach è soltanto un
artista abilissimo ed è inutile cercare nelle opere scritte così, che non
son poche, recondite profondità mistiche, alle quali certo l'autore
non pensava e che neppur inconsciamente sentiva. E questo vale
non soltanto per molte delle opere istrumentali ma ancor più per le
cantate, scrivendo le quali Bach non poteva essere sempre invaso da
compunzione religiosa ma voleva sopperire a bisogni liturgici,
specialmente in un'epoca, in cui la religiosità s'univa ad un pietismo
protestante barocco.
Gli elementi della musica di Bach sono i più svariati. Il fondamento
ne è il corale protestante, ma egli studiò altresì e profittò delle opere
di Palestrina, Lotti, Caldara, Frescobaldi, molte delle quali egli copiò
di propria mano. Nella musica istrumentale sono Corelli, Vivaldi
(Concerti), Marcello, Albinoni, Couperin, Froberger, Buxtehude ed
altri che esercitarono un influsso palese sulle sue opere.
Fra i numerosi figli di Bach, quattro furono musicisti. Il maggiore,
Friedemann (1710-1784), mostrò grande ingegno ed ebbe a maestro
il padre, che su lui avea fondato le sue speranze. Organista della
cattedrale di Halle, vi stette venti anni. Ma il suo carattere strano, la
sua vita scapestrata lo trassero a rovina. Dedito al bere, cadde
sempre più in basso, abbandonò il suo posto e vagò per la
Germania, finchè morì in miseria a Berlino. Nei suoi momenti felici fu
uno dei più grandi organisti del suo tempo, dottissimo in teoria e
lasciò più composizioni, fra cui polonesi, cantate, sonate per piano e
violoncello ed un concerto per organo che è degno delle migliori
opere del padre.
Miglior sorte ebbe l'altro figlio di Bach, Filippo Emanuele (1714-
1788), allievo pure del padre, che visse onorato e stimato ad
Amburgo. Fra le sue numerose composizioni vanno menzionate le
sue sonate per piano, che furono il breviario di Haydn e segnarono
una nuova fase nello sviluppo della sonata quantunque non sia
giusto ascrivergli quello che fu il frutto dei tentativi di più maestri
anteriori e contemporanei. In ultima linea le opere di F. E. Bach
appartengono ormai allo stile galante, reso meno snello dalla
pedanteria germanica dei suoi tempi.
Tanto Friedemann che Filippo Emanuele si risentono dell'influenza
superficiale dell'epoca e sono lontani dal raggiungere la grandezza e
profondità del padre. Gli altri due figli, Cristoforo Federico, direttore
a Bückeburg e Giovanni Cristiano, direttore a Milano e poi a Londra
non si elevarono sopra la mediocrità.
I numerosissimi manoscritti di Bach — durante la sua vita ne
vennero stampati soltanto alcuni — furono divisi tra i due figli
Friedemann e Filippo Emanuele. Ma il primo poco si curò del
prezioso retaggio e così molte opere del grande genio di Turingia
andarono perdute per sempre.
Pochi giorni prima di Bach nasceva in Halle (23 febbraio 1685)
Giorgio Federico Händel, quel genio che insieme a Bach, per lungo
tempo assicurò alla Germania il primato musicale. Anche Händel,
come tanti altri, ebbe a lottare col padre prima di potersi dedicare
alla musica, finchè quest'ultimo, per l'intercessione del principe di
Weissenfels, acconsentì all'ardente desiderio del figlio e lo mandò
alla scuola dell'organista Zachau, eccellente teorico. A undici anni si
recò a Berlino, dove viveva allora Bononcini e dove apprese nuove
cose ed intravide orizzonti ben diversi da quelli che il suo maestro
avevagli additato. Ma egli seppe resistere alla tentazione di rimanere
e ritornò ai severi studi, che alternava con quelli della giurisprudenza
all'Università, finchè a 19 anni si recò ad Amburgo per dedicarsi
intieramente alla musica.
Amburgo era allora il centro musicale germanico dell'opera ed offriva
al giovane musicista ricco campo di studio ed esperienza. Difatti il
suo soggiorno non fu senza frutto, chè di lui si eseguirono con buon
successo tre opere. In Amburgo accadde pure la nota storia del suo
duello con Mattheson, il turbolento e litigioso critico, che per poco
non lo uccideva. La conoscenza dell'opera destò in Händel il
desiderio di visitare l'Italia (1707), dove stette tre anni componendo
più opere nello stile dell'epoca e riscuotendo grande plauso. Il
soggiorno di Händel in Italia influì grandemente sulla sua musica,
che ad onta di tanti punti di contatto, pure è sì diversa da quella di
Bach. Lotti e Scarlatti gli furono prodighi di consigli e dalle opere di
questi e della scuola romana, specialmente di Carissimi, trasse
proficui ammaestramenti.
Nel 1710 abbandona l'Italia e si ferma ad Annover, dove si trova con
Steffani, il gentile ed ispirato autore di celebri duetti e cantate. Di là
passa a Londra, che doveva divenire la sua patria adottiva. Nel 1711
la sua opera Rinaldo, lo rende noto al pubblico inglese ed in breve
tempo egli diventa l'autore più di moda. Ma la sua vittoria fu
amareggiata da continue lotte con rivali ed una forte fazione d'inimici
invidiosi cercò con ogni mezzo di soppiantarlo e discreditarlo. Le
contese coi colleghi, fra cui Ariosti, Bononcini, Porpora, con cantanti
e cantatrici, fra le quali la Cuzzoni e Faustina Hasse rivali ed inimiche
acerrime, la cattiva riuscita delle sue imprese teatrali, finirono col
disgustarlo del teatro, sicchè nel 1740 colla sua opera Deidamia,
diede un addio alle scene e si dedicò ormai in età avanzata
all'oratorio, a quel genere in cui si era anni avanti (1732-34: Ester,
Debora, Atalia, la festa di Alessandro, 1736), provato con successo.
Fra le opere di questo periodo nomineremo come le più celebri ed
ancor oggi notissime, Israele in Egitto, coi suoi grandiosi cori che
descrivono le sventure del popolo eletto; l'Allegro ed il Pensieroso;
nel 1741 il celebre Messia, l'oratorio prediletto del pubblico inglese;
nel 1742 Sansone, una delle opere più ispirate e grandiose per
contrasti di tinte; nel 1746 Giuda Maccabeo, e finalmente Iefte, che
Händel scrisse quando le tenebre della cecità si erano distese sui
suoi occhi, due anni prima della sua morte (1759).
Händel scrisse quaranta opere teatrali, diciotto oratorî, passioni,
Anthems, Te Deum, Cantate, duetti, Concerti grossi, Sonate, Suites,
musica d'organo.
L'importanza di Händel sta precipuamente nell'oratorio. Nell'opera
lirica egli non si innalza gran fatto al disopra dei contemporanei e se
nelle sue arie la caratteristica è forse più efficace di quella di tanti
altri maestri, le sue melodie sono meno insinuanti ed ispirate di
quelle dei migliori italiani. Anche in Händel manca come nei maestri
napoletani il sentimento drammatico dell'intiera opera e se un'aria o
l'altra, singolarmente presa, mostra grande verità espressiva e
s'adatta al testo, il tutto non è che una collezione di arie collegate coi
recitativi.
Dell'origine dell'oratorio abbiamo fatto cenno parlando di quella
dell'opera. In Italia esso si era già al principio del secolo XVII diviso
in due specie distinte. La prima a somiglianza delle antiche azioni
liturgiche con testo latino, la seconda in forma di leggende di santi
od azioni sacre drammatizzate con apparato scenico. Una
suddivisione di quest'ultima sono gli Oratorî con persone allegoriche
e simboli, ma essa iniziata da Cavalieri andò presto in disuso
(Maragnoli-Vita humana 1658). Le azioni sacre drammatiche invece
vennero molto in voga e le biblioteche italiane e straniere
posseggono una quantità di simili azioni sacre in musica, fra le quali
nomineremo come le principali l'Eumelio di Ag. Agazzari, S. Alessio di
Landi (circa 1620), gli Oratorî di Aless. Scarlatti, Stradella (Modena),
S. Francesco di G. Alessandri (Dresda) molti di Caldara (Vienna),
Leo, ecc., e per dare un'idea della voga dell'oratorio basti il dire, che
il padre Martini aveva nella sua biblioteca 350 oratori scritti da
maestri italiani, che poi andarono dispersi ed in parte perduti. La
forma dell'oratorio drammatico italiano va sempre più avvicinandosi
a quella dell'opera e la parte dell'Historicus scompare ben presto,
perchè essa era incompatibile colla forma drammatica, e l'esecuzione
scenica, che molte volte si adottava.
L'affinità fra l'azione dell'Oratorio con quella dell'opera influiva pure
sullo stile. Una certa serietà ed elevatezza nelle arie e nei recitativi
accompagnati, molte volte bellissimi, è l'unica caratteristica. I cori
vanno sempre più perdendo d'importanza e si riducono di solito a
due, al principio ed alla fine e ciò neppur sempre. L'interesse va
perciò diminuendo e noi vediamo spegnersi l'oratorio, almeno in
Italia, alla fine del secolo XVIII.
È inutile indagare quali motivi abbiano deciso Händel ad
abbandonare l'opera lirica e dedicarsi intieramente all'oratorio. Certo
essi non sono da cercarsi solamente nelle circostanze esteriori. Più
che queste influirono senza dubbio il suo carattere severo ed
austero, l'altezza dei suoi ideali e l'impossibilità di raggiungerli
nell'opera. Nell'oratorio di Händel si compie la fusione dell'elemento
mondano e divino, che nella musica sacra era impossibile. La bibbia
offriva ad Händel soggetti adatti alla sua natura inclinata all'epico, al
grandioso; alla mancanza dell'elemento drammatico individuale
suppliva la vastità del quadro michelangiolesco, dove invece di una
singola persona parlava un popolo intiero. La mente di Händel non
era inclinata alla contemplazione mistica, ma vedeva la vita
oggettivamente cogli occhi di un cosmopolita. Perciò quello che
Händel non seppe raggiungere nell'opera lirica, egli raggiunse
nell'oratorio, il sentimento drammatico cioè e perciò i suoi grandiosi
cori sono più veri ed espressivi che le sue arie, le quali per lo più
sono antiquate e risentono del tempo tanto nelle loro forme alle
volte barocche e convenzionali che nelle fioriture.
L'orchestrazione di Händel è più ricca e colorita di quella di Bach, che
doveva sempre contentarsi di pochi e mediocri suonatori, più
interessante ed elaborata di quella dei maestri italiani. Fra le sue
migliori opere istrumentali contano i Concerti grossi, per archi soli o
per archi ed oboe, lo strumento preferito da Händel. La forma è
quella dei Concerti di Corelli con qualche cambiamento.
Händel è molto più comprensibile e vicino a noi italiani di Bach sia
per le sue doti sia e forse di più per l'influenza che ebbero su di lui i
maestri italiani ed il lungo soggiorno in Italia. «Andate in Italia a
liberarvi la testa dalle idee superflue e le ubbie» diceva il vecchio
musicista Fux ad un suo scolaro e fu certo in Italia che Händel
imparò la chiarezza, l'equilibrio e la semplicità, che sono i suoi
maggiori pregi e che Bach non seppe mai raggiungere in sì alto
grado.
La potenza assimilatrice di Händel è stragrande ed egli non ebbe mai
scrupolo di servirsi di motivi e temi di altri maestri per le sue opere.
Ma egli sa assorbire tutti gli elementi estranei in modo tale, che
l'imitazione non diventa plagio e perde ogni importanza.
Nell'opera egli non cercò nè trovò nuove vie ma seguì le battute.
Nell'oratorio invece egli tenta continuamente nuovi esperimenti e gli
fa subire diverse trasformazioni, innestandogli anche forza
drammatica più che nelle sue opere teatrali, ora contentandosi di
cori omofoni ora fugati, ora misti con soli. La sua facoltà inventiva
sembra inesauribile, sicchè gli bastano poche settimane, alle volte
pochi giorni per comporre un'opera od un oratorio (p. e. il Messia fu
scritto fra il 22 agosto ed il 14 settembre 1741). I suoi Concerti per
organo ed orchestra sono quasi improvvisazioni ed egli si contenta
alle volte d'una stenografia musicale per seguire l'irruenza della sua
fantasia.
Bach e Händel sono due geni, che vicendevolmente si completano
come Goethe e Schiller. Bach inclina al misticismo, alla
contemplazione: egli basa completamente sul sentimento religioso
protestante. Händel è più oggettivo e contempla la vita da un ampio
e libero punto di vista; perciò il primo è essenzialmente lirico, mentre
l'altro è epico e somiglia agli uomini dell'antichità. Il sentimento
religioso in lui non è esclusivo come in Bach, ma è soltanto il
fondamento su cui poggia il suo edifizio. Bach rimase germanico
nell'arte ed esclusivamente nazionale, mentre Händel ne allargò i
confini, e conservando la propria fisonomia, apprese e si perfezionò
alla scuola degli italiani. Bach è più profondo e complicato di Händel
che si serve di mezzi più chiari, più semplici; il primo è più accurato
nei particolari, mentre il secondo dipinge a tratti più larghi. Ambedue
menarono vita semplice ed integra e ad alte aspirazioni unirono
somma attività e diligenza.
Con Bach ed Händel finisce la prima grande epoca della musica
tedesca. L'antica religiosità andava scomparendo per far luogo a
nuove idee; all'antico dogmatismo succede il razionalismo di Kant; la
Rivoluzione francese, che da lungo preparavasi, abbatte gli antichi
pregiudizi e viene proclamata la libertà d'azione e di pensiero. Anche
la musica si risente delle nuove idee e da queste nascono l'opera di
Gluck e la musica istrumentale sinfonica moderna.

LETTERATURA

C. v. Winterfeld — Der evangelische Kirchengesang, Lipsia, 1843-47.


H. Köstlin — Luther als der Vater des evang. Kirchengesanges,
Lipsia, Breitkopf und Härtel.
Pirro A. — Schütz, Paris, 1912.
Pirro A. — L'estethique de I. S. Bach, Paris, 1907.
Ph. Spitta — Heinrich Schütz Leben u. Werke, Berlin, 1904, nel libro
Musikalische Aufsätze.
— I. S. Bach, Lipsia, 1873 e seg.
C. Bitter — S. Bach, Dresda, 1880.
Schweitzer A. — I. S. Bach, le musicien poête, Leipzig, 1904.
Fr. Chrysander — G. F. Händel, Lipsia (incompiuto.)
T. Volbach — G. F. Händel, Berlino, 1898.
Rolland R. — Händel, Paris, 1910.
C. Bitter — Die Söhne Bachs, Berlino, 1868.
— Beiträge zur Geschichte des Oratoriums, 1872.
Le opere degli autori nominati, anteriori a Schütz sono in parte
pubblicate in Antologie.
Quelle di Schütz, Bach ed Händel furono intieramente pubblicate
dalla casa Breiktopf und Härtel e dalla Società Händel.
CAPITOLO XIII.
La musica monodica da camera e l'arte del
canto fino al secolo XIX. Teatri e decorazioni.

Una delle qualità che secondo Baldassare Castiglione deve avere il


Cortigiano (1518) è che egli sia «ancor musico ed oltre allo intendere
ed esser sicuro a libro sappia varii istrumenti». (Libro I. Cap. XLVIII).
«Il tempo poi nel quale si possono usare queste sorti di musica,
stimo che sia sempre che l'omo si trova in una domestica e cara
compagnia, quando altre faccende non vi sono». (Lib. II. Cap. XIII).
Simili accenni troviamo negli Asolani di Pietro Bembo, nella vita di
Guido da Montefeltro, scritta da Vespasiano dei Bisticci, nei Dialoghi
di Torquato Tasso ed in molte altre opere dei secoli scorsi, p. e.
nell'Introduzione al Novellare nelle Cene di Francesco Grassini, detto
il Lasca («si dierono a cantare certi madrigali a cinque voci di
Verdolotto e d'Arcadelte in casa di una ricca e bella donna vedova, il
di cui fratello aveva una camera fornita di canzonieri scelti e d'ogni
sorte d'istromento lodevoli, sappiendo tutti quei giovani, chi più, chi
meno, cantare e suonare»). La musica comincia a divenire col
Rinascimento veramente un elemento di coltura e diletto delle classi
alte e medie ed ad avere una parte non senza importanza nella vita
privata. Paolo Veronese, Giorgione, Bonifazio dipingevano i cosidetti
Concerti. Leonardo, Benvenuto Cellini, Salvator Rosa erano buoni
musicisti, cantanti o suonatori; le corti di Firenze e specialmente di
Mantova e Ferrara risuonavano di canti e suoni e musicisti celebri vi
trovavano gentile ed onorevole accoglienza; Isabella ed Alfonso
d'Este possedevano una raccolta di strumenti preziosi non allo scopo
di farne una collezione ma di usarli praticamente. A differenza di
prima di musica si occupavano e seriamente anche i dilettanti e basti
il nominare fra le donne celebri o note per altri motivi Properzia dei
Rossi, Irene da Spilimbergo e Tarquinia Molza quali distinte cantanti
e suonatici e fra le compositrici Maddalena Casolana e Vittoria Aleotti
che scrissero Madrigali, che si stamparono assieme a quelli dei
maestri più celebri e finalmente la cortigiana Imperia che aveva
studiato la composizione ed era abilissima cantante. La musica non
mancava mai alle feste, conviti e persino nei conventi di monache si
cantava e suonava per semplice svago e divertimento. In questo
accordo perfetto di lodi alla musica non si ha che una stonatura nella
lettera di Bembo a sua figlia Elena (1529), alla quale scrive che «il
suonare è cosa da donna vana e leggiera e che è meglio esercitarsi
nelle lettere e far la cucina».
Più tardi il teatro e l'opera ebbero il predominio ma non perciò
cessarono i concerti privati ed i trattenimenti dove la musica aveva
gran parte. Così sappiamo p. e. dei famosi Lunedì del Cardinale
Ottoboni a Roma, dove suonava Corelli e convenivano i più celebri
musicisti (Scarlatti, Händel, Steffani, ecc.) e Burney ci racconta nelle
sue memorie di una quantità di simili trattenimenti musicali in più
città di Italia. Nè altrimenti si potrebbe spiegare la grande quantità di
opere vocali ed istrumentali, scritte per scopi estranei al teatro, quali
dapprima le Canzoni a più voci, i Madrigali, le innumerevoli
composizioni per liuto, le canzoni monodiche, le cantate e la musica
per istrumenti ad arco e tasto.
Lo stesso può dirsi della Germania, quantunque la sua vita artistica
non fosse certo sì sviluppata che in Italia. M. Agricola ci parla nella
prefazione alla sua Musica istrumentalis (1545) in versi prosaici e da
colascione della musica nella vita privata tedesca. Walther, l'amico di
Lutero, ci racconta che questi prima e dopo tavola si metteva a
cantare e che Melantone faceva il basso. Le raccolte di canzoni
Kurzweilig, frische gute Liedlein, sono numerosissime ed
appartengono alla musica di carattere intimo, al qual genere sono
pure da annoverarsi le opere di Clavicembalo della famiglia dei Bach,
di Kuhnau, Froberger come in Francia, quelle di Couperin, Rameau,
Daquin ed altri. In Germania poi i cosidetti Collegia Musica erano
società di dilettanti, che durarono quasi fino al termine del secolo
XVIII e che, come lo indica la parola, erano circoli musicali privati,
dove si eseguiva una quantità di opere vocali ed istrumentali con o
senza uditorio. La conclusione che se ne può trarre è che ai tempi
odierni si fa certo più musica che nei tempi passati ma che la musica
da camera prima veniva molto più coltivata nelle famiglie e nelle
radunanze private, al che influì senza dubbio anche la maggiore
difficoltà tecnica della musica moderna.
La musica da camera vocale monodica dei secoli scorsi è pressochè
ignota non solo al cosidetto gran pubblico ma anche a molti
musicisti. Eppure essa è d'una ricchezza incredibile ed è a sperare
che ora che adagio adagio si vanno pubblicando le migliori opere
antiche oltre le poche note celebri, noi impareremo a conoscerla e
ad apprezzarla come lo merita. Essa, della quale trovammo già
accenni nell'Ars nova fiorentina ben presto andata in dimenticanza e
che visse soltanto nella canzone popolare, rinacque quasi
contemporaneamente all'opera ed è pure frutto del Rinascimento
musicale. Tentennante da principio ed avvicinantesi alle melopee di
Peri e Caccini, ben presto si depura ed invigorisce, diventa
spontanea, fresca ed ispirata per la linea melodica, ora calda
d'espressione, ora vivace di ritmo, ora caratteristica. Le nostre
biblioteche possiedono una quantità di queste canzoni ed arie
antiche e quando esse saranno di nuovo note ci accorgeremo di
avere una meravigliosa lirica musicale antica, alla quale deve
riannodare la lirica moderna, se non si vuole imbastardire l'arte
nazionale.
Fra le opere appartenenti a questo genere nomineremo oltre quelle
pubblicate da L. Torchi nelle Canzoni ed Arie italiane ad una voce del
secolo XVII, i Madrigali ed Arie a voce sola di Giovanni Francesco
Capello, la Sphaera armoniosa di Paolo Quagliati (1623) i Madrigali di
Francesco Turini (1629) e Biagio Marini (1649) qualche canzone di
Salvator Rosa (1614-1673) il celebre pittore e di Alessandro
Stradella. Riemann esamina nella sua storia della musica una
quantità di queste raccolte di arie di maestri italiani affatto
sconosciuti e ne riporta lunghi brani, parlando con grande

You might also like