Budgetone makering5

Budgetone custom ringtone

Firmware 1.0.5.0

Actually, I think the format of the file has changed in version 1.0.50.
I did some sniffing, and came up with an approach that worked for me.
I've attached the modified version of makering.pl that I've used (thanks to Tony and Stephen), as it may work better for others.
It also includes a breakdown of the header format as I understand it to now be.

Cheers,
Jeremy


 #!/usr/bin/perl
 #------------------------------------------------------------------------------
 # Create ringtone file for Grandstream BT100 phone, using uLaw input.
 #
 # Author: Tony Mountifield <tony@softins.co.uk>
 # Date:   28 May 2004
 # File:   makering.pl
 # History:
 #  28/05/2004  Initial version.
 #  29/05/2004  Added checks for input file size being even and not too large.
 #  30/05/2004  Phone will not accept files larger than 65536 bytes.
 #  06/06/2004  Modified for the 1.05.00 firmware, probably doesn't support
 #              older firmware any longer
 #------------------------------------------------------------------------------
 #
 # Usage:
 #  Use sox to convert any audio input file to uLaw and pipe to this prog, e.g.
 #
 #  sox inputfile -r 8000 -c 1 -t ul - rate | makering.pl ring1.bin
 #
 # (try using /usr/share/sounds/phone.wav for the inputfile)
 #
 #  Check the output file by using the following command:
 #
 #  tail +513c ring1.bin | play -t ul -
 #
 #  Finally, put the ring file in /tftpboot on the phone's TFTP server,
 #  and reboot the phone.
 #
 #------------------------------------------------------------------------------
 #
 # Credits:
 #  Based on analysis by Stephen R. Besch <sbesch@acsu.buffalo.edu>
 #
 # Copyright: placed into the public domain by the author
 #
 # Warranty: none!
 #
 #------------------------------------------------------------------------------

 $filename = shift or die "need output filename\n";

 undef $/;	# slurp whole file at once...

 $audio = <>;	# ... like this

 $filesize = 512 + length $audio;

 if ($filesize & 1) {
	# length odd, add a zero byte (should never happen)
	$audio .= chr(0);
 }


 if ($filesize >= (2 * 65536)) {
    print STDERR "Warning:  $filesize is bigger than 2 bytes, trouble may be ahead."
 }

 # this is the format for the header
 $headerfmt = "N n C4 n C C C C a16 C C x4 n n x214 n n N x72 a176";

 # get the current date and time
 ($min, $hour, $day, $month, $year) = (localtime)[[1..5];
 $year += 1900;
 $month += 1;

 # create the header, with zero for the checksum
 $header = pack $headerfmt,
		$filesize/2,    #  00 - filesize/2
                                #       FIXME:  I'm guessing that the 0000 we
                                #               always see at the beginning of
                                #               the files are an extended file size
		0,		#  04 - put checksum in later
		1,0,0,1,	#  06 - version
		$year,          #  0a - year
                $month,         #  0c - month
                $day,           #  0d - day
                $hour,          #  0e - hour
                $min,           #  0f - min
		"ring.bin",     #  10 - name, seems to always be ring.bin
                                #       FIXME:  Assumption 1: always ring.bin
                                #       FIXME:  Assumption 2: name field is 16 chars
                0,              #  20 - ?
                0,              #  21 - ? 0 (ring1.bin) or 9 (ring2.bin) - Codec?
                                #  22 - 4 NULL bytes, unknown
                0xc8,           #  26 - ? 00C8 (0 sometimes seen before)
                0,              #  28 - 0000 (ring2.bin) or 0001 (ring1.bin) - why?
                                #  2a - 214 null bytes
                0,              # 100 - ? 0
                256,            # 102 - ? 0x0100
                $filesize/2,    # 104 - 
                                #   Next comes an array of positions, which seems
                                #   to be a sort of 'play until' set of instructions
                                # 150 - Description
		"Grandstream standard music ring";

 # sanity check
 $headerlen = length $header;
 die "header length wrong ($headerlen)\n" unless $headerlen == 512;

 # add the audio
 $header .= $audio;

 # compute the checksum
 $checksum = unpack "%16n*", $header;
 printf "checksum before = %04x\n", $checksum;

 # insert it in the correct place
 substr($header,4,2) = pack "n",-$checksum;

 # ensure the new checksum is zero
 $checksum = unpack "%16n*", $header;
 printf "checksum after  = %04x\n", $checksum;
 die "checksum failed\n" unless $checksum == 0;

 # write the file
 open F, ">$filename" or die "can't open output file $filename: $!\n";
 print F $header;
 close F;

 # end




Go back to Budgetone

Budgetone custom ringtone

Firmware 1.0.5.0

Actually, I think the format of the file has changed in version 1.0.50.
I did some sniffing, and came up with an approach that worked for me.
I've attached the modified version of makering.pl that I've used (thanks to Tony and Stephen), as it may work better for others.
It also includes a breakdown of the header format as I understand it to now be.

Cheers,
Jeremy


 #!/usr/bin/perl
 #------------------------------------------------------------------------------
 # Create ringtone file for Grandstream BT100 phone, using uLaw input.
 #
 # Author: Tony Mountifield <tony@softins.co.uk>
 # Date:   28 May 2004
 # File:   makering.pl
 # History:
 #  28/05/2004  Initial version.
 #  29/05/2004  Added checks for input file size being even and not too large.
 #  30/05/2004  Phone will not accept files larger than 65536 bytes.
 #  06/06/2004  Modified for the 1.05.00 firmware, probably doesn't support
 #              older firmware any longer
 #------------------------------------------------------------------------------
 #
 # Usage:
 #  Use sox to convert any audio input file to uLaw and pipe to this prog, e.g.
 #
 #  sox inputfile -r 8000 -c 1 -t ul - rate | makering.pl ring1.bin
 #
 # (try using /usr/share/sounds/phone.wav for the inputfile)
 #
 #  Check the output file by using the following command:
 #
 #  tail +513c ring1.bin | play -t ul -
 #
 #  Finally, put the ring file in /tftpboot on the phone's TFTP server,
 #  and reboot the phone.
 #
 #------------------------------------------------------------------------------
 #
 # Credits:
 #  Based on analysis by Stephen R. Besch <sbesch@acsu.buffalo.edu>
 #
 # Copyright: placed into the public domain by the author
 #
 # Warranty: none!
 #
 #------------------------------------------------------------------------------

 $filename = shift or die "need output filename\n";

 undef $/;	# slurp whole file at once...

 $audio = <>;	# ... like this

 $filesize = 512 + length $audio;

 if ($filesize & 1) {
	# length odd, add a zero byte (should never happen)
	$audio .= chr(0);
 }


 if ($filesize >= (2 * 65536)) {
    print STDERR "Warning:  $filesize is bigger than 2 bytes, trouble may be ahead."
 }

 # this is the format for the header
 $headerfmt = "N n C4 n C C C C a16 C C x4 n n x214 n n N x72 a176";

 # get the current date and time
 ($min, $hour, $day, $month, $year) = (localtime)[[1..5];
 $year += 1900;
 $month += 1;

 # create the header, with zero for the checksum
 $header = pack $headerfmt,
		$filesize/2,    #  00 - filesize/2
                                #       FIXME:  I'm guessing that the 0000 we
                                #               always see at the beginning of
                                #               the files are an extended file size
		0,		#  04 - put checksum in later
		1,0,0,1,	#  06 - version
		$year,          #  0a - year
                $month,         #  0c - month
                $day,           #  0d - day
                $hour,          #  0e - hour
                $min,           #  0f - min
		"ring.bin",     #  10 - name, seems to always be ring.bin
                                #       FIXME:  Assumption 1: always ring.bin
                                #       FIXME:  Assumption 2: name field is 16 chars
                0,              #  20 - ?
                0,              #  21 - ? 0 (ring1.bin) or 9 (ring2.bin) - Codec?
                                #  22 - 4 NULL bytes, unknown
                0xc8,           #  26 - ? 00C8 (0 sometimes seen before)
                0,              #  28 - 0000 (ring2.bin) or 0001 (ring1.bin) - why?
                                #  2a - 214 null bytes
                0,              # 100 - ? 0
                256,            # 102 - ? 0x0100
                $filesize/2,    # 104 - 
                                #   Next comes an array of positions, which seems
                                #   to be a sort of 'play until' set of instructions
                                # 150 - Description
		"Grandstream standard music ring";

 # sanity check
 $headerlen = length $header;
 die "header length wrong ($headerlen)\n" unless $headerlen == 512;

 # add the audio
 $header .= $audio;

 # compute the checksum
 $checksum = unpack "%16n*", $header;
 printf "checksum before = %04x\n", $checksum;

 # insert it in the correct place
 substr($header,4,2) = pack "n",-$checksum;

 # ensure the new checksum is zero
 $checksum = unpack "%16n*", $header;
 printf "checksum after  = %04x\n", $checksum;
 die "checksum failed\n" unless $checksum == 0;

 # write the file
 open F, ">$filename" or die "can't open output file $filename: $!\n";
 print F $header;
 close F;

 # end




Go back to Budgetone

Created by: JustRumours, Last modification: Tue 12 of Jun, 2012 (02:43 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+