• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python fluidsynth.init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mingus.midi.fluidsynth.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, packetlistener):
        self._packetlistener = packetlistener
        self._packetanalyser = PacketAnalyser(self._packetlistener)

        fluidsynth.init("Bandpass.sf2", 'alsa')

        self._music_loop()
开发者ID:ElRakabawi,项目名称:musicalpackets,代码行数:7,代码来源:musicalpackets.py


示例2: main

def main():
    if not os.path.isfile('./data/probs.json'):
        print ('Creating json file...')
        fname = "./data/interval-5gram.csv"
        counts = get_counts(fname, 4)
        probs = get_probs(counts)
        with open('./data/probs.json', 'w') as outfile:
            json.dump(probs, outfile)

    with open('./data/probs.json', 'r') as infile:
        probs_dict = json.load(infile, encoding='utf-8')

    start_int = C4
    melody = []
    fluidsynth.init("/usr/share/sounds/sf2/FluidR3_GM.sf2", "alsa")

    streamer = stream_notes(probs_dict)
    for i in range(100):
        next_int = start_int + int(next(streamer))
        next_note = Note()
        next_note.from_int(next_int)

        melody.append(next_note)
        start_int = next_int
        print(next_note)
        fluidsynth.play_Note(next_note)
        time.sleep(.2)
开发者ID:oufeidong,项目名称:markov-improv,代码行数:27,代码来源:improvise.py


示例3: generate_composition

def generate_composition(pattern, progression_type, nb_bars, key="C", rythm=60):
    fluidsynth.init("198_u20_Electric_Grand.SF2") # permet d'initialiser l'instrument
    newComposition = Composition()

    progression_list = on_progression_type_change(progression_type, nb_bars)
    left_hand = generate_pattern(progression_list, key, pattern, nb_bars)
    newComposition.add_track(left_hand)
    MidiFileOut.write_Composition("myComposition.mid", newComposition, rythm, False)
开发者ID:julienR2,项目名称:BluesMyMind,代码行数:8,代码来源:generate_composition.py


示例4: __init__

    def __init__(self, master):

        frame = Frame(master)
        frame.pack()
       
	fluidsynth.init("ChoriumRevA.SF2")

        roman_num = [0,2,4,5,7,9,11]

        self.progression = []
        self.buttons = {}
        
        self.prog_var = StringVar()
        self.display = Label( master, textvariable = self.prog_var).pack()
        
        self.uniprog_var = StringVar()
        self.unidisplay = Label( master, textvariable = self.uniprog_var).pack()

	self.sug_var = StringVar()
	self.sug_label = Label( master, textvariable = self.sug_var).pack()	

    #### Chord Buttons ####
         
	self.key_btn = Listbox(frame)
        self.key_btn.bind("<<ListboxSelect>>", self.display_progression)
	self.key_btn.pack(side=BOTTOM)
        for k in number.keys():
            self.key_btn.insert(END, k)

        for ch in roman_num:
            
            btn = Button(frame, text=roman[ch], command=partial( self.print_ch, ch ) )
            btn.pack(side=LEFT)
            
            self.buttons[ ch ] = btn 

    #### other buttons ####
            
        self.pop = Button(frame, text='Del', command=self.pop_ch)
        self.pop.pack(side=BOTTOM)

	self.play = Button(frame, text='Play', command=self.play_prog)
	self.play.pack(side=TOP)

	self.sugg = Button(frame, text='?', command=self.suggest)
	self.sugg.pack(side=BOTTOM)	

	self.save_btn = Button(frame, text='Save', command=self.save_midi)
	self.save_btn.pack(side=TOP)

    #### Checkbox buttons for intervals ####
        self.add7_var = BooleanVar()
        self.add7 = Checkbutton( master, text="+ 7", variable = self.add7_var )
        self.add7.pack()

        self.maj_var = BooleanVar()
        self.maj = Checkbutton( master, text="Major", variable = self.maj_var )
        self.maj.pack()
开发者ID:HackerSchool12,项目名称:chordparser,代码行数:58,代码来源:music_gui.py


示例5: playNotes

