2008. 10. 3. 17:32

[펌] DirectMusic


 

Introduction

This article focuses on the use of CMidiMusic which allows an easy access to DirectX DirectMusic API. This class allows loading and playing general midi sequence files(.mid), segment files (.sgt) and PCM waveform files (.wav). The class is designed to perform midi playback in one segment and offers additional features like using any midi port installed in your system, 3D sound environment, sound effects, etc...

Direct Audio specifications

The DirectX 8.0 Audio part offers improved integration between DirectSound and DirectMusic, including a great set of new features. Some of these are listed hereafter:

  • The last version of Direct Audio allows using hardware acceleration for sound synthesis.
  • With the new AudioPath model the sound of a port does not go directly to a directsound buffer, instead, it goes to an audiopath which controls data flow from a performance to the final output. The audiopath allows controlling the 3D position of each sound and adding other effects
  • The segments are modified independently and you can apply effects like pan, volume, individually.
  • It allows using DLS2 (Downloadable sound level 2 standard) which provides a great sound quality
    and unlimited use of instruments with the software synthetizer.
  • FX (Reverb, Chorus...) if it is available in the software synthetizer.
  • It overcomes the 16 midi channels limit, allowing the use of as many midi channels as the software is able to handle.
  • The playback can be controlled accurately in run time by selecting different sets of musical variations
    and changes in the chords progress.
  • 3D Positioning.

Main Intefaces of DirectMusic

IDirectMusic8: This interface allows managing buffers and ports. There should only exist one instance of this
interface per application.

IDirectMusicPerformance8: This is the most important interface in playback management. It is used to add
and remove ports, play segments, notify event reception, control music parameters and obtain timing
information.

IDirectMusicPort8: This interface provides access to DirectMusicPorts objects like MPU-401 or the software
synthesizer.

IDirectMusicSegment8: This interface represents a segment, musical piece made up of multiple tracks.
It can contain a midi file,a wave,a segment.

IDirectMusicLoader8: Its main function is to find and load the different objects.
These objects are to be stored in a segment.

IDirectMusicSegmentState8: The (playback) engine creates a SegmentState object which allows
analyzing the state of the segment currently playing.

IDirectMusicAudioPath8: The IDirectMusicAudioPath8 interface represents the stages of data flow from the data file to the primary buffer.

DirectMusic Architecture

Once a resource has been loaded in a segment, the performance dispatches the messages defined by a tool of an application, such tools are grouped in toolgraphs which process specific segment messages. A tool can modify a message and pass it on, delete it, or send a new message.

Finally, the messages are delivered to the output tool, which converts the data to MIDI format before passing it to the synthesizer. Channel-specific MIDI messages are directed to the appropriate channel group on the synthesizer. The synthesizer creates sound waves and streams them to a device called a sink, which manages the distribution of data through buses to DirectSound buffers.

There are three kinds of buffers:

  • Sink-in buffers are DirectSound secondary buffers into which the sink streams data. Here are applied
    many effects like 3D, pan, volume, etc...The resulting waveform is passed either directly to the primary buffer or to one or more mix-in buffers.
  • Mix-in buffers receive data from other buffers, apply effects, and mix the resulting wave forms. These buffers can be used to apply global effects.
  • The primary buffer performs the final mixing on all data and passes it to the rendering device.

The following diagram shows the flow of data from files to the speakers:

 

 


일부 번역


 

< DirectMusic 인터페이스 >

IDirectMusicPerformance8 : 재생관련과 관계된 관리를 위해 쓰이는 인터페이스이다. 포트의 추가,제거에 쓰이며 세그먼트를 재생, 이벤트 전송, 음원에 대한 설정값을 컨트롤 할 수 있다. 그리고 타이밍에 대한 정보도 포함한다.

 

IDirectMusicSegment8 : 이 인터페이스는 멀티 트랙으로 이루어진 음악조각인 세그먼트를 대표하며 미디파일, WAV, 하나의 세그먼트 단위를 포함할 수 있다.

 

IDirectMusicLoader8 : 이것의 주된 기능은 다른 오브젝트를 찾고 로드하는 것으로 이 오브젝트들은 세그먼트안에 저장되어져 있다.

 

< 구조 >

 일단 리소스가 세그먼트에 로드되면 Performance는 명세된 세그먼트 메시지를 처리하는 그룹화된 어플리케이션의 도구에 의해 정의된 메시지로 디스패치된다. 최종적으로 이 메시지들은 출력도구로 전달되어지며 출력도구란 신시사이저에 전달되기전 데이터를 미디포멧으로 변환하는 것을 말한다.

채널별로 명시된 미디메시지는 신시사이저내에 할당된 채널그룹에 향하게 되고 신시사이저는 Sound Waves과 Streams을 생성한다.

 


