×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    25

    Could someone please share their 7650 tone loading code?

    Hey folks,

    I'm almost done with a new game for the Nokia 7650, but I've been having trouble throughout development with my sound loading code. I've posted here a couple of times about it, but nobody decided to answer. I'm trying to load some OTT files I created with Nokia PC Composer, but I get NO sound at all in the Series 60 emulator... Could anyone share some code and/or advice please? This project is due within the next couple of days, so I'd appreciate any help I can get.

    Thanks,
    Dave

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Posts
    382

    RE: Could someone please share their 7650 tone loading code?

    Hello

    Here is small example how you can load files and create tones to be played from Java MIDP any tools capable of creating .ott files.
    .ott is binary conversion of rtttl which is text description of sound file.

    Here is one example for you where .ott file is loaded and played:
    also playing note are introduced,
    notice that .ott file is placed into classes folder in this case.
    could be also other folder when making package, but the paths need to be right.

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import com.nokia.mid.sound.*;
    import java.io.ByteArrayOutputStream;
    import java.io.InputStream;

    public class Ring extends MIDlet implements CommandListener
    {
    private Display display = null;
    private List list = null;

    private Sound sound = null;

    private final static byte[] BYTES =
    {
    (byte)0x02, (byte)0x4a, (byte)0x3a, (byte)0x69,
    (byte)0x8c, (byte)0xe9, (byte)0x71, (byte)0x99,
    (byte)0xbd, (byte)0xc9, (byte)0xd5, (byte)0xb5,
    (byte)0xb9, (byte)0xbc, (byte)0x04, (byte)0x00,
    (byte)0x10, (byte)0xd9, (byte)0x65, (byte)0x13,
    (byte)0x82, (byte)0x4c, (byte)0x40, (byte)0x8c,
    (byte)0x09, (byte)0xc4, (byte)0x00
    };

    private final static String PATH = "/some_name.ott";

    public Ring()
    {
    list = new List("Sound in MIDP", List.IMPLICIT);
    list.append("Play Ott File", null);
    list.append("Play Binary Array", null);
    list.setCommandListener(this);
    }

    protected void destroyApp(boolean p0) throws MIDletStateChangeException {}

    protected void startApp() throws MIDletStateChangeException
    {
    Display.getDisplay(this).setCurrent(list);
    }


    protected void pauseApp() {}

    public void commandAction (Command c, Displayable d)
    {
    if(c == List.SELECT_COMMAND)
    {
    if(list.getSelectedIndex() == 0)
    {
    System.out.print("Playing Ott File"
    try
    {
    InputStream tune = this.getClass().getResourceAsStream("/some_name.ott"
    byte[] buffer = new byte[100000];
    tune.read(buffer, 0, buffer.length);
    sound = new Sound(buffer, Sound.FORMAT_TONE);
    sound.init(buffer, Sound.FORMAT_TONE);
    sound.play(1);
    } catch (Exception e) {}
    }

    if(list.getSelectedIndex() == 1)
    {
    System.out.print("Playing Binary Array"
    sound = new Sound(BYTES, Sound.FORMAT_TONE);
    sound.init(BYTES, Sound.FORMAT_TONE);
    sound.play(2);
    }
    }
    }

    }

    Playing WAV files from 7650 Java is also possible, be carefull and not play too big files.

    InputStream tune = this.getClass().getResourceAsStream("/some_name.wav"
    byte[] buffer = new byte[100000];
    tune.read(buffer, 0, buffer.length);
    sound = new Sound(buffer, Sound.FORMAT_WAV);
    sound.init(buffer, Sound.FORMAT_WAV);
    sound.play(1);
    buffer = null;


    The Nokia PC Suite and Nokia Developer suite 1.1 contains some tools
    for creating .ott files and converting files to .ott.

    3650 supports MMA which enables playing midi files.

    I hope this help you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×