def playNotes(notes, xscale = 0.01):
    fluidsynth.init('/usr/share/sounds/sf2/FluidR3_GM.sf2',"alsa")
    currTime = 0
    for n in notes:
        waitTime = n.startx * xscale - currTime
        currTime = n.startx * xscale
        fluidsynth.play_Note(pow(n.energy, 0.2), 0, 100)
        print("Played %s, Waiting for %s " % (n, waitTime))
        time.sleep(waitTime)

    fluidsynth.stop_everything()
开发者ID:dilawar,项目名称:birdsong,代码行数:11,代码来源:play_piano.py


示例6: __init__

    def __init__(self):
        self.store = db()
        fluidsynth.init(MIDI_FILE, 'alsa')

        self.builder = gtk.Builder()
        self.builder.add_from_file('res/gui.glade')

        self.window = self.builder.get_object('window')
        self.new_evolution_dialog = self.builder.get_object('new_evolution_dialog')
        self.new_neural_network_dialog = self.builder.get_object('new_neural_network_dialog')
        self.open_evolution_dialog = self.builder.get_object('open_evolution_dialog')
        

        self.nn_list = gtk.ListStore(str)
        self.nn_combo = self.builder.get_object('nn_combo')
        self.nn_combo.set_model(self.nn_list)
        cell = gtk.CellRendererText()
        self.nn_combo.pack_start(cell, True)
        self.nn_combo.add_attribute(cell,'text', 0)

        self.update_nn_list()

        self.evolution_list = gtk.ListStore(str)
        self.evolution_combo = self.builder.get_object('evolution_combo')
        self.evolution_combo.set_model(self.evolution_list)
        cell = gtk.CellRendererText()
        self.evolution_combo.pack_start(cell, True)
        self.evolution_combo.add_attribute(cell, 'text', 0)

        self.update_evolution_list()

        self.genome_list = gtk.ListStore(int, str)
        self.genome_view = self.builder.get_object('genome_view')
        self.genome_view.set_model(self.genome_list)
        cell = gtk.CellRendererText()
        column = gtk.TreeViewColumn('Genome', cell, text=1)
        self.genome_view.append_column(column)

        self.controls = {
            'initialize': self.builder.get_object('initialize_button'),
            'evaluate': self.builder.get_object('evaluate_button'),
            'select' : self.builder.get_object('apply_selection_button'),
            'play' : self.builder.get_object('play_button')
        }

        self.console = gtk.TextBuffer()
        self.builder.get_object('console').set_buffer(self.console)
        
        # hide dialogs instead of destroying them for reuse
        self.hide_dialog = gtk.Widget.hide_on_delete

        self.builder.connect_signals(self)
开发者ID:cagatay,项目名称:Evolution-9,代码行数:52,代码来源:main.py


示例7: play_pattern

def play_pattern(pattern_index, key):
    pattern = patterns.PATTERNS[pattern_index]
    fluidsynth.init("198_u20_Electric_Grand.SF2") # permet d'initialiser l'instrument

    previews_note = None
    b = Bar(key, (4, 4))
    position_note = 0
    already_used=[]
    for pattern_note in pattern :
        if position_note not in already_used :
            is_chord = chord_length(pattern_note, pattern, position_note)
            if is_chord[2] :
                note_list = []
                # c est un accord
                for p_note in pattern[is_chord[0]:is_chord[1]+1] :
                    note_str = get_note_pattern(p_note, key)
                    note = Note(note_str, p_note[5])
                    if previews_note is not None:
                        if p_note[4]=='+':
                            if int(note) < previews_note :
                                note.octave_up()
                        elif p_note[4]=='-':
                            if int(note) > previews_note :
                                note.octave_down()      
                    previews_note = int(note)
                    note_list.append(note)
                    
                for n in range(is_chord[0], is_chord[1]+1):
                    already_used.append(n)
                
                b.place_notes(note_list, pattern_note[1])

                        
            else :    
                note_str = get_note_pattern(pattern_note, key)
                note = Note(note_str, pattern_note[5])
                
                if previews_note is not None:
                    if pattern_note[4]=='+':
                        if int(note) < previews_note :
                            note.octave_up()

                    elif pattern_note[4]=='-':
                        if int(note) > previews_note :
                            note.octave_down()
                            
                previews_note = int(note)
                b.place_notes(note, pattern_note[1])
                already_used.append(position_note)
        position_note+=1
            
    fluidsynth.play_Bar(b, 1, 60)                      
