summaryrefslogtreecommitdiff
path: root/muse2/muse/functions.h
blob: 9493caf7f684d45e996f56f53bc66516faa22f57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//=========================================================
//  MusE
//  Linux Music Editor
//    $Id: functions.h,v 1.20.2.19 2011/05/05 20:10 flo93 Exp $
//  (C) Copyright 2011 Florian Jung (flo93@sourceforge.net)
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; version 2 of
//  the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//
//=========================================================

#ifndef __FUNCTIONS_H__
#define __FUNCTIONS_H__

#include <set>
#include "part.h"
#include "dialogs.h"
#include <QWidget>

class QString;
class QMimeData;

#define FUNCTION_RANGE_ONLY_SELECTED 1
#define FUNCTION_RANGE_ONLY_BETWEEN_MARKERS 2



namespace MusECore {
class Undo;

std::set<const Part*> partlist_to_set(PartList* pl);
std::set<const Part*> part_to_set(const Part* p);
std::map<const Event*, const Part*> get_events(const std::set<const Part*>& parts, int range);

//these functions simply do their job, non-interactively
bool modify_velocity(const std::set<const Part*>& parts, int range, int rate, int offset=0);
bool modify_off_velocity(const std::set<const Part*>& parts, int range, int rate, int offset=0);
bool modify_notelen(const std::set<const Part*>& parts, int range, int rate, int offset=0);
bool quantize_notes(const std::set<const Part*>& parts, int range, int raster, bool len=false, int strength=100, int swing=0, int threshold=0);
bool erase_notes(const std::set<const Part*>& parts, int range, int velo_threshold=0, bool velo_thres_used=false, int len_threshold=0, bool len_thres_used=false);
bool delete_overlaps(const std::set<const Part*>& parts, int range);
bool set_notelen(const std::set<const Part*>& parts, int range, int len);
bool move_notes(const std::set<const Part*>& parts, int range, signed int ticks);
bool transpose_notes(const std::set<const Part*>& parts, int range, signed int halftonesteps);
bool crescendo(const std::set<const Part*>& parts, int range, int start_val, int end_val, bool absolute);
bool legato(const std::set<const Part*>& parts, int range, int min_len=1, bool dont_shorten=false);


//the below functions automatically open the dialog
//they return true if you click "ok" and false if "abort"
bool modify_velocity(const std::set<const Part*>& parts);
bool modify_notelen(const std::set<const Part*>& parts);
bool quantize_notes(const std::set<const Part*>& parts);
bool set_notelen(const std::set<const Part*>& parts);
bool move_notes(const std::set<const Part*>& parts);
bool transpose_notes(const std::set<const Part*>& parts);
bool crescendo(const std::set<const Part*>& parts);
bool erase_notes(const std::set<const Part*>& parts);
bool delete_overlaps(const std::set<const Part*>& parts);
bool legato(const std::set<const Part*>& parts);

//the below functions operate on selected parts
bool modify_velocity();
bool modify_notelen();
bool quantize_notes();
bool set_notelen();
bool move_notes();
bool transpose_notes();
bool crescendo();
bool erase_notes();
bool delete_overlaps();
bool legato();


//functions for copy'n'paste
void copy_notes(const std::set<const Part*>& parts, int range);
bool paste_notes(const Part* paste_into_part=NULL); // shows a dialog
void paste_notes(int max_distance=3072, bool always_new_part=false, bool never_new_part=false, const Part* paste_into_part=NULL, int amount=1, int raster=3072);
QMimeData* selected_events_to_mime(const std::set<const Part*>& parts, int range);
QMimeData* parts_to_mime(const std::set<const Part*>& parts);


void paste_at(const QString& pt, int pos, int max_distance=3072, bool always_new_part=false, bool never_new_part=false, const Part* paste_into_part=NULL, int amount=1, int raster=3072);

//functions for selections
void select_all(const std::set<const Part*>& parts);
void select_none(const std::set<const Part*>& parts);
void select_invert(const std::set<const Part*>& parts);
void select_in_loop(const std::set<const Part*>& parts);
void select_not_in_loop(const std::set<const Part*>& parts);

//functions for parts
void shrink_parts(int raster=-1); //negative values mean "config.division"
void expand_parts(int raster=-1);
void schedule_resize_all_same_len_clone_parts(const Part* part, unsigned new_len, Undo& operations);
void clean_parts();
bool merge_selected_parts();
bool merge_parts(const std::set<const Part*>& parts);

// internal
QMimeData* file_to_mimedata(FILE *datafile, QString mimeType);

} // namespace MusECore

#endif