If a person attends a court as a witness in a felony, misdemeanor, or ordinance violation case upon the request of the prosecuting attorney or defendant by virtue of a recognizance or subpoena for that purpose, whether at the trial of the case or other proceeding in the case, to testify as an expert witness, the person may be paid as compensation for the service a sum in excess of the ordinary witness fees provided by law. The sum to be awarded shall be determined by the judge before whom the witness appears.