public void CreateNote(int noteID, Vector3 position, InstrumentOption instrumentOption) { Note newNote = Instantiate(notePrefab, transform, true); newNote.transform.position = position; newNote.NoteStupidConstructor(this, instrumentOption.key, noteID, instrumentOption.instrumentName); placedNotes[noteID] = newNote; }
void CreatePalette() { float xPos = instrumentOptionStartPos.x; float yPos = instrumentOptionStartPos.y; int tmpcounter = 0; foreach (AudioClip audioClip in allInstruments.allStupidAudioClips) { RectTransform instrumentOptionPrefabClone = Instantiate(instrumentOptionPrefab); // placement instrumentOptionPrefabClone.position = new Vector3(xPos, yPos, 0f); instrumentOptionPrefabClone.SetParent(holder); if (tmpcounter == maxRows) { yPos = instrumentOptionStartPos.y; xPos += 700f; } else { yPos -= instrumentOptionHeight + instrumentOptionMargin; } // properties; should probably move all this to its Start() <-- TO DO InstrumentOption newInstrumentOption = instrumentOptionPrefabClone.GetComponent <InstrumentOption>(); newInstrumentOption.key = AllInstruments.instrumentStartingNotes[audioClip.name]; //newInstrumentOption.keyLabel.text = ((int)(newInstrumentOption.key / AllInstruments.noteLengths[audioClip.name])).ToString(); newInstrumentOption.noteLabel.text = audioClip.name; newInstrumentOption.instrumentName = audioClip.name; newInstrumentOption.audioClip = audioClip; newInstrumentOption.highestKey = (AllInstruments.numberOfOctaves[audioClip.name] * 12) - 1; newInstrumentOption.CalculateClipStartTimeAndPitchShift(); newInstrumentOption.keyLabel.text = (newInstrumentOption.key).ToString(); tmpcounter++; } //holder.gameObject.SetActive(false); }
public void OptionClicked(InstrumentOption instrument) { activeInstrument = instrument.instrumentName; int note = instrument.key % 12; activeInstrumentLabel.text = instrument.instrumentName + " " + AllInstruments.instrumentNoteIDToName[note]; audioSource.clip = instrument.audioClip; audioSource.time = instrument.audioClipStartTime; pitchShiftAmount = instrument.pitchShiftAmount; // we also need pitchShiftAmount to decide how long we play the file audioSource.pitch = Mathf.Pow(1.05946f, pitchShiftAmount); activeInstrumentOption = instrument; activeInstrumentClip = instrument.audioClip; StopAllCoroutines(); audioSource.Stop(); StartCoroutine(PlayNote_()); }
void CreateNote(int cellNumber, int spotID, Vector3 position, InstrumentOption instrumentOption) { int noteID = (cellNumber * 4) + (spotID); activeRing.CreateNote(noteID, position, instrumentOption); }