Tim Westergren is due to take the stage in an hour, yet he seems half asleep. His shoulders are rolled forward, his hair floppy and unbrushed, and he's wearing loose blue jeans and scuffed hiking boots. He ambles around the auditorium he's rented at the San Francisco Museum of Modern Art while the staff of Pandora, the online radio company he founded, buzzes around him. The salespeople smile at the advertisers, the biz-dev folks pump the arms of partners, the engineers form a nervous little knot. Meanwhile, the crowd gathering outside the auditorium doors keeps getting larger.

Pandora has been around in one form or another since 1999 and has spent most of its existence on the brink of shutting down. Yet Westergren has always found a way to rescue his company and infuse it with new hope, new direction. Tonight is one more of those times: Pandora's biggest product launch since its debut. The company is announcing a move into mobile products, which will let listeners access their personalized radio stations over Sprint (NYSE:S) phones or Sonos and Slim Devices in-home music players.

Finally, at 6:45, the doors open and Westergren, 41, snaps to life. Most companies have customers. Pandora has fans. Nearly 300 of them stream in to hear what Westergren has to say. There are guys in short-sleeve button-downs, a red-haired middle-aged woman who's brought her digital camera, a man with long ropey dreadlocks, a girl with highlighted hair and precise bangs, and a couple with a tiny baby sucking a pacifier. They look more like they're headed to a downtown wine bar than to a high-tech product launch. The fact that they've given up their Tuesday night to listen to Westergren suggests that he has built something unique.

With almost all the seats filled, Westergren takes the stage. He's donned a jacket for his moment in the spotlight, although it's teal, zip-up, and made of fleece. "I'm Tim Westergren, and I'm the founder of Pandora," he says. The audience claps and shouts. "So I've done a bunch of these town halls, and I am jacked up," he says. "Ask any questions you have about the company. The more we can, sort of, talk to each other, the better." He means it. As Westergren details the battered history of his company, the crowd laughs and claps and oohs and aahs. Westergren has that rare talent of seeming chatty and intimate with an audience of hundreds. Listeners raise their hands and suggest ways that Pandora might outwit regulators; others volunteer to view more ads on their Pandora radio players if that will help the company make money. It's tough to imagine even the most rabid consumers, like Apple's customers, offering to view more advertising. Now it's up to Westergren to turn that adulation into action to save his company once again.

He's in a common enough position. He's trying to make a real business of this product he passionately believes in, but he's never quite gotten his baby out of start-up mode. Still, after eight years of being tossed around, Westergren isn't talking about just making Pandora turn the corner. He wants to make it huge.

Pandora has developed a proprietary method to analyze music--Westergren calls it the music genome--that lets users create online radio stations generated by the software's recommendations. Tell Pandora your favorite song is "Casey Jones" by the Grateful Dead, and within seconds it will create a station--Casey Jones Radio--that streams nonstop songs from artists such as the Youngbloods, the Byrds, and the Beatles, along with stuff you might not expect, like R.E.M., the Jam, and Tom Petty. It's undeniably cool and completely addictive, but Pandora has never quite found its footing as a business. Indeed, the company has been through an almost unbelievable number of setbacks, a series of blows that would make the most determined entrepreneur throw in the towel. Westergren has run out of money, which forced to him to lay off his entire staff (except for those willing to work for free). He's been rejected some 350 times by venture capitalists. He has faced bankruptcy, haggled with anxious creditors, and been sued by employees. Deal after deal has fallen through at the last minute.

Yet somehow Westergren has managed to amass more than eight million very enthusiastic listeners, advertisers like Microsoft and Lexus, and a database of some 500,000 songs. Over the years, he's raised more than $30 million in funding, most recently an undisclosed amount from Hearst Interactive Media, the media company's venture capital arm, in 2006. "I've got to give Tim the all-time award for persistence. I probably turned him down at least three or four times," says Peter Gotcher, a venture capitalist who eventually participated in a $12 million round in 2005. "I liked his passion and entrepreneurial spirit." Call it passion, spirit, an obstinate refusal to quit. It's kept Pandora alive.