开发者ID:julienR2,项目名称:BluesMyMind,代码行数:52,代码来源:play_pattern.py


示例8: __init__

    def __init__(self, instrument=None):
        super(FlowTrack, self).__init__(instrument)

        if type(instrument) is Guitar:
            fluidsynth.init('soundfonts/acoustic_guitar.sf2')
        else:
            fluidsynth.init('soundfonts/grand_piano.sf2')

        self.rate = 100

        self.chords = []
        self.key = 'C'
        self.octave = 4
开发者ID:algobunny,项目名称:3tonic,代码行数:13,代码来源:ext.py


示例9: build

    def build(self):
        fluidsynth.init(os.path.join(ROOT_DIR, 'sounds', 'FluidR3_GM.sf2'))
        self.midi_in = MidiInputDispatcher()
        midi_device = self.config.get('MIDI', 'Input device')
        if midi_device:
            self.midi_in.open_port(midi_device)

        self.setting_panel = Settings()

        party = PlayerParty()
        sm = TonePoemGame(OrderedDict([
            ('area', AreaScreen(name='area')),
            ('encounter', EncounterScreen(name='encounter', party=party))
        ]), app=self)
        return sm
开发者ID:valrus,项目名称:tone_poem,代码行数:15,代码来源:tonepoem.py


示例10: __init__

    def __init__(self, filename):
        fluidsynth.init(filename)
        note_names = ("C-4", "C#4", "D-4", "D#4", "E-4", "F-4", "F#4", "G-4", "G#4", "A-4", "A#4", "B-4",
                      "C-5", "C#5", "D-5", "D#5", "E-5", "F-5", "F#5", "G-5", "G#5", "A-5", "A#5", "B-5")
        coords = (15, 35, 52, 71, 88, 125, 144, 160, 180, 197, 216, 234, 
                  270, 289, 307, 325, 343, 378, 398, 415, 434, 452, 470, 487)
        
        self.is_pressed = dict.fromkeys(note_names, [False] * len(note_names))
        self.note_coordinate = dict(zip(note_names, coords))
        self.note_names = note_names

        self.window_title = 'Keyboard'
        cv2.namedWindow(self.window_title)
        self.img = cv2.imread('./resources/keyboard.jpg', cv2.CV_LOAD_IMAGE_COLOR)
        cv2.imshow(self.window_title, self.img)
        self.turn_sound_on()
开发者ID:kobolok,项目名称:piano-on-paper,代码行数:16,代码来源:sound.py


示例11: __init__

    def __init__(self, soundfont_name=None):

        if soundfont_name is None:
            fluidsynth.init('../soundfonts/soundfont.sf2', 'alsa')
        else:
            fluidsynth.init(soundfont_name, 'alsa')

        self.m_chain = MarkovChain(get_all_progressions())
        self.sim = self.m_chain.infinite_progression()

        down1 = (0.7, 0.05, 0.2)
        down2 = (0.2, 0.05, 0.7)
        off = (0.0, 0.4, 0.1)

        self.bassproba = [down1, off, down2, off, down1, off, down2, off]

        self.current = self.m_chain.START
开发者ID:31415us,项目名称:snooki-dj,代码行数:17,代码来源:Snooki.py


示例12: __init__

    def __init__(self, 
                 soundfont_file,
                 soundfont_driver="alsa",
                 valve_mapping=default_valve_mapping,
                 freq_ranges=default_freq_ranges,
                 note_mapping=default_note_mapping):
        """
        Initialize Trumpet
        """
        self.valve_mapping = valve_mapping # Valve to key map
        self.freq_ranges = freq_ranges     # Freq range to harmonic series
        # Note mapping indexed as [freq range index][valve combo (index)]
        self.note_mapping = note_mapping  

        # Initialize Fluidsynth
        self.soundfont_file = soundfont_file
        self.soundfont_driver = soundfont_driver
        fluidsynth.init(soundfont_file, soundfont_driver)
        # Keep track of the current note state
        self.current_note = "" 
        self.prev_freq = 0
