Police said Melendez called 911 late Saturday and reported that two men with guns were watching him.
Police records show he hung up, so the dispatcher called back.
Melendez answered and asked the dispatcher to hold on, but the dispatcher could still hear what was being said.
A voice can be heard on the recording of the call saying: "What you need? A 10-pack? You need a 10-pack? All right." Police say "10-pack" is slang for a bundle of heroin.
The dispatcher called police, who found Melendez at the location he gave, had the dispatcher call his cell phone again, and said they found cocaine in his trousers.
There was no immediate indication Tuesday if Melendez, 20, had an attorney to speak for him.