But now, just when Westergren thought he'd finally moved Pandora into safe territory, he's facing his biggest battle yet: steep hikes in music royalty rates that were announced earlier this year. Every time Pandora plays a song, it must pay a small fee to the music's publisher, songwriter, performer, and label. Westergren has lobbied Congress and organized a grass-roots campaign of millions of Internet radio listeners. Why the urgency? The rate hike has sent Pandora's operating expenses soaring and threatens to silence Pandora for good.

Westergren plays the piano, the bassoon, the recorder, the drums, and the clarinet. His personal Pandora stations are based on songs by Muddy Waters, Ben Folds, Josh Fix, Oscar Peterson, Art Farmer, Elvis Costello, and James Taylor. He studied music at Stanford--Stan Getz was one of his professors--and graduated in 1988 with a deep understanding of music theory and computer applications for music, and a notion that he could somehow make money as a musician. He played piano in a series of taking-themselves-seriously acoustic rock bands called Late Coffee and Oranges, Barefoot, and Yellowwood Junction. But after years of driving a van all over the West Coast, crashing in friends' basements, he became frustrated with how hard it was to get noticed. Band life fell apart in 1995.

Westergren started composing scores for low-budget independent films, and that's when he began thinking differently about music. He'd ask directors about the sounds they were searching for and listen as otherwise articulate, creative people struggled to find the right words, usually falling back on descriptions like "something like Natalie Merchant, but more scary." Sitting at his piano, trying to evoke a frightening Natalie Merchant, Westergren thought about what terms such as "scarier" and "darker" and "happier" meant in purely musical terms. Would changing the rhythm, the melody, or the alto sax arrangement produce the desired result? If so, then wouldn't it be possible to create a giant database of music based on its underlying characteristics, which would make it easier for listeners to find exactly what they were looking for?

Around the same time, he read an article about the plight of singer-songwriter Aimee Mann. Though Mann's two previous records had sold a respectable 227,000 copies and won critical acclaim, her record label was refusing to release her current effort; it was focusing instead on blockbuster artists with sales in the millions. For Westergren, Mann's story brought back bitter feelings about Yellowwood Junction, which had built a strong following in the western United States but had no way to get its music out to larger audiences. "All the ideas that had been swimming in my head coalesced at that point," he says.

Lucky for him, it was 1999, and everyone in the Bay Area seemed to be starting a company. Westergren founded his, Savage Beast Technologies, with two friends, Jon Kraft and Will Glaser. Kraft, who'd already started and sold a tech business, helped Westergren sketch out a business plan, Glaser worked on the software, and Westergren worked on the music.

His premise was that music could be broken down in an objective way by trained musicians; he called his effort the Music Genome Project, a riff on the drive to map human DNA. Westergren began by thinking about how any musician would describe a piece of music and came up with about 600 qualities. He hired a professional musicologist to refine the approach and Glaser created an algorithm based on the work. The system now includes about 400 different "genes" for each genre (pop, classical, jazz, and hip-hop) that break down the music's form, the instruments used and their tone (is the saxophone gravelly?), the level of virtuosity, and the overall mood and style. (For classical music, is the mood pastorale, giocoso, or agitato? For jazz, is there an R&B or a smooth jazz influence?) It analyzes lyrical content, along with harmony, rhythm, and pretty much any other factor you can think of. Westergren was insistent on having humans analyze each song, arguing that computers alone would not be able to pick up the nuances and mood. Analysts rate each song on a 10-point scale on each of the 400 attributes. Those ratings constitute the song's musical DNA, which is entered into a database. The goal is to point listeners toward music they might enjoy based on an analysis of what they already like.

