MADNewton

MAD Max is an MP3 player for Newton MessagePads 2000 and 2100. It is based on MAD Newton, a port of Robert Leslie’s excellent MAD MP3 decoder to the Newton and plays MP3 files and Icecast or Shoutcast MP3 streams.

Usage

MAD Max is a NewtApp based program and is similar to other NewtApp programs such as Dates or Names. It manages a number of tracks and streams via an overview and a detailed view. Beyond the typical NewtApp UI, the interface it simple and consists of a play button, a stop button and a volume control slider. Due to the nature of the decoding process, the volume for regular file playback can only be set when playback is stopped. Also, the progress indicator does not work for regular file playback any more.

Getting files onto the Newton

Uploading MP3 files to the Newton is currently done using Eric Schneck’s neat iTunes plugin for iTunes 2.0 running under Mac OS 9 or Classic.

Files can also be downloaded via the Fetch URL transport available in NHttpLib (from version 3.0 on). The Fetch URL transport downloads MP3 data into the Inbox from where it can be put away to MAD Max (The MP3 data is stored in a Soup called ‘‘Audio’’). When files are put away, MAD Max uses the ID3 tag data in the file to set the artist, album and title fields of the track.

The third option is MP3Builder by Daniel Padilla, a NTK project to load MP3 files to the Newton without the iTunes plugin. It was used to create a test file which can be used to verify the correct installation of MAD Max.

Data Formats

The recommended parameters for MP3 files are currently up to 128 kbit/s sample rate, 22khz bit rate, mono. Generally, the decoder handles also VBR encoding, 11khz, 22khz or 44khz, mono, stereo or joint stereo. For playback of Icecast or Shoutcast streams, 56kbit seem to be the optimal due to the added load of networking. Stream playback also depends on the networking performance in general. Since the Newton does not have very much memory, the network buffers are quite small, resulting in playback gaps when the network chokes.

A good starting point for streams is ::radiofreenewton:: by Jesse Garnier. If you use Newt’s Cape to browse the web, you can launch MAD Max to play MP3 streams from web pages by installing Victor Rehorst’s LaunchPLS.

Changes

  • Version 1.0.1: Exising Audio soup no longer required when putting away
  • Version 1.0: Added ID3 tag update function, removed decoder part in favour of codec. Note that only MAD Max.pkg and MP3Codec.pkg are required now. MAD Newton.pkg is not necessary anymore and MAD Newton:40Hz can be removed from the Extensions folder on the Newton.

Implementation Notes

MAD Newton is implemented as an MP3 codec (only the decoding part is implemented) which can be used like any other codec. The codec produces 16 bit samples at 22050 Hz. It’s name is “TMP3Codec” and it can be used in a sound frame like this:

	sound := {
		samples: samples,
		dataType: k16Bit,
		compressionType: kSampleLinear,
		sndFrameType: 'codec,
		codecName: "TMP3Codec",
		bufferCount: 4,
		bufferSize: 10368,
		samplingRate: 22050.0,
	};

Current Restrictions

There are a number of issues with the current impementation of MAD Max, the actual player application.

One basic problem with MP3 data is that it has to be decoded in complete frames. Incomplete frames will simply be dropped. This requires some buffer management which is a bit complicated due to the Newton’s limited memory (mostly on the NewtonScript side).

File playback schedules the whole MP3 data for a file at once to achieve maximum sound quality. This however takes away the possibilty to implement a progress bar or volume control during playback.

Many streams are streamed at a rate which is slightly above the bit rate of the MP3 data. For a 128kbit/s stream, this means that data comes in at maybe 13KBytes per second. This does not leave much leeway to do decoding if the network layer and the decoding layer are synchronous (as is the case with MAD Max). The current NHttpLib implementation can read data at about 25KBytes per second on a MP2100.

Implementing a classic producer/consumer architecture which would take care of some of the streaming issues is not very easy since the NewtonScript interpreter is single threaded and does not include things like Mutexes or other synchronization means.

To Do List

  • New Roll-based UI
  • Integrate LaunchPLS
  • Option to prevent Newton from going to sleep when playing
  • Make output device selectable (line-out or speaker)
  • Working Previous track button
  • Alarm clock functionality
  • Show buffer level for stream playback
  • Test more bitrates and sample rates (MAD Newton)
  • Document the API (MAD Newton)
  • Enhance accuracy by using 64 bit multiplications (MAD Newton)
  • Provide flexible output (sample rates, mono/stereo, sample sizes) (MAD Newton)

Credits

Thanks go to Robert Leslie (author of MAD) Eric Schneck (iTunes plug-in, the logo and general feedback), Roman Pixell (feedback, creating and hosting the web pages for the plug-in), Paul Guyot for reverse engineering parts of the Newton OS codec interface, Daniel Padilla and Victor Rehorst for building useful tools on top of MAD Newton… and many others!