开发者ID:cwoodall,项目名称:pytrumpet,代码行数:21,代码来源:pytrumpet.py


示例13: generate_composition

def generate_composition(pattern_index, progression_type, nb_bars, mode='none', key="C", rythm=60):
    fluidsynth.init("198_u20_Electric_Grand.SF2") # permet d'initialiser l'instrument
    newComposition = Composition()
    progression_list = on_progression_type_change(progression_type, nb_bars)
    
     # truc pour la main droite
    if nb_bars == 1 :
        phrase_list = choose_phrases(key, mode, nb_bars)
        right_hand = use_phrase(phrase_list, progression_list, nb_bars, pattern_index, mode='none', key="C")
    else :
        chorus = generate_chorus(progression_list, pattern_index, mode, key)
        #chorus retourne : une phrase de debut, une phrase de fin, 3 bars fixes
        phrase_list = choose_first_phrases(nb_bars, key, mode, chorus[1], chorus[2], pattern_index)
        right_hand = generate_long_right_hand(phrase_list, progression_list, nb_bars, pattern_index, mode, key, chorus)
    
    newComposition.add_track(right_hand)
    
    left_hand = generate_pattern(progression_list, key, pattern_index, nb_bars)
    newComposition.add_track(left_hand)
    MidiFileOut.write_Composition("myCompo.mid", newComposition, rythm, False)
   
    return newComposition
开发者ID:julienR2,项目名称:BluesMyMind,代码行数:22,代码来源:generate_composition.py


示例14: playProgression

def playProgression():
    progression = ["I", "vi", "ii", "iii7", "I7", "viidom7", "iii7", "V7"]
    key = "C"

    chords = progressions.to_chords(progression, key)

    if not fluidsynth.init(SF2):
        print "Couldn't load soundfont", SF2
        sys.exit(1)

    while 1:
        i = 0
        for chord in chords:
            c = NoteContainer(chords[i])
            l = Note(c[0].name)
            p = c[1]
            l.octave_down()
            print ch.determine(chords[i])[0]

            # Play chord and lowered first note
            fluidsynth.play_NoteContainer(c)
            fluidsynth.play_Note(l)
            time.sleep(1.0)

            # Play highest note in chord
            fluidsynth.play_Note(c[-1])

            # 50% chance on a bass note
            if random() > 0.5:
                p = Note(c[1].name)
                p.octave_down()
                fluidsynth.play_Note(p)
            time.sleep(0.50)

            # 50% chance on a ninth
            if random() > 0.5:
                l = Note(intervals.second(c[0].name, key))
                l.octave_up()
                fluidsynth.play_Note(l)
            time.sleep(0.25)

            # 50% chance on the second highest note
            if random() > 0.5:
                fluidsynth.play_Note(c[-2])
            time.sleep(0.25)

            fluidsynth.stop_NoteContainer(c)
            fluidsynth.stop_Note(l)
            fluidsynth.stop_Note(p)
            i += 1
        print "-" * 20
开发者ID:radjkarl,项目名称:wii6DoF,代码行数:51,代码来源:midi_output.py


示例15: synthComm

def synthComm():
    # print "I AM IN synthComm"
    timeStart = time.time()
    fluidsynth.init(config.sf2Path)

    note = Note()
    ser = serial.Serial(config.megaPath, config.megaBaud,timeout = 1)
    fluidsynth.stop_Note(note)
    while config.playing:
        info = ser.readline()
        print info
        if info is not '' and len(info) == 9:
            # print info
            # print timeStart
            fluidsynth.stop_Note(note)
            # print "---"
            # print len(info)
            # print "---"

            timeElp, x, y, vel = parseInput(timeStart, info)
            n = pos2Num(x,y)
            # print n
            # print names[n]
            note = Note(names[n],octave)
            note.velocity = vel
            fluidsynth.play_Note(note)

            print "-----"
            print "Time: {0} \nPosition: {1},{2}\n Velocity: {3}".format(timeElp, x, y, vel)
            print "-----"
        else:
            fluidsynth.stop_Note(note)

                # config.userHits = np.hstack((config.userHits, np.array([[time],[vel],[x],[y])))
    # when done, close out connection
    ser.close()
    # print " I HAVE CLOSED THE connection"
    return