출처 : http://www.codeproject.com/KB/audio-video/cmidimusic.aspx

관련 소스

 

 

2008. 10. 3. 17:31

여러 쿼리 예제


SELECT * FROM lendinginfo_view WHERE userid = @UserID

DELETE FROM reservation WHERE idx = @Idx

SELECT count(*) AS counter from reservationinfo_view WHERE bookname = @bookname

SELECT count(*) AS counter from book WHERE isbn = @isbn

DELETE FROM reservation WHERE bookidx = @bookidx and useridx = @useridx

INSERT INTO lending (bookidx, useridx, returnplan, lendday) VALUES(@bookidx, @useridx, @returnplan, @lendday)

... WHERE bookname like @search and type = @type and useridx = @useridx

...ORDER BY returnday DESC

select * from book where typecode = 1

SELECT count(*) AS counter FROM magazineinfos WHERE bookname = @bookname

INSERT INTO magazineinfos (bookname, publisher, author, addyear, addmonth, addisbn, cd, term, bookgroup, position) "
   + "VALUES(@bookname, @publisher, @author, @addyear, @addmonth, @addisbn, @cd, @term, @bookgroup, @position)";

UPDATE magazineinfos SET publisher = @publisher, author = @author, " +
   "addyear = @addyear, addmonth = @addmonth, addisbn = @addisbn, cd = @cd, term = @term, bookgroup = @bookgroup, position = @position WHERE bookname = @bookname";

SELECT count(*) AS counter from book WHERE isbn = @isbn

UPDATE book SET samecount = samecount + 1 WHERE isbn = @isbn


"and NOT type = '토익' ";
"WHERE NOT type = '토익' ";

UPDATE book SET samecount = @samecount WHERE isbn = @isbn

DELETE FROM reservation WHERE bookidx = @bookidx and useridx = @useridx

SELECT * from bookinfo_view WHERE samecount > 1

SELECT A.useridx, B.username + ' ' + Convert(VARCHAR, B.season) + '기' 'user' FROM auth A, userdb B WHERE A.useridx = B.idx AND A.authcode = @AuthCode ORDER BY B.username

INSERT INTO bookrequestdate VALUES(@BeginDay, @EndDay)

SELECT username, season, university, major, userid, idx FROM userinfo_view WHERE auth = '가입대기'

SELECT distinct userid, username, season, university, major, idx FROM userinfo_view WHERE auth <> '가입대기' OR auth IS null

SELECT distinct userid, username, season, university, major, idx FROM userinfo_view WHERE username like @search

INSERT INTO university VALUES(@Univ)

 

