IPWL_NoteNotify* CPWL_NoteItem::GetNoteNotify() const { if (const CPWL_Note* pNote = GetNote()) return pNote->GetNoteNotify(); return NULL; }
void CPWL_NoteItem::ResetSubjectName(FX_INT32 nItemIndex) { if (nItemIndex < 0) { if (CPWL_Wnd* pParent = this->GetParentWindow()) { ASSERT(pParent->GetClassName() == "CPWL_Note_Contents"); CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pParent; nItemIndex = pContents->GetItemIndex(this); } } const CPWL_Note* pNote = GetNote(); ASSERT(pNote != NULL); CFX_WideString sSubject; sSubject.Format(pNote->GetReplyString(), nItemIndex); if (!m_sAuthor.IsEmpty()) { sSubject += L" - "; sSubject += m_sAuthor; } this->SetSubjectName(sSubject); this->RePosChildWnd(); }
void SynthGroupElement::NoteOff(NoteInstanceID inNoteID, UInt32 inFrame) { #if DEBUG_PRINT_NOTE printf("SynthGroupElement::NoteOff %d\n", inNoteID); #endif UInt32 noteState = kNoteState_Attacked; SynthNote *note = GetNote(inNoteID, true, ¬eState); // asking for unreleased only if (note) { #if DEBUG_PRINT_NOTE printf(" old note state: %d\n", note->mState); #endif if (noteState == kNoteState_Attacked) { mNoteList[noteState].RemoveNote(note); if (mSustainIsOn) { mNoteList[kNoteState_ReleasedButSustained].AddNote(note); } else { note->Release(inFrame); mNoteList[kNoteState_Released].AddNote(note); } #if DEBUG_PRINT_NOTE printf(" new note state: %d\n", note->mState); #endif } else /* if (noteState == kNoteState_Sostenutoed) */ { mNoteList[kNoteState_Sostenutoed].RemoveNote(note); mNoteList[kNoteState_ReleasedButSostenutoed].AddNote(note); } } }
ComponentResult AUInstrumentBase::Reset( AudioUnitScope inScope, AudioUnitElement inElement) { #if DEBUG_PRINT printf("AUInstrumentBase::Reset\n"); #endif if (inScope == kAudioUnitScope_Global) { // kill all notes.. mFreeNotes.Empty(); for (UInt32 i=0; i<mNumNotes; ++i) { SynthNote *note = GetNote(i); if (note->IsSounding()) note->Kill(0); note->ListRemove(); mFreeNotes.AddNote(note); } mNumActiveNotes = 0; mAbsoluteSampleFrame = 0; // empty lists. UInt32 numGroups = Groups().GetNumberOfElements(); for (UInt32 j = 0; j < numGroups; ++j) { SynthGroupElement *group = (SynthGroupElement*)Groups().GetElement(j); group->Reset(); } } return noErr; }
UInt32 AUInstrumentBase::CountActiveNotes() { // debugging tool. UInt32 sum = 0; for (UInt32 i=0; i<mNumNotes; ++i) { SynthNote *note = GetNote(i); if (note->mState <= kNoteState_Released) sum++; } return sum; }
std::wstring GraphicsException::GetFullMessage() const { const std::wstring empty = L""; const std::wstring errorName = GetErrorName(); const std::wstring errorDesc = GetErrorDescription(); const std::wstring& note = GetNote(); const std::wstring location = GetLocation(); return ( !errorName.empty() ? std::wstring( L"Error: " ) + errorName + L"\n" : empty ) + ( !errorDesc.empty() ? std::wstring( L"Description: " ) + errorDesc + L"\n" : empty ) + ( !note.empty() ? std::wstring( L"Note: " ) + note + L"\n" : empty ) + ( !location.empty() ? std::wstring( L"Location: " ) + location : empty ); }
void AUInstrumentBase::SetNotes(UInt32 inNumNotes, UInt32 inMaxActiveNotes, SynthNote* inNotes, UInt32 inNoteDataSize) { #if DEBUG_PRINT printf("AUInstrumentBase::SetNotes %d %d %08X %d\n", inNumNotes, inMaxActiveNotes, inNotes, inNoteDataSize); #endif mNumNotes = inNumNotes; mMaxActiveNotes = inMaxActiveNotes; mNoteSize = inNoteDataSize; mNotes = inNotes; for (UInt32 i=0; i<mNumNotes; ++i) { SynthNote *note = GetNote(i); note->Reset(); mFreeNotes.AddNote(note); } }
wxSize wxCommandLinkButton::DoGetBestSize() const { wxSize size; // account for the text part if we have it or if we don't have any image at // all (buttons initially created with empty label should still have a non // zero size) if ( ShowsLabel() || !m_imageData ) { int flags = 0; if ( GetAuthNeeded() ) flags |= wxMSWButton::Size_AuthNeeded; wxCommandLinkButton *thisButton = const_cast<wxCommandLinkButton *>(this); wxClientDC dc(thisButton); wxFont noteFont = dc.GetFont(); // 4/3 is the relationship between main label and note font sizes. dc.SetFont(noteFont.Scaled(4.0f/3.0f)); size = dc.GetMultiLineTextExtent(GetLabelText(GetMainLabel())); dc.SetFont(noteFont); wxSize noteSize = dc.GetMultiLineTextExtent(GetLabelText(GetNote())); if ( noteSize.x > size.x ) size.x = noteSize.x; size.y += noteSize.y; size = wxMSWButton::GetFittingSize(thisButton, size, flags); // The height of a standard command link button is 25 and 35 DLUs for // single lines and two lines respectively. Width is not accounted for. int heightDef = GetNote().AfterFirst('\n').empty() ? 25 : 35; wxSize sizeDef = thisButton->ConvertDialogToPixels(wxSize(50, heightDef)); if ( size.y < sizeDef.y ) size.y = sizeDef.y; } if ( m_imageData ) { AdjustForBitmapSize(size); } else { // The default image size is 16x16. size.x += 16; if ( size.y < 16 ) size.y = 16; } size.x += MAINLABEL_NOTE_LEFT_MARGIN; size.y += MAINLABEL_TOP_MARGIN + NOTE_BOTTOM_MARGIN; if ( !GetNote().empty() ) size.y += MAINLABEL_NOTE_MARGIN; CacheBestSize(size); return size; }
int main ( int argc, char** argv ) { int CountTaskNote,CurNote,LastNote=0; int TaskNote[]=TASK_NOTES; int Solve=1; CountTaskNote= sizeof(TaskNote)/4; // initialize SDL video SDL_Init(SDL_INIT_VIDEO); // make sure SDL cleans up before exit atexit(SDL_Quit); // create a new window SCREEN = SDL_SetVideoMode(600,400,32, SDL_HWSURFACE|SDL_DOUBLEBUF); SDL_WM_SetCaption("C maj","ex1"); // load images LINES=SDL_LoadBMP("NoteLines_600_400.bmp"); NOTE=SDL_LoadBMP("Note.bmp"); LINEADD=SDL_LoadBMP("LineAdd.bmp"); //инициализация портаудио FreqOfNotes();// заполняем структуру нот PaStreamParameters inputParameters; PaStream *stream = NULL; float *sampleBlock; int j,Real_Note=0; int numBytes; float Im[FRAMES_PER_BUFFER]; numBytes = FRAMES_PER_BUFFER * NUM_CHANNELS * SAMPLE_SIZE ; sampleBlock = (float *) malloc( numBytes ); CLEAR( sampleBlock ); Pa_Initialize(); inputParameters.device = Pa_GetDefaultInputDevice(); inputParameters.channelCount = NUM_CHANNELS; inputParameters.sampleFormat = PA_SAMPLE_TYPE; inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultHighInputLatency ; inputParameters.hostApiSpecificStreamInfo = NULL; Pa_OpenStream( &stream, &inputParameters, 0, SAMPLE_RATE, FRAMES_PER_BUFFER, paClipOff, NULL, NULL ); Pa_StartStream( stream ); fflush(stdout); // ########################################## // program main loop int done=0; while(done==0) { // message processing loop SDL_Event event; while (SDL_PollEvent(&event)) { // check for messages switch (event.type) { case SDL_QUIT: done = 1; break; case SDL_KEYDOWN: { if (event.key.keysym.sym == SDLK_ESCAPE) done = 1; break; } }// end switch }// end of message processing // ########################################## // GENERATE AND DRAWING if (Solve==1) { do { CurNote=( rand()%(CountTaskNote)); } while (CurNote==LastNote); LastNote=CurNote; DrawNote(TaskNote[CurNote]); //DRAW SDL Solve=0; } // ###################################### // PortAudio analyzer float max_sample=0; Pa_ReadStream( stream, sampleBlock, FRAMES_PER_BUFFER ); // определяем максимальную амплитуду for (j=0; j<FRAMES_PER_BUFFER; ++j) { if (sampleBlock[j] > max_sample) max_sample=sampleBlock[j]; } // *************************************** // если аплтитуда мала, ничего не анализируем! if (max_sample>0.2) { // отправляем массив на БПФ, обнулив мнимую часть CLEAR( Im ); FFT(sampleBlock, Im, FRAMES_PER_BUFFER, POW_2, -1); Real_Note=GetNote(sampleBlock, Im, FRAMES_PER_BUFFER); } if (Real_Note==TaskNote[CurNote]) Solve=1 ; }// end main loop //close portaudio CLEAR( sampleBlock ); free( sampleBlock ); Pa_StopStream( stream ); Pa_Terminate(); // free loaded bitmap SDL_FreeSurface(LINES); SDL_FreeSurface(LINEADD); SDL_FreeSurface(NOTE); return 0; }
void Instrument::SetEnharmonic(char pitch, int alter, uint octave, char* buffer, size_t length) { Note* enharmonicNote; switch(alter) { case 0: switch(pitch) { case 'E': case 'B': Music::NextPitch(pitch, octave); enharmonicNote = GetNote(pitch, octave); enharmonicNote->flatLength = length; enharmonicNote->flat = buffer; break; case 'C': case 'F': Music::PreviousPitch(pitch, octave); enharmonicNote = GetNote(pitch, octave); enharmonicNote->sharpLength = length; enharmonicNote->sharp = buffer; break; } break; // first switch case -1: switch(pitch) { case 'C': case 'F': Music::PreviousPitch(pitch, octave); enharmonicNote = GetNote(pitch, octave); enharmonicNote->normalLength = length; enharmonicNote->normal = buffer; break; default: Music::PreviousPitch(pitch, octave); enharmonicNote = GetNote(pitch, octave); enharmonicNote->sharpLength = length; enharmonicNote->sharp = buffer; break; } break; // first switch case 1: switch(pitch) { case 'E': case 'B': Music::NextPitch(pitch, octave); enharmonicNote = GetNote(pitch, octave); enharmonicNote->normalLength = length; enharmonicNote->normal = buffer; break; default: Music::NextPitch(pitch, octave); enharmonicNote = GetNote(pitch, octave); enharmonicNote->flatLength = length; enharmonicNote->flat = buffer; break; } break; // first switch } }
bool Instrument::AddNote(const char* fileName, char pitch, int alter, uint octave) { Note* note; size_t streamSize; char* buffer; csRef<iSndSysData> noteData; csRef<iSndSysStream> noteStream; // variables used to get the stream data void* data1; void* data2; size_t length1; size_t length2; size_t positionMarker; // checking if parameters are correct if(!(alter == 0 || alter == 1 || alter == -1)) { return false; } // loading data if(!SoundSystemManager::GetSingleton().GetSoundData()->LoadSoundFile(fileName, noteData)) { return false; } // If format is null this is the first added note: create format if(format == 0) { const csSndSysSoundFormat* f = noteData->GetFormat(); format = new csSndSysSoundFormat(); format->Bits = f->Bits; format->Channels = f->Channels; format->Flags = f->Flags; format->Freq = f->Freq; } // creating the decoded stream noteStream = noteData->CreateStream(format, CS_SND3D_ABSOLUTE); noteStream->SetLoopState(CS_SNDSYS_STREAM_DONTLOOP); streamSize = noteStream->GetFrameCount() * (format->Bits / 8) * format->Channels; note = GetNote(pitch, octave); // initializing notes' buffer switch(alter) { case 0: if(note->normal != 0) { return false; // the note and its enharmonic already exist } note->normalLength = streamSize; note->normal = new char[streamSize]; buffer = note->normal; break; case -1: if(note->flat != 0) { return false; } note->flatLength = streamSize; note->flat = new char[streamSize]; buffer = note->flat; break; case 1: if(note->sharp != 0) { return false; } note->sharpLength = streamSize; note->sharp = new char[streamSize]; buffer = note->sharp; break; // we checked before that alter is right, no need for default } SetEnharmonic(pitch, alter, octave, buffer, streamSize); // updating longestBufferSize if(longestBufferSize < streamSize) { longestBufferSize = streamSize; } // reading and copying data noteStream->InitializeSourcePositionMarker(&positionMarker); noteStream->Unpause(); // unpause otherwise data is never read do { noteStream->AdvancePosition(streamSize); noteStream->GetDataPointers(&positionMarker, streamSize, &data1, &length1, &data2, &length2); // copying buffer 1 for(size_t i = 0; i < length1; i++) { (*buffer) = ((char*)data1)[i]; buffer++; } // copying buffer 2 for(size_t i = 0; i < length2; i++) { (*buffer) = ((char*)data2)[i]; buffer++; } }while(noteStream->GetPauseState() == CS_SNDSYS_STREAM_UNPAUSED); return true; }