The question was how to make money with this thing. In 2000, Westergren pitched the company as an e-commerce site that would recommend music based on the genome, and in March he raised $1.5 million in venture capital. Two weeks later, the stock market crashed, rendering an underfunded e-commerce site a very bad idea. The next four years saw a plethora of different business plans for Pandora. "The first day I started, I sat down with Tim and I said tell me about the product," says Dan Lythcott-Haims, who joined Westergren in 2000 and is now Pandora's creative director. "He said, 'No, you tell us about the product.' There was no product, just a loose idea." Westergren set out to license the genome to other sites as a recommendation engine, but after more than a year his efforts resulted only in a meager $20,000 development fee from Barnes & Noble.com. His next idea was to put the technology into in-store kiosks at music retailers. At the end of 2002, Westergren reached a licensing deal with AOL Music, and Best Buy (NYSE:BBY) chose Pandora over 15 competitors to run a trial kiosk program. Both deals stretched payments out over a few years.

But Pandora already was deep in debt and the cash problems continued to mount. By this point, Jon Kraft had left and Westergren had about 15 employees and 30 part-time music analysts on staff. He paid office rent from his own checkbook. The only solution he could think of was asking employees to defer their salaries. "There was this core group of people that just believed in it. There was no quitting," says Lythcott-Haims. Westergren, meanwhile, kept knocking on the doors of VCs. He's a likable guy, casual and well-informed, but the VCs objected to his business plan, in its third iteration by now. Gotcher, for example, thought there were only a handful of customers in either the licensing or the kiosk business. "But I also thought Tim was a refreshing entrepreneur," he says. "Most entrepreneurs, if you bring up a flaw in the business model, will just adamantly try to claim they've got it all figured out. Tim said, 'Well, that's our best idea right now.' It was a good reaction."

But the situation at the company was increasingly dire. At the end of 2003, four former employees slapped Pandora with a lawsuit. They'd discovered that deferring salaries was illegal, a possibility Westergren hadn't even considered. He had to argue his case before the California Division of Labor Standards, which forced him to settle with the employees with the last of his remaining money. He let the rest of the employees go, though a few true believers continued to pitch in.

By now, Westergren had pitched Pandora to venture capitalists about 350 times and had finally learned to hint that his was a hot investment, that other VCs were about to pour money into it. The Best Buy trial was also showing good results, and Westergren convinced Walden Venture Capital to lead an $8 million round in 2004. The money meant that Westergren could hand out salary checks for $60,000 or $80,000 to employees who had been working for free. Meanwhile, he and the board decided to bring in a new CEO. They tapped Joe Kennedy, a former Saturn executive, in spring 2005. Hiring a CEO with consumer experience turned out to be a prescient move. Six months after Kennedy joined, deals with Borders (NYSE:BGP) and Best Buy fell through, and the company once again had to reinvent itself. Having exhausted their business-to-business ideas, Kennedy and Westergren turned to the consumer market, where online radio was an obvious option. The company decided to develop a website offering personalized radio stations and charge $36 a year for subscriptions.

Pandora radio runs counter to nearly every Internet trend. It eschews automation in favor of actual human musicians doing data entry. Unlike rival webcasters such as Last.fm, Mog, and Rhapsody, it ignores social networks and the wisdom of crowds in favor of expert selection. "It's profoundly unscalable. Our method is really absurd in that regard," Westergren says. "That was the VCs' biggest objection: How could you use this approach given how much music is out there? In the end, the only way to answer that question is to look at the experience itself and to ask, does this approach give you noticeably better results?" The site has a simple interface that asks users to enter a song or an artist they like. Pandora then streams a radio station that plays songs with a similar genome profile; you can give thumbs-up or thumbs-down votes to guide Pandora or add additional seeds. Say you're in the mood for a power ballad and enter Guns N' Roses' "Patience" as the seed song. Pandora will begin streaming similar songs that are slow, heavy on guitar, and cool sounding: "Distant Mornings" by Gustav and the Seasick Sailors, a Swedish rock band with slight folk influences, and "Hell Just Ain't the Same" by Theory of a Deadman, a Canadian band. It delivers surprises--you're tempted to dismiss Cat Stevens's "Hard Headed Woman" immediately, but then you find that it does sound kind of like "Patience." You also can direct Pandora. If, for instance, you want more power and less ballad, you can give Cat the thumbs-down or add another seed--say, Aerosmith's "What It Takes." Now the mix changes to Meat Loaf, U2, and, surprisingly, Guided By Voices and Dinosaur Jr., a pair of postpunk bands that fit in well.

The genome doesn't work perfectly, as Westergren admits. When you enter an eclectic artist like the Beatles as a seed, the system doesn't know which direction to take--do you want psychedelia like "Lucy in the Sky With Diamonds," British Invasion pop like "Love Me Do," or electric blues like "Yer Blues"? And for some reason it misfires altogether with Beck and Frank Zappa. Still, when you seed a station with a song, rather than an artist, and use the thumbs-up or thumbs-down ratings to guide the system, you end up with hours upon hours of very good radio.

Pandora launched in September 2005. After a quiet rollout to friends and family, the company had to double capacity three times in the first week. "Nobody--nobody--had dreamed it would be as popular as it was," says Lythcott-Haims. E-mails poured in, gushing about how cool it was.

Unfortunately, Westergren's latest business model turned out, again, to be not so cool. Pandora offered listeners 10 hours for free before requiring them to subscribe, but users easily could log in with different e-mail addresses and continue getting the free version. Fortunately, by now Westergren was a pro at, as he puts it, "jumping to another lily pad." Pandora scrapped the subscription model and decided to make money via advertisements on its site. Users interacted with the site a lot to rate songs or refine their stations, and every time they did so, Pandora could load a new ad. It could offer advertisers segmentation, so a Lexus ad would be shown on a jazz station, while a BET Awards ad would be shown on a rap station. Soon the company was doubling the number of listeners every month. Investors liked the new model and gave the company another $12 million. "That was the most enjoyable year of my adult life," Westergren says. Pandora was working at last. But just over a year later, it would be in crisis mode again.

Westergren was taking a bus to work on March 2 when his Treo buzzed with a news alert. He read it and called Joe Kennedy right away, frantic. The Copyright Royalty Board--an arm of the Library of Congress that oversees radio stations' royalty payments--had changed the amounts that Internet radio stations had to pay. Web radio stations are charged on a per listener, per hour basis. Starting next year they will be charged on a per listener, per song basis. Pandora's costs will almost triple, to about three cents an hour for each listener. The CRB also added a new charge of $500 a year per individual station--which in Pandora's case, with its millions of personalized channels, would be catastrophic. The new fees would triple Pandora's costs and Westergren and Kennedy debated shutting down immediately. At the new rates, says Kennedy, "the business model falls apart."

SoundExchange, the body that collects royalties for the recording industry, is lobbying for the increase, arguing that artists and songwriters need to be paid when their music airs. Online broadcasters agree that some payment is necessary, but argue that it should be at rates they can afford; they insist that they're helping market music that wouldn't otherwise be heard. Westergren, for his part, finds the rate change inherently unfair. AM/FM broadcasters pay royalties only to publishers and songwriters, not to artists or labels. Satellite radio stations pay a flat fee of less than 4 percent of revenue for royalties. But the new system charges Web broadcasters based on a range of factors, many of them on the esoteric side, such as whether use of the service serves to promote or substitute for record sales, and the fees tend to be higher. At an emergency meeting, some board members argued that the company should fight the rates; others suggested striking separate deals with the record labels themselves, which was deemed unrealistic. Pandora uses music from more than 6,000 different labels; it would be impossible to arrange agreements with all of them.

Westergren rallied. He began by calling other webcasters, who together founded SaveNetRadio, then hired a D.C. lobbying firm, Qorvis, which has done work for AOL, Amazon.com, and Halliburton, to get behind it. The firm helped place op-eds and solicit endorsements from nearly 7,000 artists and managers. It arranged a tour of Capitol Hill, where small groups of broadcasters and musicians met with congressional staffers, explaining their side of the story. The coalition also named June 26 a day of silence for Web radio; when listeners tuned in to Pandora, Yahoo Music, Live365, and other online broadcasters, they'd hear no music, just a message telling them about the rate changes and directing them to contact their representatives.