开发者ID:shahrodkh,项目名称:seniorDesign,代码行数:38,代码来源:readHits.py


示例16: __init__

    def __init__( self ):
    # possible fluidsynth guys
##main_volume(channel, value)
##modulation(channel, value)
##pan(channel, value)

        if not fluidsynth.init( os.path.join( config.RESOURCEdirectory, config.SOUNDfont), 
            config.FLUIDSYNTHdriver ):
            sys.exit(" COULD NOT LOAD SOUNDFONT PianoMenu.sf2 ")
        # set instruments on each channel.  
        fluidsynth.set_instrument( config.PIANOchannel,    ## channel to set instrument on
                                   config.SOUNDfontPIANO ) ## instrument.  determined by sound font

        self.keysmod12 = [ "C", "C#", "D", "Eb", "E", "F", "F#", "G", "Ab", "A", "Bb", "B" ]
        self.keyson = [ 0 ]*12  # denotes all keys on in an octave
        self.newnotesonlist = [ ]   # list of new [note,velocity] that player has hit
        self.newnotesofflist = [ ]  # list of new note that player has taken fingers off of
        #self.noteson = set()    # set of notes that the player currently has down 
        # commented out since it was crashing things to remove notes sometimes...
        self.pitchwheel = 64    # current value of the pitch wheel
        self.modwheel = 0       # current value of the mod wheel
        self.transientnotes = []
        pygame.midi.init()
开发者ID:kreyes12,项目名称:pyanoh3ro,代码行数:23,代码来源:iomidi.py


示例17: generate_scale

"""
"""

from mingus.core import progressions, intervals, chords
from mingus.core.scales import ionian, aeolian, locrian, whole_note, mixolydian
from mingus.containers import NoteContainer, Note, Bar, Track, Composition
from mingus.midi import fluidsynth
import time, sys
import random
import math

solo_sound_font = "soundfont.sf2"

if not fluidsynth.init(solo_sound_font):
	print "Couldn't load soundfont", solo_sound_font
	sys.exit(1)

choose_scale = {'M' : ionian,
				'm' : aeolian,
				'dim' : locrian,
				'+' : whole_note,
				'7' : mixolydian,
				'm7': aeolian,
				'M7': ionian}

def generate_scale(chord_name):
	i = 1
	while chord_name[i] == 'b' or chord_name[i] == '#':
		i += 1
	return choose_scale[chord_name[i:]](chord_name[:i])
开发者ID:djfoote,项目名称:atunal,代码行数:30,代码来源:improv.py


示例18: init

def init(soundfont_path='FluidR3_GM.sf2', driver='alsa'):
    fluidsynth.init(soundfont_path, driver)
开发者ID:Loamhoof,项目名称:codesound,代码行数:2,代码来源:soundcode.py


示例19:

from mingus.midi import fluidsynth

fluidsynth.init('/usr/share/sounds/sf2/FluidR3_GM.sf2')

fluidsynth.play_Note(64,0, 100)
开发者ID:TheVillageIdiot2,项目名称:hackathon,代码行数:5,代码来源:testaudio.py


示例20: setUp

	def setUp(self):
		fluidsynth.init("/home/bspaans/workspace/fluidsynth/ChoriumRevA.SF2")
		fluidsynth.set_instrument(0,0)
                s = SequencerObserver()
                fluidsynth.midi.attach(s)
开发者ID:anzev,项目名称:mingus,代码行数:5,代码来源:test_fluidsynth.py



注:本文中的mingus.midi.fluidsynth.init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python minicontest.contestClassifier函数代码示例发布时间:2022-05-27
下一篇:
Python ormsession.ThreadLocalORMSession类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap