def test_add_and_edit_note(app):
    app.song.add_note(
        Note(
            note="Contemplantes ad proprietate vocis disseruero, factus Buddha."
        ))
    time.sleep(3)
    # note_number - note's sequence number on the song editing page (for example first note)
    app.song.open_note_dropdown_menu(note_number="1")
    # note_number - note's sequence number on the song editing page (for example first note)
    # item_number - button edit or remove note
    # 1 - edit
    # 3 - remove
    app.song.choose_item_in_note_dropdown_menu(note_number="1",
                                               item_number="1")
    app.song.close_modal_window_button_close()
    app.song.open_note_dropdown_menu(note_number="1")
    app.song.choose_item_in_note_dropdown_menu(note_number="1",
                                               item_number="1")
    app.song.button_cancel_in_edit_note_modal_window()
    app.song.open_note_dropdown_menu(note_number="1")
    app.song.choose_item_in_note_dropdown_menu(note_number="1",
                                               item_number="1")
    app.song.edit_note_text(
        Note(
            note=
            "Contemplantes ad proprietate vocis disseruero, factus Buddha!!!!!"
        ))
    app.song.button_edit_in_edit_note_modal_window()
コード例 #2
0
ファイル: note.py プロジェクト: 10000ms/neko_server
def note_delete(request):
    """
    留言删除路由
    """
    note_id = request.query.get('id', None)
    if note_id is not None:
        Note.delete([
            note_id,
        ])
        return redirect(request, '/note')
    else:
        return error(request, 404)
コード例 #3
0
ファイル: main.py プロジェクト: DavidBrionesFF/Kick-Nigth
def create_note():
    titulo = str(input("Ingrese el titulo: "))
    mensaje = str(input("Ingrese el cuerpo de la nota: "))

    note = {
        "title": titulo,
        "content": mensaje,
        "create_at": str(datetime.datetime.now()),
        "no": Note.generate_no()
    }

    note_created = Note.create(note)
 def create(book_id, note_dict):
     """
     Method to create a Note and associate it to a Book.
     :param book_id: Record of Book to associate the note to.
     :param note_dict: Attributes of note to create a new Note.
     :return: Dictionary of created Note.
     """
     print("NoteDao.create()")
     note = Note(**note_dict)
     db.session.add(note)
     note.book_id = book_id
     print(note)
     db.session.commit()
     return note.to_dict()
コード例 #5
0
def read_note_from_sound_file(filename: str,
                              samplerate: int = DEFAULT_SAMPLE_RATE):
    """
    this method try to read notes from a sound wave file with a list of dict of start_time, pitch and duration
    """
    print("====> reading notes from sound file")
    win_s = 512 // DOWN_SAMPLE  # fft size
    hop_s = 256 // DOWN_SAMPLE  # hop size
    # adjust sample rate
    s = source(filename, samplerate, hop_s)
    samplerate = s.samplerate
    notes_o = notes("default", win_s, hop_s, samplerate)

    result = []
    total_frames = 0
    while True:
        samples, read = s()
        new_note = notes_o(samples)
        # note too high considered as noise
        if new_note[0] != 0 and new_note[0] <= 120:
            note_klass = Note(time=total_frames / float(samplerate),
                              pitch=new_note[0],
                              volume=new_note[1] - 20,
                              duration=new_note[2])
            result.append(note_klass)
        total_frames += read
        if read < hop_s:
            break

    return result
コード例 #6
0
def note_result_to_notes(note_result: List[dict], tempo: int, octave: int):
    """
    note_result consists a list of dict with keys: time, pitch, volume, duration.
    But the problem is that time stays in second and duration in some mist unit...
    So we just don't want notes to be overlapped.
    """
    # standardize the durations
    durations = [note_dict['duration'] / 100 for note_dict in note_result]
    durations = shift_to_standard_duration(durations)

    notes = [note_dict['pitch'] for note_dict in note_result]
    notes = shift_to_c_major_pitch(notes)

    # reformat note_list with new values, affect each note a uuid
    fmt_note_result = []
    for i, note_dict in enumerate(note_result):
        fmt_note = dict(uuid=uuid.uuid4(), pitch=notes[i], duration=durations[i], volume=note_dict['volume'])
        fmt_note_result.append(fmt_note)

    # now with durations, we can split notes into bars.
    # the condition is simple, one bar should not have sum duration > 4
    bar_note_pos_result = []
    bar_note_pos = []
    sum_duration = 0
    for i, duration in enumerate(durations):
        if sum_duration + duration <= 4:
            bar_note_pos.append(dict(pos=i, duration=duration))
            sum_duration += duration
        else:
            # create a new bar, persist that last bar
            bar_note_pos_result.append(bar_note_pos)
            bar_note_pos = []
            sum_duration = 0

    # and we can build chord for each bar
    bar_note_names = []
    for one_bar_note_pos in bar_note_pos_result:
        pitches = [notes[pos['pos']] for pos in one_bar_note_pos]
        note_names = [reverse_note_map[pitch][0] for pitch in pitches]
        bar_note_names.append(note_names)
    bar_chord_names = build_chord_names(bar_note_names)

    # now we can build the music with chord, appregio and melody
    start_time = 0
    octave = 5
    notes = []
    for i, one_bar in enumerate(bar_note_names):
        bar_time = start_time
        for j, note_name in enumerate(one_bar):
            duration = duration_map['quarter_note']
            pos_duration_dict_list = bar_note_pos_result[i]
            for d in pos_duration_dict_list:
                if d['pos'] == j:
                    duration = d['duration']
                    break
            note = Note(start_time=bar_time, pitch=note_name_octave_to_pitch())
            bar_time += duration
        start_time += 4
コード例 #7
0
ファイル: pumpcontroller.py プロジェクト: j2sg/woody
    def userTimeline(self, id, limit = 0):
        if not self._api or not id:
            return None

        notes = []

        for activity in self._api.Person(id).outbox.major[:limit]:
            author = User(activity.actor.webfinger,
                          activity.actor.display_name.encode('utf-8'),
                          activity.actor.summary.encode('utf-8'),
                          activity.actor.location.display_name.encode('utf-8'))

            note = Note(activity.obj.url, author, activity.published, activity.obj.content.encode('utf-8') if activity.obj.content is not None else '')
            note.source = str(activity.generator)

            notes.append(note)

        return notes
コード例 #8
0
ファイル: track.py プロジェクト: NaiveMusic/NaiveMusic
    def addNote(self, key, vel, on, off):
        if len(self.search(on, off, keys=[key])) > 0:
            return False
        if (key not in KEY_RANGE) or (vel not in VEL_RANGE) or (on > off) or (
                on < 0):
            return False

        self.notes[self.curID] = Note(key, vel, on, off)
        self.curID += 1
        return self.curID - 1
コード例 #9
0
 def create_from_name_and_octave(chord_name: str, octave: int, time: int,
                                 duration: int, volume: int):
     pitches = c_major_octave_chord(chord_name, octave)
     notes = []
     for pitch in pitches:
         note = Note(pitch=pitch,
                     time=time,
                     duration=duration,
                     volume=volume)
         notes.append(note)
     return Chord(notes)
コード例 #10
0
    def create(chord_name: str,
               octave: int,
               time: int,
               volume: int,
               beat_count: int = 4,
               note_duration: int = duration_map['quarter_note']):
        pitches = c_major_octave_chord(chord_name, octave)
        notes = []
        start_time = copy(time)
        extended_note_duration = copy(note_duration)
        extended_note_duration *= 1.1
        should_stop = False
        i = 0
        pitch_len = len(pitches)
        while should_stop is not True:
            # even number, forward
            if (i // pitch_len) % 2 == 0:
                for pitch in pitches:
                    note = Note(pitch=pitch,
                                time=start_time,
                                duration=extended_note_duration,
                                volume=volume)
                    notes.append(note)
                    start_time += note_duration
                    i += 1
                    if time + beat_count <= start_time:
                        should_stop = True
            else:
                # odd number, backward
                for pitch in reversed(pitches[0:len(pitches) - 1]):
                    note = Note(pitch=pitch,
                                time=start_time,
                                duration=extended_note_duration,
                                volume=volume)
                    notes.append(note)
                    start_time += note_duration
                    i += 1
                    if time + beat_count <= start_time:
                        should_stop = True

        return Appregio(notes)
コード例 #11
0
    def userTimeline(self, id, limit=0):
        if not self._api or not id:
            return None

        notes = []

        for activity in self._api.Person(id).outbox.major[:limit]:
            author = User(activity.actor.webfinger,
                          activity.actor.display_name.encode('utf-8'),
                          activity.actor.summary.encode('utf-8'),
                          activity.actor.location.display_name.encode('utf-8'))

            note = Note(
                activity.obj.url, author, activity.published,
                activity.obj.content.encode('utf-8')
                if activity.obj.content is not None else '')
            note.source = str(activity.generator)

            notes.append(note)

        return notes
コード例 #12
0
 def build_root_note(self, std_octave: int, volume: int = volume_map['p']):
     root_notes = []
     start_time = copy(self.start_time)
     for note_name in self.bars_of_chord:
         octave = copy(std_octave)
         note = Note(pitch=note_name_octave_to_pitch(note_name, octave),
                     duration=4,
                     time=start_time,
                     volume=volume)
         root_notes.append(note)
         start_time += 4
     return root_notes
コード例 #13
0
ファイル: twittercontroller.py プロジェクト: j2sg/woody
    def timeline(self, limit = 0):
        if not self._api:
            return None

        notes = []

        for tweet in tweepy.Cursor(self._api.home_timeline).items(limit):
            author = User(tweet.user.screen_name,
                          tweet.user.name.encode('utf-8'),
                          tweet.user.description.encode('utf-8'),
                          tweet.user.location.encode('utf-8'),
                          tweet.user.friends_count,
                          tweet.user.followers_count,
                          tweet.user.statuses_count,
                          tweet.user.favourites_count)

            note = Note(tweet.id_str, author, tweet.created_at, tweet.text.encode('utf-8'))

            note.replyto = self.user(tweet.in_reply_to_screen_name)
            note.source = tweet.source.encode('utf-8')
            note.shares = tweet.retweet_count
            note.likes = tweet.favorite_count

            notes.append(note)

        return notes
コード例 #14
0
ファイル: twittercontroller.py プロジェクト: j2sg/woody
    def userTimeline(self, id, limit = 0):
        if not self._api or not id:
            return None

        res = self._api.user_timeline(screen_name = id, count = limit)

        if not res:
            return None

        notes = []

        for tweet in res:
            author = User(tweet.user.screen_name,
                          tweet.user.name.encode('utf-8'),
                          tweet.user.description.encode('utf-8'),
                          tweet.user.location.encode('utf-8'),
                          tweet.user.friends_count,
                          tweet.user.followers_count,
                          tweet.user.statuses_count,
                          tweet.user.favourites_count)

            note = Note(tweet.id_str, author, tweet.created_at, tweet.text.encode('utf-8'))

            note.replyto = self.user(tweet.in_reply_to_screen_name)
            note.source = tweet.source.encode('utf-8')
            note.shares = tweet.retweet_count
            note.likes = tweet.favorite_count

            notes.append(note)

        return notes
コード例 #15
0
 def build_double_root_note(self,
                            std_octave: int,
                            volume: int = volume_map['p']):
     root_notes = []
     start_time = copy(self.start_time)
     for note_name in self.bars_of_chord:
         octave = copy(std_octave)
         # chord may need octave shifting when it comes to higher chord
         if note_name in ['G', 'A', 'B']:
             octave -= 1
         note1 = Note(pitch=note_name_octave_to_pitch(note_name, octave),
                      duration=2,
                      time=start_time,
                      volume=volume)
         note2 = Note(pitch=note_name_octave_to_pitch(note_name, octave),
                      duration=2,
                      time=start_time + 2,
                      volume=volume)
         root_notes.append(note1)
         root_notes.append(note2)
         start_time += 4
     return root_notes
コード例 #16
0
ファイル: note.py プロジェクト: 10000ms/neko_server
def note_index(request):
    """
    留言主页路由
    """
    session = request.cookies.get('session', None)
    login = False
    if session is not None:
        u = User.current_user(session)
        if u is not None:
            login = True
    notes = Note.all()
    d = {
        'login': login,
        'note': notes,
    }
    return render_template(request, 'note_index.html', d)
コード例 #17
0
def handler_create_note(event, context):
    # TODO: pass payload to service
    # TODO: validation should be in service
    bodydict = json.loads(event['body'])

    # TODO: move me in repository code
    note = Note(hash_key=str(uuid.uuid4()), **bodydict)
    note.save()
    note.refresh()

    # TODO: use existing wrappers and helpers
    return {"body": json.dumps(dict(note)), "statusCode": HTTPStatus.CREATED}
コード例 #18
0
ファイル: main.py プロジェクト: DavidBrionesFF/Kick-Nigth
def update_note():
    no = input("Ingrese el ID de nota: ")
    note = Note.find_by_id(no)

    title = input(
        "Ingrese el nuevo titulo  (Titulo antiguo, vacio para conservarlo: " +
        note.title + ")")
    content = input(
        "Ingrese el nuevo contenido  (Contenido antiguo, vacio para conservarlo: "
        + note.content + ")")

    if len(title) > 1:
        note.title = title

    if len(content) > 1:
        note.content = content

    note.update()
コード例 #19
0
    def build(self):
        # standardize the durations
        durations = [note.duration / 100 for note in self.input_note_list]
        durations = shift_to_standard_duration(durations)

        pitches = [note.pitch for note in self.input_note_list]
        pitches = shift_to_c_major_pitch(pitches)

        volumes = [note.volume for note in self.input_note_list]
        volumes = shift_to_standard_volume(volumes)

        std_notes = []
        for i, input_note in enumerate(self.input_note_list):
            # start time still unknown
            std_notes.append(Note(pitch=pitches[i], duration=durations[i], volume=volumes[i], time=0))

        # then with durations, we can split notes into bars.
        # the condition is simple, one bar should not have sum duration > 4
        bar_note_result_list = []
        bar_note_result = []
        beats_of_one_bar = 4
        sum_duration = 0
        for i, duration in enumerate(durations):
            if sum_duration + duration <= beats_of_one_bar:
                bar_note_result.append(std_notes[i])
                sum_duration += duration
            else:
                # create a new bar, persist that last bar
                bar_note_result_list.append(bar_note_result)
                bar_note_result = []
                sum_duration = 0

        # we have divided notes into melody
        # compute each note's start time
        start_time = copy(self.start_time)
        for one_bar in bar_note_result_list:
            bar_start_time = start_time
            for note in one_bar:
                note.time = bar_start_time
                bar_start_time += note.duration
            start_time += beats_of_one_bar

        self.bar_note_result_list = bar_note_result_list
        return self
コード例 #20
0
ファイル: note.py プロジェクト: 10000ms/neko_server
def note_add(request):
    """
    留言增加路由
    """
    m = request.method
    if m == 'get':
        return render_template(request, 'note_add.html')
    elif m == 'post':
        d = request.form()
        session = request.cookies.get('session', None)
        user = User.current_user(session)
        d.update({
            'user': user.id,
        })
        note = Note.new(d)
        note.save()
        return redirect(request, '/note')
    else:
        return error(request, 405)
コード例 #21
0
ファイル: twittercontroller.py プロジェクト: j2sg/woody
    def sentMessages(self):
        if not self._api:
            return None

        messages = []

        for msg in tweepy.Cursor(self._api.sent_direct_messages).items():
            receiver = User(msg.recipient.screen_name,
                            msg.recipient.name.encode('utf-8'),
                            msg.recipient.description.encode('utf-8'),
                            msg.recipient.location.encode('utf-8'),
                            msg.recipient.friends_count,
                            msg.recipient.followers_count,
                            msg.recipient.statuses_count,
                            msg.recipient.favourites_count)

            message = Note(msg.id_str, receiver, msg.created_at, msg.text.encode('utf-8'))

            messages.append(message)

        return messages
コード例 #22
0
ファイル: note.py プロジェクト: 10000ms/neko_server
def note_edit(request):
    """
    留言编辑路由
    """
    note_id = request.query.get('id', None)
    if note_id is not None:
        note = Note.find_by(id=note_id)
        if note is not None:
            m = request.method
            if m == 'get':
                d = {
                    'note': note,
                }
                return render_template(request, 'note_edit.html', d)
            elif m == 'post':
                d = request.form()
                note.title = d['title']
                note.content = d['content']
                note.save()
                return redirect(request, '/note')
            else:
                return error(request, 405)
    return error(request, 400)
コード例 #23
0
def add_note(notebook_id):
    note_data = request.form
    note = Note(**note_data)
    db.session.add(note)
    db.session.commit()
    return redirect(url_for("get_notebook_by_id", notebook_id=notebook_id))
コード例 #24
0
def add_note():
    note_data = request.form
    note = Note(**note_data)
    db.session.add(note)
    db.session.commit()
    return redirect(url_for("get_all_notebooks"))
コード例 #25
0
ファイル: main.py プロジェクト: DavidBrionesFF/Kick-Nigth
def find_all_note():
    for note in Note.find_all():
        preformat_note(note)
コード例 #26
0
ファイル: main.py プロジェクト: DavidBrionesFF/Kick-Nigth
def delete_note():
    no = input("Ingrese el ID de la nota: ")
    opt = input("Desea elimnar la nota (y/n)")

    if opt == "y":
        Note.delete(no)
コード例 #27
0
def step_impl():
    # pass
    if not Note.exists():
        Note.create_table(read_capacity_units=1, write_capacity_units=1, wait=True)

    return Note.exists()
コード例 #28
0
def save_note(note):
    n = Note(note['title'], note['content'], user['user_id'])
    db.session.add(n)
    db.session.commit()
    return u
def new_note():
    note = Note(note_title='Cool Book',
                note='Really enjoyed the book',
                book_id=1)
    return note
コード例 #30
0
    def __build_one_bar_notes(self, chord_name: str, note_names: List[str], bar_start_time: int, volume: int):
        note_count = len(note_names)
        in_chord_notes = get_in_chord_notes(chord_name, note_names)
        print("===> given chord %s and note names %s, in chord notes is %s" % (chord_name, note_names, in_chord_notes))

        # find ones to stretch, no one, just ignore it
        stretch_note_idx = []
        for i in range(len(note_names)):
            if note_names[i] in in_chord_notes:
                stretch_note_idx.append(i)

        # value affection in conditions below
        max_stretch_count = 0
        std_duration = 0
        if note_count == 1:
            std_duration = duration_map['whole_note']
        elif note_count == 2:
            std_duration = duration_map['half_note']
        elif note_count == 3:
            max_stretch_count = 1
            std_duration = duration_map['quarter_note']
        elif note_count == 4:
            std_duration = duration_map['quarter_note']
            pass
        elif 4 < note_count < 8:
            max_stretch_count = 8 - note_count
            std_duration = duration_map['eighth_note']
            pass
        elif note_count == 8:
            std_duration = duration_map['eighth_note']
            pass
        elif 8 < note_count < 16:
            max_stretch_count = 16 - note_count
            std_duration = duration_map['sixteenth_note']
            pass
        elif 16 == note_count:
            std_duration = duration_map['sixteenth_note']
            pass
        elif note_count > 16:
            std_duration = duration_map['sixteenth_note']
            # here we need to cut something
            note_names = note_names[0:16]
            pass

        note_shifting_values = [0 for _ in note_names]
        prev_notes = set([])
        for i, note_name in enumerate(note_names):
            if i - 1 >= 0 and note_names[i - 1] == 'C' and note_names[i] == 'B':
                # if C's next is a be, lower the octave of B note to C
                note_shifting_values[i] = note_shifting_values[i - 1] - 1
                continue
            # if previous note is near order, shift the octave
            if note_name in prev_notes:
                # do shifting for doubling
                note_shifting_values[i] = 1
                # remove from set
                prev_notes.discard(note_name)
                continue
            prev_notes.add(note_name)
        notes = []
        start_time = copy(bar_start_time)
        stretch_count = 0
        for i, note_name in enumerate(note_names):
            # compute duration
            duration = std_duration
            if i in stretch_note_idx:
                if stretch_count > max_stretch_count:
                    break
                duration = std_duration * 2
                stretch_count += 1

            octave = self.std_octave + note_shifting_values[i]
            print("====> note name %s%s, duration %s, start time %s" % (note_name, octave, duration, start_time))
            notes.append(Note(pitch=note_name_octave_to_pitch(note_name, octave), time=start_time,
                              duration=duration, volume=volume))
            start_time += duration
        return notes