private void cmbDone_Click(object sender, System.EventArgs e) { //// Gets the GUID of the selected sound device //globalSettings.audioDevice = directSoundDevices[cmbDevices.SelectedIndex]; ////globalSettings.selectedAudioDevice = cmbDevices.SelectedIndex; //globalSettings.aDC.selectedAudioDevice = cmbDevices.SelectedIndex; //audioDeviceSave(); //if (dsInterface.aSoundCard == null) if (sdlInterface.SDLInitalised == false) { // Sets up the DX Audio Interface for the program //dsInterface.setupAudio(this); //Sets up the SDL Audio Interface sdlInterface.setupAudio(this); } //else //{ // dsInterface.changeAudioDevice(); //} // Setup OpenALInterface if (!OpenAlInterface.OpenAlInitalised) { OpenAlInterface.setupOpenAL(this); } // Close it all down //testSound = null; //testCard = null; AboutTimer = null; this.Close(); }
/// <summary> /// Add sample to track; both the sample image on the track and save the location to global settings /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbAdd_Click(object sender, EventArgs e) { // First check if the sample is loaded - if not then prompt to load a sample if (globalSettings.osj.sampleLoaded[_sample] == false) { if (DialogResult.OK == loadSamples.ShowDialog()) { string sampleLocation = loadSamples.FileName.ToString(); // Attempt to load the sample string error = sdlInterface.loadSample(sampleLocation, _sample); if (error != "") { // Display the error if the file didn't load correctly System.Windows.Forms.MessageBox.Show("There was an error loading sample number " + _sample.ToString() + ", this sample has not been loaded and can not be played. There are a few reasons this can occur: The samples format may be invalid, it may be to small, etc. Please refer to the website for more information. http://www.evolvingsoftware.com :: Direct sound error message follows - " + error, "Sample " + _sample.ToString() + " was not loaded ::"); } else { // Save the sample to the memory stream byte[] _bytes; _bytes = System.IO.File.ReadAllBytes(sampleLocation); globalSettings.osj.sample_MemoryStream[_sample] = new System.IO.MemoryStream(_bytes); // Everything OK - sample loaded sucessfully globalSettings.osj.sampleLocations[_sample] = sampleLocation; globalSettings.osj.sampleLoaded[_sample] = true; globalSettings.osj.sampleDetails_sampleName[_sample] = getSampleName(sampleLocation); // CR 1661564 // Display the track name after it has been loaded lblTrack.Text = globalSettings.osj.sampleDetails_sampleName[_sample]; //Enable the button after the sample has been loaded // CR 1671525 cmbSettings.Enabled = true; // Load the sample settings from the OpenAlInterface OpenAlInterface.getSampleSetting(_sample); } } } // Still want to add the sample to the screen once it has been loaded if (globalSettings.osj.sampleLoaded[_sample] == true) { globalSettings.osj.TrackEditor_SampleInstance_Sample[globalSettings.osj.TrackEditor_SampleInstance_InAction] = _sample; globalSettings.osj.TrackEditor_SampleInstance_Location[globalSettings.osj.TrackEditor_SampleInstance_InAction] = 200; globalSettings.osj.TrackEditor_SampleInstance_Enabled[globalSettings.osj.TrackEditor_SampleInstance_InAction] = true; // Adds a new _sampleInstance with all of the relevant details addNewInstance(globalSettings.osj.TrackEditor_SampleInstance_Location[globalSettings.osj.TrackEditor_SampleInstance_InAction]); //Needed to make sure when moving a _sampleInstance that the global location is also updated correctly _globalSampleInstanceRelation[_storedInstances] = globalSettings.osj.TrackEditor_SampleInstance_InAction; // Increment the local variable of the number of labels - this is kept seperate from the one below as each sample // is treated seperatly by virtue of the user control _storedInstances++; // Increments the global variable keeping track of all of the _sampleInstance and their related details globalSettings.osj.TrackEditor_SampleInstance_InAction++; } }
public short[] getBuffer(int sampleToRead) { //numOfBytes = dsInterface.aSound[sampleToRead].Caps.BufferBytes; //int bytesPerSample = dsInterface.aSound[sampleToRead].Format.BitsPerSample / 8; numOfBytes = globalSettings.osj.sampleFormat_BufferBytes_Size[sampleToRead]; int bytesPerSample = globalSettings.osj.sampleFormat_BitsPerSample[sampleToRead] / 8; CreateStreamBuffers(); CreateStreams(); // Create a 16bit Buffer for the total number of samples assuming the maximum // bits per sample is 16 int iNumOfSamples = numOfBytes / bytesPerSample; short[] Points = new Int16[iNumOfSamples]; // Read the complete stream in to a memory stream //dsInterface.aSound[sampleToRead].Read(0, stream0, numOfBytes, Microsoft.DirectX.DirectSound.LockFlag.EntireBuffer); // Read the complete stream in to a memory stream Byte[] waveData = OpenAlInterface.getSampleBytes(sampleToRead); MemoryStream OrigionalWaveData = new MemoryStream(waveData); OrigionalWaveData.WriteTo(stream0); //System.Windows.Forms.MessageBox.Show(bytesPerSample.ToString()); // Get the data from the sample for (int i = 0; i < numOfBytes; i = i + bytesPerSample) { Int16 iSample = 0; switch (bytesPerSample) { case 1: //Int16Converter iC = new Int16Converter(); //iC.ConvertFrom( iSample = streamBuffer0[i]; Points[i] = iSample; break; case 2: //iSample = streamBuffer0[i + 1]; //// Shifts the data 8 bits to the left //iSample <<= 8; //// Performs a Bitwise logical OR //iSample |= streamBuffer0[i]; //Points[i / 2] = iSample; // Submitted by Alfeu Marcatto - alfmarc :: via sourceforge.com iSample = streamBuffer0[i + 1]; if (iSample > 127) { iSample -= 255; } iSample <<= 8; Points[i / 2] = iSample; break; default: break; } } return(Points); }
private void frmProperties_Load(object sender, System.EventArgs e) { //// Check if the sample is loaded first;= //if (globalSettings.osj.sampleLoaded[sample] == false) //{ // System.Windows.Forms.MessageBox.Show("Sample not loaded"); // //this.Close(); // this.Dispose(); // return; //} //else //{ //int tempSample = sample + 1; //this.Text = "Sample " + sample.ToString() + " Properties"; this.Text = "Sample Properties :: " + globalSettings.osj.sampleDetails_sampleName[sample]; txtLocation.Text = globalSettings.osj.sampleDetails_sampleName[sample]; //if (dsInterface.loopSample[sample] == true) if (sdlInterface.loopSample[sample] == true) { chkLoop.Checked = true; } else { chkLoop.Checked = false; } //if (dsInterface.reverseSample[sample] == true) //{ // chkReverse.Checked = true; //} //else //{ // chkReverse.Checked = false; //} //trkPan.Value = dsInterface.getPan(sample); //trkVolume.Value = dsInterface.getVolume(sample); trkVolume.Value = sdlInterface.getVolume(sample); // Loads the sample settings to the globalSettings.osj instance OpenAlInterface.getSampleSetting(sample); // Retrives the details and populates the form. lblChannels.Text = lblChannels.Text + globalSettings.osj.sampleFormat_Channels[sample]; lblBitDepth.Text = lblBitDepth.Text + globalSettings.osj.sampleFormat_BitsPerSample[sample]; lblLength.Text = lblLength.Text + globalSettings.osj.sampleFormat_LengthInSeconds[sample]; lblFrequency.Text = lblFrequency.Text + globalSettings.osj.sampleSettings_Frequency[sample]; // Setup the trkFreq try { //This needs to be set to the pratical minimum so that when // the sample is set to the minimum the display of the sample length // in the lay down is correct; otherwise it is too long, longer than // the real play length if the value is set lower than what direct x will play. trkFreq.Minimum = 4000; // v0.05 changed to make sure the highest value is still playable. // Seems to only actually handle a frequency value of 3000 more. //TODO: SG - Add freq stuff //trkFreq.Maximum = dsInterface.getFrequency(sample) + 3000; //trkFreq.Value = dsInterface.getCurrentFrequency(sample); } catch { } //} }