When Duke Ellington wrote "Take the A Train," he envisioned people climbing aboard the subway to get to Harlem's Cotton Club in the 1920s. But the A train runs in two directions, and today Greenwich Village is the place to go for jazz in New York. The A train's Fourth Street stop in the Village will be the most important one for jazz lovers from Aug. 23 to Sept. 2, when the Village will hold its fourth annual jazz festival.

New and world-famous musicians will be featured playing all varieties of jazz at bargain prices -- names like Dizzy Gillespie, Stan Getz, Kenny Burrell, Ahmad Jamal. Of course, there's nothing new about jazz in the Village. The first Eddie Condon's Club opened there. Nick's for Dixieland was a Seventh Avenue landmark in the 1930s. And in that decade, too, Cafe Society, the first racially integrated club downtown, presented Billie Holiday. She premiered "Strange Fruit" there.

Many of this year's Greenwich stars also played in the Kool New York Festival, a jazz extravaganza in the city's major concert halls last month. But somehow much of the music sounds better in the Village. Maybe it's because the Dewar's Village Jazz Festival takes place in the jazz clubs, the original habitat of jazz, with musicians playing in their usual, well-rehearsed groups. And very importantly, the Village festival is affordable.

If you purchase a $10 pass at any Village club with a cover, you can get into every club for half the cover charge -- most normally charge about $8 to $10 admission. The pass is good for the first two sets -- normally clubs have two or three in one evening -- and it also entitles you to free admission to the last set if one is played. Since the clubs are located in close proximity to each other, it's possible to go to three sets at three clubs on the same night during the entire festival.

In addition, all special related events, including a jazz film festival and lectures by musicians and critics, cost half price for pass holders.

The Village also has clubs that feature piano-bass duos, and these rarely have cover charges. During the festival, it will be business as usual for them, although they will participate and feature some of the festival players.

However, the most famous piano-bass duo room in New York, Bradley's, had a $5 cover for the last weekend of the 1985 Kool festival -- probably the first time it ever levied a charge. "It was too hectic, too crowded without it," says manager Tom Derecas, and the club has continued to charge a cover on weekends after 9 p.m. The bar usually is jam-packed on weekends, so you might want to reserve a table for dinner -- but remember that the kitchen closes at 12:30 a.m. Bradley's has a $7.50 table minimum; in fact, all the clubs have table minimums (usually no more than $15) in addition to the cover.

Bradley's is one of 15 clubs sponsoring the festival this year. It began in 1982 when 13 club owners -- ranging from the redoubtable Max Gordon, for 50 of his 80 years owner of the Village Vanguard, to the new owners of Sweet Basil, Mel Litoff and Phyllis Weisbart -- noticed how many jazz clubs were opening in town and attracting crowds after a lull in the '60s and '70s.

They offered discount passes, called it a festival and booked Dizzy Gillespie to play a free 5 p.m. concert in Washington Square Park at the foot of Fifth Avenue as the opener. "Ten thousand people went to that concert," says Horst Liepolt, producer of next month's show along with Mel Litoff, who also is president of the festival corporation. (Dewar's White Label is the primary sponsor.)

Since then, the festival has opened every year with a free concert. In 1983, singer Joe Williams and trumpeter Wynton Marsalis starred; in 1984 Benny Carter, a major arranger and alto saxophonist, led an all-star group with the ubiquitous Gillespie sitting in.

This year's free concert will be played by saxophonist Stan Getz and his quartet along with jazz guitarist Kenny Burrell and his trio. Gillespie will play in this year's festival, too, at the Blue Note (131 W. Third St., 212-475-8592) Aug. 23-25, from 10 p.m. Table reservations are suggested. The rest of the festival schedule at this club includes former Basie band reeds player Frank Wess leading a band on Sept. 2; every night there will be a jam session from 2 to 4 a.m., and Sunday brunches will feature a band, too, from 2 to 5 p.m.

Other highlights of the festival and the participating clubs will include:

*Bradley's, 70 University Place, (212) 473-9700. Veteran pianist Cedar Walton, playing state-of-the-art, contemporary jazz piano, will perform with bassist David Williams Aug. 26-31.

*Fat Tuesday's, 190 Third Ave., (212) 533-7902. Pianist Ahmad Jamal will perform Aug. 23-25, and singer Morgana King will be featured Aug. 29-Sept. 1. On Sept. 2, Labor Day, guitarist Les Paul will lead his trio. (Fat Tuesday's is one of the few sponsoring clubs not situated right in the Village.)

*Jazz Center of New York, 380 Lafayette St., between Great Jones and East Fourth streets, a block east of Broadway, (212) 505-5660. Trumpeter Clark Terry will sing his unusual scat-jazz invention Aug. 26-27. Powerful, rich-voiced Dakota Staton, now more bluesy than in her early career, will appear Aug. 30-Sept. 1.

*Village Vanguard, 178 Seventh Ave. S., (212) 255-4037. Tommy Flanagan, a pianist's pianist, joins with his bassist, George Mraz, and drummer Art Taylor Aug. 27 through Sept. 1.

*Sweet Basil, 88 Seventh Ave. S., (212) 242-1785. Drummer Art Blakey and his Jazz Messengers will play Aug. 27-Sept. 1.

Sweet Basil will host a large share of the festival's special events. For the second year, the club will present a full day of music, "Music Is an Open Sky," with some experimental jazz sounds, Sept. 2 from 2 p.m. to midnight. Trombonist Steve Turre and jazz violinist John Blake will start the program.

Other afternoon events at the Basil: Musicians Union officials will discuss the effects of legislation on music, Aug. 27 from 2 to 4 p.m. (In New York City, some clubs are prohibited from hiring drummers and horn players -- a trend that has increasingly brought the bass into the limelight.) And Village Voice jazz critic Gary Giddins will talk about his work Aug. 29, from 2 to 4 p.m.

A festival highlight every year, a jazz film series at the Bleecker Street Cinema, 144 Bleecker St., (212) 674-2560, features three shows daily. See films about Duke, Bird, Satchmo and tap dancers such as Honi Coles and the legendary Baby Laurence, "Jazz Hoofer." Laurence explains and exhibits how he learned rhythmic sophistication from great instrumentalists such as pianist Art Tatum and drummer Papa Jo Jones -- and then danced rings around everyone. "Jazz on a Summer Day" has a touching vignette of Anita O'Day in a broad-brimmed hat singing a classic "Tea for Two." Call the theater for the extensive film schedule, with half-price tickets for pass holders.

A full festival schedule is available from any of the participating clubs. Others include: Arthur's Tavern, 57 Grove St., (212) 242-9468; Greenwich House, 27 Barrow St., opposite Sweet Basil, (212) 242-4140; Seventh Avenue South, 21 Seventh Ave. S., (212) 242-4694, and the 55 Bar, 55 Christopher St., (212) 929-9883; the Village Corner, Bleecker Street at LaGuardia Place, (212) 473-9762; the Village Gate, 160 Bleecker St., (212) 475-5720; Discovery of SoHo, 451 Broome St., (212) 334-1222; and Zinno's, one of the best Italian restaurants in town, 126 W. 13th St., (212) 924-5182, with piano-bass duos from 8 p.m. nightly.