// 석주 --
 public static string connectStr = "server=DGSSMBOOK\\MSSQLSERVER,1433;database=bookdb;uid=bookdb;pwd=bookdb";
 public static string sqlStrNew = "Select count(*) From bookinfo_view where month(purchasedate) = @month and year(purchasedate) = @year";
    public static string sqlStrNewPage = "Select TOP 3 * FROM bookinfo_view WHERE month(purchasedate) = @month and year(purchasedate) = @year and idx NOT IN (SELECT TOP (@iPage * 3) idx FROM bookinfo_view WHERE month(purchasedate) = @month and year(purchasedate) = @year ORDER BY purchasedate ASC) ORDER BY purchasedate ASC";
 public static string sqlStrBest = "Select top 3 * From bookinfo_view order by lendcount desc ";
 public static string sqlStrSelectedBook = "Select * From bookinfo_view where idx = @idx";
 public static string sqlStrInsertBookReview = "Insert into bookreview(bookidx, useridx, username, userseason, info) Values(@bookidx, @useridx, @username, @userseason, @info)";
 public static string sqlstrBookreview = "Select * from bookreview where bookidx = @bookidx order by reviewno desc";
 public static string sqlstrBooklendhistory = "Select * from lendhistoryinfo_view where bookidx = @bookidx order by lendday desc";
    public static string sqlStrInsertReservation = "Insert into reservation (bookidx, useridx) Values(@bookidx, @useridx)";
    public static string sqlStrSearchAll = "Select * From bookinfo_view order by purchasedate desc";
   
    // -- 석주

    //세미나일정
    public readonly static string sqlStrScheduleCount = "SELECT count(*) FROM seminar WHERE year(starttime) = @year and month(starttime) = @month";
    public readonly static string sqlStrSchedule = "SELECT * FROM seminar WHERE year(starttime) = @year and month(starttime) = @month order by starttime asc";
    public readonly static string sqlStrToday = "Select * FROM seminar WHERE month(starttime) = @month and year(starttime) = @year and day(starttime) = @day order by starttime asc";
    public readonly static string sqlStrDayScheduleCount = "SELECT count(*) FROM seminar WHERE year(starttime) = @year and month(starttime) = @month and day(starttime) = @day";
    public readonly static string sqlStrScheduleInput = "Insert into seminar (category, announcer, subject, starttime) Values(@category, @announcer, @subject, @starttime)";
    public readonly static string sqlStrCategory = "SELECT * FROM seminar_category order by idx asc";
    public readonly static string sqlStrStudyCategory = "SELECT * FROM study";
    public readonly static string sqlStrStudyInput = "Insert into study (studyname, starttime, period, people, introduce, leader) Values(@studyname, @starttime, @period, @people, @introduce, @leader)";
    public readonly static string sqlStrStudyCheckInput = "Insert into studyattend (studyname, attend, absent, report, etc, studydate, status) Values(@studyname, @attend, @absent, @report, @etc, @studydate, @status)";
 
  
    public readonly static string sqlStrStudyPeopleInput = "Insert into studypeople (studyname, person) Values(@studyname, @person)";
  
 // 지환 --
 // 도서신청검색 쿼리문(유저)
 public static string sqlstrUserViewReqBook = "SELECT * from requestinfo_view WHERE month(requestdate) = @month and year(requestdate) = @year and useridx = @useridx";
 // 도서신청검색 쿼리문(관리자)
 public static string sqlstrAdminViewReqBook = "SELECT * from requestinfo_view WHERE month(requestdate) = @month and year(requestdate) = @year";
 // 도서신청내용 삽입 쿼리문
 public static string sqlstrReqBook = "INSERT INTO requestbook (useridx, bookname, price, reason, site, link, compare) VALUES(@useridx, @bookname, @price, @reason, @site, @link, @compare)";
 // 도서신청내용 수정 쿼리문
    public static string sqlstrReqBookAdjust = "UPDATE requestbook SET " +
            "bookname = @bookname, price = @price, reason = @reason, site =@site, "
          + "link = @link, compare =@compare WHERE idx = @idx";
    // 도서를 등록할 삽입 쿼리문
 public static string sqlstrInsertBook = "INSERT INTO book (isbn, picture, typecode, bookname, publisher, author, cd, term, bookgroup ,position, samecount, purchasedate, publishdate, url) "
   + "VALUES(@isbn, @picture, @typecode, @bookname, @publisher, @author, @cd, @term, @bookgroup ,@position, @samecount, @purchasedate ,@publishdate, @url)";
 // 도서검색 관리 권한 체크 쿼리문
 public static string sqlstrCheckAdmin = "SELECT count(*) AS counter from auth WHERE id = @ID AND auth = '도서신청'";
 // 도서신청 모든 내용 보기(관리자용)
 public static string sqlstrAdminViewReqBook_All = "SELECT * from requestinfo_view";
 // 도서신청 모든 내용 보기(유저용)
 public static string sqlstrUserViewReqBook_All = "SELECT * from requestinfo_view WHERE useridx = @useridx";

2008. 10. 3. 17:30

[oracle] 시퀀스를 이용한 기본키 자동 생성

 

시퀀스를 이용한 기본키 자동 생성

- 사용자가 키 값을 직접 입력하지 않고 서버단에서 자동 생성 된다.


 삽입할 타겟 테이블은 students( s_id, s_name, s_residents, s_address )


 시퀸스 생성


 SQL> create sequence foo_seq;

주문번호가 생성되었습니다.

 

 


트리거 생성


 SQL> create trigger pk_gen
  2   before insert on student
  3   for each row
  4   begin
  5  select foo_seq.nextval
  6     into :new.st_id
  7     from dual;
  8   end;
  9  /

트리거가 생성되었습니다.

 

 


데이터 입력 ( id 입력 제외 )


 insert into students(s_name, s_residents, s_address ) values( 'ghah', '456456',  '수성구');

 


데이터 확인


 SQL> select * from students;

S_ID
--------------------
S_RESIDENTS
--------------------------------------------------------------------------------
S_NAME
--------------------------------------------------------------------------------
S_ADDRESS
--------------------------------------------------------------------------------
1
231244
서지환

 

S_ID
--------------------
S_RESIDENTS
--------------------------------------------------------------------------------
S_NAME
--------------------------------------------------------------------------------
S_ADDRESS
--------------------------------------------------------------------------------
12
435647
하할ㄹㄹ

 

S_ID
--------------------
S_RESIDENTS
--------------------------------------------------------------------------------
S_NAME
--------------------------------------------------------------------------------
S_ADDRESS
--------------------------------------------------------------------------------
44
457657
김말자

 

S_ID
--------------------
S_RESIDENTS
--------------------------------------------------------------------------------
S_NAME
--------------------------------------------------------------------------------
S_ADDRESS
--------------------------------------------------------------------------------
5
456456
ghah
수성구