Toolbox.NETMF.Hardware.Somo


Toolbox.NETMF.Hardware.Somo(Clock, Data, Busy)
  • Clock The pin to which the clock signal is connected
  • Pin The pin to which the data signal is connected
  • Busy Optional; the pin to which the busy signal is connected

Methods

  • PlayRepeat(TrackNo) Plays a track in the background and repeats the track
  • PlayTrack(TrackNo, Wait) Plays a track, when Wait is false in the background, otherwise it returns when it's stopped playing
  • SetVolume(Volume) Sets the volume
  • PlayPause() Sends a play/pause signal
  • Stop() Stops playing

Properties

  • IsPlaying True when a track is playing
  • CurrentTrack The track that's currently selected

Events

  • OnStartPlaying(Unused, Unused, Time) Triggered when a track starts playing
  • OnStopPlaying(Unused, Unused, Time) Triggered when a track stops playing

How to connect

Toolbox.NETMF.Hardware.Somo.png

Busy pin note

The busy pin is optional; sometimes it's more useful when the SOMO-14D is connected over just two wires, so you can use the other pins for your project. This comes with a downside though. Some features are only available when the Busy-pin is defined. When the pin is not set, these functions won't work:
  • Somo.IsPlaying
  • Somo.OnStartPlaying()
  • Somo.OnStopPlaying()
  • Somo.PlayRepeat()
  • PlayTrack() (only the wait-parameter won't work)

Sample code in C#

/*
 * This sample uses 5 files on the SD-card. They can be found in netmftoolbox\Samples\Visual C#\Sound Module\samples
 */
public static ushort EXTERMINATE = 0;
public static ushort WAAAAAAAAAAAA = 1;
public static ushort YOUMAYNOTLEAVE = 2;
public static ushort TARDIS = 3;
public static ushort SONIC = 4;

public static void Main()
{
    // The module is connected to these pins
    Somo SoundModule = new Somo(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1, Pins.GPIO_PIN_D2);

    // Sets the volume fully open
    SoundModule.SetVolume(7);

    // Plays "Exterminate!"
    Debug.Print("EXTERMINATE");
    SoundModule.PlayTrack(EXTERMINATE, true);

    // Plays the Tardis-sound
    Debug.Print("TARDIS");
    SoundModule.PlayTrack(TARDIS, true);

    // Plays "You may not leave my precence!"
    Debug.Print("YOUMAYNOTLEAVE");
    SoundModule.PlayTrack(YOUMAYNOTLEAVE, true);

    // Plays the sonic screwdriver sound
    Debug.Print("SONIC");
    SoundModule.PlayTrack(SONIC, true);

    // Repeatedly play "Waaaaaaaaa!"
    Debug.Print("WAAAAAAAAAAAA (repeated)");
    SoundModule.PlayRepeat(WAAAAAAAAAAAA);

    // Let this go on infinitely
    Thread.Sleep(Timeout.Infinite);
}

Sample code in VB

'
' This sample uses 5 files on the SD-card. They can be found in netmftoolbox\Samples\Visual C#\Sound Module\samples
'
Const EXTERMINATE As UShort = 0
Const WAAAAAAAAAAAA As UShort = 1
Const YOUMAYNOTLEAVE As UShort = 2
Const TARDIS As UShort = 3
Const SONIC As UShort = 4

Sub Main()
    ' The module is connected to these pins
    Dim SoundModule As Somo = New Somo(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1, Pins.GPIO_PIN_D2)

    ' Sets the volume fully open
    SoundModule.SetVolume(7)

    ' Plays "Exterminate!"
    Debug.Print("EXTERMINATE")
    SoundModule.PlayTrack(EXTERMINATE, True)

    ' Plays the Tardis-sound
    Debug.Print("TARDIS")
    SoundModule.PlayTrack(TARDIS, True)

    ' Plays "You may not leave my precence!"
    Debug.Print("YOUMAYNOTLEAVE")
    SoundModule.PlayTrack(YOUMAYNOTLEAVE, True)

    ' Plays the sonic screwdriver sound
    Debug.Print("SONIC")
    SoundModule.PlayTrack(SONIC, True)

    ' Repeatedly play "Waaaaaaaaa!"
    Debug.Print("WAAAAAAAAAAAA (repeated)")
    SoundModule.PlayRepeat(WAAAAAAAAAAAA)

    ' Let this go on infinitely
    Thread.Sleep(Timeout.Infinite)
End Sub

Related documents

Last edited Jan 1, 2013 at 9:20 PM by Garrcomm, version 3