# new function to create ITUNSMPB tag?

**URL:** https://community.mp3tag.de/t/new-function-to-create-itunsmpb-tag/11208
**Category:** General Discussion
**Created:** [November 29, 2010, 6:29pm UTC](https://community.mp3tag.de/t/new-function-to-create-itunsmpb-tag/11208 "2010-11-29T18:29:18Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![djs777](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/8dc957/32.png) [@djs777](https://community.mp3tag.de/u/djs777)
#### Post date: [November 29, 2010, 6:29pm UTC](https://community.mp3tag.de/t/new-function-to-create-itunsmpb-tag/11208/1 "2010-11-29T18:29:18Z")

</div>

I love the improved compatibility with iTunes tags, and being able to convert Replaygain tags into an iTunes tag using the function $rg2sc. This greatly reduces my library load times, which I do frequently as I mess with tags and file names.

To further reduce library load times, is it possible to start with the $rg2sc code to create a new function to create the hex data for iTune's gapless tag ITUNSMPB? I apologize if this has been discussed before and I failed to find it, but what little exists on how to create ITUNSMPB is in this thread [http://www.hydrogenaudio.org/forums/index....8231&st=136](http://www.hydrogenaudio.org/forums/index.php?showtopic=48231&st=136)

I'm no programmer, but I hope this is not too difficult to do. It seems like the hard part could be finding out what all the values mean in ITUNSMPB, but I couldn't find that anywhere when searching here or anywhere else. The only threads I found anywhere mentioned how to create a "fake" ITUNSMPB to prevent the iTunes gapless scan, but those methods prevent accurate gapless playback. I'd like to skip the gapless scan but still have accurate gapless playback.

Thanks again for a great tool!

---

<div class="post-metadata">

### Author: ![rungumprun](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/51bf81/32.png) [@rungumprun](https://community.mp3tag.de/u/rungumprun)
#### Post date: [December 4, 2010, 2:11pm UTC](https://community.mp3tag.de/t/new-function-to-create-itunsmpb-tag/11208/2 "2010-12-04T14:11:12Z")

</div>

I would like this as well. I think the information at this link defines how to encode ITUNSMPB - maybe Florian can use it to create a new function for this:

[http://bitbucket.org/wez/atomicparsley/src/4caecca5cdc6](http://bitbucket.org/wez/atomicparsley/src/4caecca5cdc6)

or maybe Wez can provide Florian some help to do this.

---

<div class="post-metadata">

### Author: ![rungumprun](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/51bf81/32.png) [@rungumprun](https://community.mp3tag.de/u/rungumprun)
#### Post date: [December 4, 2010, 2:37pm UTC](https://community.mp3tag.de/t/new-function-to-create-itunsmpb-tag/11208/3 "2010-12-04T14:37:21Z")

</div>

Looking the first link above, the following edited extract from that link seems to define all of the non-zero values for ITUNSMPB:

"[441000.mp3] (a 10 second file with 441000 samples)  
TT2: segment1  
COM(eng): iTunPGAP=0  
TEN: iTunes v7.0.0.70  
COM(eng): iTunSMPB= 00000000 00000210 000007C8 000000000006BAA8 00000000 00026783 00000000 00000000 00000000 00000000 00000000 00000000

As (this) MP3 file (has) 385 frames, the number of decoded samples will be 1152 \* 385 = 443520 samples (without any handling for gapless playback).  
The second and third values in iTunSMPB present the numbers of encoder delay and encoder padding in samples. ...The original sample length: 443520 - 528 (0x210) - 1992 (0x7C8) = 441000 [samples] = 10 [sec].  
The forth value in iTunSMPB frame probably represents the original sample length since 0x6BAA8 equals to 441000 [samples].  
The sixth value is the byte offset from the first audio frame to the 8th-from-last frame. This provides a resynchronization mechanism to restore a decoder's true sample number after a seek. "

The other values always seem to be all zeros. Is there any other information needed to create a new function for ITUNSMPB?

---

<div class="post-metadata">

### Author: ![djs777](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/d/8dc957/32.png) [@djs777](https://community.mp3tag.de/u/djs777)
#### Post date: [December 4, 2010, 6:56pm UTC](https://community.mp3tag.de/t/new-function-to-create-itunsmpb-tag/11208/4 "2010-12-04T18:56:33Z")

</div>

If reading the mp3 header is not already part of Mp3tag, then reading the header would also be needed, I think. From other posts here, a few links on what the header looks like and a way to read it:

[http://gabriel.mp3-tech.org/mp3infotag.html](http://gabriel.mp3-tech.org/mp3infotag.html)  
[http://phwip.wordpress.com/home/audio/](http://phwip.wordpress.com/home/audio/)

Many people use LAME or the LAME header format for mp3 files, so this seems pretty helpful. I don't know what header foramt m4a or other iTunes formats use, but creating this function for files with LAME headers should work for most iTunes users.