Westergren realized he had a huge weapon in his arsenal: his customers. Westergren sends a welcome e-mail to everyone that signs up. It's an automated e-mail from an alias address, but whenever anyone replies, he replies back. Last year, when he was touring the country looking for new music, Westergren decided to begin holding meetings with listeners. He'd choose a locale, post it on the Pandora blog, and invite anyone in the area to attend. Four people attended the first meetup in Austin, but as he traveled to a senior center in Phoenix, a taco joint in San Antonio, and a lecture hall at MIT, the groups grew, and soon dozens, even hundreds, of listeners were attending. All the effort spent courting nonpaying customers might seem excessive, but it lets Pandora spend next to nothing on marketing. In any case, the listeners responded. Some have become so fanatic that they've written songs about the site, sent boxes of fudge, and even made donations.

That work turning customers into fans, Westergren realized, meant he could rally them behind the royalty rate issue. So he sent an e-mail to all the Pandora listeners that identified their representative and senator and asked them to write in. Pandorans responded. Westergren estimates that about one million e-mails, phone calls, or faxes were made or sent by Pandora listeners. California Democratic Senator Dianne Feinstein received 25,000 e-mails; in the office of Jay Inslee, a Seattle-area representative, correspondence about Internet radio equaled that concerning the Iraq war. Inslee and Illinois Representative Don Manzullo drafted a bill that brought Internet radio rates in line with those of satellite stations; in the Senate, Sam Brownback and Ron Wyden sponsored a companion bill. "I said, 'Oh, my gosh, this is a bombshell ready to explode with the small radio stations," says Manzullo. The legislation has been referred to committee.

The bills show little chance of passing. Even Manzullo points out that "the last thing you want to do is have Congress regulate [royalty rates]; industry should regulate them." But the threat of legislative action seems to have pushed SoundExchange to the negotiating table. The group has agreed to meet with broadcasters and is making conciliatory gestures. "Both sides are working toward resolving it," says John Simon, SoundExchange's executive director. "These are our partners. They pay us royalties. We want to make sure Internet radio survives and thrives because they do pay us." The new fees kicked in on July 15; for now, Pandora is paying them as it hopes for a reprieve.

After the SFMoma announcement, Westergren stayed out until midnight--listeners were invited to a postparty at a South of Market art gallery with Pandora employees--but he is in the office the next morning at 7. The offices are in a rundown section of Oakland and look cash-strapped but cheerful. There are beige cubicles, but also columns painted with famous album covers and a metal cabinet full of free Kit Kats and Slim Jims.

Over on the side of the room, there are several rows of tables where the music analysts sit. It's an odd sight at a tech company that's pushing the music industry forward, these rows of humans clicking through screens and mutely analyzing songs at a rate of two to six per hour. All 50 of them work part-time. They have an incredible knowledge of music. On one job application for a music analyst opening, the applicant sketched out the chord structure of David Bowie's "Life on Mars"; another analyst explained the classical music genome (which hasn't yet launched) using terms like homophony versus polyphony versus antiphony, even though he wasn't a classical musician. The part-time arrangement gives analysts time to work on their own music, and anyone who works 20 hours a week gets health insurance. "Almost everyone that works here is an active working musician, and an active working musician needs supplemental income," says Rick Higgs, a silver-haired analyst who teaches guitar. "You can hardly find anything better for a musician. This stuff makes a lot more sense than landscaping."

At this early hour, thanks to musicians' schedules and last night's party, there's no one in the office but Westergren. He has a bunch of interviews today. He'll talk to an NPR reporter about the rate increase, then chat about the same thing with a sympathetic podcaster named Jeremy. Westergren's cell phone isn't working, and the Internet and VoIP in his office are both down. With the forbearance that only eight years at Pandora could give, Westergren isn't fazed. He tries some different lines, tries his cell phone, and shrugs. It's not the first time things haven't gone as planned and it won't be the last. "I've never, ever given up, even when we were in the most depressive bleak times," he says. "I always thought it was a good idea and would have a day." When the phone finally rings, it turns out to be a listener, calling with a question about his Pandora station. Westergren jots down his number to call him back later. He's finally got the adoring audience he always sought, finally figured out how to make a living at music. He thinks he's got it right at last. If not, another change of tune will be easy to make, given all the practice he's had.

Stephanie Clifford (sclifford@inc.com) is Inc.'s senior writer.