Firstly go to this: http://wiki.tinyclr.com/index.php?title=Gadgeteer_Driver_Modification
and learn how to modify a module source code.
Then you have Music.cs in project. Modify on Music contructor:
// Note: A constructor summary is auto-generated by the doc builder.
/// <summary></summary>
/// <param name="socketNumber">The socket that this module is plugged in to.</param>
public Music(int socketNumber)
{
// This finds the Socket instance from the user-specified socket number.
// This will generate user-friendly error messages if the socket is invalid.
// If there is more than one socket on this module, then instead of "null" for the last parameter,
// put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
Socket socket = Socket.GetSocket(socketNumber, true, this, null);
socket.EnsureTypeIsSupported(new char[] { 'S' }, this);
// Set up our SPI
m_dataConfig = new SPI.Configuration(socket.CpuPins[5], false, 0, 0, false, true, 3000, socket.SPIModule);
m_cmdConfig = new SPI.Configuration(socket.CpuPins[6], false, 0, 0, false, true, 3000, socket.SPIModule);
m_dreq = new InputPort(socket.CpuPins[3], false, Port.ResistorMode.PullUp);
m_SPI = new SPI(m_dataConfig);
Reset();
CommandWrite(SCI_MODE, SM_SDINEW);
CommandWrite(SCI_CLOCKF, 0xa000);
CommandWrite(SCI_VOL, 0x0101); // highest volume -1
if (CommandRead(SCI_VOL) != (0x0101))
{
throw new Exception("Failed to initialize MP3 Decoder.");
}
SetVolume(200, 200);
// This creates an GTI.InterruptInput interface. The interfaces under the GTI namespace provide easy ways to build common modules.
// This also generates user-friendly error messages automatically, e.g. if the user chooses a socket incompatible with an interrupt input.
//this.input = new GTI.InterruptInput(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.On, GTI.ResistorMode.PullUp, GTI.InterruptMode.RisingAndFallingEdge, this);
// This registers a handler for the interrupt event of the interrupt input (which is below)
//this.input.Interrupt += new GTI.InterruptInput.InterruptEventHandler(this._input_Interrupt);
}
Then go to
private void RecordOggVorbisThreadFunction()
{
Reset();
SetVolume(255, 255);
..........................
while (!stopRecording)
{
if (m_stopRecordingRequested && !stopRecordingRequestInProgress)
{
CommandWrite(SCI_AICTRL3, 0x0001);
m_stopRecordingRequested = false;
stopRecordingRequestInProgress = true;
}
if (stopRecordingRequestInProgress)
{
stopRecording = ((CommandRead(SCI_AICTRL3) & 0x0002) != 0);
}
samples = CommandRead(SCI_HDAT1);
if (samples > 0)
{
//totalSamples = samples > 512 ? 512 : samples;
//ReadData(samples);
//while (i < samples)
for (i =0; i<samples; i++)
{
m_SPI.WriteRead(m_sampleBuffer, 0, 2, m_recordingBuffer, i * 2, 2, 2);
// i++;
}
//if (m_recordingStream != null)
m_recordingStream.Write(m_recordingBuffer, 0, samples << 1);
//Debug.Print("I have: " + samples.ToString() + " samples");
}
//Debug.Print("no data");
}
samples = CommandRead(SCI_HDAT1);
while (samples > 0)
{
//totalSamples = samples > 512 ? 512 : samples;
//ReadData(samples);
//if (m_recordingStream != null)
for (i = 0; i < samples; i++)
{
m_SPI.WriteRead(m_sampleBuffer, 0, 2, m_recordingBuffer, i * 2, 2, 2);
// i++;
}
m_recordingStream.Write(m_recordingBuffer, 0, samples << 1);
//Debug.Print("I have: " + samples.ToString() + " samples");
samples = CommandRead(SCI_HDAT1);
}
if (m_recordingStream != null)
{
m_recordingStream.Close();
m_recordingStream = null;
}
..........................
Reset();
m_isRecording = false;
m_oggPatch = null;
_isReadyRecord = false;
}